:root {
  color-scheme: light dark;
  /* The Great Wave, on washi: Prussian-blue ink on warm paper, foam white. */
  --bg: #eee6d2;          /* washi paper — the chrome */
  --panel: #f8fafc;       /* still water — the field you write into */
  --fg: #15324a;          /* Prussian-blue ink */
  --muted: #74859b;
  --accent: #225a85;      /* deep Berlin blue — links, actions */
  --accent-fg: #ffffff;   /* foam */
  --seafoam: #5e91bb;     /* crest highlight — hovers, glow */
  --danger: #b04f4c;
  --border: #dde2e8;      /* cool hairline on water */
  --paper-edge: #ddd1b8;  /* warm hairline on paper (chrome divider) */
  --code-bg: #e8eef4;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: ui-serif, "Hiragino Mincho ProN", "Yu Mincho", "Songti SC", Georgia, serif;
  --transition-fluid: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* The night sea. */
    --bg: #0d1a28;
    --panel: #142536;
    --fg: #dde6ef;
    --muted: #7d90a6;
    --accent: #6aa6d6;
    --accent-fg: #08131f;
    --seafoam: #4d7ba6;
    --danger: #d98b86;
    --border: #243748;
    --paper-edge: #243748;
    --code-bg: #0b1622;
  }
}

/* ===== Ripple effect (CSS-only) ===== */
@keyframes ripple-out {
  from {
    transform: scale(0);
    opacity: 0.35;
  }
  to {
    transform: scale(2);
    opacity: 0;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
body {
  background: var(--bg);
  color: var(--fg);
  font-size: 17px;
  line-height: 1.45;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ===== Wave divider ===== */
.topbar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 5px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 6'%3E%3Cpath d='M0,3 Q75,0 150,3 T300,3 T450,3 T600,3 T750,3 T900,3 T1050,3 T1200,3' fill='none' stroke='%23ddd1b8' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-size: 200px 5px;
  pointer-events: none;
}
@media (prefers-color-scheme: dark) {
  .topbar::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 6'%3E%3Cpath d='M0,3 Q75,0 150,3 T300,3 T450,3 T600,3 T750,3 T900,3 T1050,3 T1200,3' fill='none' stroke='%23243748' stroke-width='1.5'/%3E%3C/svg%3E");
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
  background: linear-gradient(to right, var(--bg), color-mix(in srgb, var(--accent) 8%, var(--bg)));
}
@media (prefers-color-scheme: dark) {
  .topbar {
    background: linear-gradient(to left, var(--bg), color-mix(in srgb, var(--accent) 8%, var(--bg)));
  }
}
.topbar .brand {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 19px;
  letter-spacing: 0.03em;
  color: var(--fg);
  text-decoration: none;
}
.topbar nav { display: flex; align-items: center; gap: 14px; }
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}
.primary-nav > a {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 7px;
  border-radius: 999px;
}
.primary-nav > a:hover { color: var(--accent); }
.primary-nav > a.current {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent);
}
.topbar nav button[type="submit"] {
  padding: 6px 14px;
  font-size: 15px;
  border-radius: 8px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.primary-nav { display: flex; align-items: center; gap: 12px; }
.more-nav { position: relative; }
.more-nav summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  list-style: none;
}
.more-nav summary::-webkit-details-marker { display: none; }
.more-nav[open] summary, .more-nav summary:hover { color: var(--fg); }
.more-nav.has-current summary { color: var(--accent); }
.more-nav-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 10px);
  right: 0;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  padding: 7px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--fg) 14%, transparent);
}
.more-nav-group + .more-nav-group {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.more-nav-heading {
  padding: 4px 8px 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.more-nav-menu a, .more-nav-menu .linkish {
  display: block;
  width: 100%;
  padding: 7px 8px;
  text-align: left;
  border-radius: 6px;
  white-space: nowrap;
}
.more-nav-menu a:hover, .more-nav-menu .linkish:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--fg); }
.more-nav-menu a.current { color: var(--accent); font-weight: 600; }
@media (max-width: 480px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar-actions { gap: 7px; }
  .primary-nav { gap: 9px; }
  .primary-nav a, .more-nav summary { font-size: 14px; }
  .primary-nav > a { height: 26px; padding: 0 6px; }
  .topbar-actions > button[type="submit"] { padding: 6px 10px; font-size: 14px; }
}

/* Library hub */
.library-hub {
  max-width: 860px;
  margin: 0 auto;
  padding: 42px 24px 64px;
}
.library-hub-intro { max-width: 620px; margin-bottom: 28px; }
.library-hub-intro h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 500;
}
.library-hub-intro p:last-child { margin: 7px 0 0; color: var(--muted); }
.library-hub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.library-hub-card {
  display: flex;
  min-height: 112px;
  flex-direction: column;
  justify-content: space-between;
  padding: 17px 18px;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
}
.library-hub-card:hover { border-color: var(--seafoam); }
.library-hub-card strong { font-size: 18px; font-weight: 600; }
.library-hub-card strong small { color: var(--accent); font-size: 13px; font-weight: 500; }
.library-hub-card span { color: var(--muted); font-size: 13px; }
@media (max-width: 560px) {
  .library-hub { padding: 32px 16px 52px; }
  .library-hub-grid { grid-template-columns: 1fr; }
}

/* Chinese flashcards + dictionary */
.flashcards { max-width: 780px; }
.flashcards .tag-title span, .dictionary-search h2 span {
  margin-left: 8px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: .55em;
  font-weight: 400;
  vertical-align: middle;
}
.flashcard-review {
  min-height: 300px;
  padding: 34px 24px 22px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.flashcard-prompt {
  margin: 16px 0 30px;
  font-size: clamp(3rem, 12vw, 5.5rem);
  line-height: 1.05;
}
.flashcard-answer {
  max-width: 620px;
  margin: 0 auto 28px;
  font-size: 1.15rem;
  line-height: 1.65;
}
.flashcard-play { margin-left: 8px; background: var(--code-bg); color: var(--fg); }
.flashcard-ratings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  max-width: 520px;
  margin: 0 auto;
}
.flashcard-ratings[hidden], .flashcard-answer[hidden] { display: none; }
.flashcard-ratings .again { background: #9f3e38; }
.flashcard-ratings .hard { background: #9a681e; }
.flashcard-ratings .good { background: #28705c; }
.flashcard-ratings .easy { background: #306895; }
.flashcard-skip { margin-top: 18px; }
.flashcard-skip .linkish { color: var(--muted); font-size: .9rem; }
.flashcard-caught-up { padding: 46px 0; color: var(--muted); }
.flashcard-caught-up div { color: var(--accent); font-size: 4rem; }

.dictionary-search { margin-top: 42px; }
.dictionary-search h2 { margin-bottom: 14px; }
.dictionary-search > form { display: flex; gap: 9px; }
.dictionary-search input[type="search"] { flex: 1; min-width: 0; }
.dictionary-results { display: grid; gap: 12px; margin-top: 20px; }
.dictionary-entry {
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.dictionary-entry-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.dictionary-entry-head strong { font-size: 1.75rem; }
.dictionary-entry-head > span:not(.dictionary-pinyin) { color: var(--muted); font-size: 1.25rem; }
.dictionary-pinyin { color: var(--accent); }
.dictionary-entry-head small { margin-left: auto; color: var(--muted); }
.dictionary-entry-head form { margin-left: auto; }
.dictionary-entry-head button { padding: 6px 10px; font-size: .85rem; }
.dictionary-entry ol { margin: 12px 0 0; padding-left: 22px; line-height: 1.5; }
@media (max-width: 520px) {
  .flashcard-review { padding: 26px 14px 18px; }
  .flashcard-ratings { grid-template-columns: repeat(2, 1fr); }
  .dictionary-entry-head form { width: 100%; margin-left: 0; }
}

button {
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background var(--transition-fluid), color var(--transition-fluid);
}
button:active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255,255,255,0.4) 0%, transparent 60%);
  animation: ripple-out 0.6s ease-out forwards;
  pointer-events: none;
}
button.linkish {
  background: none;
  color: var(--muted);
  padding: 0;
  font-weight: 400;
  font-size: 15px;
  overflow: visible;
}
button.linkish.danger { color: var(--danger); }

.page-compose { display: flex; flex-direction: column; }
.compose {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
}
.compose form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.compose textarea {
  flex: 1;
  width: 100%;
  min-height: 50vh;
  resize: none;
  /* still water, with the wave resting at its foot */
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 200' preserveAspectRatio='none'%3E%3Cpath d='M0,120C200,60,360,90,560,70C760,50,900,80,1200,30L1200,200L0,200Z' fill='%23225a85' fill-opacity='0.05'/%3E%3Cpath d='M0,160C220,110,420,150,640,120C820,96,1000,124,1200,92L1200,200L0,200Z' fill='%23225a85' fill-opacity='0.07'/%3E%3C/svg%3E") center bottom / 130% auto no-repeat;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  font: inherit;
  font-size: 17px;
  line-height: 1.5;
  transition: box-shadow var(--transition-fluid);
}
@media (prefers-color-scheme: dark) {
  .compose textarea {
    background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 200' preserveAspectRatio='none'%3E%3Cpath d='M0,120C200,60,360,90,560,70C760,50,900,80,1200,30L1200,200L0,200Z' fill='%236aa6d6' fill-opacity='0.05'/%3E%3Cpath d='M0,160C220,110,420,150,640,120C820,96,1000,124,1200,92L1200,200L0,200Z' fill='%236aa6d6' fill-opacity='0.07'/%3E%3C/svg%3E") center bottom / 130% auto no-repeat;
  }
}
.compose textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent), 0 6px 28px color-mix(in srgb, var(--seafoam) 30%, transparent);
}
.compose .hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}
.compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.compose-footer button { flex: none; }

