/* ======================================================
   易学工作台 — 纸与墨
   ====================================================== */

:root {
  --paper: #f7f4ee;
  --paper-2: #fffdf8;
  --paper-3: #f1ece2;
  --ink: #1c1917;
  --ink-2: #3f3a35;
  --muted: #8a8178;
  --line: #e4ddd1;
  --line-strong: #d3c9b8;
  --accent: #9a3f30;
  --accent-soft: #f4e5df;
  --accent-ink: #7e2f23;
  --yin: #5b6b73;
  --yin-soft: #e6ecee;
  --ok: #3f6b4f;
  --warn: #9a6a1f;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.05), 0 8px 28px rgba(28, 25, 23, 0.06);
  --serif: "Iowan Old Style", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", STSong, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171513;
    --paper-2: #211e1b;
    --paper-3: #272320;
    --ink: #efe9df;
    --ink-2: #d6cec2;
    --muted: #9b9287;
    --line: #332e29;
    --line-strong: #463f38;
    --accent: #d07a63;
    --accent-soft: #33231f;
    --accent-ink: #e39a86;
    --yin: #8fa6b0;
    --yin-soft: #232b2e;
    --ok: #7fb08e;
    --warn: #d1a35c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body.sheet-open { overflow: hidden; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 22px 0;
}

/* ── 顶栏 ─────────────────────────────────────── */

#header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 max(14px, calc((100vw - 780px) / 2));
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

#title {
  flex: 1;
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions { display: flex; gap: 6px; }

.icon-btn, .header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1;
  transition: background .15s, border-color .15s;
}

.icon-btn:hover, .header-btn:hover { background: var(--paper-3); }
.header-btn { font-family: var(--serif); font-size: 15px; }
#btn-back { font-size: 18px; }

/* ── 主区 ─────────────────────────────────────── */

#main {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 20px 18px calc(72px + var(--safe-b));
}

.loading, .fatal {
  padding: 80px 20px;
  text-align: center;
  color: var(--muted);
}
.loading-glyph {
  font-size: 54px;
  color: var(--line-strong);
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .35; transform: translateY(-3px); } }
.fatal h2 { font-family: var(--serif); color: var(--ink); }

/* ── 首页 ─────────────────────────────────────── */

.hero { padding: 18px 0 26px; }

.hero-kicker {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 14px;
}

.hero-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(38px, 11vw, 54px);
  line-height: 1.18;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.hero-sub {
  margin: 16px 0 0;
  max-width: 30em;
  color: var(--muted);
  font-size: 14px;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 26px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.1;
}
.stat span { font-size: 11px; color: var(--muted); letter-spacing: .08em; }

.home-tools { position: sticky; top: 56px; z-index: 20; background: var(--paper); padding: 10px 0 12px; }

.search {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper-2);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search::placeholder { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.chip-filter {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  transition: all .15s;
}
.chip-filter:hover { border-color: var(--line-strong); color: var(--ink-2); }
.chip-filter.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.hex-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 6px;
}

.hex-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-2);
  text-align: left;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.hex-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.hex-card:active { transform: translateY(0); }
