/* ============================================================
   Self Map — V1
   Calm, minimal, light. Cool paper + ink + a low-saturation blue accent.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg:            #F7F9FB;
  --surface:       #FFFFFF;
  --surface-2:     #EFF3F8;
  --surface-3:     #E5ECF3;

  --ink:           #1A1F26;
  --ink-2:         #4E5865;
  --ink-3:         #7E8894;

  --line:          #E1E8EF;
  --line-2:        #CDD8E3;

  --accent:        #4A6C93;
  --accent-ink:    #3A5878;
  --accent-soft:   #EDF2F8;

  --danger:        #A33A2E;

  --radius-s:      8px;
  --radius:        12px;
  --radius-l:      16px;

  --shadow-s:      0 1px 2px rgba(22,30,42,.04);
  --shadow-m:      0 4px 16px rgba(22,30,42,.07);
  --shadow-l:      0 18px 48px rgba(22,30,42,.14);

  --font-serif: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono:  ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas,
                "Liberation Mono", monospace;

  --max:      1080px;
  --header-h: 60px;
}

/* ---------------- Module accents ----------------
   Each module inherits the exact tint it wears on the home board, so a
   sub-page is recognisable by colour before you read a single word.
   `--accent` / `--accent-ink` / `--accent-soft` are the three tokens the rest
   of the sheet already paints with; overriding them on <body> re-skins the
   whole page — nav pill, buttons, chips, pills, focus rings, dialogs.
   `--tint` / `--tint-line` are the softer surface pair for backgrounds.     */

:root {
  --tint:      #E9F0F8;
  --tint-line: #D5E2F0;
}

body.mod-experience {
  --accent: #4A6C93; --accent-ink: #33506F; --accent-soft: #EDF2F8;
  --tint:   #E9F0F8; --tint-line:   #D5E2F0;
}
body.mod-moment {
  --accent: #857A55; --accent-ink: #635A3C; --accent-soft: #F4F2E9;
  --tint:   #F1EFE5; --tint-line:   #E2DFD0;
}
body.mod-insight {
  --accent: #5C7D64; --accent-ink: #44614C; --accent-soft: #EDF3EE;
  --tint:   #E8F0EA; --tint-line:   #D6E3D9;
}
body.mod-qa {
  --accent: #6A6394; --accent-ink: #4F4973; --accent-soft: #F1F0F8;
  --tint:   #EDEBF5; --tint-line:   #DEDBEB;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.is-locked { overflow: hidden; }

h1, h2, h3, h4 { font-weight: 600; }
a { color: inherit; }

::selection { background: var(--accent-soft); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: 0 0 var(--radius-s) 0; font-size: 13px;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.muted { color: var(--ink-3); }

/* ---------------- Header ---------------- */

.app-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(247,249,251,.86);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: var(--max); margin: 0 auto; height: var(--header-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 32px;
}
.wordmark {
  grid-column: 1; justify-self: start;
  font-family: var(--font-serif); font-size: 19px; letter-spacing: .01em;
  text-decoration: none; display: flex; align-items: center; gap: 9px;
  color: var(--ink); white-space: nowrap;
}
.wordmark-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }

.topnav { grid-column: 2; justify-self: center; display: flex; gap: 2px; }
.topnav a {
  font-size: 13.5px; color: var(--ink-3); text-decoration: none;
  padding: 7px 13px; border-radius: 999px;
  border: 1px solid transparent; transition: .15s;
}
.topnav a:hover { color: var(--ink); background: var(--surface-2); }
.topnav a.is-active {
  color: var(--ink); background: var(--surface);
  border-color: var(--line); box-shadow: var(--shadow-s);
}

/* ---------------- Main ---------------- */

.app-main {
  max-width: var(--max); margin: 0 auto;
  padding: 44px 32px 140px;
  min-height: 55vh;
}

/* ---------------- Home ---------------- */

/* Home — a 2x2 board centred in the viewport, one screen, nothing else. */

.app-main.is-home {
  display: flex;
  min-height: calc(100vh - var(--header-h));
  padding-top: 28px; padding-bottom: 28px;
}
.home-wrap { flex: 1; display: flex; min-width: 0; }
.module-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.module-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 26px 24px;
  border: 1px solid var(--line); border-radius: var(--radius-l);
  text-decoration: none; color: inherit; box-shadow: var(--shadow-s);
  background: var(--surface); transition: .16s;
}
.module-card:hover { box-shadow: var(--shadow-m); transform: translateY(-2px); }
.module-icon { display: block; margin-bottom: 18px; color: var(--module-accent, var(--ink-3)); }
.module-icon svg { width: 26px; height: 26px; }
.module-card h2 {
  font-family: var(--font-sans); font-weight: 700; font-size: 27px;
  letter-spacing: -.02em; line-height: 1.12; margin: 0 0 9px;
}
.module-card p { font-size: 13.5px; color: var(--ink-2); margin: 0; max-width: 32ch; }