/* ===== Today ===== */
.today { max-width: 1120px; margin: 0 auto; padding: 32px 24px 56px; }
.today-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}
.today h1 { margin: 0; font-family: var(--font-display); font-size: 32px; font-weight: 500; }
.today-intro > div > p:last-child { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.today-capture {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.today-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, .55fr);
  gap: 12px;
  margin-bottom: 28px;
}
.today-status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.today-status {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  padding: 15px 16px;
}
.today-status:hover, .today-card:hover { border-color: var(--seafoam); }
.today-status-label {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.today-status strong { display: block; margin-top: 5px; font-size: 17px; }
.today-status small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.today-section { margin: 0 0 12px; }
.today-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
}
.today-card { padding: 15px 16px; border-left: 3px solid var(--accent); }
.today-jeolgi { padding: 15px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.today-card-label, .today-section-head h2 {
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.today-jeolgi-current { display: flex; align-items: baseline; gap: 8px; margin-top: 3px; }
.today-jeolgi-hanja { font-family: ui-serif, "AppleMyungjo", "Batang", "Noto Serif CJK KR", "Malgun Gothic", serif; font-size: 30px; line-height: 1.2; }
.today-jeolgi-current small, .today-jeolgi-next small { color: var(--muted); font-size: 12px; }
.today-jeolgi-next { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.today-horoscope { margin: 0 0 28px; padding: 17px 18px; background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--seafoam); border-radius: var(--radius); }
.today-horoscope-signs { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.today-horoscope-text { max-width: 780px; margin: 9px 0 0; line-height: 1.55; }
.today-horoscope-retry { display: inline; }
.today-card p {
  display: -webkit-box;
  margin: 6px 0 7px;
  overflow: hidden;
  overflow-wrap: anywhere;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}
.today-card-meta { display: block; color: var(--muted); font-size: 12px; }
.today-new { color: var(--accent-fg); background: var(--accent); border-radius: 999px; padding: 2px 6px; font-size: 10px; letter-spacing: 0; }
.today-reading { margin: 0 0 28px; }
.today-reading-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.today-reading-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.today-book-list { padding: 15px 16px; }
.today-book-list h3 { margin: 0 0 8px; color: var(--fg); font-family: var(--font-display); font-size: 18px; font-weight: 500; }
.today-book-list ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.today-book-list li { border-bottom: 1px solid var(--border); }
.today-book-list li:last-child { border-bottom: 0; }
.today-book-list li a { display: block; padding: 10px 2px; color: var(--fg); text-decoration: none; }
.today-book-list li a:hover strong { color: var(--accent); }
.today-book-list strong, .today-book-list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-book-list strong { font-size: 15px; }
.today-book-list small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.today-empty { margin: 0; color: var(--muted); font-size: 14px; }
.today-empty a { color: var(--accent); }
.today-reading-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 16px;
  color: var(--fg);
  text-decoration: none;
}
.today-reading-link:hover { border-color: var(--seafoam); }
.today-reading-link strong, .today-reading-link small { display: block; }
.today-reading-link strong { font-size: 15px; }
.today-reading-link small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.today-reading-link-arrow { flex: none; color: var(--accent); font-size: 20px; }
.today-content { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); gap: 0 24px; }
.today-reminders { grid-column: 1; }
.today-undercurrent { grid-column: 2; }
.today-content-no-reminders .today-undercurrent { grid-column: 1; }
.today-activities { grid-column: 2; }
.today-ripples { grid-column: 1 / -1; margin-top: 14px; }
.today-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.today-section-head h2 { margin: 0; color: var(--muted); }
.today-section-head a { color: var(--muted); font-size: 13px; text-decoration: none; }
.today-section-head a:hover { color: var(--accent); }
.today-ripples ul, .today-activities ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.today-ripples li, .today-activities li { border-bottom: 1px solid var(--border); }
.today-ripples li a, .today-activities li a { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 12px 2px; color: var(--fg); text-decoration: none; }
.today-ripples li a:hover span, .today-activities li a:hover span { color: var(--accent); }
.today-ripples li span {
  display: -webkit-box;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.today-activities li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-ripples li small, .today-activities li small { flex: none; color: var(--muted); font-size: 12px; text-transform: capitalize; }
.today-ripples li a { align-items: flex-start; }
.today-ripples li small { padding-top: 2px; white-space: nowrap; }
.today-reminder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
.today-reminder-main a { color: var(--fg); font-weight: 600; text-decoration: none; }
.today-reminder-main a:hover { color: var(--accent); }
.today-reminder-main small { display: block; color: var(--muted); font-size: 12px; }
.today-reminder-actions, .reminder-row-actions { display: flex; align-items: center; gap: 9px; flex: none; }
.today-reminder-actions button { padding: 6px 10px; font-size: 13px; }
.today-tasks { grid-column: 1 / -1; }
.today-task {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; margin-bottom: 8px; background: var(--panel);
  border: 1px solid var(--border); border-left: 3px solid var(--seafoam); border-radius: var(--radius);
}
.today-task-main a { color: var(--fg); font-weight: 600; text-decoration: none; }
.today-task-main a:hover { color: var(--accent); }
.today-task-main small { display: block; color: var(--muted); font-size: 12px; }
.today-task-actions { display: flex; align-items: center; gap: 9px; flex: none; }
.today-task-actions button { padding: 6px 10px; font-size: 13px; }
@media (max-width: 720px) {
  .today { max-width: 680px; padding: 28px 16px 48px; }
  .today-overview, .today-reading-grid, .today-content { grid-template-columns: 1fr; }
  .today-undercurrent, .today-reminders, .today-tasks, .today-activities, .today-ripples { grid-column: auto; }
  .today-ripples { margin-top: 14px; }
}
@media (max-width: 480px) {
  .today { padding-top: 22px; }
  .today-intro { align-items: flex-start; flex-direction: column; gap: 12px; }
  .today-capture { width: 100%; justify-content: center; }
  .today-status-grid { grid-template-columns: 1fr; }
  .today-activities li a { align-items: flex-start; }
  .today-activities li small { white-space: nowrap; }
  .today-reminder { align-items: flex-start; flex-direction: column; }
  .today-reminder-actions { width: 100%; }
  .today-task { align-items: flex-start; flex-direction: column; }
  .today-task-actions { width: 100%; }
}

/* ===== Gemini usage meter ===== */
.ai-meter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  user-select: none;
}
.ai-meter:hover { border-color: var(--seafoam); }
.ai-meter-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent);
  animation: ai-meter-pulse 2.8s ease-out infinite;
}
@keyframes ai-meter-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  70%  { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
}
.ai-meter-label {
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg);
}
.ai-meter-cost {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}
.ai-meter-sep { opacity: 0.5; }
.ai-meter-tokens { font-variant-numeric: tabular-nums; }

/* ===== AI cost dashboard ===== */
.ai-costs { max-width: 760px; margin: 0 auto; padding: 28px 16px 48px; }
.ai-costs-intro { margin-bottom: 20px; }
.ai-costs h1 { margin: 0; font-family: var(--font-display); font-size: 32px; font-weight: 500; }
.ai-costs-intro p:last-child, .ai-cost-note { color: var(--muted); margin: 5px 0 0; font-size: 14px; }
.eyebrow { color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 3px; }
.ai-cost-total { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; align-items: baseline; }
.ai-cost-total span, .ai-cost-total small { color: var(--muted); font-size: 13px; }
.ai-cost-total strong { color: var(--accent); font-size: 25px; font-variant-numeric: tabular-nums; }
.ai-cost-total small { grid-column: 1 / -1; margin-top: 2px; }
.ai-cost-section { margin-top: 30px; }
.ai-cost-section h2 { font-family: var(--font-display); font-size: 22px; font-weight: 500; margin: 0 0 10px; }
.ai-cost-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.ai-cost-table { border-collapse: collapse; width: 100%; min-width: 510px; font-size: 14px; }
.ai-cost-table th, .ai-cost-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-cost-table th:first-child { text-align: left; font-weight: 500; color: var(--fg); }
.ai-cost-table thead th { color: var(--muted); font-size: 12px; font-weight: 600; }
.ai-cost-table tbody tr:last-child th, .ai-cost-table tbody tr:last-child td { border-bottom: 0; }

.list { padding: 12px 16px 40px; max-width: 760px; margin: 0 auto; }
.note {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 14px;
  margin-bottom: 12px;
  transition: border-color var(--transition-fluid);
}
.note .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.note .meta .grow { flex: 1; }
.note .meta a { color: var(--muted); text-decoration: none; }
.note .meta a:hover { color: var(--fg); }
.note .edited { font-style: italic; }
.note .body { word-wrap: break-word; }
.note .body p:first-child { margin-top: 0; }
.note .body p:last-child { margin-bottom: 0; }
.note .body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  overflow-x: auto;
}
.note .body code {
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}
.note .body pre code { background: transparent; padding: 0; }

.empty {
  color: var(--muted);
  text-align: center;
  margin-top: 60px;
  font-size: 19px;
}

.login {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}
.login h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 26px;
  letter-spacing: 0.03em;
  text-align: center;
}
.login input {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit;
  transition: box-shadow var(--transition-fluid);
}
.login input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}
.login .error { color: var(--danger); font-size: 14px; margin: 0; text-align: center; }

