/* ==========================================================================
   Medical Nomenclature — app styles on top of the shared MirodaLab stylesheet
   (css/style.css, copied unchanged). Colours come from the shared tokens, so
   the palette and dark mode match the other sites; layout and typography are
   kept deliberately quiet: a full-height term list on the left, content
   left-aligned beside it, Latin set in a regular-weight serif.
   ========================================================================== */

:root {
  --latin: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --side: color-mix(in srgb, var(--bg-alt), var(--text) 6%);
  --hl: var(--zest-soft);
  --noun: var(--accent);
  --adj: #8a4fb0;
  --nav-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root { --adj: #c79be6; --noun: var(--link); --side: color-mix(in srgb, var(--bg-alt), var(--bg) 35%); }
}

html, body { height: 100%; }
body { font-size: 15px; line-height: 1.45; }
body::before { opacity: 0.6; }

/* ---------- Header: full width, left-aligned, no external links ---------- */
header.site-nav .wrap { max-width: none; height: var(--nav-h); padding: 0 20px; justify-content: flex-start; gap: 48px; }
.menu-toggle { margin: -8px -8px -8px auto; }   /* phones: keep the menu button on the right */
.brand { font-size: 1.1rem; }
.brand-logo { height: 40px; width: auto; flex-shrink: 0; }
@media (prefers-color-scheme: dark) {
  .brand-logo { filter: invert(1) hue-rotate(180deg); }   /* black line art -> white, green stays */
}
nav.links { font-size: 0.92rem; font-weight: 500; gap: 22px; }
nav.links a.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); padding-bottom: 2px; }
@media (max-width: 640px) {
  header.site-nav .wrap { padding: 0 16px; }
  nav.links { top: var(--nav-h); }
  nav.links a.active { box-shadow: none; color: var(--accent); }
}

/* ---------- App layout: term list on the left, content beside it ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(270px, 360px) minmax(0, 1fr);
  height: calc(100% - var(--nav-h) - 1px);
}
.main { overflow: auto; padding: 28px 40px 80px; min-width: 0; }
.main:focus { outline: none; }
.main > .wrap { max-width: 1000px; margin: 0; padding: 0; }

body[data-page="pronunciation"] .layout,
body[data-page="quiz"] .layout { grid-template-columns: minmax(0, 1fr); }
body[data-page="pronunciation"] .sidebar,
body[data-page="quiz"] .sidebar,
body[data-page="pronunciation"] .tree-toggle,
body[data-page="quiz"] .tree-toggle { display: none; }
body[data-page="pronunciation"] .main,
body[data-page="quiz"] .main { padding-left: max(40px, calc((100% - 1000px) / 2)); }

/* ---------- Term list ---------- */
.sidebar {
  background: var(--side);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.search { padding: 12px; border-bottom: 1px solid var(--border); }
.search input {
  width: 100%;
  padding: 8px 11px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search-info { font-size: 12px; color: var(--text-muted); margin-top: 6px; min-height: 1em; }

.tree { overflow: auto; flex: 1; padding: 6px 4px 40px; font-family: var(--latin); font-size: 15px; }
.tree ul { list-style: none; margin: 0; padding: 0 0 0 14px; }
.tree > ul { padding-left: 0; }
.tree li > ul { display: none; }
.tree li.open > ul { display: block; }
.row { display: flex; align-items: flex-start; border-radius: 4px; }
.row:hover { background: var(--accent-soft); }
.tw, .tw-space { flex: none; width: 20px; height: 24px; border: 0; background: none; color: var(--text-faint); cursor: pointer; font-size: 10px; padding: 0; }
.tw::before { content: "▸"; display: inline-block; transition: transform .12s; }
li.open > .row > .tw::before { transform: rotate(90deg); }
.lbl { flex: 1; color: var(--text); padding: 2px 4px; }
.lbl:hover { text-decoration: none; }
.tree > ul > li > .row .lbl { font-weight: 700; }
li.current > .row { background: var(--accent); }
li.current > .row .lbl, li.current > .row .tw, li.current > .row .count, li.current > .row .star { color: var(--accent-ink); }
.count { font-family: var(--font); font-size: 11px; color: var(--text-faint); padding: 4px 6px 0 0; }

.tree.filtering li { display: none; }
.tree.filtering li.match, .tree.filtering li.path { display: block; }
.tree.filtering li.path > ul { display: block; }
.tree mark { background: var(--hl); color: inherit; }

.tree-toggle { display: none; }

/* ---------- Content basics ---------- */
.main h1, .main h2, .main h3 { font-family: var(--font); letter-spacing: 0; }
.crumbs { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 6px; opacity: .6; }
.kicker, .main h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}
.kicker { margin: 0 0 6px; }
.main h2 { margin: 34px 0 10px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; margin-top: 3px; }
.warn { color: var(--zest); }
.loading { color: var(--text-muted); padding: 20px 0; }
.error { color: var(--bad); }
.la { font-family: var(--latin); }
.main .btn { margin-top: 10px; padding: 9px 20px; font-size: 0.9rem; }
.main .btn:disabled { opacity: .45; cursor: default; }
.main .note {
  background: var(--zest-soft);
  border-left: 3px solid var(--zest);
  padding: 10px 14px;
  border-radius: 4px;
  margin: 18px 0;
}

/* Tables */
.main table { border-collapse: collapse; width: 100%; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.main th, .main td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.main thead th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); background: var(--side); }
.main tbody th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); background: var(--side); }
.main tr:last-child td, .main tr:last-child th { border-bottom: 0; }
td.la { font-size: 18px; }
td.la a:hover { text-decoration: underline; }
.table-scroll { overflow-x: auto; }