.card-id {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.card-symbol { font-size: 30px; line-height: 1.2; color: var(--accent); }
.card-name { font-family: var(--serif); font-size: 19px; letter-spacing: .05em; }
.card-status { margin-top: 6px; font-size: 11px; color: var(--muted); }
.card-status.is-reading { color: var(--accent); }
.card-status.is-done { color: var(--ok); }

.foot-note {
  margin: 28px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
}

.empty { padding: 40px 0; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── 卦页 ─────────────────────────────────────── */

.hex-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  align-items: center;
  padding: 4px 0 22px;
}

.hex-symbol {
  font-size: clamp(52px, 15vw, 72px);
  line-height: 1;
  color: var(--accent);
}

.hex-title h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.hex-id {
  margin-left: 10px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: .08em;
  vertical-align: middle;
}
.hex-trigrams {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.bo-name { color: var(--accent); }

.status-switch {
  grid-column: 1 / -1;
  display: inline-flex;
  margin-top: 12px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
  justify-self: start;
}
.status-switch button {
  padding: 4px 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.status-switch button.active { background: var(--ink); color: var(--paper); }

.text-block {
  padding: 18px 0 18px 16px;
  border-left: 3px solid var(--accent);
}
.block-head { display: flex; align-items: center; gap: 10px; }
.block-label {
  font-size: 11px;
  letter-spacing: .2em;
  color: var(--accent);
}

.classic-text {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: clamp(20px, 5.4vw, 24px);
  line-height: 2.05;
  letter-spacing: 0.03em;
}

.ch {
  position: relative;
  padding: 0 1px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.ch:hover, .ch:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-ink);
  outline: none;
}
.ch.has-entry { border-bottom: 1px dotted var(--accent); }
.ch.has-entry::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 3px;
  height: 3px;
  margin-left: -1.5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .55;
}

.lines { margin-top: 8px; }

.line-block {
  padding: 16px 0 16px 16px;
  border-left: 3px solid transparent;
  border-top: 1px dashed var(--line);
}
.line-block:hover { border-left-color: var(--line-strong); }
.line-block.special { background: linear-gradient(90deg, var(--paper-3), transparent 60%); }

.line-head { display: flex; align-items: center; gap: 8px; }
.line-pos {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .08em;
  background: var(--paper-3);
  color: var(--ink-2);
}
.line-pos.is-yang { background: var(--accent-soft); color: var(--accent-ink); }
.line-pos.is-yin { background: var(--yin-soft); color: var(--yin); }
.line-type { font-size: 10px; color: var(--muted); }

/* 己解 */

.note-region { margin-top: 10px; }

.note-toggle {
  padding: 3px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  transition: all .15s;
}
.note-toggle:hover { color: var(--accent); border-color: var(--accent); }

.note-preview {
  margin-top: 10px;
  padding: 10px 14px;
  border-left: 2px solid var(--line-strong);
  background: var(--paper-2);
  border-radius: 0 8px 8px 0;
  font-size: 14px;
}
.note-preview:empty { display: none; }

.note-editor-wrap { display: none; margin-top: 10px; }
.note-region[data-open="true"] .note-editor-wrap { display: block; }
.note-region[data-open="true"] .note-preview { display: none; }

.note-editor {
  width: 100%;
  min-height: 88px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--paper-2);
  outline: none;
  resize: vertical;
  line-height: 1.7;
  transition: border-color .15s, box-shadow .15s;
}
.note-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.note-editor.big { min-height: 180px; font-size: 15px; }
.note-status {
  margin-top: 4px;
  text-align: right;
  font-size: 10px;
  color: var(--muted);
  min-height: 14px;
}

.interpretation {
  margin-top: 30px;
  padding: 20px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-2);
}
.interpretation h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 19px; }
.interpretation h3 .hint { margin-left: 8px; }
.interpretation .note-editor { margin-top: 10px; background: var(--paper); }

.hint {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: .06em;
}
.edit-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.prompt-box { margin-top: 12px; font-size: 12px; color: var(--muted); }
.prompt-box summary { cursor: pointer; color: var(--ink-2); }
.prompt-box ul { margin: 8px 0 0; padding-left: 18px; }
.prompt-box li { margin: 4px 0; }

.char-section { margin-top: 30px; }
.char-section h3 { margin: 0 0 12px; font-family: var(--serif); font-size: 19px; }

.char-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 6px 7px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
  font-family: var(--serif);
  font-size: 17px;
  transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.has { border-bottom: 2px solid var(--accent); }
.chip.todo {
  border-style: dashed;
  color: var(--muted);
  font-size: 15px;
}
.chip sup { font-family: var(--sans); font-size: 8px; color: var(--muted); margin-left: 1px; margin-top: -2px; }

/* ── 字库 ─────────────────────────────────────── */

.char-index-head h2 { margin: 4px 0 6px; font-family: var(--serif); font-size: 26px; }
.char-index-head p { margin: 0 0 14px; font-size: 13px; }

