:root {
  --paper: #efede6;
  --paper-shadow: #e2dfd5;
  --ink: #1f2933;
  --muted: #5f6a79;
  --line: #bcc4ce;
  --line-strong: #7b8794;
  --card: #fbfbf8;
  --card-alt: #f4f6f8;
  --header-ink: #253142;
  --header-ink-2: #324257;
  --tag-bg: #edf1f4;
  --tag-ink: #334b62;
  --accent: #436481;
  --accent-soft: rgba(67, 100, 129, 0.14);
  --danger-soft: rgba(115, 63, 51, 0.16);
  --code-bg: #f5f7f9;
  --radius: 4px;
  --card-min-width: 380px;
  --card-max-width: 580px;
  --grid-column-count: auto-fit;
  --grid-gap: 7px;
  --grid-row-unit: 6px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.52)),
    linear-gradient(90deg, rgba(88, 101, 121, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(88, 101, 121, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size:
    auto,
    28px 28px,
    28px 28px,
    auto;
}

button,
input,
textarea,
code,
pre {
  font: inherit;
}

.sheet-page {
  min-height: 100vh;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 12px;
  align-items: center;
  padding: 8px 10px 7px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92)),
    var(--paper);
  box-shadow: 0 1px 0 rgba(31, 41, 51, 0.04);
}

.toolbar-main h1 {
  margin: 1px 0;
  font-size: 1.36rem;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toolbar-note,
.toolbar-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.toolbar-note {
  margin: 0;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  align-items: center;
}

.toolbar-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 0;
}

.search-wrap {
  display: grid;
  gap: 3px;
  min-width: min(320px, 46vw);
}

.search-label {
  font-size: 0.76rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.search-input,
.tool-button {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.search-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 0.92rem;
  line-height: 1.2;
}

.search-input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.tool-button {
  padding: 6px 9px;
  font-size: 0.86rem;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.tool-button:hover {
  background: #f2f5f8;
}

.tool-button-strong {
  background: #eef3f7;
  border-color: var(--accent);
  color: #1f405b;
}

.sheet-shell {
  padding: 7px;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(
    var(--grid-column-count),
    minmax(min(100%, var(--card-min-width)), 1fr)
  );
  grid-auto-rows: var(--grid-row-unit);
  grid-auto-flow: dense;
  width: 100%;
  align-content: start;
  gap: var(--grid-gap);
  align-items: start;
}

.cheat-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #ffffff;
}

.cheat-card {
  display: flex;
  flex-direction: column;
  align-self: start;
  box-shadow: none;
}

.card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: start;
  padding: 5px 6px 5px 7px;
  border-bottom: 1px solid #1d2633;
  background: linear-gradient(180deg, var(--header-ink-2), var(--header-ink));
  color: #f7f9fb;
}

.card-header-main {
  min-width: 0;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.18;
  font-weight: 700;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.card-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.74rem;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.94);
}

.card-chip-kind {
  background: rgba(255, 255, 255, 0.16);
}

.card-handle {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  cursor: grab;
}

.card-handle::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(currentColor 1.2px, transparent 1.3px);
  background-size: 5px 5px;
  background-position: center;
  opacity: 0.78;
}

.card-handle:active {
  cursor: grabbing;
}

.card-handle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.38);
  outline-offset: 1px;
}

.card-body {
  padding: 9px 10px 10px;
  font-size: 0.93rem;
  line-height: 1.5;
  user-select: text;
}

.card-body p {
  margin: 0;
}

.mini-heading {
  margin: 0 0 6px;
  font-size: 0.84rem;
  line-height: 1.25;
  font-weight: 700;
  color: #2d3d4f;
}

.muted-note {
  margin-top: 6px;
  color: var(--muted);
}

.stack-list {
  display: grid;
  gap: 8px;
}

.stack-item,
.labeled-block,
.pitfall-block {
  padding: 7px;
  border: 1px solid #d7dee6;
  border-radius: 3px;
  background: #f9fbfc;
}

.pitfall-card {
  display: grid;
  gap: 8px;
}

.pitfall-block {
  border-left: 3px solid #b46d42;
  background: #fffaf6;
}

.syntax-card,
.snippets-card {
  display: grid;
  gap: 8px;
}

.keyword-term {
  display: inline-block;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.88rem;
  font-weight: 700;
  color: #274a6a;
}

.list-content {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
}

.list-content li::marker {
  color: var(--accent);
}

.list-content code,
.api-name,
.compare-table code,
.code-card code {
  font-family: Consolas, "Courier New", monospace;
}

.card-body code {
  padding: 0 3px;
  border-radius: 2px;
  background: #eef2f5;
  color: #1a3956;
}

.code-card {
  margin: 0;
  padding: 8px;
  overflow: auto;
  border: 1px solid #d5dde6;
  border-radius: 2px;
  background: var(--code-bg);
  color: #1e2f3f;
  font-size: 0.86rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.compare-table,
.api-table,
.data-table,
.keywords-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.compare-table th,
.compare-table td,
.api-table th,
.api-table td,
.data-table th,
.data-table td,
.keywords-table th,
.keywords-table td {
  padding: 6px 7px;
  border: 1px solid #d4dbe4;
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.compare-table th,
.api-table th,
.data-table th,
.keywords-table th {
  background: var(--card-alt);
  font-weight: 700;
}

.api-name {
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 0.88rem;
  color: #1f4464;
  font-weight: 700;
}

.keyword-term {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 14px 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.noscript-banner {
  position: fixed;
  bottom: 10px;
  left: 10px;
  right: 10px;
  z-index: 20;
  padding: 10px 12px;
  border: 1px solid #9b8076;
  border-radius: var(--radius);
  background: #fff6f2;
  color: #6e4a3f;
  font-size: 0.84rem;
}

.drag-ghost {
  opacity: 0.22;
  border-style: dashed;
  background: #f4f6f8;
  box-shadow: none;
}

.drag-chosen {
  border-color: #6c7b90;
  box-shadow: inset 0 0 0 1px rgba(67, 100, 129, 0.22);
  background: #fdfcf9;
}

.drag-dragging {
  border-color: #5d6f86;
  box-shadow: 0 4px 10px rgba(31, 41, 51, 0.1);
  transform: rotate(0.2deg);
}

.sortable-disabled .card-handle {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 720px) {
  :root {
    --card-min-width: 300px;
    --card-max-width: 420px;
    --grid-gap: 6px;
  }

  .toolbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .search-wrap {
    min-width: 100%;
  }
}

@media print {
  @page {
    margin: 8mm;
  }

  body {
    background: #ffffff;
  }

  .toolbar {
    position: static;
    padding: 0 0 6px;
    border-bottom: 1px solid #666;
    box-shadow: none;
    background: #fff;
  }

  .toolbar-actions,
  .toolbar-note {
    display: none;
  }

  .toolbar-main h1 {
    font-size: 16pt;
  }

  .toolbar-meta {
    padding-top: 0;
    color: #444;
  }

  .sheet-shell {
    padding: 5px 0 0;
  }

  .sheet-grid {
    grid-template-columns: repeat(auto-fill, 46mm);
    grid-auto-rows: 1.5mm;
    justify-content: start;
    gap: 2.5mm;
  }

  .cheat-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