/* One low-saturation tint per module, so the four are told apart at a glance. */
.mc-experience { background: #E9F0F8; border-color: #D5E2F0; --module-accent: #4A6C93; }
.mc-moment     { background: #F1EFE5; border-color: #E2DFD0; --module-accent: #857A55; }
.mc-insight    { background: #E8F0EA; border-color: #D6E3D9; --module-accent: #5C7D64; }
.mc-qa         { background: #EDEBF5; border-color: #DEDBEB; --module-accent: #6A6394; }

/* ---------------- Toolbar ---------------- */

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.filters { min-width: 0; }
.tools { display: flex; align-items: center; gap: 10px; flex: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 13px; padding: 6px 13px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--ink-3);
  cursor: pointer; transition: .15s; white-space: nowrap;
}
.chip:hover { color: var(--ink); background: var(--surface-2); }
.chip.is-active {
  color: var(--ink); background: var(--surface);
  border-color: var(--line-2); box-shadow: var(--shadow-s);
}
.search {
  font: inherit; font-size: 13.5px; padding: 8px 15px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  min-width: 250px; transition: .15s;
}
.search:focus { outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 3px rgba(22,30,42,.06); }
.search::placeholder { color: var(--ink-3); }
.search-wrap { flex: none; }

/* ---------------- Buttons ---------------- */

.btn {
  font: inherit; font-size: 13.5px; padding: 9px 16px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: .15s; display: inline-flex; align-items: center;
  gap: 7px; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; border-color: #000; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: #FBEEEC; border-color: transparent; }
.btn svg { width: 15px; height: 15px; }
.plus { font-size: 16px; line-height: 1; margin-top: -1px; }

.icon-btn {
  width: 28px; height: 28px; border-radius: 7px; border: 1px solid transparent;
  background: transparent; color: var(--ink-3); cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center; transition: .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 15px; height: 15px; }

/* ---------------- Cards ---------------- */

.card-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
  grid-auto-flow: dense;   /* backfills the row an expanded card vacates */
}
.stack { display: flex; flex-direction: column; gap: 14px; max-width: 820px; }

/* An expanded Q&A card takes the whole row: left inline it stretches the row
   and its three collapsed neighbours become tall empty boxes. */
.qa-item:has(.qa-block:not([hidden])) { grid-column: 1 / -1; }
.qa-item:has(.qa-block:not([hidden])) .qa-block { max-width: 720px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; cursor: pointer;
  box-shadow: var(--shadow-s); transition: .16s; text-align: left;
  display: block; width: 100%; font: inherit; color: inherit;
}
.card:hover { border-color: var(--line-2); box-shadow: var(--shadow-m); transform: translateY(-1px); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

.date { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .04em; color: var(--ink-3); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, #7E8894); flex: none; }
.soft-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }

.card-title { font-size: 15.5px; margin: 0 0 8px; line-height: 1.38; letter-spacing: -.005em; }
/* Clamped so a grid row keeps a predictable height; the full text is one click away. */
.card-desc {
  font-size: 13.5px; line-height: 1.62; color: var(--ink-2); margin: 0;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden;
}

.card-insight .card-title { font-family: var(--font-serif); font-weight: 400; font-size: 19px; line-height: 1.42; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tag { font-size: 11.5px; color: var(--ink-3); background: var(--surface-2); border-radius: 6px; padding: 3px 8px; }

.rel-line {
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--ink-3);
}

.empty {
  padding: 58px 24px; text-align: center;
  border: 1px dashed var(--line-2); border-radius: var(--radius);
}
.card-grid .empty { grid-column: 1 / -1; }
.empty h3 { font-size: 15px; margin: 0 0 6px; }
.empty p { font-size: 13.5px; color: var(--ink-3); margin: 0; }

/* ---------------- Q&A ---------------- */

.qa-card { padding: 16px 17px 14px; display: flex; flex-direction: column; }
.qa-card .card-top { margin-bottom: 9px; min-height: 18px; }
.qa-question { font-size: 15.5px; margin: 0; line-height: 1.45; letter-spacing: -.005em; }
.card-open {
  font: inherit; color: inherit; letter-spacing: inherit; line-height: inherit;
  background: none; border: 0; padding: 0; margin: 0; text-align: left;
  cursor: pointer; transition: color .15s;
}
.card-open:hover { color: var(--accent-ink); }
.card-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.qa-bar { display: flex; align-items: center; gap: 6px; margin-top: 13px; flex-wrap: wrap; }
.kbtn {
  font-family: var(--font-mono); font-size: 12px; width: 27px; height: 27px; flex: none;
  border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); cursor: pointer; transition: .15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.kbtn:hover { border-color: var(--ink-3); color: var(--ink); }
.kbtn.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.qa-meta-practice {
  font-family: var(--font-sans); font-size: 11px; letter-spacing: .02em;
  color: var(--ink-2); background: var(--surface-2); border-radius: 999px; padding: 3px 10px;
}
.qa-spacer { flex: 1; min-width: 8px; }

.qa-block { margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--line); }

/* Keywords — one pill per keyword, laid out horizontally */
.kw-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-pill {
  font-size: 12px; line-height: 1.5; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px;
}

/* Answer — framed box with its length in the bottom-right corner */
.answer-box {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 15px 17px 11px;
}
.answer-body { font-size: 15px; line-height: 1.72; color: var(--ink); }
.answer-body p { margin: 0 0 12px; }
.answer-body p:last-child { margin-bottom: 0; }
.answer-body ol, .answer-body ul { margin: 0 0 12px; padding-left: 22px; }
.answer-body li { margin: 5px 0; }
.answer-body strong { font-weight: 600; }
.answer-count {
  margin-top: 12px; text-align: right;
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .02em; color: var(--ink-3);
}

/* ---------------- Practice / recording ---------------- */

.practice { padding-top: 2px; }

.rec {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 26px 18px 22px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); transition: .18s;
}
.rec.is-live { border-color: #C6D5E6; background: #F3F8FD; }

.rec-timer {
  font-family: var(--font-mono); font-size: 34px; line-height: 1;
  letter-spacing: .01em; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.rec-timer.is-live { color: var(--accent-ink); font-size: 40px; }

.rec-live {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink);
}
.rec-pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  animation: recpulse 1.4s ease-in-out infinite;
}
@keyframes recpulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .35; transform: scale(.82); }
}

