/* ===========================================================================
   German Notes — design system
   ----------------------------------------------------------------------------
   Palette: "Editorial Warm"
   - Warm paper canvas + warm ink text (no cool zinc)
   - Single brand colour: a refined warm claret, deepened from the original
     signature red so it reads scholarly rather than neon-alert.
   - Playfair Display is promoted to page titles for an editorial feel;
     Outfit handles all UI chrome.
   =========================================================================== */

:root {
  /* neutrals — warm paper / ink */
  --canvas:        #FBF8F1;
  --canvas-2:      #F4EEE2;
  --surface:       #FFFFFF;
  --surface-2:     #F7F2E8;
  --border:        #E8DFCF;
  --border-strong: #D6C9B0;
  --text:          #1F1A15;
  --text-soft:     #423A30;
  --text-mute:     #7A6E5E;

  /* primary — refined warm claret (Ryan's signature red, deepened) */
  --brand:        #9C2A38;
  --brand-soft:   #F3E1E3;
  --brand-dark:   #6D1B26;

  /* topic accents — unified claret (single brand colour, by request) */
  --c-cases:    var(--brand);
  --c-verbs:    var(--brand);
  --c-prep:     var(--brand);
  --c-grammar:  var(--brand);
  --c-quiz:     var(--brand);

  /* support — slightly warmed */
  --ok:    #2E7A3E;
  --warn:  #B06A0E;
  --bad:   #B53028;

  --shadow-sm: 0 1px 2px rgba(58,42,20,.07), 0 1px 1px rgba(58,42,20,.05);
  --shadow-md: 0 6px 18px rgba(58,42,20,.10), 0 2px 4px rgba(58,42,20,.05);
  --shadow-lg: 0 24px 48px rgba(58,42,20,.18);

  --radius:    14px;
  --radius-sm: 9px;
  --radius-lg: 22px;

  --sidebar-w: 268px;
  --header-h:  62px;

  --font: "Outfit", "Inter", "Segoe UI", system-ui, -apple-system,
          "Helvetica Neue", Arial, "Noto Sans", "Noto Sans CJK", sans-serif;
  --serif: "Playfair Display", "Outfit", Georgia, "Times New Roman", serif;
  --display: "Space Grotesk", "Outfit", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--canvas);
  /* faint dotted texture (subtle, warm) */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(58,42,20,.035) 1px, transparent 0);
  background-size: 22px 22px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; transition: color .2s; }
a:hover { color: var(--brand-dark); }
button { font-family: inherit; }

/* headings get a touch of tightness; italic <em> uses Playfair Display */
h1, h2, h3 { letter-spacing: -0.015em; line-height: 1.2; font-weight: 700; margin: 0 0 1rem; }
h1 em, h2 em, h3 em { font-family: var(--serif); font-weight: 400; font-style: italic; }

/* ===========================================================================
   Header bar
   =========================================================================== */
.app-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: rgba(251,248,241,.85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center;
  text-decoration: none;
  line-height: 1;
}
.brand .wordmark {
  font-family: var(--display);
  font-weight: 500;
  font-size: 21px;
  letter-spacing: -.015em;
  color: var(--text);
  line-height: 1.05;
  transition: color .2s;
}
.brand .wordmark em {
  font-style: normal;
  font-weight: 700;
  color: var(--brand);
  transition: color .2s;
}
.brand:hover .wordmark em { color: var(--brand-dark); }

.header-search {
  flex: 1; max-width: 460px;
  position: relative;
}
.header-search input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  padding: 0 88px 0 38px;
  font-size: 14px;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.header-search input::placeholder { color: var(--text-mute); }
.header-search input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(156,42,56,.14);
}
.header-search .s-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-mute); pointer-events: none;
}
.header-search .kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: 11px; color: var(--text-mute);
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 6px;
}
.header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; cursor: pointer;
  color: var(--text-soft);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--canvas-2); color: var(--text); }
.icon-btn.active { color: var(--brand); background: var(--brand-soft); }
.menu-btn { display: none; }

/* ===========================================================================
   Shell layout — sidebar + content
   =========================================================================== */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  align-items: start;
  min-height: calc(100vh - var(--header-h));
}

