:root {
  --bg: #f6f0e6;
  --paper: #fffaf2;
  --ink: #2a241d;
  --muted: #6e6457;
  --line: #e4d9c7;
  --it: #b5532f;
  --it-soft: #f6e1d6;
  --pt: #2f6b4f;
  --pt-soft: #dcebe2;
  --gold: #b88a2e;
  --good: #2f6b4f;
  --bad: #b03a2e;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 8px 24px rgba(60, 40, 20, .07);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1814; --paper: #24201b; --ink: #f1e9dc; --muted: #b0a493; --line: #3a332a;
    --it: #e98a63; --it-soft: #43291e; --pt: #7fc4a0; --pt-soft: #1f3a2d; --gold: #d8b25e;
    --good: #7fc4a0; --bad: #ec8577; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1814; --paper: #24201b; --ink: #f1e9dc; --muted: #b0a493; --line: #3a332a;
  --it: #e98a63; --it-soft: #43291e; --pt: #7fc4a0; --pt-soft: #1f3a2d; --gold: #d8b25e;
  --good: #7fc4a0; --bad: #ec8577; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 19px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Atkinson Hyperlegible", system-ui, sans-serif; line-height: 1.6;
  min-height: 100vh; display: flex; flex-direction: column;
}
h1, h2, h3, .serif { font-family: "Fraunces", Georgia, serif; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 2.3rem; margin: 0 0 .4rem; }
h2 { font-size: 1.55rem; margin: 2.2rem 0 .8rem; }
h3 { font-size: 1.2rem; margin: 1.8rem 0 .6rem; }
a { color: var(--it); }
button { font: inherit; color: inherit; cursor: pointer; }
main { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; outline: none; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.25rem; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink);
  font-family: "Fraunces", serif; font-weight: 700; font-size: 1.35rem; }
.brand svg { width: 38px; color: var(--it); }
.top nav { display: flex; gap: .25rem; }
.top nav a { display: inline-flex; align-items: center; white-space: nowrap; text-decoration: none; color: var(--muted); padding: .4rem .8rem; border-radius: 999px; font-size: .95rem; }
.top nav a.on { color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--it);
  color: #fff; font-size: .75rem; text-align: center; line-height: 1.4em; margin-left: .2rem; }
.badge[hidden] { display: none; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem 2.5rem; }
.it-demo { color: var(--it); font-weight: 700; }

/* inline language marks */
it, .it { color: var(--it); font-weight: 700; cursor: pointer; border-bottom: 1.5px dotted color-mix(in srgb, var(--it) 50%, transparent); }
it:hover, .it:hover { border-bottom-style: solid; }
it.speaking, .it.speaking { background: var(--it-soft); border-radius: 4px; }
pt, .pt { color: var(--pt); font-style: italic; }

