:root {
  --bg: #12100f;
  --panel: #1b1817;
  --panel-2: #232020;
  --ink: #ece6dd;
  --ink-dim: #a89e92;
  --ink-faint: #6f665d;
  --line: #332e2c;
  --gold: #c9a227;
  --gold-dim: #8a7220;
  --wands: #c4622d;
  --cups: #3f7fa6;
  --swords: #9aa3ad;
  --pentacles: #6f8f4a;
  --major: #8a6bb1;
  --good: #6f9f5f;
  --bad: #a85a4e;
  --radius: 10px;
  --font: ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

#topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
#topbar .brand {
  font-family: var(--font); font-size: 1.05rem; letter-spacing: .04em;
  color: var(--gold); background: none; border: 0; cursor: pointer; padding: 0;
}
#topbar nav { display: flex; gap: .4rem; }
#topbar nav button {
  font-family: var(--sans); font-size: .8rem; letter-spacing: .05em; text-transform: uppercase;
  background: none; border: 1px solid transparent; color: var(--ink-dim);
  padding: .35rem .7rem; border-radius: 6px; cursor: pointer;
}
#topbar nav button:hover { color: var(--ink); border-color: var(--line); }

main { max-width: 780px; margin: 0 auto; padding: 1.6rem 1.2rem 4rem; }

#footer {
  max-width: 780px; margin: 0 auto; padding: 0 1.2rem 2rem;
  color: var(--ink-faint); font-family: var(--sans); font-size: .75rem;
}

h1 { font-size: 1.5rem; font-weight: 500; letter-spacing: .01em; margin: 0 0 .3rem; }
h2 { font-size: 1.1rem; font-weight: 500; margin: 2rem 0 .7rem; color: var(--ink); }
h3 { font-size: .78rem; font-family: var(--sans); font-weight: 600; letter-spacing: .12em;
     text-transform: uppercase; color: var(--ink-faint); margin: 1.6rem 0 .6rem; }
p { margin: 0 0 .8rem; }
.sub { color: var(--ink-dim); font-size: .95rem; margin-bottom: 1.4rem; }

button.primary, button.ghost, button.grade {
  font-family: var(--sans); font-size: .85rem; letter-spacing: .03em;
  padding: .6rem 1.1rem; border-radius: 7px; cursor: pointer; border: 1px solid var(--line);
}
button.primary { background: var(--gold); border-color: var(--gold); color: #191512; font-weight: 600; }
button.primary:hover { background: #dbb32f; }
button.primary:disabled { background: var(--panel-2); border-color: var(--line); color: var(--ink-faint); cursor: default; }
button.ghost { background: transparent; color: var(--ink-dim); }
button.ghost:hover { color: var(--ink); border-color: var(--ink-faint); }

.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.spacer { height: 1rem; }

/* ---- home ---- */
.track { margin-bottom: 2rem; }
.track-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: .4rem; margin-bottom: .8rem; }
.track-head h2 { margin: 0; }
.track-head .meta { font-family: var(--sans); font-size: .75rem; color: var(--ink-faint); letter-spacing: .06em; text-transform: uppercase; }

.level {
  display: flex; align-items: center; gap: .9rem;
  padding: .7rem .9rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); margin-bottom: .5rem;
}
.level.locked { opacity: .42; }
.level .num {
  font-family: var(--sans); font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  width: 2.4rem; flex: 0 0 auto; color: var(--ink-faint);
}
.level .body { flex: 1 1 auto; min-width: 0; }
.level .name { font-size: 1rem; }
.level .note { font-size: .8rem; color: var(--ink-faint); font-family: var(--sans); }
.level .bar { height: 4px; background: var(--panel-2); border-radius: 2px; margin-top: .45rem; overflow: hidden; }
.level .bar > i { display: block; height: 100%; background: var(--gold-dim); }
.level .acts { display: flex; gap: .4rem; flex: 0 0 auto; }