/* ----- Sidebar ----- */
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 18px 14px 24px 18px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.side-section { margin-bottom: 6px; }
.side-group > .side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 14.5px; font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
.side-group > .side-link:hover { background: var(--canvas-2); color: var(--text); }
.side-group .chevron {
  width: 14px; height: 14px;
  transition: transform .18s ease;
  color: var(--text-mute);
}
.side-group.open > .side-link .chevron { transform: rotate(90deg); }
.side-group .accent-dot {
  width: 9px; height: 9px; border-radius: 50%;
}
.side-sub { display: none; padding: 4px 0 6px 26px; }
.side-group.open > .side-sub { display: block; }
.side-sub a {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--text-soft);
  position: relative;
}
.side-sub a:hover { background: var(--canvas-2); color: var(--text); }
.side-sub a.active {
  background: var(--brand-soft); color: var(--brand-dark); font-weight: 600;
}

/* color the active group's accent */
.side-group[data-accent=cases]   .accent-dot { background: var(--c-cases); }
.side-group[data-accent=verbs]   .accent-dot { background: var(--c-verbs); }
.side-group[data-accent=prep]    .accent-dot { background: var(--c-prep); }
.side-group[data-accent=grammar] .accent-dot { background: var(--c-grammar); }
.side-group[data-accent=quiz]    .accent-dot { background: var(--c-quiz); }

.side-cta {
  margin-top: 14px; padding: 14px;
  background: radial-gradient(circle at center 130%, #6D1B26 0%, #9C2A38 120%);
  border-radius: 14px; color: #fff;
  box-shadow: var(--shadow-md);
}
.side-cta h4 { margin: 0 0 4px; font-size: 14px; }
.side-cta p { margin: 0 0 10px; font-size: 12.5px; opacity: .85; line-height: 1.4; }
.side-cta button {
  width: 100%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.18); color: #fff;
  padding: 8px; border-radius: 9px; font-weight: 600; font-size: 13px;
}
.side-cta button:hover { background: rgba(255,255,255,.28); }

/* mobile overlay */
.scrim { display: none; }

/* ===========================================================================
   Content area
   =========================================================================== */
.content {
  padding: 28px clamp(20px, 4vw, 56px) 80px;
  max-width: 980px;
  margin-inline: auto;
  width: 100%;
}

.crumb {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-mute);
  margin-bottom: 14px;
}
.crumb a:hover { color: var(--text); }
.crumb .sep { opacity: .5; }
.crumb .here { color: var(--text-soft); font-weight: 600; }

.tpage-header { margin-bottom: 22px; }
.tpage-header .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px;
  margin-bottom: 14px;
}
.eyebrow[data-accent=cases]   { background: rgba(156,42,56,.1);  color: var(--c-cases); }
.eyebrow[data-accent=verbs]    { background: rgba(156,42,56,.1);   color: var(--c-verbs); }
.eyebrow[data-accent=prep]     { background: rgba(156,42,56,.1);   color: var(--c-prep); }
.eyebrow[data-accent=grammar]  { background: rgba(156,42,56,.1);   color: var(--c-grammar); }
.eyebrow[data-accent=quiz]     { background: rgba(156,42,56,.1);   color: var(--c-quiz); }

.tpage-title { font-family: var(--serif); font-size: 36px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 10px; }
.tpage-lede {
  font-size: 17px; color: var(--text-soft); max-width: 64ch; margin: 0 0 18px;
}
.tpage-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-mute);
}