/* hero */
.hero { padding: 1.5rem 0 1rem; }
.kicker { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; color: var(--gold); font-weight: 700; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 40em; margin: .3rem 0 0; }
.progress-card { margin: 1.6rem 0 .5rem; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem; display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: .6rem; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--pt), var(--gold), var(--it)); border-radius: inherit; transition: width .5s; }
.levels { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: .3rem; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: .4rem; border: 0; border-radius: 999px; padding: .6rem 1.2rem;
  background: var(--it); color: #fff; font-weight: 700; text-decoration: none; font-size: .95rem; white-space: nowrap; }
.pill:hover { filter: brightness(1.06); }
.pill.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.pill.green { background: var(--pt); }
.pill[disabled] { opacity: .45; cursor: default; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* unit tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; margin-top: 1rem; }
.tile { position: relative; text-align: left; border: 0; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.2rem; display: flex; flex-direction: column; gap: .3rem; min-height: 150px; transition: transform .15s; }
.tile:hover { transform: translateY(-2px); }
.tile.open { box-shadow: 0 0 0 2px var(--it), var(--shadow); }
.tile .num { font-family: "Fraunces", serif; font-size: 2rem; color: var(--it); line-height: 1; }
.tile .t { font-family: "Fraunces", serif; font-size: 1.12rem; font-weight: 600; }
.tile .s { color: var(--muted); font-size: .9rem; }
.tile .lv { position: absolute; top: 1rem; right: 1rem; font-size: .72rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; background: var(--pt-soft); color: var(--pt); }
.tile .mini { margin-top: auto; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.tile .mini i { display: block; height: 100%; background: var(--pt); }
.tile.done .num::after { content: " ✓"; font-size: 1.1rem; color: var(--pt); }
.panel { grid-column: 1 / -1; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem 1.4rem; animation: drop .2s ease-out; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
.panel p.goal { margin: 0 0 1rem; color: var(--muted); }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .7rem; }
.lesson-link { display: flex; gap: .8rem; align-items: center; text-decoration: none; color: var(--ink); padding: .8rem 1rem;
  border-radius: 14px; background: var(--bg); }
.lesson-link:hover { background: var(--it-soft); }
.lesson-link .dot { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  font-size: .85rem; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--line); }
.lesson-link.done .dot { background: var(--pt); color: #fff; box-shadow: none; }
.lesson-link small { display: block; color: var(--muted); font-size: .8rem; }

/* lesson */
.crumb { font-size: .9rem; color: var(--muted); margin-bottom: .6rem; }
.crumb a { color: var(--muted); }
.lesson p { margin: .8rem 0; }
.tip { border-radius: 14px; padding: 1rem 1.2rem; margin: 1.2rem 0; background: var(--paper); box-shadow: var(--shadow); border-left: 5px solid var(--gold); }
.tip.bridge { border-left-color: var(--pt); }
.tip.trap { border-left-color: var(--bad); }
.tip h4 { margin: 0 0 .3rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.tip.bridge h4 { color: var(--pt); } .tip.trap h4 { color: var(--bad); } .tip.note h4 { color: var(--gold); }
.tip p { margin: .3rem 0; }
.tablewrap { overflow-x: auto; margin: 1.2rem 0; border-radius: 14px; box-shadow: var(--shadow); background: var(--paper); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: color-mix(in srgb, var(--line) 35%, var(--paper)); }
tr:last-child td { border-bottom: 0; }
.conj { margin: 1.2rem 0; background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); padding: 1rem 1.2rem; }
.conj .head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.conj .head b { font-family: "Fraunces", serif; font-size: 1.25rem; }
.conj .head span { color: var(--muted); font-size: .85rem; }
.conj .grid { display: grid; grid-template-columns: auto 1fr auto; gap: .3rem 1rem; align-items: baseline; }
.conj .p { color: var(--muted); font-size: .9rem; }
.conj .ptf { color: var(--pt); font-style: italic; font-size: .9rem; text-align: right; }
.examples { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .6rem; }
.examples li { background: var(--paper); border-radius: 14px; padding: .8rem 1.1rem; box-shadow: var(--shadow); }
.examples .ex-it { font-size: 1.1rem; }
.examples .ex-tr { font-size: .9rem; color: var(--muted); }
.dialogue { margin: 1.4rem 0; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.3rem; }
.dialogue h4 { margin: 0 0 .7rem; font-family: "Fraunces", serif; font-size: 1.1rem; }
.line { display: grid; grid-template-columns: 6.5rem 1fr; gap: .8rem; padding: .45rem 0; border-top: 1px dashed var(--line); }
.line:first-of-type { border-top: 0; }
.line .who { color: var(--muted); font-size: .85rem; padding-top: .15rem; }
.line .en { display: block; color: var(--muted); font-size: .85rem; }
.playall { margin-bottom: .4rem; }

.vocab { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .7rem; margin: 1rem 0; }
.vcard { border: 0; text-align: left; background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); padding: .8rem 1rem; }
.vcard .vit { color: var(--it); font-weight: 700; font-size: 1.08rem; }
.vcard .vpt { color: var(--pt); font-style: italic; font-size: .9rem; }
.vcard .ven { color: var(--muted); font-size: .85rem; }

/* section headers that collapse */
.sec { margin-top: 2.4rem; }
.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary h2 { margin: 0; }
.sec > summary::after { content: "⌄"; font-size: 1.4rem; color: var(--muted); transition: transform .2s; }
.sec:not([open]) > summary::after { transform: rotate(-90deg); }

/* exercises */
.quiz { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.4rem 1.5rem; margin-top: 1rem; }
.qhead { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; margin-bottom: .4rem; }
.qbar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin-bottom: 1.2rem; }
.qbar i { display: block; height: 100%; background: var(--it); transition: width .3s; }
.q { font-size: 1.2rem; margin-bottom: 1rem; }
.opts { display: grid; gap: .6rem; }
.opt { border: 0; text-align: left; padding: .85rem 1.1rem; border-radius: 14px; background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--line); font-size: 1.05rem; }
.opt:hover:not([disabled]) { box-shadow: inset 0 0 0 2px var(--it); }
.opt.right { background: var(--pt-soft); box-shadow: inset 0 0 0 2px var(--good); }
.opt.wrong { background: color-mix(in srgb, var(--bad) 14%, var(--paper)); box-shadow: inset 0 0 0 2px var(--bad); }
.answer { width: 100%; font: inherit; font-size: 1.15rem; padding: .8rem 1rem; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--bg); color: var(--ink); }
.answer:focus { outline: none; border-color: var(--it); }
.accents { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0 1rem; }
.accents button { border: 0; width: 2.6rem; height: 2.6rem; border-radius: 10px; background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--line); font-size: 1.1rem; }
.accents button:hover { box-shadow: inset 0 0 0 2px var(--it); }
.hint { color: var(--muted); font-size: .9rem; margin: .4rem 0 0; }
.fb { margin-top: 1rem; padding: .9rem 1.1rem; border-radius: 14px; font-size: 1rem; }
.fb.ok { background: var(--pt-soft); }
.fb.no { background: color-mix(in srgb, var(--bad) 13%, var(--paper)); }
.fb.warn { background: color-mix(in srgb, var(--gold) 18%, var(--paper)); }
.fb b { display: block; margin-bottom: .2rem; }
.qnav { margin-top: 1.2rem; display: flex; justify-content: flex-end; gap: .6rem; }
.score { text-align: center; padding: 1rem 0; }
.score .big { font-family: "Fraunces", serif; font-size: 3rem; color: var(--it); }