/* ===== Search bar ===== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  position: relative;
}
.search-input {
  flex: 1;
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit;
  font-size: 17px;
  transition: box-shadow var(--transition-fluid);
}
.search-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}
.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  color: var(--muted);
  border: 0;
  padding: 4px 10px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--transition-fluid), color var(--transition-fluid);
}
.search-clear:hover {
  color: var(--fg);
  background: var(--border);
}

/* ===== Search hint ===== */
.search-hint {
  margin: -8px 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.search-hint.hidden {
  display: none;
}

/* ===== Search results ===== */
.search-results {
  margin-top: 0;
}
.search-result {
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.search-result-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}
.search-result-kind {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.search-result-title {
  display: block;
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.25;
  text-decoration: none;
}
.search-result-title:hover { color: var(--accent); }
.search-result-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}
.search-result-snippet {
  margin-top: 9px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}
.result-note .body {
  font-size: 15px;
  line-height: 1.4;
  color: var(--muted);
}
.body-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.body-link:hover { color: var(--fg); }

/* ===== Highlighted terms ===== */
mark {
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0 2px;
  border-radius: 3px;
}

/* ===== Loading indicator ===== */
.loading {
  color: var(--muted);
  text-align: center;
  margin-top: 30px;
  font-style: italic;
}
.loading::after {
  content: " \2026";
  animation: dots 1.2s steps(3, end) infinite;
}
@keyframes dots {
  0%   { content: " \2026"; }
  33%  { content: " ."; }
  66%  { content: " .."; }
  100% { content: " \2026"; }
}

/* ===== AI answer card ===== */
.ai-card {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.ai-answer {
  line-height: 1.6;
  word-wrap: break-word;
}
.ai-answer p:first-child { margin-top: 0; }
.ai-answer p:last-child { margin-bottom: 0; }
.ai-answer code {
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}
.ai-answer pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  overflow-x: auto;
}
.ai-answer pre code { background: transparent; padding: 0; }

.ai-sources {
  margin-top: 12px;
  font-size: 14px;
}
.ai-sources summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}
.ai-source {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}
.ai-source:last-child { border-bottom: 0; }
.ai-source a {
  color: var(--fg);
  text-decoration: none;
  display: block;
}
.ai-source a:hover { color: var(--accent); }
.ai-source .meta-time {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

/* ===== AI error banner ===== */
.ai-error {
  background: var(--danger);
  color: var(--accent-fg);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 14px;
}

/* ===== Read-only assistant ===== */
.assistant-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 30px 16px 56px;
}
.assistant-intro { margin-bottom: 20px; }
.assistant-intro h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 500;
}
.assistant-intro p:last-child {
  max-width: 660px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
}
.assistant-form {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.assistant-form textarea {
  display: block;
  width: 100%;
  min-height: 108px;
  padding: 10px 11px;
  resize: vertical;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--fg);
  font: inherit;
  line-height: 1.45;
}
.assistant-form textarea:focus {
  outline: 2px solid var(--seafoam);
  outline-offset: 1px;
}
.assistant-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.assistant-readonly, .assistant-status {
  color: var(--muted);
  font-size: 13px;
}
.assistant-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 22px;
}
.assistant-example {
  padding: 7px 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}
.assistant-example:hover { color: var(--fg); border-color: var(--seafoam); }
.assistant-status { min-height: 20px; margin: 0 0 8px; }
.assistant-answer-card { margin-top: 8px; }
.assistant-answer-card .ai-sources { margin-top: 18px; }

/* ===== Flash messages ===== */
.flash-msg {
  background: var(--accent);
  color: var(--accent-fg);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  text-align: center;
}
.flash-msg.flash-err {
  background: #b3261e;
  color: #fff;
  margin-top: 8px;
}

/* ===== View page ===== */
.page-view { display: flex; flex-direction: column; }
.view { padding: 16px; max-width: 760px; margin: 0 auto; width: 100%; }
.view .view-note { margin-bottom: 24px; }
.view .view-note .body { font-size: 17px; line-height: 1.6; }
.view .view-note .body p:first-child { margin-top: 0; }