.pill {
  font-family: var(--sans); font-size: .7rem; letter-spacing: .05em; text-transform: uppercase;
  padding: .25rem .55rem; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-dim);
  background: var(--panel-2); white-space: nowrap;
}
.pill.hot { background: var(--gold); color: #191512; border-color: var(--gold); font-weight: 700; }
.pill.new { background: #2f4a63; color: #cfe4f5; border-color: #3d5f7d; font-weight: 700; }

.bigrow { display: flex; gap: .8rem; margin: 1.2rem 0 2rem; }
.bigrow .cta {
  flex: 1 1 0; text-align: left; padding: 1rem 1.1rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--ink);
  font-family: var(--font); font-size: 1rem;
}
.bigrow .cta:hover:not(:disabled) { border-color: var(--ink-faint); }
.bigrow .cta:disabled { opacity: .4; cursor: default; }
.bigrow .cta .n { display: block; font-size: 1.9rem; line-height: 1.1; color: var(--gold); }
.bigrow .cta .l { font-family: var(--sans); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); }

/* ---- study / review ---- */
.card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  padding: 1.4rem 1.5rem; margin-bottom: 1rem;
}
.prompt-kind {
  font-family: var(--sans); font-size: .7rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: .7rem;
}
.prompt { font-size: 1.3rem; line-height: 1.4; margin-bottom: 1.1rem; }
.prompt em { color: var(--gold); font-style: normal; }

/* ---- card images ---- */
.cardimg {
  display: block; width: 100%; max-width: 240px; height: auto;
  border-radius: 5px; border: 1px solid var(--line);
  background: var(--panel-2);
}
.cardimg.small { max-width: 150px; }
.prompt .cardimg { margin: 0 auto; max-width: 260px; }

/* Crops the printed card name off the bottom so sight-read drills aren't
   solvable by reading the caption. The scans are ~500x865 with the illustration
   frame ending near y=688, so this shows the art and none of the title band. */
.crop {
  display: block; position: relative; width: 100%; max-width: 240px;
  aspect-ratio: 500 / 688; overflow: hidden;
  border-radius: 5px; border: 1px solid var(--line); background: var(--panel-2);
}
.crop .cardimg {
  position: absolute; top: 0; left: 0;
  width: 100%; max-width: none; border: 0; border-radius: 0;
}
.prompt .crop { margin: 0 auto; }

/* Image beside its text, stacking on narrow screens. */
.plate { display: flex; gap: 1.2rem; align-items: flex-start; margin: 1rem 0; }
.plate .cardimg { flex: 0 0 auto; width: 200px; max-width: 40%; }
.plate-body { flex: 1 1 auto; min-width: 0; }
.plate-body p:first-child { margin-top: 0; }