.pos { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; border: 1px solid currentColor; }
.pos.noun { color: var(--noun); }
.pos.adjective { color: var(--adj); }
.pos.other { color: var(--text-faint); }
.reading { display: block; }
.reading + .reading { margin-top: 3px; }
.reading + .reading::before { content: "or "; color: var(--text-muted); font-style: italic; }
.reading .agr { color: var(--text-muted); font-size: 13px; }
.reading .agr i { font-family: var(--latin); font-size: 15px; }

ul.termlist { columns: 2 260px; column-gap: 28px; padding: 0; margin: 0; list-style: none; font-family: var(--latin); font-size: 16px; }
ul.termlist li { break-inside: avoid; padding: 2px 0; }

/* ---------- Term page ---------- */
.term { display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 0 0 30px; }
.tok { display: flex; flex-direction: column; color: inherit; border-radius: 8px; padding: 4px 6px; margin: -4px -6px; }
a.tok:hover { background: var(--accent-soft); text-decoration: none; }
.tok .la { font-size: clamp(32px, 4.6vw, 52px); line-height: 1.1; color: var(--text); border-bottom: 2px solid transparent; }
a.tok:hover .la { border-bottom-color: var(--accent); }
.tok .en { font-size: 15px; color: var(--link); margin-top: 4px; }
.tok .no { font-size: 13px; color: var(--text-muted); }
.tok.unknown .la { color: var(--text-faint); border-bottom: 2px dashed var(--border); }

.star { color: var(--zest); font-weight: 700; }
sup.star { margin-left: 1px; font-family: var(--font); font-size: 12px; }
.tok .la.star { margin-left: -20px; }
.correction { margin: -14px 0 24px; font-size: 14px; max-width: 760px; }
.correction:not(.muted) { background: var(--zest-soft); border-left: 3px solid var(--zest); padding: 8px 12px; border-radius: 4px; }