/* ===== Related notes ===== */
.related-notes {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.related-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 12px;
}
.related-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.related-note-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color var(--transition-fluid);
  position: relative;
  overflow: hidden;
}
.related-note-card:active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), color-mix(in srgb, var(--accent) 25%, transparent) 0%, transparent 60%);
  animation: ripple-out 0.6s ease-out forwards;
  pointer-events: none;
}
.related-note-card:hover {
  border-color: var(--accent);
}
.related-note-link {
  text-decoration: none;
  color: var(--fg);
  display: block;
}
.related-note-link:hover { color: var(--accent); }
.related-snippet {
  font-size: 14px;
  line-height: 1.4;
  margin: 0 0 4px;
  color: var(--muted);
}
.related-note-link:hover .related-snippet {
  color: var(--fg);
}
.related-similarity {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

/* ===== Undercurrent link (topbar cue) ===== */
.undercurrent-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.undercurrent-link.uc-unseen { color: var(--accent); font-weight: 500; }
.undercurrent-link.uc-seen,
.undercurrent-link.uc-none { color: var(--muted); }

/* The drop on water — one motif, three states. The center point and the
   settled ring are static, so the cue still reads under reduced motion. */
.uc-dot {
  position: relative;
  width: 10px;
  height: 10px;
  flex: none;
}
.uc-dot::before,
.uc-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

/* calm: still water — a faint drop point at rest, no rings */
.uc-none .uc-dot {
  background: radial-gradient(circle at center, var(--muted) 0 1.4px, transparent 2px);
  opacity: 0.65;
}

/* seen: the ripple has settled — one quiet ring around the drop point */
.uc-seen .uc-dot {
  background: radial-gradient(circle at center, var(--accent) 0 1.4px, transparent 2px);
}
.uc-seen .uc-dot::before {
  border: 1.5px solid color-mix(in srgb, var(--accent) 40%, transparent);
  transform: scale(1.3);
}

/* unseen: a fresh drop — rings spreading outward from a bright center */
.uc-unseen .uc-dot {
  background: radial-gradient(circle at center, var(--accent) 0 1.5px, transparent 2px);
}
.uc-unseen .uc-dot::before,
.uc-unseen .uc-dot::after {
  border: 1.5px solid var(--accent);
  opacity: 0;
  animation: uc-ripple 3.2s ease-out infinite;
}
.uc-unseen .uc-dot::after { animation-delay: 1.6s; }

@keyframes uc-ripple {
  0%   { transform: scale(0.25); opacity: 0; }
  20%  { opacity: 0.55; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ===== Undercurrent page ===== */
.undercurrent-intro { margin-bottom: 16px; }
.undercurrent-title {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin: 0 0 4px;
}
.undercurrent-sub { color: var(--muted); font-size: 14px; margin: 0; }
.note-actions { display: flex; align-items: center; gap: 12px; margin: 8px 0 0; }
.note-actions form { margin: 0; }
.note-actions a {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.note-actions a:hover { text-decoration: underline; }
.related-meta { display: flex; gap: 10px; align-items: baseline; }
.related-when { color: var(--muted); font-size: 12px; }
.undercurrent-calm { text-align: center; margin-top: 60px; }
.calm-glyph {
  font-size: 48px;
  line-height: 1;
  color: var(--muted);
  opacity: 0.5;
}
.calm-sub {
  color: var(--muted);
  font-size: 14px;
  max-width: 360px;
  margin: 4px auto 0;
}

/* ===== Toast overlay ===== */
.toast-overlay {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 15px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 1000;
  opacity: 0;
  transition: opacity var(--transition-fluid), transform var(--transition-fluid);
  pointer-events: none;
  white-space: nowrap;
}
.toast-overlay.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast-overlay.fade-out {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
}
.toast-overlay a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.toast-overlay a:hover {
  text-decoration: underline;
}

/* ===== Tags ===== */

/* Inline #tags inside rendered notes read as quiet currents you can follow. */
.tag-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.tag-link:hover { text-decoration: underline; }

/* Autocomplete dropdown, floated at the caret. */
.tag-suggest {
  position: fixed;
  z-index: 1100;
  min-width: 140px;
  max-width: 260px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  padding: 4px;
}
.tag-suggest-item {
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 15px;
  color: var(--fg);
  cursor: pointer;
  white-space: nowrap;
}
.tag-suggest-item.active,
.tag-suggest-item:hover {
  background: var(--code-bg);
  color: var(--accent);
}

/* Thread view: all the ripples in one current. */
.tag-intro { margin: 8px 0 20px; }
.tag-title {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 26px;
  margin: 0;
}
.tag-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 4px 0 0;
}
.tag-reading-link { margin: 8px 0 0; font-size: 14px; }
.tag-reading-link a { color: var(--accent); }
.tag-thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.thread-note {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

/* Tag index: every current at a glance. */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.tag-cloud-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 15px;
}
.tag-cloud-item:hover { border-color: var(--accent); }
.tag-cloud-count {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}

/* The Appeal: source-authored visual checkpoints, not generic AI cards. */
.reading { max-width: 900px; padding-bottom: 48px; }
.reading-back { margin: 8px 0 20px; font-size: 14px; }
.reading-back a { color: var(--muted); text-decoration: none; }
.reading-head { margin-bottom: 24px; }
.reading-head h1 { font-family: var(--font-display); font-size: clamp(2rem, 6vw, 3rem); margin: 0; }
.reading-head p, .reading-evidence { color: var(--muted); }
.reading-slider-panel, .reading-summary {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin: 18px 0;
}
.reading-slider-panel label { display: block; margin-bottom: 9px; }
.reading-slider-panel input[type="range"] { width: 100%; accent-color: var(--accent); }
.reading-slots { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.reading-slots a { color: var(--muted); font-size: 13px; text-decoration: none; padding: 2px 7px; border-radius: 99px; }
.reading-slots a.current { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); font-weight: 700; }
.reading-stamp { color: var(--muted); font-size: 13px; margin-top: 0; }
.reading-empty { margin: 24px 0; }
.appeal-snapshot { overflow: hidden; }
.appeal-snapshot h2 { font-family: var(--font-display); margin: 28px 0 12px; font-size: 1.45rem; }
.appeal-scene { display: grid; gap: 20px; }
.appeal-family { padding: 16px; border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border)); border-radius: 12px; background: color-mix(in srgb, var(--accent) 4%, var(--panel)); }
.appeal-family > h3 { margin: 0 0 12px; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.appeal-relationship-map { width: 100%; min-width: 780px; height: auto; overflow: visible; }
.appeal-relationship-map .link { fill: none; stroke: var(--seafoam); stroke-width: 2; }
.appeal-relationship-map .link.uncertain { stroke-dasharray: 6 5; opacity: .75; }
.appeal-relationship-map .arrow { fill: var(--seafoam); }
.appeal-person rect { fill: var(--panel); stroke: var(--accent); stroke-width: 1.4; rx: 8; }
.appeal-person text { fill: var(--fg); font-size: 14px; font-weight: 600; text-anchor: middle; }
.appeal-person .detail { fill: var(--muted); font-size: 11px; font-weight: 400; }
.appeal-relation { fill: var(--muted); font-size: 11px; font-style: italic; }
.appeal-map-scroll { overflow-x: auto; padding-bottom: 5px; }
.appeal-cast { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.appeal-cast div { display: grid; gap: 2px; padding: 9px 10px; border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent); }
.appeal-cast strong { font-size: 14px; }
.appeal-cast span { color: var(--muted); font-size: 13px; }
.appeal-note { margin: 0; padding: 12px 14px; border-left: 3px solid var(--seafoam); background: color-mix(in srgb, var(--accent) 5%, var(--panel)); }
.appeal-uncertain { color: var(--muted); font-style: italic; }
.appeal-overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.appeal-overview-grid p { margin: 0 0 12px; }
.appeal-overview-grid p:last-child { margin-bottom: 0; }
.appeal-roster { align-content: start; }
.appeal-roster > div { padding: 10px 12px; border-left: 2px solid color-mix(in srgb, var(--seafoam) 55%, var(--border)); }
.appeal-roster strong { font-size: 14px; }
.appeal-roster-wide p { margin: 0 0 10px; }
.appeal-roster-wide p:last-child { margin-bottom: 0; }
.appeal-dossier { --appeal-warn: #c97944; }
.appeal-dossier-lead { position: relative; padding: 21px 22px 22px; border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border)); border-radius: 14px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 9%, var(--panel)), var(--panel) 66%); }
.appeal-dossier-lead::after { content: "110"; position: absolute; right: 18px; top: 9px; color: color-mix(in srgb, var(--accent) 10%, transparent); font: 700 4.5rem/1 var(--font-display); pointer-events: none; }
.appeal-checkpoint-155 .appeal-dossier-lead::after { content: "155"; }
.appeal-checkpoint-190 .appeal-dossier-lead::after { content: "190"; }
.appeal-dossier-lead h2 { position: relative; z-index: 1; margin: 4px 0 9px; max-width: 720px; font-size: clamp(1.65rem, 4vw, 2.3rem); }
.appeal-dossier-lead > p:last-child { position: relative; z-index: 1; max-width: 780px; margin: 0; }
.appeal-kicker { margin: 0 0 5px; color: var(--accent); font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.appeal-status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.appeal-status-grid article { padding: 13px; border-top: 3px solid color-mix(in srgb, var(--seafoam) 75%, var(--border)); border-radius: 3px 3px 10px 10px; background: color-mix(in srgb, var(--seafoam) 5%, var(--panel)); }
.appeal-status-grid strong { display: block; margin: 3px 0 7px; font-size: .93rem; }
.appeal-status-grid p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.48; }
.appeal-status-label { color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.appeal-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 25px; margin-bottom: 15px; }
.appeal-section-heading h3 { margin: 0; color: var(--fg); font-family: var(--font-display); font-size: 1.22rem; letter-spacing: 0; text-transform: none; }
.appeal-section-heading > p { max-width: 300px; margin: 0; color: var(--muted); font-size: .78rem; text-align: right; }
.appeal-ledger-section { padding: 18px; }
.appeal-ledger { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--border); }
.appeal-ledger article { min-height: 132px; padding: 13px 14px; background: var(--panel); }
.appeal-ledger article.appeal-ledger-conflict { background: color-mix(in srgb, var(--appeal-warn) 7%, var(--panel)); }
.appeal-ledger strong { display: block; margin: 4px 0 7px; color: var(--accent); font: 700 1.3rem/1.1 var(--font-display); }
.appeal-ledger-conflict strong { color: color-mix(in srgb, var(--appeal-warn) 82%, var(--fg)); }
.appeal-ledger p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.appeal-ledger-step { font-size: .65rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.appeal-ledger-footnotes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.appeal-ledger-footnotes p { margin: 0; padding: 10px 12px; border-left: 2px solid var(--appeal-warn); background: color-mix(in srgb, var(--appeal-warn) 5%, var(--panel)); font-size: .8rem; }
.appeal-rumour-section { padding: 18px; }
.appeal-rumour-chain { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin: 0; padding: 0; list-style: none; }
.appeal-rumour-chain li { position: relative; display: flex; gap: 9px; min-width: 0; }
.appeal-rumour-chain li:not(:last-child)::after { content: "→"; position: absolute; top: 2px; right: -18px; color: var(--seafoam); font-size: 1.2rem; }
.appeal-rumour-chain li > span { display: grid; flex: 0 0 25px; height: 25px; place-items: center; border-radius: 50%; background: var(--seafoam); color: #102a29; font-size: .73rem; font-weight: 800; }
.appeal-rumour-chain strong { display: block; font-size: .82rem; line-height: 1.3; }
.appeal-rumour-chain p { margin: 5px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.45; }
.appeal-pressure-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.appeal-pressure-card { padding: 16px; }
.appeal-pressure-card h3 { margin: 0 0 10px; color: var(--fg); font-family: var(--font-display); font-size: 1.08rem; letter-spacing: 0; text-transform: none; }
.appeal-pressure-card p:not(.appeal-kicker) { margin: 0 0 9px; font-size: .84rem; }
.appeal-pressure-card p:last-child { margin-bottom: 0; }
.appeal-world-context > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.appeal-world-context p { margin: 0; font-size: .82rem; }
.appeal-crosscheck-section { padding: 18px; }
.appeal-crosscheck-grid { display: grid; grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr); gap: 10px; align-items: stretch; }
.appeal-crosscheck-grid article { padding: 13px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel); }
.appeal-crosscheck-grid article > span { color: var(--muted); font-size: .65rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.appeal-crosscheck-grid article strong { display: block; margin: 4px 0 6px; font-size: .84rem; }
.appeal-crosscheck-grid article p { margin: 0; color: var(--muted); font-size: .77rem; line-height: 1.45; }
.appeal-versus { display: grid; place-items: center; color: color-mix(in srgb, var(--appeal-warn) 82%, var(--fg)); font: 700 1.2rem/1 var(--font-display); }
.appeal-pressure-wide { grid-column: 1 / -1; }
.appeal-thread-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.appeal-thread-list p { padding-left: 10px; border-left: 2px solid color-mix(in srgb, var(--seafoam) 65%, var(--border)); }
.appeal-production-board { padding: 18px; }
.appeal-production-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.appeal-production-grid article { padding: 12px; border-top: 2px solid color-mix(in srgb, var(--seafoam) 65%, var(--border)); background: color-mix(in srgb, var(--seafoam) 4%, var(--panel)); }
.appeal-production-grid strong { display: block; margin-bottom: 6px; font-size: .83rem; }
.appeal-production-grid p { margin: 0; color: var(--muted); font-size: .77rem; line-height: 1.48; }
@media (max-width: 620px) { .appeal-overview-grid { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .appeal-status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .appeal-rumour-chain { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 20px; } .appeal-rumour-chain li:nth-child(2)::after { content: none; } .appeal-world-context > div, .appeal-production-grid { grid-template-columns: 1fr; gap: 10px; } }
@media (max-width: 620px) { .appeal-ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); } .appeal-pressure-grid { grid-template-columns: 1fr; } .appeal-pressure-wide { grid-column: auto; } .appeal-thread-list { grid-template-columns: 1fr; } .appeal-section-heading { display: block; } .appeal-section-heading > p { max-width: none; margin-top: 7px; text-align: left; } }
@media (max-width: 520px) { .reading { padding-left: 12px; padding-right: 12px; } .reading-slider-panel, .reading-summary { padding: 15px; } .appeal-cast { grid-template-columns: 1fr; } }
@media (max-width: 460px) { .appeal-status-grid, .appeal-ledger, .appeal-ledger-footnotes, .appeal-rumour-chain, .appeal-crosscheck-grid { grid-template-columns: 1fr; } .appeal-rumour-chain li:not(:last-child)::after { content: "↓"; top: auto; right: auto; bottom: -19px; left: 7px; } .appeal-versus { min-height: 20px; } .appeal-dossier-lead { padding: 17px; } }

/* ===== The tide (RSS reader) ===== */

/* Nav cue: a quiet count of what's washed in unread. */
.tide-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  vertical-align: 1px;
}

.tide { padding: 12px 16px 48px; max-width: 760px; margin: 0 auto; }

.tide-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0 20px;
}
.tide-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  color: var(--fg);
  margin: 0;
}
.tide-sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.tide-head-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.tide-actions-text {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}
.tide-toggle { color: var(--muted); text-decoration: none; }
.tide-toggle:hover { color: var(--fg); }

/* Sort mode: a two-icon segmented pill. ✦ = for you, clock = latest. */
.tide-sort {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.tide-sort-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 26px;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.tide-sort-opt + .tide-sort-opt { border-left: 1px solid var(--border); }
.tide-sort-opt:hover { color: var(--fg); }
.tide-sort-opt.is-active { background: var(--accent); color: var(--accent-fg); }
.tide-sort-opt svg { display: block; }

.tide-list { list-style: none; margin: 0; padding: 0; }
.tide-item {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--seafoam);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 12px;
  transition: border-color var(--transition-fluid), opacity var(--transition-fluid);
}
.tide-item:hover { border-left-color: var(--accent); }
.tide-item.is-read { opacity: 0.5; border-left-color: var(--border); }
.search-tide-result {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
}

/* The sliding surface (built by JS) that carries the card content; swipe hints
   sit behind it and are revealed as it slides. */
.tide-swipe-body {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: var(--panel);
  touch-action: pan-y;
  will-change: transform;
  transition: transform 0.28s cubic-bezier(.2,.7,.2,1), opacity 0.28s ease;
}
.tide-hint {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: none;
  align-items: center;
  padding: 0 20px;
  font-size: 13px;
  font-weight: 600;
}
.tide-hint.show { display: flex; }
.tide-hint-up {
  justify-content: flex-start;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
}
.tide-hint-down {
  justify-content: flex-end;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 16%, var(--panel));
}
/* Smooth collapse when a card is dismissed via "mark read" or a swipe. */
.tide-item.is-dismissing {
  transition: height 0.3s ease, margin 0.3s ease, opacity 0.3s ease;
}