.rec-btn {
  font: inherit; font-size: 15px; font-weight: 600; letter-spacing: -.005em;
  min-height: 50px; padding: 13px 30px; border-radius: 999px;
  border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; transition: .15s;
}
.rec-btn svg { width: 18px; height: 18px; }
.rec-btn:hover:not(:disabled) { background: #000; border-color: #000; }
.rec-btn:disabled { opacity: .55; cursor: default; }
.rec-btn-rec { background: var(--accent); border-color: var(--accent); }
.rec-btn-rec:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
.rec-btn-stop { background: var(--accent-ink); border-color: var(--accent-ink); }
.rec-btn-stop:hover:not(:disabled) { background: #2E4763; border-color: #2E4763; }

.rec-hint {
  margin: 0; max-width: 400px; text-align: center;
  font-size: 12.5px; line-height: 1.6; color: var(--ink-3);
}

.p-history { margin-top: 24px; }
.p-title {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 12px; font-weight: 600;
}
.p-empty { font-size: 13px; color: var(--ink-3); margin: 0; }

.p-record {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 15px 17px; margin-bottom: 10px;
}
.p-record:last-child { margin-bottom: 0; }
.p-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.p-num { font-size: 13px; font-weight: 600; letter-spacing: -.005em; }

.p-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.p-btn {
  font: inherit; font-size: 12.5px; min-height: 38px; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); cursor: pointer; transition: .14s;
  display: inline-flex; align-items: center; gap: 6px;
}
.p-btn svg { width: 13px; height: 13px; }
.p-btn:hover:not(:disabled) { border-color: var(--ink-3); color: var(--ink); background: var(--surface-2); }
.p-btn:disabled { opacity: .42; cursor: not-allowed; }
.p-btn.is-playing { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }

.p-missing {
  margin: 11px 0 0; padding: 9px 11px; border-radius: 7px;
  background: var(--surface-2); font-size: 12px; line-height: 1.55; color: var(--ink-3);
}
.p-note {
  margin: 11px 0 0; padding: 9px 11px; border-radius: 7px;
  background: var(--accent-soft); font-size: 12px; line-height: 1.55; color: var(--accent-ink);
}

.p-refl { margin-top: 14px; }
.p-refl .field-label { margin-bottom: 6px; }
.p-refl-input { min-height: 62px; font-size: 14px; }


/* ---------------- Focus mode ---------------- */

.focus-view {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column; overflow-y: auto;
  opacity: 0; transition: opacity .2s ease;
}
#layer-root.is-open .focus-view { opacity: 1; }

.focus-head {
  position: sticky; top: 0; z-index: 2; flex: none; height: 56px;
  padding: 0 32px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; border-bottom: 1px solid var(--line);
  background: rgba(247,249,251,.92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.focus-head-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.focus-head-right { display: flex; align-items: center; gap: 8px; flex: none; }

.focus-body { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 52px 32px 140px; }
.focus-q {
  font-family: var(--font-serif); font-weight: 400; font-size: 31px;
  line-height: 1.3; letter-spacing: -.012em; margin: 0 0 28px;
}
.focus-kw { counter-reset: kw; list-style: none; margin: 0 0 36px; padding: 0 0 28px; border-bottom: 1px solid var(--line); }
.focus-kw li { position: relative; padding-left: 34px; margin: 10px 0; font-size: 14.5px; color: var(--ink-2); }
.focus-kw li::before {
  counter-increment: kw; content: counter(kw);
  position: absolute; left: 0; top: 1px; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-3);
  border: 1px solid var(--line-2); border-radius: 50%;
}
.focus-answer { font-size: 17.5px; line-height: 1.78; color: var(--ink); }
.focus-answer p { margin: 0 0 18px; }
.focus-answer p:last-child { margin-bottom: 0; }
.focus-answer ol, .focus-answer ul { margin: 0 0 18px; padding-left: 26px; }
.focus-answer li { margin: 7px 0; }
.focus-meta {
  margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line);
  text-align: right;
  font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); letter-spacing: .02em;
}