.choices { display: grid; gap: .5rem; }
.choices.pics { grid-template-columns: repeat(4, 1fr); gap: .55rem; }
.choice.pic { padding: .35rem; background: var(--panel-2); }
.choice.pic .crop { max-width: 100%; border: 0; border-radius: 3px; }
.choice {
  text-align: left; font-family: var(--font); font-size: 1rem; color: var(--ink);
  padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); cursor: pointer;
}
.choice:hover:not(:disabled) { border-color: var(--ink-faint); }
.choice.correct { border-color: var(--good); background: #1f2a1c; }
.choice.wrong { border-color: var(--bad); background: #2a1c1a; }
.choice:disabled { cursor: default; }

.reveal { border-top: 1px solid var(--line); margin-top: 1.1rem; padding-top: 1.1rem; }
.reveal .lab { font-family: var(--sans); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: .25rem; }
.reveal .val { margin-bottom: .9rem; }
.reveal .val:last-child { margin-bottom: 0; }
.reveal .derivation { color: var(--gold); }

textarea.scratch {
  width: 100%; min-height: 6rem; resize: vertical; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
  font-family: var(--font); font-size: 1rem; padding: .7rem .8rem; line-height: 1.5;
}
textarea.scratch:focus { outline: none; border-color: var(--ink-faint); }

.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: 1rem; }
button.grade { background: var(--panel-2); color: var(--ink-dim); text-align: center; }
button.grade:hover { color: var(--ink); border-color: var(--ink-faint); }
button.grade b { display: block; font-size: .95rem; color: var(--ink); font-weight: 500; }
button.grade span { font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }

.sessionbar { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.1rem; font-family: var(--sans); font-size: .75rem; color: var(--ink-faint); letter-spacing: .05em; }
.sessionbar .track-bar { flex: 1 1 auto; height: 3px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.sessionbar .track-bar > i { display: block; height: 100%; background: var(--gold-dim); }

/* ---- teach ---- */
.teach .glyph { font-family: var(--sans); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; }
.teach .title { font-size: 1.7rem; margin: .2rem 0 .1rem; }
.teach .kw { color: var(--ink-dim); font-style: italic; margin-bottom: 1rem; }
.kv { display: grid; grid-template-columns: 7.5rem 1fr; gap: .45rem .9rem; margin: 1rem 0; }
.kv .k { font-family: var(--sans); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); padding-top: .28rem; }
.kv .v { }
ul.details { margin: .3rem 0 0; padding-left: 1.1rem; color: var(--ink-dim); }
ul.details li { margin-bottom: .2rem; }

.prov { font-family: var(--sans); font-size: .65rem; letter-spacing: .1em; text-transform: uppercase; padding: .15rem .45rem; border-radius: 4px; border: 1px solid var(--line); color: var(--ink-faint); }
.prov.framework { color: #b79ad6; border-color: #4a3a5e; }
.prov.canonical { color: var(--gold-dim); border-color: var(--gold-dim); }

.callout { border-left: 2px solid var(--gold-dim); padding: .1rem 0 .1rem .9rem; color: var(--ink-dim); font-size: .92rem; margin: 1rem 0; }

/* ---- reference ---- */
.ref-group { margin-bottom: 1.4rem; }
.ref-group h3 { margin-top: 1.2rem; }
.ref-note { color: var(--ink-faint); font-family: var(--sans); font-size: .78rem; line-height: 1.45; margin: -.2rem 0 .6rem; }
.ref-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: .5rem; }
.ref-row {
  display: block; text-align: left; padding: .55rem .7rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  color: var(--ink); font-family: var(--font); cursor: pointer;
}
.ref-row:hover { border-color: var(--ink-faint); }
.ref-row .t { display: block; font-size: .98rem; line-height: 1.3; }
.ref-row .g { display: block; font-family: var(--sans); font-size: .72rem; line-height: 1.35; color: var(--ink-dim); }
.ref-row .s { display: block; font-family: var(--sans); font-size: .6rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-dim); margin-top: .2rem; }

/* Inline navigation inside prose — a card's "built from" line, mostly. */
button.link {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  color: var(--gold); border-bottom: 1px solid var(--gold-dim);
}
button.link:hover { color: #dbb32f; border-bottom-color: var(--gold); }

/* ---- browse ---- */
.filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.filters button { font-family: var(--sans); font-size: .75rem; padding: .35rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-dim); cursor: pointer; }
.filters button.on { background: var(--gold); border-color: var(--gold); color: #191512; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: .7rem; }
.mini { text-align: left; padding: .45rem .5rem .55rem; border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px; background: var(--panel); cursor: pointer; color: var(--ink); font-family: var(--font); }
.mini:hover { border-color: var(--ink-faint); }
.mini .cardimg.thumb { max-width: 100%; margin-bottom: .4rem; border: 0; }
.mini .n { font-size: .88rem; line-height: 1.25; }
.mini .k { font-family: var(--sans); font-size: .68rem; color: var(--ink-faint); }
.mini .st { font-family: var(--sans); font-size: .6rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-dim); margin-top: .15rem; }
.s-wands { border-left-color: var(--wands); }
.s-cups { border-left-color: var(--cups); }
.s-swords { border-left-color: var(--swords); }
.s-pentacles { border-left-color: var(--pentacles); }
.s-major { border-left-color: var(--major); }

table.stats { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: .85rem; }
table.stats td { padding: .35rem 0; border-bottom: 1px solid var(--line); color: var(--ink-dim); }
table.stats td:last-child { text-align: right; color: var(--ink); }

.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-faint); }

@media (max-width: 560px) {
  .grades { grid-template-columns: repeat(2, 1fr); }
  .bigrow { flex-direction: column; }
  .kv { grid-template-columns: 1fr; gap: .1rem .9rem; }
  .kv .k { padding-top: .5rem; }
  .plate { flex-direction: column; }
  .plate .cardimg { width: 62%; max-width: 220px; margin: 0 auto; }
  .choices.pics { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
}