.tide-item-main { min-width: 0; flex: 1; }
a.tide-item-title {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.35;
  color: var(--fg);
  text-decoration: none;
  margin: 0 0 4px;
}
a.tide-item-title:hover { color: var(--accent); }
.tide-summary {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin: 4px 0 8px;
  word-wrap: break-word;
}
.tide-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}
.tide-source { font-weight: 600; color: var(--seafoam); }
a.tide-source-link { text-decoration: none; }
a.tide-source-link:hover { color: var(--accent); text-decoration: underline; }
.tide-dot { opacity: 0.5; }

.tide-item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: none;
}
.tide-ripple {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  white-space: nowrap;
}
.tide-extended { color: var(--muted); font-size: 13px; white-space: nowrap; text-decoration: none; }
.tide-extended:hover { color: var(--accent); text-decoration: underline; }
.tide-mark { font-size: 13px; white-space: nowrap; }
.tide-to-read { font-size: 13px; white-space: nowrap; color: var(--seafoam); }

.tide-extended-page { max-width: 760px; }
.tide-extended-back { margin: 8px 0 18px; }
.tide-extended-back a { color: var(--muted); text-decoration: none; }
.tide-extended-back a:hover { color: var(--accent); }
.tide-extended-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.tide-extended-card h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 5vw, 2.4rem); line-height: 1.2; margin: 0 0 10px; }
.tide-extended-card h2 { font-family: var(--font-display); font-size: 1.35rem; margin: 24px 0 10px; }
.tide-extended-card p, .tide-extended-card li { line-height: 1.6; }
.tide-extended-source { color: var(--muted); font-size: 13px; }
.tide-extended-status { text-align: center; margin-top: 40px; }

/* Predicted-match badge, shown only in the "for you" (smart) ranking. */
.tide-score { color: var(--accent); font-weight: 600; }

/* Up/down taste controls. Muted until hovered or active, so they sit quietly
   until the reader wants to teach the tide something. */
.tide-rate { display: inline-flex; gap: 2px; }
.tide-thumb {
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 12px;
  line-height: 1;
  border-radius: 6px;
  color: var(--muted);
  opacity: 0.55;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
}
.tide-thumb:hover { opacity: 1; background: var(--panel); }
.tide-up.is-active { color: var(--accent); opacity: 1; }
.tide-down.is-active { color: var(--danger); opacity: 1; }

.tide-empty { text-align: center; margin-top: 56px; }
.tide-empty .calm-sub a { color: var(--accent); text-decoration: none; }
.tide-empty .calm-sub a:hover { text-decoration: underline; }

/* Feeds management */
.feed-add {
  display: flex;
  gap: 8px;
  margin: 0 0 20px;
}
.feed-add .search-input { flex: 1; }
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.feed-row-main { min-width: 0; }
.feed-name {
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 3px;
}
.feed-name:hover { color: var(--accent); }
.feed-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}
.feed-unread { color: var(--accent); font-weight: 600; }
.feed-error { color: var(--danger); }

/* Read later is a durable queue for links from the tide or from the user's
   own hand. It intentionally has no notes/search/embedding behavior. */