/* ---------------- Layer / sheet ---------------- */

#layer-root { position: relative; z-index: 70; }

.layer-backdrop {
  position: fixed; inset: 0; background: rgba(22,30,42,.30);
  opacity: 0; transition: opacity .2s ease;
}
#layer-root.is-open .layer-backdrop { opacity: 1; }

/* Detail / editor — a centred dialog, not a side drawer.
   Centred with top/left + transform rather than `inset: 0; margin: auto`,
   because the latter stretches height:auto elements to the full viewport
   and a short record ended up in a mostly-empty box. */
.sheet {
  position: fixed; top: 50%; left: 50%;
  width: min(720px, 92vw); max-height: 88vh;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-l);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translate(-50%, calc(-50% + 14px)) scale(.985); opacity: 0;
  transition: transform .2s ease, opacity .2s ease;
}
#layer-root.is-open .sheet { transform: translate(-50%, -50%); opacity: 1; }

.sheet-head {
  flex: none; height: 58px; padding: 0 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 {
  font-size: 12px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--ink-3); margin: 0; font-weight: 600;
}
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 28px 26px 40px; overscroll-behavior: contain; }
.sheet-foot {
  flex: none; padding: 14px 26px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; background: var(--surface);
  border-radius: 0 0 var(--radius-l) var(--radius-l);
}
.foot-spacer { flex: 1; }
.discard-msg { font-size: 13.5px; color: var(--ink-2); }