/* review */
.flash { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.2rem 1.5rem; text-align: center; margin: 1.2rem 0; }
.flash .front { font-size: 1.6rem; color: var(--pt); font-style: italic; }
.flash .en { color: var(--muted); margin-top: .3rem; }
.flash .back { font-size: 2rem; margin-top: 1.4rem; font-weight: 700; }
.grades { justify-content: center; margin-top: 1.4rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin: 1rem 0; }
.stat { background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); padding: 1rem 1.1rem; }
.stat b { display: block; font-family: "Fraunces", serif; font-size: 1.8rem; color: var(--it); }
.stat span { color: var(--muted); font-size: .85rem; }

.search { width: 100%; font: inherit; padding: .8rem 1.1rem; border-radius: 999px; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); margin: .6rem 0 1rem; }
.empty { color: var(--muted); text-align: center; padding: 2rem 1rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.4rem; flex-wrap: wrap; }

@media (max-width: 600px) {
  html { font-size: 18px; }
  h1 { font-size: 1.85rem; }
  main { padding: 1rem 16px 3rem; }
  .top { padding: .6rem 16px; }
  .top nav a { font-size: .88rem; padding: .35rem .6rem; }
  .progress-card { grid-template-columns: 1fr; }
  .line { grid-template-columns: 1fr; gap: 0; }
  .conj .grid { grid-template-columns: auto 1fr; }
  .conj .ptf { grid-column: 2; text-align: left; margin-top: -.3rem; }
}