.char-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.char-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
  text-align: left;
  transition: border-color .15s, transform .15s;
}
.char-row:hover { border-color: var(--accent); transform: translateY(-1px); }
.char-row-glyph {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--paper-3);
  font-family: var(--serif);
  font-size: 21px;
}
.char-row-meta { display: flex; flex-direction: column; gap: 2px; }
.char-row-freq { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.char-row-tag {
  font-size: 9px;
  letter-spacing: .06em;
  color: var(--accent);
}
.char-row-tag.is-reviewed { color: var(--ok); }
.char-row-tag.is-disputed { color: var(--warn); }
.char-row-tag.empty { color: var(--muted); }

/* ── 字条抽屉 ─────────────────────────────────── */

.sheet-root { position: fixed; inset: 0; z-index: 60; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 20, 18, 0.38);
  opacity: 0;
  transition: opacity .2s;
  backdrop-filter: blur(1.5px);
}
.sheet-root.is-open .sheet-backdrop { opacity: 1; }

.sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 700px;
  max-height: 90dvh;
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, 102%);
  transition: transform .24s cubic-bezier(.22, .8, .3, 1);
  overflow: hidden;
}
.sheet-root.is-open .sheet { transform: translate(-50%, 0); }

@media (min-width: 720px) {
  .sheet {
    bottom: auto;
    top: 50%;
    max-height: 86vh;
    border-radius: 20px;
    transform: translate(-50%, -46%) scale(.98);
    opacity: 0;
    transition: transform .22s, opacity .18s;
  }
  .sheet-root.is-open .sheet { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.sheet-head {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.char-big {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--paper-2);
  font-family: var(--serif);
  font-size: 38px;
  line-height: 1;
}
.char-meta { flex: 1; min-width: 0; }
.char-pinyin { font-size: 13px; color: var(--muted); letter-spacing: .06em; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.badge {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--paper-3);
  color: var(--ink-2);
  font-size: 9px;
  letter-spacing: .04em;
}
.badge.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.badge.status-reviewed { background: var(--ok); color: var(--paper); }
.badge.status-disputed { background: var(--warn); color: var(--paper); }
.badge.status-draft { background: var(--accent-soft); color: var(--accent-ink); }
.sheet-close { flex: 0 0 auto; }

.tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 2px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  padding: 11px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab.push { margin-left: auto; }

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px calc(36px + var(--safe-b));
  overscroll-behavior: contain;
}
.sheet-body.grow { display: flex; flex-direction: column; }

.sheet-section { margin-bottom: 24px; }
.sheet-section h3 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  color: var(--muted);
  text-transform: uppercase;
}
.sheet-section h3 .hint { margin-left: 8px; letter-spacing: .04em; text-transform: none; }
.sheet-section.grow { flex: 1; display: flex; flex-direction: column; }

.origin-line {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.5;
  letter-spacing: .02em;
}
.evidence { margin: 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.85; }

.context-box {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13.5px;
  line-height: 1.8;
}

.glyph-list, .evo-list, .sense-list, .variant-list, .dispute-list, .question-list, .source-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.glyph-list { border-left: 1px solid var(--line-strong); margin-left: 4px; }
.glyph-item {
  position: relative;
  padding: 0 0 18px 18px;
}
.glyph-item::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--accent);
}
.glyph-stage {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: .06em;
  color: var(--accent-ink);
}
.glyph-desc { margin-top: 3px; font-size: 13.5px; line-height: 1.85; }
.glyph-src, .evo-src, .dispute-src {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}
.glyph-image {
  display: block;
  max-width: 120px;
  max-height: 120px;
  margin-top: 8px;
  border-radius: 8px;
  background: var(--paper-2);
}

.evo-list { counter-reset: evo; }
.evo-item {
  counter-increment: evo;
  position: relative;
  padding: 10px 0 10px 26px;
  border-bottom: 1px dashed var(--line);
}
.evo-item:last-child { border-bottom: 0; }
.evo-item::before {
  content: counter(evo);
  position: absolute;
  left: 0;
  top: 11px;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--paper-3);
  color: var(--muted);
  font-size: 9px;
}
.evo-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.evo-stage { font-family: var(--serif); font-size: 14px; color: var(--ink-2); }
.evo-claim { margin-top: 2px; font-size: 13.5px; line-height: 1.8; }
.conf {
  padding: 0 6px;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: .04em;
}
.conf-high { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.conf-medium { background: var(--paper-3); color: var(--warn); }
.conf-low { background: var(--accent-soft); color: var(--accent-ink); }

.sense-list li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13.5px;
  line-height: 1.75;
}
.sense-list li:last-child { border-bottom: 0; }
.sense-name { font-family: var(--serif); font-size: 15px; margin-right: 8px; }
.sense-note { color: var(--muted); }