/* ---------- Word page ---------- */
.main .headword { font-family: var(--latin); font-weight: 400; letter-spacing: 0; font-size: clamp(36px, 5.5vw, 56px); line-height: 1.05; margin: 0; }
.headword small { font-size: .45em; color: var(--text-muted); font-style: italic; }
.meaning { font-size: 20px; margin: 10px 0 0; color: var(--link); }
.meaning-no { font-size: 15px; color: var(--text-muted); margin: 2px 0 0; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.facts li { background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 3px 10px; font-size: 13px; }
.facts b { color: var(--text-muted); font-weight: 600; margin-right: 4px; }
.back { display: inline-block; margin-bottom: 16px; font-size: 14px; }

.decl td, .decl th { text-align: center; }
.decl td:first-child, .decl th:first-child { text-align: left; }
.decl td.f { font-family: var(--latin); font-size: 19px; }
.decl td.f.hit { background: var(--accent-soft); font-weight: 700; box-shadow: inset 0 0 0 2px var(--accent); }
.decl td.f.same { background: color-mix(in srgb, var(--zest) 9%, var(--card-bg)); }
.decl td.empty { color: var(--border); }
.decl tr.group th { background: var(--card-bg); color: var(--text); text-align: left; }
.legend { font-size: 13px; color: var(--text-muted); margin: -4px 0 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.legend .sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; margin-left: 10px; }
.legend .sw:first-child { margin-left: 0; }
.legend .sw.hit { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.legend .sw.same { background: color-mix(in srgb, var(--zest) 9%, var(--card-bg)); border: 1px solid color-mix(in srgb, var(--zest) 30%, var(--border)); }

/* ---------- Home ---------- */
.welcome h1 { font-family: var(--latin); font-weight: 400; font-size: 42px; letter-spacing: 0; margin: 0 0 8px; }
.welcome p { max-width: 640px; color: var(--text-muted); font-size: 16px; }
.stats { display: flex; gap: 28px; margin: 24px 0; }
.stats div { font-size: 13px; color: var(--text-muted); }
.stats b { display: block; font-family: var(--latin); font-size: 30px; font-weight: 400; color: var(--text); }

/* ---------- Pronunciation ---------- */
.main .page-title { font-family: var(--latin); font-weight: 400; letter-spacing: 0; font-size: 42px; line-height: 1.1; margin: 0; }
.pron-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.lang-switch { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.lang-switch button { font: inherit; padding: 5px 12px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); border-radius: 6px; cursor: pointer; }
.lang-switch button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pron[data-lang="en"] [data-lang-no], .pron[data-lang="no"] [data-lang-en] { display: none; }
.pron .lead { color: var(--text-muted); margin: -4px 0 12px; max-width: 700px; }
.pron-table td { vertical-align: middle; }
.pron-table td:first-child { width: 170px; }
.pron-table td:nth-child(2) { width: 40%; }
.pron-table tr.vfirst td { border-top: 1px solid var(--border); }
.letter { font-family: var(--latin); font-size: 22px; font-weight: 700; margin-right: 8px; }
.ctx { display: block; font-size: 12px; color: var(--text-muted); }
.qty { display: inline-block; min-width: 42px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.pron .la { font-size: 17px; }
.pron .gloss { color: var(--text-muted); font-size: 13px; }
.small-inline { font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.stress-rules { padding-left: 22px; max-width: 760px; }
.stress-rules li { margin-bottom: 16px; }
.stress-rules p { margin: 0 0 4px; }
.syll { font-family: var(--latin); font-size: 19px; }
.syll b { color: var(--accent); }
.syll .hy { color: var(--text-faint); margin: 0 1px; }
.ybreve { position: relative; display: inline-block; }
.ybreve::after { content: "˘"; position: absolute; left: 0; right: 0; top: -0.45em; text-align: center; font-size: .9em; }

/* ---------- Quiz ---------- */
.quiz-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 16px; }
.quiz-tabs a { padding: 8px 14px; color: var(--text-muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.quiz-tabs a:hover { color: var(--text); text-decoration: none; }
.quiz-tabs a[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.quiz-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.quiz-intro { margin: 0; max-width: 620px; }
.quiz-score { display: flex; gap: 10px; align-items: center; font-size: 14px; white-space: nowrap; }
.quiz-score .streak { background: var(--zest-soft); color: var(--zest); padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.quiz-filters { display: flex; gap: 16px; flex-wrap: wrap; margin: 14px 0 0; font-size: 14px; color: var(--text-muted); }
.quiz-filters select { margin-left: 6px; font: inherit; color: var(--text); background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; }
.quiz-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 24px 28px; margin-top: 18px; }
.q-term { font-family: var(--latin); font-size: clamp(26px, 4vw, 40px); line-height: 1.3; color: var(--text-faint); }
.q-term .target { color: var(--text); background: var(--hl); border-bottom: 3px solid var(--zest); padding: 0 4px; border-radius: 3px; }
.q-ask { font-size: 16px; margin: 14px 0 18px; }
.q-ask .la, .quiz .la { font-size: 1.1em; }
.q-groups { display: grid; gap: 12px; }
.q-group { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; }
.q-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.q-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.q-opts button { font: inherit; font-size: 14px; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
.q-opts button:hover:not(:disabled) { border-color: var(--accent); }
.q-opts button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.q-opts button.is-right { background: var(--good); border-color: var(--good); color: #fff; }
.q-opts button.is-wrong { background: var(--bad); border-color: var(--bad); color: #fff; text-decoration: line-through; }
.q-opts button:disabled { cursor: default; }
.q-actions { margin-top: 20px; }
.q-feedback:not(:empty) { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.verdict { font-weight: 700; font-size: 18px; margin: 0 0 6px; }
.verdict.ok { color: var(--good); }
.verdict.bad { color: var(--bad); }
.q-readings { margin: 4px 0 8px; }
.linkish { font: inherit; background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; text-decoration: underline; }
.q-word { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.q-meta { font-size: 14px; color: var(--text-muted); }
.q-decl { max-width: 560px; margin-top: 8px; }
.main .q-decl td { padding: 8px; }
.q-decl td.given { font-family: var(--latin); font-size: 19px; text-align: center; }
.q-decl input { width: 100%; font-family: var(--latin); font-size: 18px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); text-align: center; }
.q-decl input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.q-decl input.is-right { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--card-bg)); }
.q-decl input.is-wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.q-correct { display: block; font-family: var(--latin); font-size: 17px; color: var(--good); font-weight: 700; margin-top: 4px; text-align: center; }

/* ---------- Narrow screens ---------- */
@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .tree-toggle {
    display: inline-flex; align-items: center; gap: 8px; justify-self: start;
    font: inherit; font-weight: 600; font-size: 14px; color: var(--text);
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px;
    padding: 6px 12px; margin: 12px 16px 0;
  }
  .sidebar {
    position: fixed; top: var(--nav-h); bottom: 0; left: 0; width: min(88vw, 380px); z-index: 20;
    transform: translateX(-100%); transition: transform .2s; visibility: hidden;
  }
  body.drawer .sidebar { transform: none; visibility: visible; box-shadow: 0 0 30px rgba(0,0,0,.25); }
  .main { padding: 16px 16px 60px; }
  body[data-page="pronunciation"] .main, body[data-page="quiz"] .main { padding-left: 16px; }
  .tok .la { font-size: 34px; }
  .main th, .main td { padding: 7px 8px; }
  .quiz-card { padding: 16px; }
}
@media (max-width: 600px) {
  .q-group { grid-template-columns: 1fr; gap: 4px; }
  .pron-table thead { display: none; }
  .pron-table, .pron-table tbody, .pron-table tr, .pron-table td { display: block; width: auto !important; }
  .pron-table tr { padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .main .pron-table td { border: 0; padding: 2px 0; }
  .pron-table tr.vfirst td { border-top: 0; }

  /* grammar table: one card per word */
  .gram thead { display: none; }
  .gram, .gram tbody, .gram tr, .gram td { display: block; width: auto; }
  .gram tr { padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .gram tr:last-child { border-bottom: 0; }
  .main table.gram td { border: 0; padding: 3px 0 5px; }
  .main table.gram td.la { padding-bottom: 6px; }
  .gram td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font); font-size: 10.5px; font-weight: 600; line-height: 1.3;
    text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  }
}
@media (max-width: 420px) {
  .brand { font-size: 1rem; }
  .brand-logo { height: 34px; }
}