/* toolbar (mode toggle, randomize, reviewed) */
.topic-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px; padding: 10px 12px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.topic-toolbar .spacer { flex: 1; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer;
  padding: 7px 12px; border-radius: 9px;
  font-size: 13px; font-weight: 600;
  transition: background .14s, border-color .14s, transform .06s;
}
.btn:hover { background: var(--canvas-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(156,42,56,.28);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

/* ----- Case detection practice ----- */
.feedback { font-size: 14px; color: var(--text-soft); }
.feedback.ok  { color: var(--ok); font-weight: 600; }
button[id^="case-detection-"].correct   { background: rgba(22,163,74,.1); border-color: var(--ok); color: #11773A; font-weight: 600; }
button[id^="case-detection-"].incorrect { background: rgba(220,38,38,.08); border-color: var(--bad); color: #9B1F1F; font-weight: 600; }
button[id^="case-detection-"]:disabled { cursor: default; opacity: .6; }
button[id^="case-detection-"].correct:disabled,
button[id^="case-detection-"].incorrect:disabled { opacity: 1; }

/* ----- Content blocks ----- */
section.block { margin: 28px 0; }
section.block > h2 {
  font-size: 21px; margin: 0 0 4px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}
section.block > h2 .h-ico {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-size: 13px;
}
section.block > p { color: var(--text-soft); margin: 0 0 12px; max-width: 72ch; }

/* callouts */
.callout {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 16px 16px;
  display: grid; grid-template-columns: 30px 1fr; gap: 12px;
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.callout .ico {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; font-size: 15px;
}
.callout h4 { margin: 0 0 4px; font-size: 14.5px; }
.callout p { margin: 0; font-size: 14px; color: var(--text-soft); }
.callout.tip   { background: linear-gradient(180deg, #fff, var(--brand-soft)); }
.callout.tip .ico   { background: var(--brand); color: #fff; }
.callout.warn { background: linear-gradient(180deg, #fff, #FBF1DC); border-color: #E8D5A0; }
.callout.warn .ico { background: var(--warn); color: #fff; }
.callout.trap { background: linear-gradient(180deg, #fff, #F8E4E4); border-color: #E0B5B5; }
.callout.trap .ico { background: var(--bad); color: #fff; }

/* example sentence highlight */
.example {
  font-size: 16px; line-height: 1.6;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 11px;
  padding: 14px 18px;
  margin: 12px 0;
}
.example .de { font-weight: 600; }
.example .de .hi {
  background: linear-gradient(180deg, transparent 60%, rgba(156,42,56,.28) 60%);
  padding: 0 2px;
  border-radius: 3px;
}
.example .en { color: var(--text-mute); font-style: italic; font-size: 14px; margin-top: 4px; }

/* ----- reveal table ----- */
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.tbl-wrap table { width: 100%; border-collapse: collapse; min-width: 100%; }
.tbl-wrap caption {
  text-align: left; padding: 12px 16px 0; color: var(--text-mute);
  font-size: 12.5px; caption-side: top; font-weight: 600;
}
.tbl-wrap thead th {
  text-align: left; font-size: 12.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-mute);
  background: var(--surface-2);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.tbl-wrap tfoot th {
  text-align: left; font-size: 12.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-mute);
  background: var(--surface-2);
  padding: 11px 16px;
  border-top: 1px solid var(--border);
}
.tbl-wrap tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
}
.tbl-wrap tbody tr:last-child td { border-bottom: 0; }
.tbl-wrap tbody tr:hover { background: var(--surface-2); }

/* revealable cell */
.cell {
  cursor: pointer; user-select: none;
  position: relative;
}
.cell.revealed .reveal-text { color: var(--text); }
.cell.revealed .reveal-cover { display: none; }
.cell .reveal-cover {
  position: absolute; inset: 0;
  background: var(--canvas-2);
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700; color: var(--text-mute);
  letter-spacing: .02em; text-transform: uppercase;
  white-space: nowrap;
  border-radius: 4px; margin: 4px 6px;
  width: auto; inset: 4px 6px;
}
.cell .reveal-cover::before { content: "click to reveal"; }
.cell .reveal-text { visibility: hidden; color: var(--text); }
.cell.revealed .reveal-text { visibility: visible; }

.tbl-toolbar {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 2px 0; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-mute);
}
.tbl-toolbar .btn { padding: 6px 11px; font-size: 12.5px; }

/* ----- quiz ----- */
.quiz {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin: 30px 0;
}
.quiz-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(120deg, var(--c-quiz), #C24552);
  color: #fff;
}
.quiz-head .q-ico {
  width: 34px; height: 34px; border-radius: 9px;
  background: rgba(255,255,255,.2);
  display: grid; place-items: center; font-size: 17px;
}
.quiz-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.quiz-head p { margin: 2px 0 0; font-size: 12.5px; opacity: .9; }
.quiz-head .q-stage { margin-left: auto; font-size: 12.5px; font-weight: 600; }

.quiz-body { padding: 18px; }
.quiz-sentence {
  font-size: 17px; font-weight: 500; padding: 22px 18px; line-height: 2;
}
.quiz-sentence select,
.quiz-sentence input {
  font-size: 16px; padding: 4px 10px; border: 1.5px solid var(--border);
  border-radius: 7px; background: var(--surface); color: var(--text);
  margin: 0 4px; font-family: inherit;
}
.quiz-sentence select.correct,
.quiz-sentence input.correct {
  border-color: var(--ok); background: rgba(22,163,74,.08); color: #11773A;
}
.quiz-sentence select.incorrect,
.quiz-sentence input.incorrect {
  border-color: var(--bad); background: rgba(220,38,38,.06); color: #9B1F1F;
}
.quiz-controls {
  padding: 0 18px 4px; font-size: 13px; color: var(--text-soft);
}
.quiz-controls input[type="checkbox"] { margin-right: 6px; accent-color: var(--brand); }
.q-progress {
  height: 6px; background: var(--canvas-2); border-radius: 999px; overflow: hidden;
  margin-bottom: 16px;
}
.q-progress > span {
  display: block; height: 100%; width: 30%;
  background: linear-gradient(90deg, var(--c-quiz), #C24552);
  border-radius: 999px; transition: width .3s;
}
.q-question { font-size: 17px; font-weight: 600; margin: 0 0 14px; }
.q-context  { color: var(--text-mute); font-size: 13.5px; margin-bottom: 14px; }
.q-options  { display: grid; gap: 9px; }
.q-options button {
  text-align: left; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface);
  padding: 11px 14px; border-radius: 11px;
  font-size: 14.5px; font-weight: 500;
  display: flex; align-items: center; gap: 12px;
  transition: border-color .14s, background .14s, transform .06s;
}
.q-options button .key {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--canvas-2); color: var(--text-soft);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; flex: none;
}
.q-options button:hover { border-color: var(--brand); background: var(--brand-soft); }
.q-options button:hover .key { background: var(--brand); color: #fff; }
.q-options button.correct   { border-color: var(--ok); background: rgba(22,163,74,.1); color: #11773A; }
.q-options button.correct .key  { background: var(--ok); color: #fff; }
.q-options button.incorrect { border-color: var(--bad); background: rgba(220,38,38,.08); color: #9B1F1F; }
.q-options button.incorrect .key { background: var(--bad); color: #fff; }
.q-options button.disabled { cursor: default; pointer-events: none; }
.q-options button.disabled:not(.correct):not(.incorrect) { opacity: .6; }

.q-foot {
  display: flex; align-items: center; gap: 10px; margin-top: 16px;
  padding: 0 18px 18px;
}
.q-foot .btn-primary { margin-left: auto; }
.q-feedback { font-size: 13.5px; color: var(--text-soft); }
.q-feedback.ok  { color: var(--ok); font-weight: 600; }
.q-feedback.bad { color: var(--bad); font-weight: 600; }
.q-foot .spacer { flex: 1; }

/* quiz result card */
.q-result {
  text-align: center; padding: 30px 22px 26px;
}
.q-result .score {
  font-size: 56px; font-weight: 800;
  background: linear-gradient(120deg, var(--c-quiz), #C24552);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: -.03em;
}
.q-result .score small { font-size: 22px; color: var(--text-mute); -webkit-text-fill-color: var(--text-mute); }

/* ----- prev / next ----- */
.flow {
  display: flex; gap: 12px; align-items: stretch;
  margin-top: 48px;
}
.flow a {
  flex: 1; border: 1px solid var(--border);
  background: var(--surface); border-radius: 14px;
  padding: 14px 16px; display: block;
  transition: border-color .14s, transform .1s;
}
.flow a:hover { border-color: var(--brand); transform: translateY(-1px); }
.flow .label { font-size: 12px; color: var(--text-mute); }
.flow .title { font-size: 15px; font-weight: 700; margin-top: 2px; }
.flow a.next { text-align: right; }
.flow .spacer { flex: 0 0 0; }

/* ===========================================================================
   Home / hub specific
   =========================================================================== */
.home-hero {
  position: relative; margin-bottom: 28px;
  background:
    radial-gradient(circle at center 150%, #6D1B26 0%, #9C2A38 110%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 36px 36px 32px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.home-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle at 2px 2px, rgba(255,255,255,1) 1px, transparent 0);
  background-size: 20px 20px; opacity: .08; mix-blend-mode: overlay;
}
.home-hero .h-eyebrow {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: rgba(255,255,255,.92);
}
.home-hero h1 { font-family: var(--serif); font-size: 40px; margin: 14px 0 8px; font-weight: 700; letter-spacing: -.015em; max-width: 18ch; }
.home-hero p { margin: 0 0 18px; color: rgba(255,255,255,.82); max-width: 52ch; }
.home-hero .h-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.home-hero .h-stat {
  position: absolute; right: 28px; bottom: 24px;
  display: flex; gap: 18px;
}
.home-hero .h-stat .n { font-size: 26px; font-weight: 800; }
.home-hero .h-stat .l { font-size: 11.5px; color: rgba(255,255,255,.7); text-transform: uppercase; letter-spacing: .05em; }

.btn-glass {
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22); color: #fff;
}
.btn-glass:hover { background: rgba(255,255,255,.24); }
.btn-glass-solid { background: #fff; color: var(--brand-dark); border: 1px solid #fff; }
.btn-glass-solid:hover { background: var(--brand-soft); }

.section-h {
  display: flex; align-items: baseline; gap: 10px;
  margin: 32px 0 14px;
}
.section-h h2 { margin: 0; font-size: 20px; font-weight: 700; }
.section-h .link {
  margin-left: auto; font-size: 13px; color: var(--brand); font-weight: 600;
}

.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 14px; }
.tcard {
  position: relative;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform .14s, box-shadow .14s, border-color .14s;
  display: flex; flex-direction: column; gap: 10px;
  overflow: hidden;
}
.tcard::before {
  content: ""; position: absolute; inset: 0 auto 0 0;
  width: 5px; background: var(--accent, var(--brand));
}
.tcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.tcard[data-accent=cases]   { --accent: var(--c-cases); }
.tcard[data-accent=verbs]   { --accent: var(--c-verbs); }
.tcard[data-accent=prep]    { --accent: var(--c-prep); }
.tcard[data-accent=grammar] { --accent: var(--c-grammar); }
.tcard[data-accent=quiz]    { --accent: var(--c-quiz); }
.tcard .tc-ic {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; font-size: 19px; color: #fff;
  background: var(--accent);
}
.tcard h3 { margin: 0; font-size: 16px; font-weight: 700; }
.tcard p { margin: 0; font-size: 13px; color: var(--text-mute); line-height: 1.5; }
.tcard .tc-foot {
  display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 4px;
}
.tcard .tc-chip {
  font-size: 11.5px; font-weight: 600; color: var(--text-soft);
  background: var(--canvas-2); padding: 3px 9px; border-radius: 999px;
}
.tcard .tc-progress {
  margin-left: auto; font-size: 11.5px; color: var(--text-mute);
  display: flex; align-items: center; gap: 6px;
}
.tcard .tc-bar { width: 50px; height: 5px; border-radius: 999px; background: var(--canvas-2); overflow: hidden; }
.tcard .tc-bar > span { display: block; height: 100%; background: var(--accent); }

/* recent list */
.recent-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.recent-list a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.recent-list a:last-child { border-bottom: 0; }
.recent-list a:hover { background: var(--surface-2); }
.recent-list .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.recent-list .rt { flex: 1; }
.recent-list .rt b { font-weight: 600; }
.recent-list .rt span { color: var(--text-mute); font-size: 12.5px; margin-left: 8px; }
.recent-list .time { color: var(--text-mute); font-size: 12.5px; }

/* quiz hub */
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 16px; }
.qcard {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  transition: transform .14s, box-shadow .14s;
}
.qcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.qcard .qc-top { display: flex; align-items: center; gap: 10px; }
.qcard .qc-ic {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-size: 17px;
}
.qcard h3 { margin: 0; font-size: 16px; font-weight: 700; }
.qcard .topic-tag { font-size: 11.5px; color: var(--text-mute); }
.qcard p { margin: 0; font-size: 13px; color: var(--text-soft); line-height: 1.5; }
.qcard .qc-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.qcard .qc-stars { color: var(--c-prep); font-size: 14px; letter-spacing: 1px; }
.qcard .qc-score { font-size: 13px; font-weight: 700; }
.qcard .qc-score small { font-weight: 500; color: var(--text-mute); }
.qcard .btn-primary { padding: 7px 14px; font-size: 13px; }
.qcard.locked  { opacity: .55; }

/* ===========================================================================
   CMD+K search overlay
   =========================================================================== */
.search-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(30,22,12,.55);
  backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 11vh 20px 20px;
}
.search-overlay.open { display: flex; }
.search-panel {
  width: 100%; max-width: 580px;
  background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-lg); overflow: hidden;
  border: 1px solid var(--border);
}
.search-panel input {
  width: 100%; border: 0; padding: 18px 22px;
  font-size: 16px; border-bottom: 1px solid var(--border);
}
.search-panel input:focus { outline: none; }
.search-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.search-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
}
.search-item:hover, .search-item.active { background: var(--brand-soft); }
.search-item .si-dot { width: 8px; height: 8px; border-radius: 50%; }
.search-item .si-meta { flex: 1; }
.search-item .si-meta b { font-weight: 600; }
.search-item .si-meta span { color: var(--text-mute); font-size: 12.5px; margin-left: 8px; }
.search-item .si-enter { color: var(--text-mute); font-size: 12px; }
.search-empty { padding: 24px; text-align: center; color: var(--text-mute); font-size: 14px; }

/* ===========================================================================
   Articles cheat-sheet overlay
   =========================================================================== */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 75;
  background: rgba(30,22,12,.55);
  backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 9vh 20px 20px;
}
.sheet-overlay.open { display: flex; }
.sheet-panel {
  width: 100%; max-width: 880px;
  height: 82vh;
  max-height: calc(100dvh - 9dvh - 40px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-lg); overflow: hidden;
  border: 1px solid var(--border);
}
.sheet-tabs {
  display: flex; gap: 4px;
  padding: 10px 14px 0;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.sheet-tabs::-webkit-scrollbar { display: none; }
.sheet-tab {
  padding: 6px 12px; font-size: 12px; font-weight: 600;
  border-radius: 999px; border: 1px solid transparent;
  background: transparent; color: var(--text-mute);
  cursor: pointer; white-space: nowrap;
  transition: background .14s, color .14s;
}
.sheet-tab:hover { background: var(--canvas-2); color: var(--text); }
.sheet-tab.active {
  background: var(--brand); color: #fff; border-color: var(--brand);
}
.sheet-hd {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.sheet-titles { flex: 1; }
.sheet-titles h2 { font-size: 17px; font-weight: 700; }
.sheet-titles p { font-size: 12.5px; color: var(--text-mute); margin-top: 2px; }
.sheet-adv,
.sheet-rand {
  padding: 7px 13px; font-size: 12.5px; font-weight: 600;
  white-space: nowrap;
}
.sheet-close { font-size: 22px; line-height: 1; flex-shrink: 0; }
.sheet-body { flex: 1 1 0; min-height: 0; padding: 14px; overflow-y: auto; }

/* cheat-sheet table readability tweaks */
.sheet-body .cell .reveal-cover::before { content: "reveal"; }
.sheet-body .tbl-wrap { box-shadow: none; }
.sheet-body .tbl-wrap tbody td:first-child {
  font-weight: 700; color: var(--text); white-space: nowrap;
}
.sheet-body .tbl-wrap tbody td {
  vertical-align: top; line-height: 1.45; position: relative;
}
.sheet-body .tbl-wrap tbody td > :first-child,
.sheet-body .tbl-wrap tbody td {
  font-size: 15px;
}
.sheet-body .tbl-wrap tbody td small.cs-extra {
  display: block; margin-top: 1px;
  color: var(--text-mute); font-size: 12px; line-height: 1.5;
}
.sheet-body .tbl-wrap tbody td small.cs-extra.alt {
  color: var(--brand-dark); font-size: 11px; margin-top: 4px;
}
.sheet-body.cs-basic .tbl-wrap tbody td small.cs-extra { display: none; }
.sheet-body.cs-basic .tbl-wrap tbody td { font-size: 16px; }

/* guess mode — hide the article in any body cell (case column preserved) */
.sheet-body.cs-guess .tbl-wrap tbody td:not(:first-child) {
  position: relative;
  cursor: pointer;
  color: transparent;
  transition: background .14s;
}
.sheet-body.cs-guess .tbl-wrap tbody td:not(:first-child) small {
  color: transparent !important;
}
.sheet-body.cs-guess .tbl-wrap tbody td:not(:first-child)::after {
  content: "guess";
  position: absolute;
  inset: 4px 6px;
  display: grid; place-items: center;
  background: var(--canvas-2);
  color: var(--text-mute);
  font-size: 11px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  border-radius: 4px;
  border: 1px dashed var(--border-strong);
  transition: background .14s, color .14s;
}
.sheet-body.cs-guess .tbl-wrap tbody td:not(:first-child):hover::after {
  background: var(--brand-soft); color: var(--brand-dark);
}
.sheet-body.cs-guess .tbl-wrap tbody td:not(:first-child).revealed {
  color: var(--text); cursor: default;
}
.sheet-body.cs-guess .tbl-wrap tbody td:not(:first-child).revealed small {
  color: var(--text-mute) !important;
}
.sheet-body.cs-guess .tbl-wrap tbody td:not(:first-child).revealed::after {
  display: none;
}

/* dark theme — warm espresso */
body[data-theme=dark] {
  --canvas: #1A1612;
  --canvas-2: #241F1A;
  --surface: #221D18;
  --surface-2: #2B251F;
  --border: #3A3128;
  --border-strong: #4A3F33;
  --text: #F0E9DC;
  --text-soft: #C9BEAD;
  --text-mute: #8E8170;
  --brand-soft: #2E1A1E;
  --brand-dark: #E0707E;
  background-color: var(--canvas);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,.04) 1px, transparent 0);
}
body[data-theme=dark] .icon-btn:hover { background: var(--canvas-2); }
body[data-theme=dark] .app-header { background: rgba(34,29,24,.82); }
body[data-theme=dark] .home-hero .btn-glass-solid:hover { background: var(--brand-soft); }
body[data-theme=dark] .tabbar { background: rgba(34,29,24,.92); }

/* ===========================================================================
   Responsive
   =========================================================================== */
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(82vw, 320px); height: 100vh;
    z-index: 70;
    transform: translateX(-105%);
    transition: transform .26s cubic-bezier(.4,.1,.2,1);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .menu-btn { display: grid; }
  .scrim {
    display: none; position: fixed; inset: 0; z-index: 60;
    background: rgba(30,22,12,.5); backdrop-filter: blur(2px);
  }
  body.nav-open .scrim { display: block; }
  .header-search { display: none; }
  .home-hero .h-stat { display: none; }
  .content { padding: 22px 18px 80px; }
  .tpage-title { font-size: 28px; }
}

@media (max-width: 560px) {
  .home-hero { padding: 26px 22px; }
  .home-hero h1 { font-size: 30px; }
  .flow { flex-direction: column; }
  .flow a.next { text-align: left; }
}

/* mobile bottom tabbar */
.tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(251,248,241,.92); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(env(safe-area-inset-bottom, 6px));
}
.tabbar .tab {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; font-size: 11px; font-weight: 600; color: var(--text-mute);
}
.tabbar .tab .ti { font-size: 16px; }
.tabbar .tab.active { color: var(--brand); }
@media (max-width: 880px) {
  .tabbar { display: flex; }
  .content { padding-bottom: 96px; }
}