.variant-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.variant-list li:last-child { border-bottom: 0; }
.variant-char {
  grid-row: 1 / span 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--paper-3);
  font-family: var(--serif);
  font-size: 20px;
}
.variant-src { font-size: 11px; color: var(--muted); }
.variant-note { grid-column: 2; font-size: 13px; line-height: 1.7; }

.dispute-list li {
  padding: 8px 0 8px 14px;
  border-left: 2px solid var(--warn);
  margin-bottom: 8px;
  font-size: 13.5px;
  line-height: 1.75;
  background: color-mix(in srgb, var(--warn) 6%, transparent);
  border-radius: 0 8px 8px 0;
}

.question-list li {
  position: relative;
  padding: 5px 0 5px 18px;
  font-size: 13.5px;
  line-height: 1.75;
}
.question-list li::before {
  content: "？";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-family: var(--serif);
}
.source-list li { font-size: 12px; color: var(--muted); padding: 2px 0; }
.source-list li::before { content: "· "; }

.occ-summary { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.occ-group { margin-bottom: 16px; }
.occ-goto {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--accent-ink);
}
.occ-symbol { font-size: 20px; color: var(--accent); }
.occ-group ul { margin: 4px 0 0; padding: 0; list-style: none; }
.occ-item {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px dashed var(--line);
  font-size: 13.5px;
  line-height: 1.7;
}
.occ-where {
  flex: 0 0 auto;
  min-width: 34px;
  font-size: 10px;
  color: var(--muted);
  padding-top: 3px;
}
.occ-text { font-family: var(--serif); font-size: 15px; }
mark { background: var(--accent-soft); color: var(--accent-ink); padding: 0 1px; border-radius: 3px; }

.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { font-family: var(--serif); margin: 12px 0 6px; }
.md ul, .md ol { margin: 6px 0; padding-left: 20px; }
.md blockquote {
  margin: 8px 0;
  padding-left: 12px;
  border-left: 2px solid var(--line-strong);
  color: var(--muted);
}
.md code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--paper-3);
  font-size: .9em;
}

.sheet-section.grow .note-editor { flex: 1; min-height: 45vh; }

/* 编辑表单 */

.edit-form { display: flex; flex-direction: column; gap: 14px; }
.edit-hint { margin: 0; font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.edit-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-2);
}
.edit-form label .field-hint {
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
}
.edit-form input, .edit-form select, .edit-form textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--paper-2);
  outline: none;
  font-size: 13.5px;
  line-height: 1.6;
  resize: vertical;
}
.edit-form input:focus, .edit-form select:focus, .edit-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.edit-form textarea { font-family: var(--sans); }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 6px;
}

/* ── 按钮 ─────────────────────────────────────── */

.btn-primary, .btn-secondary, .btn-danger {
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13px;
  transition: all .15s;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { opacity: .88; }
.btn-secondary { background: var(--paper-2); border-color: var(--line-strong); color: var(--ink-2); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--warn); }
.btn-danger:hover { background: color-mix(in srgb, var(--warn) 10%, transparent); }

/* ── 设置弹窗 ─────────────────────────────────── */

#modal-root { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(24, 20, 18, 0.42); backdrop-filter: blur(2px); }
.modal {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 18px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-family: var(--serif); font-size: 18px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-body h4 { margin: 0 0 6px; font-size: 12px; letter-spacing: .12em; color: var(--muted); }
.modal-body p { font-size: 13px; line-height: 1.75; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.modal-actions button { width: 100%; }
.danger-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.build-note { margin-top: 22px; text-align: center; }

/* ── Toast ────────────────────────────────────── */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  z-index: 90;
  transform: translate(-50%, 12px);
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  letter-spacing: .04em;
  opacity: 0;
  transition: opacity .18s, transform .18s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── 宽屏 ─────────────────────────────────────── */

@media (min-width: 560px) {
  .hex-grid { grid-template-columns: repeat(3, 1fr); }
  .hex-head { grid-template-columns: auto 1fr auto; }
  .status-switch { grid-column: auto; margin-top: 0; }
}

@media (min-width: 760px) {
  .hex-grid { grid-template-columns: repeat(4, 1fr); }
  #main { padding-left: 24px; padding-right: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