/* ---------------- Detail ---------------- */

.detail-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-title {
  font-family: var(--font-serif); font-weight: 400; font-size: 27px;
  line-height: 1.3; letter-spacing: -.012em; margin: 18px 0 14px;
}
.detail-desc { font-size: 15px; color: var(--ink-2); line-height: 1.7; margin: 0 0 24px; }
.detail-kw { margin: 0 0 22px; }
.detail-content { font-size: 15px; line-height: 1.78; }
.detail-content p { margin: 0 0 14px; }
.detail-content ol, .detail-content ul { margin: 0 0 14px; padding-left: 24px; }
.detail-content li { margin: 5px 0; }

.related { margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--line); }
.related h3 {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 12px; font-weight: 600;
}
.rel-item {
  display: flex; gap: 12px; align-items: baseline; width: 100%;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  cursor: pointer; font: inherit; font-size: 14px; color: var(--ink);
  background: transparent; border-left: none; border-right: none; border-top: none;
  text-align: left; transition: .14s;
}
.rel-item:last-child { border-bottom: none; }
.rel-item:hover { color: var(--accent-ink); }
.rel-kind {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); width: 76px; flex: none; padding-top: 2px;
}

/* ---------------- Form fields ---------------- */

.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 4px; }
.field-label {
  display: block; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 8px; font-weight: 600;
}
.field-hint { font-size: 12px; color: var(--ink-3); margin-top: 7px; line-height: 1.5; }
.req { color: var(--accent); margin-left: 3px; }

/* Multi-value Type picker */
.pill-group { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-opt {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 99px;
  background: var(--surface); font-size: 13.5px; color: var(--ink-2);
  transition: .15s; user-select: none;
}
.pill-opt:hover { border-color: var(--line-2); background: var(--surface-2); }
.pill-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.pill-opt::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line-2); transition: .15s;
}
.pill-opt.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.pill-opt.is-on::before { background: var(--accent); border-color: var(--accent); }
.pill-opt:focus-within { box-shadow: 0 0 0 3px rgba(22,30,42,.06); }

.input, .textarea, select.input {
  width: 100%; font: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 13px; transition: .15s;
}
.input:focus, .textarea:focus, select.input:focus {
  outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 3px rgba(22,30,42,.06);
}
.textarea { resize: vertical; line-height: 1.7; min-height: 92px; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237E8894' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 15px;
}
.is-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(163,58,46,.1) !important; }

.rich-bar {
  display: flex; gap: 4px; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-bottom: none; border-radius: 9px 9px 0 0;
}
.rich-btn {
  font: inherit; font-size: 12.5px; min-width: 30px; height: 26px; padding: 0 8px;
  border-radius: 6px; border: 1px solid transparent; background: transparent;
  color: var(--ink-2); cursor: pointer; transition: .14s;
}
.rich-btn:hover { background: var(--surface); border-color: var(--line-2); }
.rich-field .textarea { border-radius: 0 0 9px 9px; }
.rich-meta {
  margin-top: 8px; text-align: right;
  font-size: 12px; color: var(--ink-3);
  font-family: var(--font-mono); letter-spacing: .02em;
}