.reading-list { max-width: 760px; }
.reading-list-intro { margin-bottom: 18px; }
.reading-list-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  margin: 0 0 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.reading-list-form h2, .reading-list-section h2 { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 500; }
.reading-list-form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.reading-list-form input, .reading-list-form textarea { width: 100%; padding: 9px 10px; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; font: inherit; }
.reading-list-form textarea { resize: vertical; }
.reading-list-form button { align-self: flex-start; }
.reading-list-views { display: flex; gap: 14px; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.reading-list-views a { padding: 0 0 8px; color: var(--muted); text-decoration: none; font-size: 14px; }
.reading-list-views a.current { color: var(--accent); border-bottom: 2px solid var(--accent); font-weight: 600; }
.reading-list-items { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.reading-list-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.reading-list-item.is-completed { opacity: .68; }
.reading-list-item-main { min-width: 0; flex: 1; }
.reading-list-title { display: block; color: var(--fg); font-family: var(--font-display); font-size: 18px; line-height: 1.35; text-decoration: none; overflow-wrap: anywhere; }
.reading-list-title:hover { color: var(--accent); }
.reading-list-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px; margin-top: 5px; color: var(--muted); font-size: 12px; }
.reading-list-note { margin: 8px 0 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.reading-list-actions { display: flex; flex: none; flex-direction: column; align-items: flex-end; gap: 8px; }
.reading-list-actions form { margin: 0; }
.reading-list-actions button { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
.reading-list-actions .linkish { padding: 4px 2px; }
.reading-list-actions .danger { color: var(--danger); }
.reading-list-empty { text-align: center; margin-top: 46px; }
.reading-list-empty .calm-sub { color: var(--muted); font-size: 14px; }
@media (max-width: 520px) {
  .reading-list-item { flex-direction: column; }
  .reading-list-actions { width: 100%; flex-direction: row; align-items: center; justify-content: flex-end; }
}

/* Reminders are deliberately a small management surface: one place to make a
   schedule and one quiet list of what needs attention. */
.tasks { max-width: 760px; }
.task-form {
  display: flex; flex-direction: column; gap: 12px; padding: 16px; margin: 0 0 24px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.task-form h2, .task-section h2 { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 500; }
.task-form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.task-form input, .task-form textarea, .task-form select {
  width: 100%; padding: 9px 10px; color: var(--fg); background: var(--bg);
  border: 1px solid var(--border); border-radius: 7px; font: inherit;
}
.task-form textarea { resize: vertical; }
.task-form button { align-self: flex-start; }
.task-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.task-views { display: flex; gap: 14px; margin: 0 0 22px; border-bottom: 1px solid var(--border); }
.task-views a { padding: 0 0 8px; color: var(--muted); text-decoration: none; font-size: 14px; }
.task-views a.current { color: var(--accent); border-bottom: 2px solid var(--accent); font-weight: 600; }
.task-section { margin: 0 0 28px; }
.task-section h2 { margin-bottom: 10px; }
.task-section-help { margin: -2px 0 12px; color: var(--muted); font-size: 13px; }
.task-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 13px 14px; margin-bottom: 8px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.task-row.is-stale { border-left: 3px solid var(--danger); }
.task-row.is-done, .task-row.is-dropped { opacity: .66; }
.task-row-main { min-width: 0; flex: 1; }
.task-title { display: block; color: var(--fg); font-family: var(--font-display); font-size: 18px; line-height: 1.35; text-decoration: none; overflow-wrap: anywhere; }
.task-title:hover { color: var(--accent); }
.task-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.task-row.is-stale .task-meta { color: var(--danger); }
.task-details { margin: 8px 0 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-row-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; flex: none; }
.task-row-actions form, .task-action-grid form { margin: 0; }
.task-row-actions button { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
.task-row-actions .linkish { padding: 4px 2px; }
.task-row-actions .danger { color: var(--danger); }
.task-detail-actions { padding-top: 2px; }
.task-action-grid { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.task-action-grid button { padding: 6px 10px; font-size: 13px; }
@media (max-width: 520px) {
  .task-fields { grid-template-columns: 1fr; }
  .task-row { flex-direction: column; }
  .task-row-actions { width: 100%; justify-content: flex-start; }
}

.reminders { max-width: 720px; }
.back-link { margin: 8px 0 16px; font-size: 14px; }
.back-link a { color: var(--muted); text-decoration: none; }
.back-link a:hover { color: var(--accent); }
.reminder-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  margin: 0 0 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.reminder-form h2, .reminder-section h2 { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 500; }
.reminder-form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.reminder-form input, .reminder-form textarea, .reminder-form select {
  width: 100%; padding: 9px 10px; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; font: inherit;
}
.reminder-form textarea { resize: vertical; }
.form-optional, .form-help { color: var(--muted); font-size: 12px; font-weight: 400; }
.form-help { margin: -4px 0 0; }
.reminder-schedule-fields { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 10px; }
.check-label { flex-direction: row !important; align-items: center; }
.check-label input { width: auto; }
.reminder-form button { align-self: flex-start; }
.reminder-views { display: flex; gap: 14px; margin: 0 0 22px; border-bottom: 1px solid var(--border); }
.reminder-views a { padding: 0 0 8px; color: var(--muted); text-decoration: none; font-size: 14px; }
.reminder-views a.current { color: var(--accent); border-bottom: 2px solid var(--accent); font-weight: 600; }
.reminder-section { margin: 0 0 28px; }
.reminder-section h2 { margin-bottom: 10px; }
.reminder-action-row, .reminder-series-list li, .occurrence-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 14px; margin-bottom: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.reminder-action-row > div:first-child, .occurrence-list li > div:first-child { min-width: 0; }
.reminder-action-row a, .reminder-series-list a { color: var(--fg); font-weight: 600; text-decoration: none; }
.reminder-action-row a:hover, .reminder-series-list a:hover { color: var(--accent); }
.reminder-action-row small, .reminder-series-list small, .occurrence-list small { display: block; color: var(--muted); font-size: 12px; }
.reminder-row-actions button { padding: 6px 10px; font-size: 13px; }
.reminder-row-actions .linkish { padding: 4px 2px; }
.reminder-schedule-list, .reminder-series-list, .occurrence-list { margin: 0; padding: 0; list-style: none; }
.reminder-schedule-list li { display: flex; align-items: baseline; gap: 14px; padding: 10px 3px; border-bottom: 1px solid var(--border); }
.reminder-schedule-list time { flex: 0 0 116px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.reminder-schedule-list a { color: var(--fg); text-decoration: none; }
.reminder-schedule-list a:hover { color: var(--accent); }
.reminder-schedule-list .is-outstanding time { color: var(--danger); font-weight: 600; }
.reminder-series-list li.is-paused { opacity: .62; }
.occurrence-list strong { font-size: 14px; font-variant-numeric: tabular-nums; }

/* Activity is a standalone movement log: freeform enough for a walk, structured
   enough to make a strength session legible later. */
.activity { max-width: 780px; }
.activity-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 0 0 22px; }
.activity-stats div { padding: 12px; background: color-mix(in srgb, var(--accent) 7%, var(--panel)); border: 1px solid var(--border); border-radius: var(--radius); }
.activity-stats strong, .activity-stats span { display: block; }
.activity-stats strong { color: var(--accent); font-family: var(--font-display); font-size: 25px; font-weight: 500; font-variant-numeric: tabular-nums; }
.activity-stats span { color: var(--muted); font-size: 12px; }
.activity-form { display: flex; flex-direction: column; gap: 12px; padding: 16px; margin: 0 0 24px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.activity-form h2, .activity-section h2 { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 500; }
.activity-form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.activity-form input, .activity-form textarea, .activity-form select { width: 100%; padding: 9px 10px; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; font: inherit; }
.activity-form textarea { resize: vertical; }
.activity-form button { align-self: flex-start; }
.activity-core-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.activity-exercises-editor { display: flex; flex-direction: column; gap: 7px; min-width: 0; margin: 0; padding: 10px; border: 1px solid var(--border); border-radius: 7px; }
.activity-exercises-editor legend { padding: 0 3px; color: var(--muted); font-size: 13px; }
.activity-exercise-heading, .activity-exercise-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px 72px auto; gap: 8px; }
.activity-exercise-rows { display: flex; flex-direction: column; gap: 7px; }
.activity-exercise-row .linkish { align-self: center; }
.activity-exercise-heading { padding: 0 1px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.activity-template-builder { margin: -8px 0 26px; }
.activity-template-builder summary { color: var(--accent); cursor: pointer; font-size: 14px; }
.activity-template-form { margin: 12px 0 0; }
.activity-section { margin: 0 0 28px; }
.activity-section h2 { margin-bottom: 10px; }
.activity-template-list, .activity-entry-list, .activity-exercise-list { margin: 0; padding: 0; list-style: none; }
.activity-template-list { display: flex; flex-direction: column; gap: 8px; }
.activity-template-list li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.activity-template-list strong, .activity-template-list span { display: block; }
.activity-template-list span { margin-top: 2px; color: var(--muted); font-size: 13px; }
.activity-template-list a { color: var(--accent); font-size: 14px; }
.activity-entry-list { display: flex; flex-direction: column; gap: 10px; }
.activity-entry-list > li { padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.activity-entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.activity-entry-head time, .activity-entry-head small { color: var(--muted); font-size: 13px; }
.activity-entry-actions { display: flex; align-items: baseline; gap: 10px; }
.activity-entry-actions a { color: var(--accent); font-size: 13px; }
.activity-kind { margin-left: 8px; color: var(--accent); font-size: 12px; text-transform: capitalize; }
.activity-form-actions { display: flex; align-items: center; gap: 12px; }
.activity-template-note, .activity-notes { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.activity-exercise-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.activity-exercise-list li { padding: 3px 7px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; font-size: 13px; }
.activity-exercise-list span { color: var(--muted); }

/* Books use the same deliberately compact management surface as reminders.
   The review itself is rendered by the normal ripple view and needs no second
   markdown system here. */
.books { max-width: 760px; }
.book-identity { position: sticky; top: 0; z-index: 3; margin: 8px 0 20px; padding: 10px 0 12px; background: var(--bg); border-bottom: 1px solid var(--border); }
.book-form { display: flex; flex-direction: column; gap: 12px; padding: 16px; margin: 0 0 24px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.book-form h2, .book-section h2, .book-review h2, .book-observations h2 { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 500; }
.book-form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.book-form input, .book-form textarea, .book-form select { width: 100%; padding: 9px 10px; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; font: inherit; }
.book-form textarea { resize: vertical; }
.book-form button { align-self: flex-start; }
.book-core-fields, .book-meta-fields { display: grid; gap: 10px; }
.book-core-fields { grid-template-columns: 1fr 1fr; }
.book-meta-fields { grid-template-columns: repeat(3, 1fr); }
.book-observations-editor fieldset { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; padding: 10px; border: 1px solid var(--border); border-radius: 7px; }
.book-observations-editor legend { padding: 0 3px; color: var(--muted); font-size: 13px; }
.book-observation-rows { display: flex; flex-direction: column; gap: 8px; }
.book-observation-row { display: grid; grid-template-columns: 132px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.book-observation-row .linkish { padding: 5px 2px; font-size: 13px; white-space: nowrap; }
.book-section { margin: 0 0 28px; }
.book-section h2 { margin-bottom: 10px; }
.book-list { margin: 0; padding: 0; list-style: none; }
.book-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 12px 14px; margin-bottom: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.book-list a { min-width: 0; color: var(--fg); text-decoration: none; }
.book-list a:hover { color: var(--accent); }
.book-list a strong, .book-list a span { display: block; }
.book-list a span, .book-list small { color: var(--muted); font-size: 13px; }
.book-list small { flex: none; }
.book-review-link { margin: 10px 0 0; font-size: 14px; }
.book-review-link a { color: var(--accent); }
.book-tag-link, .tag-book-link { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.book-tag-link a, .tag-book-link a { color: var(--accent); }
.book-recommendations { max-width: 860px; }
.recommendation-message { margin-bottom: 20px; }
.recommendation-list { display: flex; flex-direction: column; gap: 14px; }
.recommendation-card { padding: 18px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.recommendation-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.recommendation-heading h2 { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 500; }
.recommendation-heading p, .recommendation-award { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.recommendation-match { flex: none; padding: 5px 8px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 999px; font-size: 13px; }
.recommendation-synopsis { margin: 14px 0; line-height: 1.55; }
.recommendation-subjects { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.recommendation-subjects span { padding: 3px 7px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 999px; font-size: 12px; }
.recommendation-evidence { display: flex; align-items: baseline; gap: 7px; margin: 10px 0; line-height: 1.45; font-size: 14px; }
.recommendation-evidence .observation-status { font-size: 12px; }
.recommendation-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.recommendation-actions form { margin: 0; }
.recommendation-actions a { color: var(--accent); font-size: 13px; }
.cwa-review { max-width: 860px; }
.cwa-review-intro { margin-bottom: 24px; }
.cwa-review-card { margin: 0 0 22px; padding: 18px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.cwa-review-card h2 { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 500; }
.cwa-review-meta { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.cwa-review-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 18px; margin: 16px 0; }
.cwa-review-source, .cwa-review-proposal { padding: 14px; background: color-mix(in srgb, var(--bg) 68%, transparent); border: 1px solid var(--border); border-radius: 8px; }
.cwa-review-grid h3 { margin: 0 0 9px; font-size: 15px; }
.cwa-review-grid p { margin: 8px 0; line-height: 1.5; }
.cwa-review-grid a { color: var(--accent); }
.cwa-review-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.cwa-review-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.cwa-review-actions button { padding: 7px 11px; font-size: 13px; }
.cwa-review-actions .reject { background: var(--danger); }
.cwa-review-manual { border-top: 1px solid var(--border); padding-top: 16px; }
.cwa-review-manual summary { color: var(--muted); cursor: pointer; font-size: 13px; }
.cwa-review-edit { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.cwa-review-edit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cwa-review-edit label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.cwa-review-edit input, .cwa-review-edit textarea { width: 100%; padding: 9px 10px; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; font: inherit; }
.cwa-review-edit textarea { resize: vertical; min-height: 110px; }
.cwa-review-edit button { align-self: flex-start; }
.book-review { margin: 0 0 24px; padding: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.book-review h2 { margin-bottom: 12px; }
.book-review p:last-child { margin-bottom: 0; }
.book-observations { margin: 0 0 24px; padding: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.book-observations h2 { margin-bottom: 10px; }
.book-observations ul { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.book-observations li { display: flex; align-items: baseline; gap: 8px; }
.book-posts { margin: 0 0 24px; }
.book-posts h2 { margin: 0 0 10px; font-family: var(--font-display); font-size: 21px; font-weight: 500; }
.book-post-list { display: flex; flex-direction: column; gap: 14px; }
.book-post { padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.book-post .body { margin-top: 10px; }
.observation-status { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; font-weight: 700; font-size: 14px; }
.observation-status.positive { color: #216c3a; background: #d9f0df; }
.observation-status.negative { color: #9a3430; background: #f9dedc; }
.note-book-link { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.note-book-link a { color: var(--accent); }
.author-suggest { position: fixed; z-index: 20; min-width: 180px; max-width: min(420px, calc(100vw - 24px)); overflow: hidden; background: var(--panel); border: 1px solid var(--border); border-radius: 7px; box-shadow: 0 7px 22px rgba(0,0,0,.18); }
.author-suggest-item { padding: 9px 10px; cursor: pointer; color: var(--fg); font-size: 14px; }
.author-suggest-item.active, .author-suggest-item:hover { color: var(--bg); background: var(--accent); }
.author-suggest-item em { font-style: normal; opacity: .78; }

/* Movies keep only the identity fields needed to find a film again. */
.movies { max-width: 760px; }
.movie-identity { position: sticky; top: 0; z-index: 3; margin: 8px 0 20px; padding: 10px 0 12px; background: var(--bg); border-bottom: 1px solid var(--border); }
.movie-form { display: flex; flex-direction: column; gap: 12px; padding: 16px; margin: 0 0 24px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.movie-form h2, .movie-section h2, .movie-review h2 { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 500; }
.movie-form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.movie-form input, .movie-form textarea { width: 100%; padding: 9px 10px; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; font: inherit; }
.movie-form textarea { resize: vertical; }
.movie-form button { align-self: flex-start; }
.movie-core-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(90px, .8fr) minmax(0, 1.2fr); gap: 10px; }
.movie-section { margin: 0 0 28px; }
.movie-section h2 { margin-bottom: 10px; }
.movie-list { margin: 0; padding: 0; list-style: none; }
.movie-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 12px 14px; margin-bottom: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.movie-list a { min-width: 0; color: var(--fg); text-decoration: none; }
.movie-list a:hover { color: var(--accent); }
.movie-list a strong, .movie-list a span { display: block; }
.movie-list a span, .movie-list small { color: var(--muted); font-size: 13px; }
.movie-list small { flex: none; }
.movie-review { margin: 0 0 24px; padding: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.movie-review h2 { margin-bottom: 12px; }
.movie-review p:last-child { margin-bottom: 0; }

@media (max-width: 480px) {
  .book-core-fields, .book-meta-fields { grid-template-columns: 1fr; }
  .book-observation-row { grid-template-columns: 1fr auto; }
  .book-observation-row input { grid-column: 1 / -1; grid-row: 2; }
  .book-list li { align-items: flex-start; flex-direction: column; gap: 4px; }
  .movie-core-fields { grid-template-columns: 1fr; }
  .movie-list li { align-items: flex-start; flex-direction: column; gap: 4px; }
  .recommendation-heading { flex-direction: column; gap: 7px; }
  .cwa-review-grid, .cwa-review-edit-fields { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .reminder-schedule-fields { grid-template-columns: 1fr 1fr; }
  .reminder-schedule-fields label:last-child { grid-column: 1 / -1; }
  .reminder-action-row, .occurrence-list li { align-items: flex-start; flex-direction: column; }
  .reminder-row-actions { flex-wrap: wrap; }
  .reminder-schedule-list li { gap: 8px; flex-direction: column; }
  .reminder-schedule-list time { flex: auto; }
  .activity-stats { grid-template-columns: 1fr; }
  .activity-core-fields { grid-template-columns: 1fr 1fr; }
  .activity-core-fields label:last-child { grid-column: 1 / -1; }
  .activity-exercise-heading { display: none; }
  .activity-exercise-row { grid-template-columns: minmax(0, 1fr) 62px 62px auto; }
}

@media (max-width: 480px) {
  .tide-swipe-body { flex-direction: column; }
  .tide-item-actions, .search-tide-result {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    align-self: stretch;
    width: 100%;
  }
}

/* ===== The current (on-demand daily news briefing) ===== */

/* Nav cue: a swell that rises when something unread has surfaced. */
.current-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.current-link.cur-unseen { color: var(--accent); font-weight: 500; }
.current-link.cur-seen,
.current-link.cur-none { color: var(--muted); }
.cur-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  border: 1.5px solid currentColor;
  background: transparent;
}
.cur-none .cur-dot { opacity: 0.5; }
.cur-unseen .cur-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent);
  animation: ai-meter-pulse 2.8s ease-out infinite;
}

.current { padding: 12px 16px 48px; max-width: 1000px; margin: 0 auto; }

/* Two-column: sticky card index on the left, cards on the right. Collapses to a
   single column (index hidden) on phones — see the media query below. */
.current-layout { display: flex; gap: 28px; align-items: flex-start; }
.current-main { flex: 1 1 auto; min-width: 0; max-width: 760px; }
.current-nav {
  flex: 0 0 208px;
  position: sticky;
  top: 16px;
  align-self: flex-start;
  font-size: 13px;
}
.current-nav-title {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 10px;
}
.current-nav ul { list-style: none; margin: 0; padding: 0; }
.current-nav li { margin-bottom: 10px; }
.current-nav li.is-cont { padding-left: 12px; }
.current-nav a {
  display: block;
  text-decoration: none;
  color: var(--fg);
  line-height: 1.35;
  border-left: 2px solid transparent;
  padding-left: 8px;
}
.current-nav a:hover { color: var(--accent); border-left-color: var(--accent); }
.current-nav-date { display: block; font-size: 11px; color: var(--muted); }
.current-nav-ttl { display: block; }
.current-nav-archive {
  display: inline-block;
  margin-top: 6px;
  padding-left: 8px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.current-nav-archive:hover { color: var(--accent); }

@media (max-width: 720px) {
  .current { max-width: 760px; }
  .current-layout { display: block; }
  .current-nav { display: none; }
  .current-main { max-width: none; }
}
.current-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0 20px;
}
.current-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  color: var(--fg);
  margin: 0;
}
.current-sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; max-width: 52ch; }
.current-status { color: var(--muted); font-size: 13px; }
.current-status-error { color: var(--danger); }

.current-list { list-style: none; margin: 0; padding: 0; }
.current-entry {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 18px;
  margin-bottom: 16px;
  scroll-margin-top: 16px;
}
.current-entry:target { border-color: var(--seafoam); box-shadow: 0 0 0 2px color-mix(in srgb, var(--seafoam) 30%, transparent); }
.current-thread {
  display: inline-block;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 6px;
}
.current-thread:hover { color: var(--accent); }
.current-entry-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--fg);
  margin: 0 0 2px;
}
.current-entry-meta { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.current-entry-body { font-size: 16px; line-height: 1.6; }
.current-entry-body p:first-child { margin-top: 0; }
.current-entry-body p:last-child { margin-bottom: 0; }
.current-overview {
  font-size: 16px;
  line-height: 1.6;
  margin: 12px 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.current-stories { margin: 0; padding-left: 24px; }
.current-story { padding: 4px 0 16px 4px; }
.current-story + .current-story { border-top: 1px solid var(--border); padding-top: 16px; }
.current-story h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  margin: 0 0 6px;
}
.current-story p { line-height: 1.55; margin: 6px 0; }
.current-why { color: var(--muted); font-size: 14px; }
.current-story { scroll-margin-top: 16px; }
.current-explainer-action { margin-top: 10px; font-size: 13px; }
.current-explainer-action form { display: inline; }
.current-explainer-action a { color: var(--accent); text-decoration: none; }
.current-explainer-action a:hover { text-decoration: underline; }
.current-explainer-page { max-width: 760px; }
.current-explainer-back { margin: 8px 0 14px; font-size: 13px; }
.current-explainer-back a { color: var(--muted); text-decoration: none; }
.current-explainer-back a:hover { color: var(--accent); }
.current-explainer-body { border-left-color: var(--seafoam); }
.current-explainer-body h2 { font-family: var(--font-display); font-size: 18px; font-weight: 500; margin: 22px 0 10px; }
.current-explainer-body h2:first-child { margin-top: 0; }
.current-explainer-body p { max-width: 62ch; line-height: 1.8; }
.current-glossary { margin: 0; }
.current-glossary dt { font-weight: 600; margin-top: 14px; }
.current-glossary dd { margin: 4px 0 0; line-height: 1.7; max-width: 62ch; }
.current-explainer-sources-title { color: var(--muted); }
.current-explainer-status { margin-top: 32px; }
.current-source-list small { color: var(--muted); margin-left: 4px; }
.current-legacy-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  color: var(--muted);
  margin: 28px 0 12px;
}
.current-sources { margin-top: 12px; font-size: 13px; }
.current-sources summary { color: var(--muted); cursor: pointer; }
.current-sources summary:hover { color: var(--accent); }
.current-source-list { margin: 8px 0 0; padding-left: 18px; }
.current-source-list li { margin-bottom: 4px; }
.current-source-list a { color: var(--accent); text-decoration: none; }
.current-source-list a:hover { text-decoration: underline; }
.current-empty { text-align: center; margin-top: 60px; }

/* ===== Chinese logic game ===== */
.logic-game { max-width: 920px; margin: 0 auto; padding: 18px 16px 56px; }
.game-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.game-heading h1 { font-family: var(--font-display); font-size: clamp(27px, 6vw, 42px); font-weight: 500; margin: 2px 0 0; }
.game-kicker { color: var(--muted); font-size: 13px; letter-spacing: .12em; margin: 0; }
.game-heading form { display: grid; justify-items: end; gap: 5px; }
.game-new { white-space: nowrap; }
.game-generation-status { color: var(--muted); max-width: 250px; text-align: right; font-size: 12px; line-height: 1.4; }
.game-error { color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 8%, var(--panel)); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.game-selector { display: flex; align-items: end; justify-content: space-between; gap: 10px 16px; margin: -4px 0 16px; padding: 10px 12px; background: color-mix(in srgb, var(--panel) 72%, transparent); border: 1px solid var(--border); border-radius: var(--radius); }
.game-selector form { display: flex; align-items: end; gap: 9px; min-width: 0; flex: 1; }
.game-selector label { color: var(--muted); font-size: 12px; display: grid; gap: 4px; min-width: 0; flex: 1; }
.game-selector select { width: min(100%, 520px); min-width: 0; }
.game-selector button { padding: 7px 2px; white-space: nowrap; }
.game-selector small { color: var(--muted); white-space: nowrap; padding-bottom: 8px; }
.game-story { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.game-story > p { font-size: 18px; line-height: 1.75; margin: 0 0 14px; }
.game-goal { border-left: 3px solid var(--accent); padding-left: 12px; }
.game-goal span, .game-hint span { color: var(--muted); font-size: 13px; margin-right: 7px; }
.game-solved { display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: baseline; background: color-mix(in srgb, var(--seafoam) 13%, transparent); border-radius: 8px; padding: 12px 14px; margin-top: 18px; }
.game-solved strong { color: var(--accent); font-size: 21px; }
.game-solved span { color: var(--muted); font-size: 14px; }
.game-board { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 16px; margin-bottom: 16px; }
.game-panel, .game-action-panel, .game-history, .game-vocabulary, .game-rules { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px 18px; }
.game-panel h2, .game-action-panel h2, .game-history h2, .game-vocabulary h2, .game-rules h2 { font-family: var(--font-display); font-size: 18px; font-weight: 500; margin: 0 0 13px; }
.game-object-group + .game-object-group { margin-top: 12px; }
.game-object-group h3 { color: var(--muted); font-size: 12px; font-weight: 500; margin: 0 0 5px; }
.game-object-group div { display: flex; flex-wrap: wrap; gap: 6px; }
.game-object-group span { background: color-mix(in srgb, var(--accent) 9%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border)); border-radius: 999px; padding: 4px 10px; }
.game-facts ul { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 18px; }
.game-facts li { break-inside: avoid; padding: 3px 0 3px 15px; position: relative; }
.game-facts li::before { content: '·'; color: var(--seafoam); position: absolute; left: 2px; }
.game-facts h3 { color: var(--muted); font-size: 12px; font-weight: 500; margin: 0 0 5px; }
.game-facts h3:not(:first-of-type) { margin-top: 12px; }
.game-derived-facts li { color: color-mix(in srgb, var(--ink) 78%, var(--seafoam)); }
.game-derived-facts li::before { content: '∴'; font-size: 11px; left: 0; }
.game-rules { margin-bottom: 16px; border-left: 3px solid var(--seafoam); }
.game-rules-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 11px; }
.game-rules-heading h2 { margin: 0; }
.game-rules-heading p { color: var(--muted); font-size: 12px; margin: 0; }
.game-rules ol { display: grid; gap: 9px; list-style: none; margin: 0; padding: 0; }
.game-rules li { display: grid; grid-template-columns: minmax(90px, .28fr) minmax(0, 1fr); gap: 8px 14px; align-items: baseline; padding: 9px 11px; background: color-mix(in srgb, var(--seafoam) 7%, transparent); border-radius: 7px; line-height: 1.55; }
.game-rules strong { color: var(--accent); font-size: 14px; }
.game-action-panel { margin-bottom: 16px; }
.game-action-help { color: var(--muted); font-size: 13px; margin: -4px 0 13px; }
.game-action-panel form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.game-action-panel label { color: var(--muted); font-size: 12px; display: grid; gap: 4px; }
.game-action-panel select { min-width: 125px; }
.game-action-panel label.game-autoplay { display: flex; align-items: center; align-self: center; gap: 7px; cursor: pointer; font-size: 13px; }
.game-autoplay input { width: auto; margin: 0; accent-color: var(--accent); }
.game-argument-selects { display: flex; flex-wrap: wrap; gap: 10px; }
.game-sentence-preview { flex-basis: 100%; min-height: 33px; font-size: 20px; font-family: var(--font-display); color: var(--accent); padding-top: 5px; }
.game-action-details { flex-basis: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px 13px; background: color-mix(in srgb, var(--seafoam) 8%, transparent); border-radius: 8px; }
.game-action-details > div + div { border-left: 1px solid var(--border); padding-left: 12px; }
.game-action-status { grid-column: 1 / -1; margin: 0; color: var(--danger); font-size: 13px; }
.game-action-details h3 { color: var(--muted); font-size: 12px; font-weight: 500; margin: 0 0 6px; }
.game-action-details ul { list-style: none; padding: 0; margin: 0; }
.game-action-details li { display: flex; gap: 7px; align-items: baseline; line-height: 1.55; }
.game-action-detail-marker { width: 1em; flex: 0 0 1em; color: var(--seafoam); font-weight: 700; text-align: center; }
.game-action-detail-add .game-action-detail-marker { color: var(--accent); }
.game-action-detail-delete .game-action-detail-marker { color: var(--danger); }
.game-action-detail-requirement.is-unmet { color: var(--danger); }
.game-action-detail-requirement.is-unmet .game-action-detail-marker { color: var(--danger); }
.game-hint { margin: 15px 0 4px; padding: 9px 11px; background: color-mix(in srgb, var(--seafoam) 10%, transparent); border-radius: 7px; }
.game-hint-link { display: inline-block; color: var(--muted); font-size: 13px; margin-top: 10px; text-decoration: none; }
.game-hint-link:hover { color: var(--accent); }
.game-stuck { color: var(--danger); }
.game-history { margin-bottom: 12px; }
.game-history ol { margin: 0; padding-left: 27px; }
.game-history li { padding: 4px 0 4px 5px; }
.game-history li::marker { color: var(--muted); }
.game-history li > span { margin-right: 10px; }
.game-audio-button { display: inline-block; padding: 2px 0; white-space: nowrap; font-size: 12px; }
.game-controls { display: flex; gap: 16px; justify-content: flex-end; }
.game-controls form { margin: 0; }
.game-vocabulary { margin-bottom: 16px; border-left: 3px solid var(--seafoam); }
.game-word-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 10px; }
.game-word-list article { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 2px 10px; padding: 9px 11px; background: color-mix(in srgb, var(--seafoam) 7%, transparent); border-radius: 7px; }
.game-word-list strong { font-size: 21px; }
.game-word-list span { color: var(--muted); }
.game-word-list small, .game-word-list form, .game-word-list em { grid-column: 1 / -1; }
.game-word-list em { color: var(--muted); font-size: 12px; font-style: normal; }
.game-word-list button { padding: 0; font-size: 13px; }
.game-empty { text-align: center; max-width: 500px; margin: 75px auto; }
.game-empty div { font-family: var(--font-display); color: var(--seafoam); font-size: 76px; line-height: 1; }
.game-empty p { line-height: 1.7; }
.game-empty small { color: var(--muted); }
.game-dictionary-token { appearance: none; border: 0; border-bottom: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent); border-radius: 0; background: transparent; color: inherit; font: inherit; padding: 0; cursor: pointer; }
.game-dictionary-token:hover, .game-dictionary-token:focus-visible { color: var(--accent); border-bottom-style: solid; outline: none; }
.game-dictionary-popover { position: fixed; z-index: 20; width: min(310px, calc(100vw - 16px)); max-height: min(360px, calc(100vh - 16px)); overflow: auto; background: var(--panel); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px color-mix(in srgb, #000 22%, transparent); padding: 14px 15px; }
.game-dictionary-popover-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.game-dictionary-popover-head strong { font-size: 25px; }
.game-dictionary-popover-head > span:not(.game-dictionary-pinyin) { color: var(--muted); }
.game-dictionary-pinyin { color: var(--accent); }
.game-dictionary-popover ol { margin: 10px 0 13px; padding-left: 21px; line-height: 1.45; }
.game-dictionary-popover button { padding: 6px 10px; font-size: 13px; }

@media (max-width: 650px) {
  .game-heading { align-items: flex-start; }
  .game-generation-status { max-width: 170px; }
  .game-selector { align-items: stretch; }
  .game-selector form { align-items: stretch; }
  .game-selector label, .game-selector select { width: 100%; }
  .game-selector small { display: none; }
  .game-board { grid-template-columns: 1fr; }
  .game-facts ul { columns: 1; }
  .game-rules li { grid-template-columns: 1fr; gap: 3px; }
  .game-action-panel form { align-items: stretch; }
  .game-action-panel label, .game-action-panel select, .game-argument-selects select { width: 100%; }
  .game-argument-selects { width: 100%; }
  .game-action-details { grid-template-columns: 1fr; }
  .game-action-details > div + div { border-left: 0; border-top: 1px solid var(--border); padding: 10px 0 0; }
}

/* Study curricula, AI-authored lessons, and the learner's private notebook. */
.study-home, .study-lesson-page {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 72px;
}
.study-intro { max-width: 680px; margin-bottom: 32px; }
.study-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.study-intro h1, .study-lesson-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 500;
  line-height: 1.12;
}
.study-intro > p:last-child, .study-lesson-header > p:last-child,
.study-book-outline > header p, .study-exercises > header > p:last-child,
.study-notes > header > p:last-child { color: var(--muted); }
.study-book-outline > header { margin-bottom: 18px; }
.study-book-outline > header h2 { margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 500; }
.study-book-outline > header p { margin: 4px 0 0; }
.study-chapters { display: grid; gap: 8px; }
.study-chapter {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.study-chapter > summary { padding: 14px 16px; cursor: pointer; font-family: var(--font-display); font-size: 17px; }
.study-chapter > summary span { margin-right: 6px; color: var(--accent); font-family: inherit; }
.study-chapter[open] > summary { border-bottom: 1px solid var(--border); }
.study-chapter ol { margin: 0; padding: 7px 0; list-style: none; }
.study-chapter li a, .study-section-title { display: block; padding: 8px 16px; }
.study-chapter li a { color: var(--fg); text-decoration: none; }
.study-chapter li a:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.study-chapter li span span, .study-chapter li a > span { display: inline-block; width: 54px; color: var(--muted); font-variant-numeric: tabular-nums; }
.study-chapter li small { margin-left: 8px; color: var(--accent); font-size: 11px; font-weight: 600; text-transform: uppercase; }
.study-chapter .awaiting-lesson { color: var(--muted); }

.study-lesson-page { width: min(800px, calc(100% - 32px)); }
.study-lesson-header { margin: 16px 0 38px; padding-bottom: 22px; border-bottom: 1px solid var(--paper-edge); }
.study-lesson-header > p:last-child { margin: 10px 0 0; font-size: 14px; }
.study-lesson-body { font-size: 18px; line-height: 1.68; }
.study-lesson-body h2 { margin-top: 2.1em; font-family: var(--font-display); font-size: 27px; font-weight: 500; }
.study-lesson-body h3 { margin-top: 1.8em; font-size: 20px; }
.study-lesson-body code, .study-exercise code { color: var(--accent); }
.study-lesson-body mjx-container, .study-exercise mjx-container { color: var(--fg); }
.study-lesson-body mjx-container[display="true"], .study-exercise mjx-container[display="true"] {
  max-width: 100%;
  margin: 1.25em 0 !important;
  overflow-wrap: normal;
}
.study-lesson-body li + li { margin-top: 5px; }
.study-exercises, .study-notes {
  margin-top: 52px;
  padding-top: 30px;
  border-top: 1px solid var(--paper-edge);
}
.study-exercises h2, .study-notes h2 { margin: 0; font-family: var(--font-display); font-size: 30px; font-weight: 500; }
.study-exercises > header > p:last-child, .study-notes > header > p:last-child { margin-top: 7px; }
.study-exercises > ol { display: grid; gap: 14px; margin: 24px 0 0; padding: 0; list-style: none; counter-reset: study-exercise; }
.study-exercise {
  padding: 18px 19px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  counter-increment: study-exercise;
}
.study-exercise::before { content: "Exercise " counter(study-exercise); display: block; margin-bottom: 7px; color: var(--accent); font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.study-exercise .body > p:first-child { margin-top: 0; }
.study-exercise details { margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--border); }
.study-exercise details summary { color: var(--accent); cursor: pointer; font-size: 14px; }
.study-solution { margin-top: 11px; color: var(--muted); }
.study-notes form { display: grid; gap: 11px; margin-top: 18px; }
.study-notes textarea { width: 100%; resize: vertical; padding: 14px; color: var(--fg); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); font: inherit; line-height: 1.55; }
.study-notes button { justify-self: start; }
@media (max-width: 560px) {
  .study-home, .study-lesson-page { width: min(100% - 24px, 800px); padding-top: 30px; }
  .study-chapter li small { display: block; margin: 3px 0 0 54px; }
  .study-lesson-body { font-size: 17px; }
}

/* ===== Calm seas: respect reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
