/* Quetzal — modern, sleek, elegant, and sophisticated.
   Paper-and-ink palette, a bookish serif for reading (Literata), a precise sans for interface (Inter). */

:root {
  --font-serif: "Literata", "Iowan Old Style", "Palatino Linotype", Georgia, "Hiragino Mincho ProN", "Songti SC", "Noto Serif CJK SC", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "PingFang SC", "Noto Sans", sans-serif;

  --bg: #f7f5f0;
  --bg-elev: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f2efe8;
  --surface-3: #e9e5dc;
  --ink: #1a1917;
  --ink-2: #4c4943;
  --ink-3: #858076;
  --ink-4: #b1ab9f;
  --line: #e4dfd5;
  --line-strong: #d3cdc0;
  --accent: #533d6a;
  --accent-ink: #ffffff;
  --accent-soft: #eeeaf3;
  --accent-line: #d5cce1;
  --gold: #a07b42;
  --gold-soft: #f4ecdf;
  --green: #3e6b50;
  --green-soft: #e5efe8;
  --amber: #a5701f;
  --amber-soft: #f6ecda;
  --red: #a1443a;
  --red-soft: #f6e5e2;
  --focus: 0 0 0 3px rgba(83, 61, 106, 0.22);
  /* Word-state series (validated for colour-vision deficiency, light surface) */
  --st-new: #8459a8;
  --st-learning: #c98a2b;
  --st-young: #3baca6;
  --st-mature: #2a7d4f;

  --shadow-1: 0 1px 2px rgba(26, 25, 23, 0.04), 0 1px 1px rgba(26, 25, 23, 0.03);
  --shadow-2: 0 2px 6px rgba(26, 25, 23, 0.05), 0 12px 32px -12px rgba(26, 25, 23, 0.12);
  --shadow-3: 0 24px 64px -16px rgba(26, 25, 23, 0.24), 0 4px 12px rgba(26, 25, 23, 0.06);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --hover: 0.12s;  /* hover and focus feedback: quick, so the interface feels immediate */
  --header-h: 64px;
  --measure: 680px;
  --reader-size: 1.25rem;
  --logo: url("../img/logo.png");
  --logo-inverse: url("../img/logo-dark.png");
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121315;
  --bg-elev: #16181b;
  --surface: #1b1d21;
  --surface-2: #22252a;
  --surface-3: #2b2f35;
  --ink: #ecebe6;
  --ink-2: #c3c0b8;
  --ink-3: #8f8c85;
  --ink-4: #5e5c58;
  --line: #2b2e33;
  --line-strong: #3a3e45;
  --accent: #beaad4;
  --accent-ink: #15111a;
  --accent-soft: #2d2535;
  --accent-line: #4c3e5a;
  --gold: #d1ad74;
  --gold-soft: #2e271c;
  --green: #8cc3a0;
  --green-soft: #1c2a22;
  --amber: #e0b066;
  --amber-soft: #2e2618;
  --red: #e59a8f;
  --red-soft: #33201d;
  --focus: 0 0 0 3px rgba(190, 170, 212, 0.3);
  --st-new: #a174c4;
  --st-learning: #c08529;
  --st-young: #3baca6;
  --st-mature: #137d41;
  --logo: url("../img/logo-dark.png");
  --logo-inverse: url("../img/logo.png");
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.25), 0 12px 32px -12px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 24px 64px -16px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 var(--font-sans);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.no-scroll { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); color: var(--ink); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

.serif { font-family: var(--font-serif); }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { display: inline-block; vertical-align: -0.18em; width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }
.icon.filled { fill: currentColor; }