/* ---------------- Picker ---------------- */

.picker { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 8px; }
.picker-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.picker-chips:empty { display: none; }
.picker-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px;
  background: var(--surface-2); border-radius: 6px; padding: 4px 6px 4px 9px; color: var(--ink-2);
}
.picker-chip button {
  border: none; background: transparent; color: var(--ink-3); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 2px; border-radius: 4px;
}
.picker-chip button:hover { color: var(--danger); }
.picker-chips + .picker-input { margin-top: 4px; }
.picker-input {
  width: 100%; border: none; background: transparent; font: inherit;
  font-size: 13.5px; padding: 7px 5px 3px; color: var(--ink); border-radius: 6px;
}
.picker-input:focus { outline: none; }
.picker-menu { max-height: 208px; overflow-y: auto; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.picker-opt {
  display: flex; gap: 12px; align-items: baseline; padding: 7px 8px;
  border-radius: 6px; cursor: pointer; font-size: 13.5px; color: var(--ink-2);
}
.picker-opt:hover { background: var(--surface-2); color: var(--ink); }
.picker-opt .rel-kind { padding-top: 1px; }
.picker-empty { padding: 8px; font-size: 12.5px; color: var(--ink-3); }

/* ---------------- Settings panels ---------------- */

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; margin-bottom: 16px; max-width: 760px;
}
.panel h2 { font-size: 15px; margin: 0 0 8px; letter-spacing: -.005em; }
.panel > p { font-size: 13.5px; color: var(--ink-2); line-height: 1.68; margin: 0 0 16px; }
.panel > p:last-child { margin-bottom: 0; }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.panel-actions + .hint { margin-top: 16px; }
.hint { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); letter-spacing: .01em; }

.counts { list-style: none; margin: 0; padding: 0; max-width: 380px; }
.counts li {
  display: flex; justify-content: space-between; gap: 16px;
  font-size: 13.5px; color: var(--ink-2); padding: 10px 0; border-bottom: 1px solid var(--line);
}
.counts li:last-child { border-bottom: none; padding-bottom: 0; }
.counts span { font-family: var(--font-mono); color: var(--ink); }

/* ---------------- Toast ---------------- */

.toast-root {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; max-width: calc(100vw - 32px);
}
.toast {
  background: var(--ink); color: #fff; font-size: 13px; padding: 10px 18px;
  border-radius: 999px; box-shadow: var(--shadow-m);
  opacity: 0; transform: translateY(8px); transition: .2s ease;
  text-align: center;
}
.toast.is-in { opacity: 1; transform: none; }

.tabbar { display: none; }

/* ---------------- Module skin ----------------
   Everything below only bites on the four module pages (body.is-module),
   where --accent* has already been swapped for that module's palette.
   Settings and Home keep the neutral blue/ink treatment.                   */

/* A whisper of the module's tint at the top of the page — enough to tell the
   four apart at a glance, faint enough to stay a calm light surface.
   `no-repeat` matters: without it the gradient is sized to the body box and
   tiles vertically, so a page shorter than the viewport showed a second tint
   band along the bottom edge. `fixed` pins it to the viewport instead. */
body.is-module {
  background: linear-gradient(180deg, var(--tint) 0px, var(--bg) 60vh) no-repeat fixed;
}

body.is-module .topnav a.is-active {
  background: var(--accent-soft); border-color: var(--tint-line); color: var(--accent-ink);
}
body.is-module .tabbar a.is-active {
  color: var(--accent-ink); background: var(--accent-soft);
}

body.is-module .chip.is-active {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink);
}

body.is-module .btn-primary { background: var(--accent-ink); border-color: var(--accent-ink); }
body.is-module .btn-primary:hover { background: var(--accent); border-color: var(--accent); }

