/* Black Field: pages for reading (paper), a black field for quizzing (the topic panel and the
   quiz screen). One signal color (orange) for state. Archivo: condensed widths for headings and
   numerals, normal width for text. Light or dark follows the system; the field stays black. */
:root {
  --paper: #ffffff;
  --ink: #111111;
  --grey: #6b6b6b;
  --hair: #e3e3e3;
  --field: #111111;
  --field-ink: #f3f3f3;
  --field-grey: #9b9b9b;
  --field-hair: #333333;
  --sig: #ff4d17;
  --on-sig: #111111;
  --gutter: max(18px, env(safe-area-inset-left, 0px));
  --gutter-r: max(18px, env(safe-area-inset-right, 0px));
  --font: Archivo, "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --dock-h: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #18181a;
    --ink: #ededed;
    --grey: #9a9a9a;
    --hair: #2c2c2e;
    --field: #000000;
    --field-ink: #f3f3f3;
    --field-grey: #8e8e8e;
    --field-hair: #2a2a2a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper); color: var(--ink);
  font-family: var(--font); font-stretch: 100%; font-size: 16px; line-height: 1.42;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top, 0px);
}
body.on-field { background: var(--field); color: var(--field-ink); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: inherit; }
[hidden] { display: none !important; }
img { max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--sig); outline-offset: 2px; }
#app { max-width: 520px; margin: 0 auto; padding: 0 var(--gutter-r) calc(var(--dock-h) + 40px) var(--gutter); }
.cond, h1, .h2 b, .h2 span, .len, .big, .score, .facts b, .tk b, .time, .btn small { font-stretch: 68%; }
.tab { font-variant-numeric: tabular-nums; }
.muted { color: var(--grey); }
.on-field .muted { color: var(--field-grey); }
.err { color: var(--sig); font-weight: 600; }

/* Top */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: inherit; display: flex; align-items: center; justify-content: space-between; min-height: 60px; }
body:not(.on-field) .top { background: var(--paper); }
.mark { font-stretch: 68%; font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding-right: 12px; margin-left: -5px; font-size: 15px; font-weight: 500; }
.back svg, .x svg { width: 22px; height: 22px; flex: none; }

/* Labels and headings */
.lab { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--grey); }
.on-field .lab, .field .lab { color: var(--field-grey); }
.h2 { display: flex; justify-content: space-between; align-items: baseline; margin: 32px 0 0; }
.h2 b { font-size: 34px; font-weight: 800; line-height: 1; letter-spacing: -.015em; }
.h2 span { font-size: 34px; font-weight: 400; line-height: 1; color: var(--grey); opacity: .6; }
.sec { margin: 26px 0 10px; }
h1 { font-size: 42px; font-weight: 800; line-height: .94; letter-spacing: -.02em; margin: 10px 0 0; text-wrap: balance; overflow-wrap: anywhere; }