/* The quetzal as the translation mark. Its height sets its size; the width follows the artwork. */
.bird { display: inline-block; flex: none; height: 1.2em; aspect-ratio: 91 / 150; background: var(--logo) center / contain no-repeat; vertical-align: -0.2em; }
.bird.bird-text { height: 1.35em; vertical-align: -0.32em; margin: 0 1px; }  /* in running text */
.bird.bird-tool { height: 24px; }                                               /* reader toolbar */
.bird.bird-hint { height: 20px; margin: 0 1.5px; }                              /* hint list, aligned with 15px icons */
.bird.bird-pop { height: 17px; background-image: var(--logo-inverse); }         /* on the inverted selection pop-up */
.bird.bird-trans { height: 30px; margin-top: 1px; }                              /* beside a translation in the panel */

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease);
}
.app-header.scrolled { border-bottom-color: var(--line); }

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  justify-self: start;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.01em;
}
/* Draft quetzal artwork; the dark-theme version has lightened wing feathers. */
.brand-mark { display: block; align-self: center; height: 56px; margin: -6px -2px -8px 0; }
.brand-mark img { display: block; height: 100%; width: auto; }
.brand-mark .logo-dark, :root[data-theme="dark"] .brand-mark .logo-light { display: none; }
:root[data-theme="dark"] .brand-mark .logo-dark { display: block; }

.portal-switch {
  position: relative;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.portal-switch a {
  position: relative;
  z-index: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 7px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-3);
  transition: color var(--hover) var(--ease);
  white-space: nowrap;
}
.portal-switch a.active { color: var(--ink); }
.portal-switch .thumb {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--line);
  transition: transform 0.35s var(--ease), width 0.35s var(--ease);
}

.header-actions { justify-self: end; display: flex; align-items: center; gap: 8px; }

.avatar-button {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  transition: border-color var(--hover), box-shadow var(--hover);
}
.avatar-button:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 600; font-size: 13px;
}

/* ---------------------------------------------------------------- Sub-nav */

.subnav {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  color: var(--ink-3);
  transition: color var(--hover), background var(--hover);
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab.active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.tab .count {
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 600;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 28px 96px;
  animation: page-in 0.4s var(--ease);
}
.page.narrow { max-width: 780px; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px; }
.display { font-family: var(--font-serif); font-weight: 400; font-size: clamp(30px, 4vw, 42px); line-height: 1.1; letter-spacing: -0.02em; margin: 0; }
.display em { font-style: italic; color: var(--ink-2); }
.lede { color: var(--ink-2); font-size: 16px; max-width: 58ch; margin: 10px 0 0; }
h2.section-title { font-family: var(--font-serif); font-weight: 500; font-size: 22px; letter-spacing: -0.01em; margin: 0 0 14px; }

/* --------------------------------------------------------------- Controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px; font-weight: 500;
  white-space: nowrap;
  transition: background var(--hover), border-color var(--hover), box-shadow var(--hover), transform 0.1s, opacity var(--hover);
}
.btn:hover { border-color: var(--ink-4); box-shadow: var(--shadow-1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 88%, var(--accent)); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); background: var(--red-soft); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.lg { height: 48px; padding: 0 26px; font-size: 15px; }
.btn.icon-only { width: 40px; padding: 0; }
.btn.sm.icon-only { width: 32px; }
.btn.block { width: 100%; }
.btn .kbd { margin-left: 4px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 999px;
  border: 0; background: transparent; color: var(--ink-2);
  transition: background var(--hover), color var(--hover);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.active { color: var(--accent); }
.icon-btn.active:has(.bird) { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.icon-btn.sm { width: 30px; height: 30px; }

.kbd {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  font: 500 11px/1 var(--font-sans);
  color: var(--ink-3);
  background: var(--surface);
}
.btn.primary .kbd { background: transparent; color: inherit; opacity: 0.6; border-color: currentColor; }

.field { display: grid; gap: 7px; }
.field > span, .label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  transition: border-color var(--hover), box-shadow var(--hover);
}
.textarea { height: auto; min-height: 110px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.select { appearance: none; padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2385807a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }

.search {
  position: relative;
  display: flex; align-items: center;
}
.search .icon { position: absolute; left: 14px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 40px; border-radius: 999px; height: 40px; }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.segmented button {
  border: 0; background: transparent;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13.5px; font-weight: 500;
  color: var(--ink-3);
  transition: background var(--hover), color var(--hover), box-shadow var(--hover);
}
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.segmented.stack button { display: grid; gap: 1px; text-align: center; padding: 9px 12px; }
.segmented.stack button small { font-size: 11px; font-weight: 400; color: var(--ink-3); }
.segmented.full { display: flex; width: 100%; }
.segmented.full button { flex: 1; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  transition: all var(--hover) var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .n { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chip.active .n { color: inherit; opacity: 0.65; }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--ink-2); user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track { width: 36px; height: 21px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background 0.25s var(--ease); flex: none; }
.toggle .track::after { content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform 0.25s var(--ease); }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(15px); }
.toggle input:focus-visible + .track { box-shadow: var(--focus); }
.toggle-detail { align-items: flex-start; }
.toggle-detail .track { margin-top: 1px; }
.toggle-title { display: block; color: var(--ink); font-weight: 500; }
.toggle-hint { display: block; margin-top: 2px; font-size: 13px; line-height: 1.45; color: var(--ink-3); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11.5px; font-weight: 500; letter-spacing: 0.01em;
  white-space: nowrap;
}
.tag.pos { font-style: italic; font-family: var(--font-serif); font-size: 12.5px; background: transparent; padding: 0; height: auto; color: var(--ink-3); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.gold { background: var(--gold-soft); color: var(--gold); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.red { background: var(--red-soft); color: var(--red); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; background: var(--ink-4); }
.dot.new { background: var(--st-new); }
.dot.learning { background: var(--st-learning); }
.dot.young { background: var(--st-young); }
.dot.mature { background: var(--st-mature); }
.dot.due { background: var(--red); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card.pad { padding: 24px; }

.divider { height: 1px; background: var(--line); border: 0; margin: 20px 0; }

/* ----------------------------------------------------------------- Banner */

.banner {
  max-width: 1180px;
  margin: 14px auto 0;
  padding: 0 28px;
}
.banner > div {
  display: flex; align-items: center; gap: 14px; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--gold-soft);
  border: 1px solid color-mix(in srgb, var(--gold) 25%, transparent);
  color: var(--ink-2);
  font-size: 14px;
}
.banner .icon { color: var(--gold); }

/* ----------------------------------------------------------------- Toasts */

.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: toast-in 0.35s var(--ease);
}
.toast.error { background: var(--red); color: #fff; }
.toast button { border: 0; background: transparent; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.toast.out { animation: toast-out 0.25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------ Modal and drawers */

.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 19, 17, 0.36);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 24px;
  animation: fade-in 0.25s var(--ease);
}
.overlay.closing { animation: fade-out 0.2s var(--ease) forwards; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

.modal {
  width: min(480px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  padding: 30px;
  animation: modal-in 0.35s var(--ease);
}
.modal.wide { width: min(640px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.985); } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.modal-title { font-family: var(--font-serif); font-size: 26px; font-weight: 500; letter-spacing: -0.015em; margin: 0; }
.modal-sub { color: var(--ink-3); margin: 6px 0 0; font-size: 14px; }
.modal form { display: grid; gap: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.form-error { color: var(--red); font-size: 13.5px; min-height: 0; margin: 0; }
.form-note { color: var(--green); font-size: 13.5px; margin: 0; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-size: 13.5px; font-weight: 500; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.drawer-overlay { place-items: stretch end; padding: 0; background: rgba(20, 19, 17, 0.22); }
.drawer {
  width: min(520px, 100vw);
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: drawer-in 0.4s var(--ease);
  display: flex; flex-direction: column;
}
.closing .drawer { animation: drawer-out 0.25s var(--ease) forwards; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } }
@keyframes drawer-out { to { transform: translateX(40px); opacity: 0; } }
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 18px; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.drawer-body { padding: 26px 30px 40px; }

.menu {
  position: absolute; z-index: 70;
  min-width: 220px;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  animation: menu-in 0.18s var(--ease);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: 9px; font-size: 14px; color: var(--ink-2); text-align: left; }
.menu-item:hover { background: var(--surface-2); color: var(--ink); }
.menu-item.danger { color: var(--red); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-label { padding: 8px 12px 4px; font-size: 12px; color: var(--ink-3); }

/* ---------------------------------------------------------------- Landing */

.landing { max-width: 1180px; margin: 0 auto; padding: 56px 28px 100px; }
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 64px; align-items: center; min-height: calc(100vh - 220px); }
.hero h1 { font-family: var(--font-serif); font-weight: 400; font-size: clamp(42px, 6vw, 72px); line-height: 1.02; letter-spacing: -0.03em; margin: 0; }
.hero h1 em { color: var(--accent); }
.hero p.lede { font-size: 18px; margin-top: 22px; }
.hero .cta { display: flex; gap: 12px; margin-top: 34px; flex-wrap: wrap; }
.hero-art { position: relative; }
.specimen {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  padding: 34px 34px 28px;
  font-family: var(--font-serif);
  font-size: 21px; line-height: 1.75;
  transform: rotate(-1deg);
}
.specimen .hl { background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 1px 3px; box-shadow: 0 0 0 1px var(--accent-line); }
.specimen .saved-sample { text-decoration: underline dotted var(--gold); text-underline-offset: 5px; text-decoration-thickness: 1.5px; }
.specimen-pop {
  position: absolute; right: -28px; bottom: -118px;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: 18px 20px;
  transform: rotate(1.5deg);
  font-size: 13.5px;
}
.specimen-pop .w { font-family: var(--font-serif); font-size: 22px; }
.portals { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 100px; }
.portal-card { padding: 34px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); }
.portal-card h3 { font-family: var(--font-serif); font-weight: 500; font-size: 26px; margin: 16px 0 10px; letter-spacing: -0.01em; }
.portal-card p { color: var(--ink-2); margin: 0; }
.portal-card ul { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 9px; color: var(--ink-2); font-size: 14.5px; }
.portal-card li { display: flex; gap: 10px; align-items: flex-start; }
.portal-card li .icon { color: var(--accent); margin-top: 2px; }
.badge-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }

/* ----------------------------------------------------------------- Review */

.review-wrap { max-width: 760px; margin: 0 auto; }
.review-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.queue-counts { display: flex; gap: 18px; font-size: 13.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.queue-counts span { display: inline-flex; align-items: center; gap: 7px; }
.queue-counts b { color: var(--ink); font-weight: 600; }
.progress-line { height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-bottom: 22px; }
.progress-line > span { display: block; height: 100%; background: var(--ink); border-radius: 3px; transition: width 0.5s var(--ease); }

.flash {
  position: relative;
  min-height: 420px;
  padding: 56px 56px 40px;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  display: flex; flex-direction: column;
  animation: card-in 0.4s var(--ease);
}
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(0.99); } }
.flash .kind { position: absolute; top: 20px; left: 24px; display: flex; gap: 8px; align-items: center; }
.flash .corner { position: absolute; top: 14px; right: 14px; display: flex; gap: 2px; }
.flash-front { text-align: center; display: grid; gap: 14px; justify-items: center; padding: 18px 0 8px; }
.flash-word { font-family: var(--font-serif); font-weight: 400; font-size: clamp(40px, 6vw, 60px); line-height: 1.08; letter-spacing: -0.02em; margin: 0; word-break: break-word; }
.flash-word.rtl { direction: rtl; }
.flash-meta { display: flex; gap: 10px; align-items: center; justify-content: center; color: var(--ink-3); }
.flash-prompt { font-family: var(--font-serif); font-size: 22px; line-height: 1.5; max-width: 34ch; color: var(--ink); margin: 0; }
.flash-context { font-family: var(--font-serif); font-size: 19px; line-height: 1.65; color: var(--ink-2); max-width: 46ch; margin: 6px auto 0; }
.flash-context mark { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 3px; }
.flash-back { margin-top: 26px; padding-top: 26px; border-top: 1px solid var(--line); animation: reveal 0.35s var(--ease); }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } }
.flash-gloss { font-family: var(--font-serif); font-size: 22px; line-height: 1.45; margin: 0 0 6px; }
.flash-foot { margin-top: auto; padding-top: 30px; display: flex; justify-content: center; }

.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; }
.grade {
  display: grid; gap: 3px; justify-items: center;
  padding: 12px 8px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-weight: 500; font-size: 14.5px;
  transition: all var(--hover) var(--ease);
}
.grade small { font-size: 12px; color: var(--ink-3); font-weight: 400; font-variant-numeric: tabular-nums; }
.grade:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.grade.again:hover { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.grade.hard:hover { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }
.grade.good:hover { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.grade.easy:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.done { text-align: center; padding: 70px 30px; }
.done .seal { width: 64px; height: 64px; margin: 0 auto 22px; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.done h2 { font-family: var(--font-serif); font-weight: 400; font-size: 34px; margin: 0 0 10px; letter-spacing: -0.02em; }
.done p { color: var(--ink-2); margin: 0 auto; max-width: 46ch; }
.done .actions { display: flex; gap: 10px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }

/* ----------------------------------------------------- Definitions (shared) */

.senses { display: grid; gap: 22px; }
.pos-group h4 { margin: 0 0 10px; font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 15px; color: var(--ink-3); }
.sense-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; counter-reset: sense; }
.sense { position: relative; padding-left: 30px; counter-increment: sense; line-height: 1.55; }
.sense::before { content: counter(sense); position: absolute; left: 0; top: 1px; width: 20px; height: 20px; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--ink-3); border: 1px solid var(--line-strong); border-radius: 50%; }
.sense .def { color: var(--ink); }
.sense .ex { display: block; margin-top: 4px; font-family: var(--font-serif); font-style: italic; color: var(--ink-3); font-size: 14.5px; }
.sense.relevant { padding: 12px 14px 12px 44px; border-radius: 12px; background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.sense.relevant::before { left: 14px; top: 13px; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.sense.relevant .fit { display: inline-flex; margin-bottom: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.sense.form-of .def { color: var(--ink-3); font-style: italic; }
.source-line { margin-top: 18px; font-size: 12px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.source-line a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.more-senses { margin-top: 10px; }

.note-box { padding: 12px 14px; border-radius: 12px; background: var(--gold-soft); color: var(--ink-2); font-size: 14px; }
.note-box b { display: block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold); margin-bottom: 2px; }

/* ------------------------------------------------------------------ Words */

.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .left, .toolbar .right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .search { width: min(340px, 100%); }

.word-table { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.word-row {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr auto;
  gap: 20px; align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--hover);
}
.word-row:first-child { border-top: 0; }
.word-row:hover { background: var(--bg-elev); }
.word-row .term { font-family: var(--font-serif); font-size: 18px; letter-spacing: -0.005em; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.word-row .term span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-row .gloss { color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.word-row .gloss.missing { color: var(--ink-4); font-style: italic; }
.word-row .status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.word-row .flag { color: var(--gold); }
.letter-bar { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 14px; }
.letter-bar button { width: 30px; height: 30px; border: 0; background: none; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--ink-3); }
.letter-bar button:hover { background: var(--surface-2); color: var(--ink); }
.letter-bar button.active { background: var(--ink); color: var(--bg); }
.letter-bar button:disabled { opacity: 0.3; pointer-events: none; }
.list-footer { padding: 18px; text-align: center; color: var(--ink-3); font-size: 13px; }

.detail-word { font-family: var(--font-serif); font-size: 40px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.1; margin: 0; word-break: break-word; }
.detail-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; color: var(--ink-3); }
.detail-section { margin-top: 30px; }
.detail-section > h3 { margin: 0 0 12px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.sched { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sched div { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.sched b { display: block; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sched span { font-size: 12px; color: var(--ink-3); }
.context-quote { margin: 0 0 12px; padding: 12px 16px; border-left: 2px solid var(--accent-line); font-family: var(--font-serif); font-size: 16px; line-height: 1.6; color: var(--ink); }
.context-quote small { display: block; margin-top: 4px; font-family: var(--font-sans); font-size: 13px; color: var(--ink-3); line-height: 1.5; }
.context-quote mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 2px; }

.empty { text-align: center; padding: 70px 24px; border: 1px dashed var(--line-strong); border-radius: var(--r-xl); background: var(--bg-elev); }
.empty .badge-icon { margin: 0 auto 18px; }
.empty h3 { font-family: var(--font-serif); font-weight: 400; font-size: 28px; margin: 0 0 8px; letter-spacing: -0.015em; }
.empty p { color: var(--ink-2); max-width: 52ch; margin: 0 auto; }
.empty .actions { display: flex; gap: 10px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Library */

.story-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.story-card {
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 220px;
  padding: 24px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: transform calc(var(--hover) * 1.4) var(--ease), box-shadow calc(var(--hover) * 1.4) var(--ease), border-color var(--hover);
}
.story-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.story-card .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.story-card h3 { font-family: var(--font-serif); font-weight: 500; font-size: 22px; line-height: 1.2; letter-spacing: -0.01em; margin: 4px 0 0; }
.story-card .tr { font-family: var(--font-serif); font-style: italic; color: var(--ink-3); font-size: 15px; margin: 0; }
.story-card .excerpt { color: var(--ink-2); font-family: var(--font-serif); font-size: 15px; line-height: 1.6; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.story-card .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--ink-3); }
.story-card .fav { color: var(--gold); }
.story-card.new-card { border-style: dashed; background: transparent; justify-content: center; align-items: center; text-align: center; color: var(--ink-2); box-shadow: none; }
.story-card.new-card:hover { background: var(--surface); }
.story-card.new-card .badge-icon { margin-bottom: 4px; }

/* --------------------------------------------------------------- Compose */

.compose { display: grid; grid-template-columns: 1fr 340px; gap: 28px; align-items: start; }
.compose-form { display: grid; gap: 26px; padding: 32px; }
.compose-aside { position: sticky; top: calc(var(--header-h) + 20px); padding: 26px; display: grid; gap: 14px; background: var(--bg-elev); }
.compose-aside h4 { margin: 0; font-family: var(--font-serif); font-weight: 500; font-size: 18px; }
.compose-aside p, .compose-aside li { color: var(--ink-2); font-size: 14px; margin: 0; }
.compose-aside ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.level-desc { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.lang-picker { position: relative; }
.lang-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px);
  max-height: 320px; overflow: auto;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-3);
}
.lang-option { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: 9px; text-align: left; font-size: 14px; }
.lang-option:hover, .lang-option.hover { background: var(--surface-2); }
.lang-option .native { color: var(--ink-3); font-family: var(--font-serif); }

.writing { text-align: center; padding: 90px 20px; }
.writing .quill { width: 64px; height: 64px; margin: 0 auto 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); animation: breathe 2.4s var(--ease) infinite; }
@keyframes breathe { 50% { transform: scale(1.07); box-shadow: 0 0 0 12px color-mix(in srgb, var(--accent-soft) 50%, transparent); } }
.writing h2 { font-family: var(--font-serif); font-weight: 400; font-size: 30px; margin: 0 0 10px; }
.writing p { color: var(--ink-3); margin: 0; min-height: 1.5em; transition: opacity 0.4s; }

/* ----------------------------------------------------------------- Reader */

.reader { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 48px; max-width: 1240px; margin: 0 auto; padding: 24px 28px 120px; }
.reader-main { min-width: 0; max-width: var(--measure); justify-self: center; width: 100%; }
.reader-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 30px; }
.reader-tools { display: flex; gap: 4px; align-items: center; }
.story-head { margin-bottom: 34px; }
.story-head .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.story-title { font-family: var(--font-serif); font-weight: 400; font-size: clamp(32px, 4.4vw, 46px); line-height: 1.1; letter-spacing: -0.025em; margin: 0; }
.story-title-tr { font-family: var(--font-serif); font-style: italic; color: var(--ink-3); font-size: 19px; margin: 10px 0 0; }

.prose { font-family: var(--font-serif); font-size: var(--reader-size); line-height: 1.85; color: var(--ink); font-optical-sizing: auto; }
.prose[dir="rtl"] { text-align: right; }
.prose p { margin: 0 0 1.15em; }
.prose .s { border-radius: 6px; transition: background 0.15s; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.prose .s.active { background: color-mix(in srgb, var(--accent-line) 70%, transparent); }
.prose .s.speaking { background: var(--gold-soft); }
.prose .w { cursor: pointer; border-radius: 4px; transition: background var(--hover), color var(--hover), box-shadow var(--hover); }
.prose .w:hover { background: var(--surface-3); }
.prose .w.saved { text-decoration: underline dotted var(--gold); text-decoration-thickness: 1.5px; text-underline-offset: 0.28em; }
.prose .w.focus { box-shadow: inset 0 -0.38em 0 var(--gold-soft); }
.prose .w.selected { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 2px var(--accent); }
.prose .s-end { white-space: nowrap; }
/* A small quetzal just after the final punctuation, raised like a superscript; the offset doesn't change line height. */
.prose .tr-btn {
  display: inline-block;
  position: relative; top: -0.3em;
  height: 1.05em;
  margin: 0 -0.12em 0 0.01em;
  padding: 0;
  vertical-align: baseline;
  border: 0; border-radius: 4px;
  background: transparent;
  opacity: 0; transition: opacity var(--hover), transform var(--hover) var(--ease), filter var(--hover);
  transform-origin: 50% 70%;
}
.prose .tr-btn .bird { display: block; height: 100%; }
.prose .s:hover .tr-btn, .prose .s.active .tr-btn, .prose .tr-btn:focus-visible { opacity: 1; }
.prose .tr-btn:hover { transform: scale(1.18); }
/* Touch screens show every quetzal, so idle ones stay quiet (gray) until their sentence is open. */
@media (hover: none) { .prose .tr-btn { opacity: 0.4; filter: grayscale(1); } .prose .s.active .tr-btn { opacity: 1; filter: none; } }
.prose .para-tr { display: block; margin: -0.45em 0 1.35em; padding: 2px 0 2px 16px; border-left: 2px solid var(--line-strong); font-family: var(--font-sans); font-size: 0.72em; line-height: 1.6; color: var(--ink-3); }
.prose .para-rom { display: block; margin: -0.6em 0 1em; font-family: var(--font-sans); font-size: 0.68em; line-height: 1.6; color: var(--ink-3); font-style: italic; }
.reader-end { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; color: var(--ink-3); font-size: 14px; }

.select-pop {
  position: absolute; z-index: 35;
  display: inline-flex; gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow-3);
  animation: menu-in 0.15s var(--ease);
}
.select-pop button { border: 0; background: transparent; color: inherit; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.select-pop button:hover { background: rgba(255,255,255,0.12); }

/* Lookup panel: a sticky column on wide screens, a bottom sheet on small ones. */
.panel {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow-y: auto;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  overscroll-behavior: contain;
}
.panel-inner { padding: 24px 26px 28px; }
.panel-empty { padding: 40px 30px; text-align: center; color: var(--ink-3); }
.panel-empty .badge-icon { margin: 0 auto 16px; }
.panel-empty h4 { font-family: var(--font-serif); font-weight: 400; color: var(--ink); font-size: 21px; margin: 0 0 8px; }
.panel-empty p { margin: 0 0 4px; font-size: 14px; }
.panel-empty .hints { margin-top: 22px; display: grid; gap: 10px; text-align: left; font-size: 13.5px; }
.panel-empty .hints div { display: flex; gap: 10px; align-items: center; }
.sheet-handle { display: none; }
.panel-close { display: none; }

.lk-sentence { padding: 16px 18px; border-radius: 14px; background: var(--surface-2); margin-bottom: 22px; }
.lk-sentence .orig { font-family: var(--font-serif); font-size: 16px; line-height: 1.6; margin: 0; }
.lk-sentence .rom { font-size: 13px; font-style: italic; color: var(--ink-3); margin: 6px 0 0; }
.lk-sentence .trans { display: flex; gap: 12px; align-items: flex-start; margin: 10px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.lk-sentence .trans p { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }
.lk-sentence .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.lk-sentence .row .label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.lk-sentence mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 2px; }

.lk-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.lk-lemma { font-family: var(--font-serif); font-size: 34px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.1; margin: 0; word-break: break-word; }
.lk-reading { color: var(--ink-3); font-size: 14px; margin-top: 6px; }
.lk-morph { margin-top: 10px; font-size: 13.5px; color: var(--ink-2); }
.lk-morph b { font-family: var(--font-serif); font-weight: 500; }
.lk-context { margin: 20px 0 4px; padding: 16px 18px; border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--accent-line); }
.lk-context .label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; color: var(--accent); }
.lk-context .gloss { font-family: var(--font-serif); font-size: 21px; line-height: 1.35; margin: 6px 0 0; color: var(--ink); }
.lk-context .expl { margin: 8px 0 0; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.lk-expression { margin-top: 12px; padding: 14px 16px; border-radius: 14px; background: var(--gold-soft); font-size: 14px; color: var(--ink-2); }
.lk-expression b { display: block; font-family: var(--font-serif); font-weight: 500; font-size: 17px; color: var(--ink); margin-bottom: 2px; }
.lk-expression .label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; color: var(--gold); display: block; margin-bottom: 4px; }
.lk-defs { margin-top: 26px; }
.lk-defs > h3 { margin: 0 0 14px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.entry-block + .entry-block { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.entry-hw { font-family: var(--font-serif); font-size: 19px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.save-btn.saved { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 40%, transparent); color: var(--gold); }

.skeleton { display: grid; gap: 12px; }
.skeleton i { display: block; height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton i.big { height: 34px; width: 55%; border-radius: 10px; }
.skeleton i.box { height: 96px; border-radius: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ Stats */

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { padding: 22px; }
.stat .v { font-family: var(--font-serif); font-size: 38px; font-weight: 400; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 18px; color: var(--ink-3); margin-left: 2px; }
.stat .k { margin-top: 8px; font-size: 13px; color: var(--ink-3); }
.panels-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.stack-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-3); gap: 2px; margin: 8px 0 16px; }
.stack-bar span { display: block; height: 100%; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; font-size: 13.5px; }
.legend div { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.bars .bar span { display: block; width: 100%; max-width: 26px; min-height: 2px; border-radius: 4px 4px 2px 2px; background: var(--ink-2); transition: height 0.6s var(--ease); }
.bars .bar.today span { background: var(--accent); }
.bars .bar.zero span { background: var(--surface-3); }
.bars .bar:hover span { background: var(--accent); }
.bars .bar .tip { position: absolute; bottom: calc(100% + 4px); padding: 3px 7px; border-radius: 6px; background: var(--ink); color: var(--bg); font-size: 11.5px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--hover); }
.bars .bar:hover .tip { opacity: 1; }
.bars-empty { height: 140px; display: grid; place-items: center; color: var(--ink-3); font-size: 14px; border-bottom: 1px dashed var(--line-strong); }
.bar-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }

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

.settings { display: grid; gap: 18px; }
.settings .card { padding: 26px 28px; }
.settings h3 { font-family: var(--font-serif); font-weight: 500; font-size: 20px; margin: 0 0 4px; }
.settings .row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 14px 0; border-top: 1px solid var(--line); }
.settings .row:first-of-type { border-top: 0; }
.settings .row .t { font-weight: 500; }
.settings .row .d { font-size: 13px; color: var(--ink-3); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.number-input { width: 90px; text-align: center; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 12px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.admin-table tr:last-child td { border-bottom: 0; }

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

@media (max-width: 1100px) {
  .reader { grid-template-columns: 1fr; padding-bottom: 60vh; }
  .panel {
    position: fixed; z-index: 50;
    left: 0; right: 0; bottom: 0; top: auto;
    max-height: 72vh;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    box-shadow: 0 -12px 40px -10px rgba(0,0,0,0.25);
    transform: translateY(110%);
    transition: transform 0.4s var(--ease);
  }
  .panel.open { transform: none; }
  .sheet-handle { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 10px auto 0; }
  .panel-close { display: inline-grid; position: absolute; top: 12px; right: 14px; }
  .panel .panel-empty { display: none; }
  .compose { grid-template-columns: 1fr; }
  .compose-aside { position: static; }
}

@media (max-width: 860px) {
  .app-header { grid-template-columns: auto 1fr auto; padding: 0 16px; gap: 10px; }
  .brand .brand-text { display: none; }
  .portal-switch { justify-self: center; }
  .portal-switch a { padding: 7px 14px; }
  .subnav, .page, .banner, .landing { padding-left: 16px; padding-right: 16px; }
  .reader { padding-left: 18px; padding-right: 18px; }
  .hero { grid-template-columns: 1fr; gap: 80px; min-height: 0; }
  .portals { grid-template-columns: 1fr; margin-top: 90px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .panels-2 { grid-template-columns: 1fr; }
  .flash { padding: 48px 22px 26px; min-height: 380px; }
  .word-row { grid-template-columns: 1fr auto; gap: 4px 14px; padding: 12px 16px; }
  .word-row .gloss { grid-column: 1 / -1; grid-row: 2; }
  .grades { gap: 6px; }
  .grade { padding: 10px 4px; font-size: 13.5px; }
  .drawer-body { padding: 22px 20px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .tabs .tab-label { display: none; }
  .tab { padding: 8px 12px; }
  .specimen-pop { right: 0; }
}

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