body.is-module .card { border-color: var(--tint-line); }
body.is-module .card:hover { border-color: var(--accent); }
body.is-module .kbtn.is-active { background: var(--accent); border-color: var(--accent); }
body.is-module .tag { background: var(--accent-soft); color: var(--accent-ink); }
body.is-module .kw-pill { background: var(--accent-soft); border-color: var(--tint-line); color: var(--accent-ink); }
body.is-module .qa-meta-practice { background: var(--accent-soft); color: var(--accent-ink); }
body.is-module .soft-label { color: var(--accent-ink); opacity: .78; }

/* The live-recording box used to be hard-wired to blue, which clashed on
   every page that isn't Experience. */
body.is-module .rec.is-live { border-color: var(--tint-line); background: var(--accent-soft); }
body.is-module .answer-box { background: var(--accent-soft); border-color: var(--tint-line); }

/* ---------------- Notice bar ---------------- */

.notice-root { background: var(--accent-soft, #EDF2F8); border-bottom: 1px solid var(--tint-line, var(--line)); }
.notice {
  max-width: var(--max); margin: 0 auto; padding: 10px 32px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 13px; line-height: 1.5; color: var(--accent-ink, #3A5878);
}
.notice p { margin: 0; flex: 1 1 320px; min-width: 0; }
.notice .btn { padding: 6px 13px; font-size: 12.5px; flex: none; }
.notice .btn-ghost { color: var(--accent-ink, #3A5878); }
.notice .btn-ghost:hover { background: rgba(255,255,255,.6); }

/* ---------------- Responsive ---------------- */

@media (max-width: 900px) {
  .topnav { display: none; }
  .header-inner { padding: 0 18px; }
  .app-main { padding: 26px 18px 118px; }
  .notice { padding: 9px 18px; font-size: 12.5px; }

  /* Home fills the screen minus the tab bar. */
  .app-main.is-home { padding-top: 16px; padding-bottom: 78px; min-height: calc(100vh - var(--header-h)); }
  .module-grid { gap: 12px; }
  .module-card { padding: 18px 14px; border-radius: var(--radius); }
  .module-icon { margin-bottom: 12px; }
  .module-icon svg { width: 22px; height: 22px; }
  .module-card h2 { font-size: 21px; }
  .module-card p { font-size: 12.5px; }

  /* Plain block, not a column flex container: a column flex line takes its
     cross size from the widest item's max-content, which made the
     horizontally-scrolling .chips row push the whole page sideways. */
  .toolbar { display: block; }
  .toolbar > * { margin-bottom: 10px; }
  .toolbar > *:last-child { margin-bottom: 0; }
  .filters { min-width: 0; }
  .chips {
    flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    width: 100%; max-width: 100%; min-width: 0; padding-bottom: 3px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; font-size: 12.5px; padding: 5px 11px; }
  .tools { width: 100%; gap: 8px; }
  .tools .search-wrap { flex: 1 1 auto; width: auto; min-width: 0; }
  .search { min-width: 0; width: 100%; font-size: 13px; padding: 8px 12px; }
  .tools .btn { flex: none; font-size: 12.5px; padding: 9px 12px; }

  /* Three-up grid so a phone screen shows nine records without scrolling.
     Everything inside shrinks with it — the full text is one tap away. */
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stack { max-width: none; }

  .card { padding: 10px 9px 9px; border-radius: 10px; box-shadow: none; }
  .qa-card { padding: 10px 9px 9px; }
  .card:hover { transform: none; box-shadow: none; }
  .card-top { display: block; margin-bottom: 5px; }
  .card-top .date { display: block; }
  .card-top .badge, .card-top .soft-label { margin-top: 2px; }
  .qa-card .card-top { min-height: 0; }
  .card .date, .card .soft-label, .card .badge { font-size: 9px; letter-spacing: .02em; }
  .card .badge { line-height: 1.25; }
  .card .badge::before { width: 5px; height: 5px; }
  .card-title {
    font-size: 11.5px; line-height: 1.34; margin-bottom: 3px;
    max-height: calc(11.5px * 1.34 * 3); overflow: hidden;
  }
  .qa-question { font-size: 11.5px; line-height: 1.34; }
  .card-insight .card-title { font-size: 13px; line-height: 1.36; }
  .card-desc { display: none; }
  .tags { margin-top: 6px; gap: 4px; }
  .tag { font-size: 9px; padding: 2px 5px; border-radius: 4px; }
  .rel-line { margin-top: 6px; padding-top: 5px; font-size: 9.5px; }
  .qa-bar { gap: 4px; margin-top: 7px; }
  .kbtn { width: 23px; height: 23px; font-size: 10px; border-radius: 6px; }
  .card .icon-btn { width: 23px; height: 23px; border-radius: 6px; }
  .card .icon-btn svg { width: 12px; height: 12px; }
  .qa-meta-practice { font-size: 9px; padding: 2px 6px; }

  /* Tapping K / A / P on a phone widens that one card to the full row —
     a 100px column is no place to read an answer or run the recorder. */
  .qa-item:has(.qa-block:not([hidden])) .qa-block { max-width: none; }
  .qa-item:has(.qa-block:not([hidden])) .card-title { font-size: 14.5px; max-height: none; }
  .qa-item:has(.qa-block:not([hidden])) .card-top { margin-bottom: 10px; }
  .qa-item:has(.qa-block:not([hidden])) .card-top .date,
  .qa-item:has(.qa-block:not([hidden])) .card-top .soft-label { font-size: 11px; }
  .qa-item:has(.qa-block:not([hidden])) .kbtn { width: 30px; height: 30px; font-size: 12px; }
  .qa-item:has(.qa-block:not([hidden])) .icon-btn { width: 30px; height: 30px; }
  .qa-item:has(.qa-block:not([hidden])) .icon-btn svg { width: 15px; height: 15px; }
  .qa-item:has(.qa-block:not([hidden])) .qa-block { margin-top: 12px; padding-top: 12px; }
  .qa-item:has(.qa-block:not([hidden])) .kw-pill { font-size: 12.5px; }
  .empty { padding: 34px 16px; }
  .empty p { font-size: 12.5px; }

  .rec { padding: 22px 14px 20px; gap: 12px; }
  .rec-timer { font-size: 38px; }
  .rec-timer.is-live { font-size: 46px; }
  .rec-btn { width: 100%; min-height: 56px; font-size: 16px; }
  .p-record { padding: 14px; }
  .p-actions { gap: 7px; }
  .p-btn { min-height: 44px; padding: 10px 15px; font-size: 13px; }
  .p-btn svg { width: 14px; height: 14px; }
  .p-refl-input { font-size: 15px; }

  /* Full-screen on small screens: a centred dialog leaves too little
     room for reading or editing a long answer. */
  .sheet {
    width: 100%; max-width: none; height: 100%; max-height: none;
    border: none; border-radius: 0;
  }
  .sheet-body { padding: 22px 18px 40px; }
  .sheet-head, .sheet-foot { padding-left: 18px; padding-right: 18px; }
  .sheet-foot { border-radius: 0; }
  .detail-title { font-size: 23px; }

  .focus-head { padding: 0 16px; }
  .focus-body { padding: 30px 20px 140px; }
  .focus-q { font-size: 23px; }
  .focus-kw li { font-size: 14px; }
  .focus-answer { font-size: 16.5px; line-height: 1.72; }

  .panel { padding: 20px 18px; }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(247,249,251,.95);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px; font-size: 10px; letter-spacing: .01em;
    color: var(--ink-3); text-decoration: none; border-radius: 8px; transition: .15s;
  }
  .tabbar a.is-active { color: var(--ink); background: var(--surface-2); }
  .tabbar svg { width: 19px; height: 19px; }

  .toast-root { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 420px) {
  .module-card h2 { font-size: 19px; }
  .module-card p { font-size: 11.5px; }
  .tabbar a span:last-child { font-size: 9.5px; }
}

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