/* Search field */
.search { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px; border: 2px solid var(--ink); background: var(--paper); }
.search svg { width: 20px; height: 20px; flex: none; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 17px; }
.search input::placeholder { color: var(--grey); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.search:focus-within { outline: 2px solid var(--sig); outline-offset: 2px; }

/* Covers */
.cv { position: relative; overflow: hidden; display: grid; place-items: center; flex: none; color: #fff; font-stretch: 68%; font-weight: 800; }
.cv img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cv.l { width: 64px; height: 64px; font-size: 26px; }
.cv.s { width: 44px; height: 44px; font-size: 18px; }
.cv.xs { width: 18px; height: 18px; font-size: 9px; }
.cv.xl { width: 76px; height: 76px; font-size: 30px; }
.strip { display: flex; gap: 10px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.strip::-webkit-scrollbar { display: none; }
.strip .cv { cursor: pointer; }
.cv.add { border: 2px solid var(--ink); color: var(--ink); font-stretch: 100%; font-size: 30px; font-weight: 400; background: transparent; }

/* Rows (the episode table and other lists) */
.thead { display: grid; grid-template-columns: 44px 1fr auto; column-gap: 12px; margin-top: 14px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.row { display: grid; grid-template-columns: 44px 1fr auto; column-gap: 12px; align-items: start; width: 100%; padding: 11px 0; border-bottom: 1px solid var(--hair); min-height: 66px; }
.row.plain { grid-template-columns: 1fr auto; align-items: center; min-height: 56px; }
.row .txt { min-width: 0; }
.row .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 15px; font-weight: 600; line-height: 1.24; }
.row .m { display: block; font-size: 12.5px; color: var(--grey); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .len { font-size: 19px; font-weight: 600; line-height: 1.05; text-align: right; white-space: nowrap; }
.row .go { font-size: 20px; color: var(--grey); align-self: center; }
.tag { display: inline-block; margin-top: 6px; padding: 3px 6px 2px; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; line-height: 1.2; }
.tag.ready { background: var(--sig); color: var(--on-sig); }
.tag.wait { color: var(--grey); box-shadow: inset 0 0 0 1px var(--grey); }
.sub { align-self: center; min-height: 36px; padding: 0 12px; font-size: 13px; font-weight: 700; border: 2px solid var(--ink); white-space: nowrap; }
.sub.on { background: var(--ink); color: var(--paper); }
.empty { margin: 22px 0 0; color: var(--grey); }
.lede { font-size: 15.5px; line-height: 1.48; margin: 16px 0 0; }

/* Podcast and episode facts */
.pod { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; font-size: 13px; font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; border-top: 2px solid var(--ink); padding-top: 7px; }
.facts b { display: block; font-size: 24px; font-weight: 700; line-height: 1.1; margin-top: 2px; }
.tk { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--hair); }
.tk li { display: grid; grid-template-columns: 28px 1fr; column-gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--hair); }
.tk b { font-size: 30px; font-weight: 800; line-height: .85; }
.tk p { margin: 0; font-size: 14.5px; line-height: 1.4; }

/* Buttons: on paper (ink) and on the field (light) */
.btn { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 56px; padding: 0 18px; font-size: 17px; font-weight: 700; text-decoration: none; }
.btn.center { justify-content: center; }
.btn small { font-size: 19px; font-weight: 600; }
.btn.ink { background: var(--ink); color: var(--paper); }
.btn.line { border: 2px solid var(--ink); }
.btn.light { background: var(--field-ink); color: var(--field); }
.btn.ghost { border: 1px solid var(--field-ink); color: var(--field-ink); }
.btn[disabled] { opacity: .45; }
.pair-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair-btns .btn { justify-content: center; }

/* The black field: fixed at the bottom of a page, or the whole quiz screen */
.field { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--field); color: var(--field-ink);
  padding: 6px var(--gutter-r) calc(14px + env(safe-area-inset-bottom, 0px)) var(--gutter); }
@media (prefers-color-scheme: dark) { body:not(.on-field) .field { border-top: 1px solid var(--field-hair); } }
.field > div { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.field .bar { display: flex; justify-content: space-between; align-items: center; min-height: 40px; }
.field .act { font-size: 13px; font-weight: 600; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }
.field .note { font-size: 12.5px; color: var(--field-grey); margin: 0; }
.field .status { font-size: 15px; margin: 6px 0 4px; }
.on-field .field { background: var(--field); padding-top: 18px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--field-hair); border: 1px solid var(--field-hair); max-height: 40vh; overflow-y: auto; }
.cell { display: grid; grid-template-columns: 18px 1fr auto; column-gap: 9px; align-items: start; min-height: 58px; padding: 10px 10px 9px; background: var(--field); cursor: pointer; }
.cell span { font-size: 13px; font-weight: 500; line-height: 1.25; }
.cell em { font-style: normal; font-stretch: 68%; font-size: 17px; font-weight: 600; line-height: 1; color: var(--field-grey); }
.cell input { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: -1px 0 0; border: 2px solid var(--field-ink); border-radius: 0; position: relative; background: transparent; }
.cell input:checked { background: var(--field-ink); }
.cell input:checked::after { content: ""; position: absolute; left: 4px; top: 0; width: 5px; height: 10px; border: solid var(--field); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.cell input:focus-visible { outline: 2px solid var(--sig); outline-offset: 2px; }
.dots span { display: inline-block; width: 6px; height: 6px; margin-right: 4px; background: var(--field-ink); animation: pulse 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .2s; } .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .2 } 40% { opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .dots span { animation: none; opacity: .6; } }

/* Quiz */
.qtop { display: flex; align-items: center; gap: 14px; min-height: 56px; }
.x { width: 44px; height: 44px; display: grid; place-items: center; margin-left: -11px; }
.prog { flex: 1; height: 2px; background: var(--field-hair); position: relative; }
.prog i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--field-ink); transition: width .25s; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-top: 8px; }
.big { font-size: 104px; font-weight: 800; line-height: .76; letter-spacing: -.03em; font-stretch: 62%; }
.big span { font-size: 30px; font-weight: 500; color: var(--field-grey); letter-spacing: 0; margin-left: 3px; }
.kind { text-align: right; padding-bottom: 1px; min-width: 0; }
.kind b { display: block; font-size: 14px; font-weight: 700; }
.kind span { display: block; font-size: 12.5px; color: var(--field-grey); margin-top: 2px; }
.stmt { font-size: 21px; font-weight: 600; line-height: 1.26; margin: 22px 0 0; padding-top: 14px; border-top: 1px solid var(--field-hair); text-wrap: pretty; }
.choices { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.choices b { display: inline-block; width: 22px; }
.verdict { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 54px; margin: 20px calc(-1 * var(--gutter-r)) 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter-r) 0 var(--gutter); }
.verdict b { font-stretch: 68%; font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -.01em; }
.verdict span { font-size: 13.5px; font-weight: 600; text-align: right; }
.verdict.no { background: var(--sig); color: var(--on-sig); }
.verdict.ok { background: var(--field-ink); color: var(--field); }
.pair { display: grid; grid-template-columns: 66px 1fr; column-gap: 12px; margin-top: 18px; }
.pair .lab { padding-top: 4px; }
.time { font-size: 19px; font-weight: 600; line-height: 1.2; }
.correct { margin: 0; font-size: 16px; line-height: 1.42; }
.quote { margin: 0; font-size: 15px; line-height: 1.42; color: #c4c4c4; }
.hint { margin: 18px 0 0; color: var(--field-grey); font-size: 15px; }

/* The place of the quote in the episode (a scrubber) */
.scrub { position: relative; height: 1px; background: var(--field-hair); margin: 30px 0 0; }
.scrub i { position: absolute; left: 0; top: -1px; height: 3px; background: var(--field-grey); }
.scrub b { position: absolute; top: -5px; width: 2px; height: 11px; background: var(--sig); transform: translateX(-1px); }
.scrub em { position: absolute; bottom: 8px; transform: translateX(-50%); font-style: normal; font-stretch: 68%; font-size: 14px; font-weight: 600; color: var(--sig); white-space: nowrap; }
.scrub em.start { transform: none; } .scrub em.end { transform: translateX(-100%); }
.ends { display: flex; justify-content: space-between; margin-top: 6px; font-stretch: 68%; font-size: 12px; color: var(--field-grey); }

/* Flag */
.flag { display: inline-flex; align-items: center; min-height: 44px; margin-top: 4px; font-size: 13px; color: var(--field-grey); text-decoration: underline; text-underline-offset: 3px; }
.flag-panel { margin-top: 14px; padding: 14px 0 0; border-top: 1px solid var(--field-hair); display: flex; flex-direction: column; gap: 10px; }
.flag-panel p { margin: 0; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { min-height: 40px; padding: 0 12px; font-size: 14px; font-weight: 600; border: 1px solid var(--field-grey); color: var(--field-ink); }
.opt[aria-pressed="true"] { background: var(--field-ink); color: var(--field); border-color: var(--field-ink); }
.note-in { width: 100%; font: inherit; font-size: 16px; color: var(--field-ink); background: transparent; border: 1px solid var(--field-grey); border-radius: 0; padding: 10px 12px; resize: vertical; }
.note-in:focus { outline: 2px solid var(--sig); outline-offset: 1px; }
.flag-done { margin: 14px 0 0; font-size: 13px; color: var(--field-grey); }

/* Feedback: a small text button on the right of each top bar. It opens a panel above the page
   (outside #app, so a new render does not touch it); the page moves down, nothing is covered. */
.fb-btn { flex: none; min-height: 44px; padding-left: 12px; font-size: 13px; font-weight: 600; color: var(--grey); text-decoration: underline; text-underline-offset: 3px; }
.on-field .fb-btn { color: var(--field-grey); }
.fb-btn[aria-expanded="true"] { color: var(--sig); }
.qtop .fb-btn { margin-left: auto; }
.fb { background: var(--paper); color: var(--ink); border-bottom: 2px solid var(--ink); padding: 4px var(--gutter-r) 18px var(--gutter); }
.on-field .fb { background: var(--field); color: var(--field-ink); border-bottom-color: var(--field-hair); }
.fb > div { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.fb-head { display: flex; justify-content: space-between; align-items: center; min-height: 50px; }
.fb-head b { font-stretch: 68%; font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -.015em; }
.fb-x { width: 44px; height: 44px; display: grid; place-items: center; margin-right: -11px; }
.fb-x svg { width: 22px; height: 22px; }
.fb textarea { width: 100%; min-height: 104px; font: inherit; font-size: 16px; color: inherit; background: transparent; border: 1px solid var(--grey); border-radius: 0; padding: 10px 12px; resize: vertical; }
.on-field .fb textarea { border-color: var(--field-grey); }
.fb textarea::placeholder { color: var(--grey); }
.fb textarea:focus { outline: 2px solid var(--sig); outline-offset: 1px; }
.fb .send { min-height: 50px; background: var(--ink); color: var(--paper); }
.on-field .fb .send { background: var(--field-ink); color: var(--field); }
.fb .err { margin: 0; font-size: 14px; }
.fb-done { margin: 0 0 4px; font-size: 17px; }

/* End card */
.score { font-size: 104px; font-weight: 800; line-height: .8; letter-spacing: -.03em; font-stretch: 62%; margin-top: 6px; }
.score span { font-size: 30px; font-weight: 500; color: var(--field-grey); letter-spacing: 0; margin-left: 3px; }
.missed { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--field-hair); }
.missed li { padding: 12px 0; border-bottom: 1px solid var(--field-hair); font-size: 15px; line-height: 1.4; }

/* Login */
.login { padding-top: 16vh; display: flex; flex-direction: column; gap: 14px; }
.login .mark { font-size: 64px; }
.login p { margin: 0; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 14px; padding: 12px; border: 2px solid var(--ink); user-select: all; word-break: break-all; }

.foot { margin-top: 40px; }
.foot button { color: var(--grey); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }
