/* The web app's stylesheet: the Sky theme, light and dark (the tokens
   below), following the design canvas (design/canvas/project/*.dc.html,
   drawn in Sky's light colours), written by hand. No build step: this
   file is compiled into the binary and served as it is (src/assets.rs).
   The pages' content security policy allows no inline style, so everything
   a page needs is a class here. */

@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Sky: a pale blue-grey ground, white cards, navy text, and one blue for
   what the student acts on and picks (buttons, a chosen option, the focus
   ring). The navy "chrome" carries the sidebar, the tab bar and the exam's
   bar; the grid of questions has a navy panel and tokens of its own (--grid*). Green and red stay only for right and wrong, so a
   picked answer never looks like a verdict. Every colour is a token here;
   the dark set below redefines the same tokens, nothing else. */
:root {
  color-scheme: light;
  --ground: #edf2f7;
  --surface: #ffffff;
  --ink: #1a2537;
  --muted: #4a586d;
  --placeholder: #66748a;
  --line: #d8e0ea;
  --control-line: #75869c;
  --wash: #f2f6fb;
  --accent: #2160c4;
  --accent-hover: #1a4ea3;
  --accent-wash: #e7effb;
  --on-accent: #ffffff;
  --chrome: #1d3557;
  --chrome-raised: #284670;
  --chrome-edge: #1d3557;
  --on-chrome: #ffffff;
  --on-chrome-muted: #b9c8dc;
  --on-chrome-success: #6ee7a0;
  --on-chrome-warning: #fde68a;
  --danger: #b42318;
  --danger-wash: #fbeceb;
  --success: #146b39;
  --success-wash: #e3f3e9;
  --warning: #8a5f00;
  --warning-wash: #f6eedb;
  --info: #1d5fbf;
  --info-wash: #e5eefa;
  --on-status: #ffffff;
  --progress: #6d4bd1;
  --tint: #ece8fb;
  --formula-wash: rgb(33 96 196 / 0.09);
  --grid: #1d3557;
  --grid-cell: #284670;
  --grid-ink: #b9c8dc;
  --grid-line: rgb(255 255 255 / 0.32);
  --grid-current: #ffffff;
  --grid-answered: #8ab3ff;
  --grid-right: #6ee7a0;
  --grid-wrong: #ffa59c;
  --grid-flag: #fde68a;
  --on-grid-fill: #0c1630;
  --backdrop: rgb(10 22 40 / 0.5);
  --font: "Geist", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  --shadow-card: 0 1px 3px rgb(29 53 87 / 0.06);
  --shadow-button: 0 1px 2px rgb(29 53 87 / 0.24), 0 4px 12px rgb(29 53 87 / 0.16);
  --shadow-panel: 0 4px 16px rgb(29 53 87 / 0.14);
}

/* Sky at night, when the device asks for dark (unless the reader chose
   light) or the reader chose dark: charcoal with a blue cast,
   not black, and off-white text, not white, so letters do not glow. The
   chrome is darker than the ground and keeps an edge to stand apart. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #121721;
    --surface: #1b2230;
    --ink: #e3e8f0;
    --muted: #a3aec0;
    --placeholder: #8692a7;
    --line: #2c3546;
    --control-line: #6a7790;
    --wash: #232b3b;
    --accent: #8ab3ff;
    --accent-hover: #a8c7ff;
    --accent-wash: #1f2f4d;
    --on-accent: #0c1630;
    --chrome: #0b1019;
    --chrome-raised: #1f2838;
    --chrome-edge: #2c3546;
    --on-chrome: #e3e8f0;
    --on-chrome-muted: #98a3b6;
    --on-chrome-success: #5fcf8a;
    --on-chrome-warning: #f6cd7d;
    --danger: #ff8a80;
    --danger-wash: #3b1f22;
    --success: #5fcf8a;
    --success-wash: #16302a;
    --warning: #f0b44c;
    --warning-wash: #3a2f1a;
    --info: #8ab3ff;
    --info-wash: #1f2f4d;
    --on-status: #0c1210;
    --progress: #a48cff;
    --tint: #2c2550;
    --formula-wash: rgb(138 179 255 / 0.14);
    --grid: #0b1019;
    --grid-cell: #1f2838;
    --grid-ink: #98a3b6;
    --grid-line: rgb(255 255 255 / 0.26);
    --grid-current: #e3e8f0;
    --grid-answered: #8ab3ff;
    --grid-right: #5fcf8a;
    --grid-wrong: #ff8a80;
    --grid-flag: #f6cd7d;
    --on-grid-fill: #0c1630;
    --backdrop: rgb(0 0 0 / 0.6);
    --shadow-card: none;
    --shadow-button: none;
    --shadow-panel: 0 4px 16px rgb(0 0 0 / 0.4);
  }
}

/* chosen on the profile (`data-theme`, src/theme.rs): the same values as
   the block above, which a test keeps equal */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #121721;
  --surface: #1b2230;
  --ink: #e3e8f0;
  --muted: #a3aec0;
  --placeholder: #8692a7;
  --line: #2c3546;
  --control-line: #6a7790;
  --wash: #232b3b;
  --accent: #8ab3ff;
  --accent-hover: #a8c7ff;
  --accent-wash: #1f2f4d;
  --on-accent: #0c1630;
  --chrome: #0b1019;
  --chrome-raised: #1f2838;
  --chrome-edge: #2c3546;
  --on-chrome: #e3e8f0;
  --on-chrome-muted: #98a3b6;
  --on-chrome-success: #5fcf8a;
  --on-chrome-warning: #f6cd7d;
  --danger: #ff8a80;
  --danger-wash: #3b1f22;
  --success: #5fcf8a;
  --success-wash: #16302a;
  --warning: #f0b44c;
  --warning-wash: #3a2f1a;
  --info: #8ab3ff;
  --info-wash: #1f2f4d;
  --on-status: #0c1210;
  --progress: #a48cff;
  --tint: #2c2550;
  --formula-wash: rgb(138 179 255 / 0.14);
  --grid: #0b1019;
  --grid-cell: #1f2838;
  --grid-ink: #98a3b6;
  --grid-line: rgb(255 255 255 / 0.26);
  --grid-current: #e3e8f0;
  --grid-answered: #8ab3ff;
  --grid-right: #5fcf8a;
  --grid-wrong: #ff8a80;
  --grid-flag: #f6cd7d;
  --on-grid-fill: #0c1630;
  --backdrop: rgb(0 0 0 / 0.6);
  --shadow-card: none;
  --shadow-button: none;
  --shadow-panel: 0 4px 16px rgb(0 0 0 / 0.4);
}

/* EXPERIMENT: Clay, to compare with Sky. Chosen on the profile only
   (`clay-light`, `clay-dark`); they come after the device's dark block and
   redefine every token, so they hold whatever the device says. Warm paper
   and charcoal grounds, near-black and off-white text, and a clay orange as
   the one accent; the sidebar is a shade of the ground, not navy. White on
   the orange is below WCAG AA for text (about 3.9:1 light, 3.1:1 dark). */
:root[data-theme="clay-light"] {
  color-scheme: light;
  --ground: #faf9f5;
  --surface: #ffffff;
  --ink: #141413;
  --muted: #5e5d59;
  --placeholder: #73726c;
  --line: #e3e1d9;
  --control-line: #8a8880;
  --wash: #f5f4ed;
  --accent: #c96442;
  --accent-hover: #b5573a;
  --accent-wash: #f7ebe5;
  --on-accent: #ffffff;
  --chrome: #f0eee6;
  --chrome-raised: #e6e3d8;
  --chrome-edge: #dedcd1;
  --on-chrome: #141413;
  --on-chrome-muted: #5e5d59;
  --on-chrome-success: #2a6b12;
  --on-chrome-warning: #7a5300;
  --danger: #a33a32;
  --danger-wash: #f8e9e6;
  --success: #2a6b12;
  --success-wash: #e8f1e0;
  --warning: #7a5300;
  --warning-wash: #f5eddb;
  --info: #1f6fbf;
  --info-wash: #e6eff9;
  --on-status: #ffffff;
  --progress: #c96442;
  --tint: #f3ece3;
  --formula-wash: rgb(201 100 66 / 0.08);
  --grid: #f0eee6;
  --grid-cell: #e3e0d4;
  --grid-ink: #5e5d59;
  --grid-line: #8a8880;
  --grid-current: #141413;
  --grid-answered: #e9a48a;
  --grid-right: #9fd08a;
  --grid-wrong: #f0a59e;
  --grid-flag: #7a5300;
  --on-grid-fill: #141413;
  --backdrop: rgb(20 20 19 / 0.4);
  --shadow-card: 0 1px 3px rgb(20 20 19 / 0.05);
  --shadow-button: 0 1px 2px rgb(20 20 19 / 0.15);
  --shadow-panel: 0 4px 20px rgb(20 20 19 / 0.08);
}

:root[data-theme="clay-dark"] {
  color-scheme: dark;
  --ground: #262624;
  --surface: #30302e;
  --ink: #faf9f5;
  --muted: #c2c0b6;
  --placeholder: #9c9a92;
  --line: #41403c;
  --control-line: #7a7870;
  --wash: #2b2b29;
  --accent: #d97757;
  --accent-hover: #e38b6e;
  --accent-wash: #3d2c25;
  --on-accent: #ffffff;
  --chrome: #1f1e1d;
  --chrome-raised: #30302e;
  --chrome-edge: #3a3936;
  --on-chrome: #faf9f5;
  --on-chrome-muted: #9c9a92;
  --on-chrome-success: #7ec46a;
  --on-chrome-warning: #e6b45a;
  --danger: #e5726b;
  --danger-wash: #3b2220;
  --success: #7ec46a;
  --success-wash: #23301d;
  --warning: #e6b45a;
  --warning-wash: #372d1b;
  --info: #7cb0ea;
  --info-wash: #1f2a37;
  --on-status: #141413;
  --progress: #d97757;
  --tint: #35302b;
  --formula-wash: rgb(217 119 87 / 0.12);
  --grid: #1f1e1d;
  --grid-cell: #3a3936;
  --grid-ink: #c2c0b6;
  --grid-line: #7a7870;
  --grid-current: #faf9f5;
  --grid-answered: #e38b6e;
  --grid-right: #7ec46a;
  --grid-wrong: #e5726b;
  --grid-flag: #e6b45a;
  --on-grid-fill: #141413;
  --backdrop: rgb(0 0 0 / 0.6);
  --shadow-card: none;
  --shadow-button: none;
  --shadow-panel: 0 4px 16px rgb(0 0 0 / 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
p,
ul,
dl,
dd,
figure {
  margin: 0;
}

/* read out, not drawn */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.mono,
.number {
  font-family: var(--mono);
}

.number {
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}

/* an email address in a sentence: breaks anywhere rather than run off a phone */
.address {
  font-weight: 500;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
}

/* the mark and the name, as in the sidebar */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--on-chrome);
  color: var(--chrome);
  font-size: 12px;
  font-weight: 700;
}

.brand-mark-dark {
  background: var(--chrome);
  color: var(--on-chrome);
  /* in dark mode the chrome is darker than the ground: an edge keeps the mark */
  box-shadow: inset 0 0 0 1px var(--chrome-edge);
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
}

/* a text link; also a button that reads as one */
.link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--control-line);
  cursor: pointer;
}

.link:hover {
  text-decoration-color: currentColor;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--shadow-button);
  cursor: pointer;
}

.button:hover {
  background: var(--accent-hover);
}

.button-secondary {
  width: auto;
  min-height: 44px;
  padding: 0 18px;
  border-color: var(--control-line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  box-shadow: none;
}

.button-secondary:hover {
  background: var(--wash);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- forms ---- */

.form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 14px;
  font-weight: 500;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--control-line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.input::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.input-code {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 0.3em;
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}

.field-error svg {
  flex: none;
  margin-top: 2px;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 12px;
  background: var(--danger-wash);
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}

.notice svg {
  flex: none;
}

.notice .link {
  color: var(--danger);
  text-decoration-color: currentColor;
}

.form-line {
  color: var(--muted);
  font-size: 14px;
}

/* ---- the signed-out pages ---- */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 8px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 12px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  padding: 32px 40px 40px;
  border-radius: 20px;
  background: var(--chrome);
  border: 1px solid var(--chrome-edge);
  color: var(--on-chrome);
  box-shadow: var(--shadow-panel);
}

.auth-pitch {
  display: grid;
  gap: 32px;
  max-width: 400px;
  margin-block: auto;
  padding-block: 48px;
}

.auth-pitch-title {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.auth-features {
  display: grid;
  gap: 20px;
  padding: 0;
  list-style: none;
}

.auth-features li {
  display: flex;
  gap: 14px;
}

.auth-feature-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--chrome-raised);
}

.auth-feature-title {
  display: block;
  font-weight: 600;
}

.auth-feature-body {
  display: block;
  color: var(--on-chrome-muted);
  font-size: 14px;
}

.auth-main {
  display: flex;
  flex-direction: column;
  padding: 32px clamp(16px, 4vw, 48px) 40px;
}

.auth-phone-brand {
  display: none;
}

.auth-col {
  width: 100%;
  max-width: 400px;
  margin: auto;
  padding-block: 32px;
}

.auth-heading {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.auth-lede {
  margin-top: 8px;
  margin-bottom: 32px;
  color: var(--muted);
  font-size: 16px;
}

.auth-foot {
  display: grid;
  gap: 8px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 14px;
}

.reference {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .auth {
    grid-template-columns: minmax(0, 1fr);
    padding: 0;
  }

  .auth-brand {
    display: none;
  }

  .auth-phone-brand {
    display: flex;
  }

  .auth-main {
    padding: 20px 16px 32px;
  }

  .auth-col {
    margin-top: 48px;
  }
}

/* ---- the signed-in landing page ---- */

.landing {
  display: grid;
  gap: 24px;
  width: 100%;
  max-width: 640px;
  margin-inline: auto;
  padding: 32px 16px;
}

.who {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

/* ==== components (src/components/, templates/components/) ==== */

.icon {
  flex: none;
}

/* ---- Button ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  box-shadow: var(--shadow-button);
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn[data-size="sm"] {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 14px;
}

.btn[data-variant="secondary"] {
  border-color: var(--wash);
  background: var(--wash);
  color: var(--ink);
  box-shadow: none;
}

.btn[data-variant="secondary"]:hover {
  border-color: var(--line);
  background: var(--line);
}

.btn[data-variant="outline"] {
  border-color: var(--control-line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}

.btn[data-variant="outline"]:hover {
  background: var(--wash);
}

.btn[data-width="full"] {
  display: flex;
  width: 100%;
}

/* a link to a place that has no page yet */
.btn[aria-disabled="true"] {
  opacity: 0.5;
  box-shadow: none;
  cursor: not-allowed;
}

.btn[aria-disabled="true"]:hover {
  background: var(--accent);
}

.btn[data-variant="secondary"][aria-disabled="true"]:hover {
  border-color: var(--wash);
  background: var(--wash);
}

.btn[data-variant="outline"][aria-disabled="true"]:hover {
  background: var(--surface);
}

/* a button that waits for its form's request */
.btn:disabled {
  opacity: 0.5;
  box-shadow: none;
  cursor: progress;
}

.btn:disabled:hover {
  background: var(--accent);
}

/* ---- IconButton ---- */

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--wash);
}

/* ---- Avatar ---- */

.avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--wash);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.avatar[data-size="sm"] {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.avatar[data-tone="raised"] {
  background: var(--chrome-raised);
  color: var(--on-chrome);
}

.avatar[data-tone="tint"] {
  background: var(--tint);
}

/* ---- StatusChip: a fill, a border and a dot, never colour alone ---- */

.status-chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 10px;
  border: 1px solid var(--chip, var(--control-line));
  border-radius: 999px;
  background: var(--chip-wash, var(--wash));
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.status-chip::before {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--chip, var(--control-line));
  content: "";
}

.status-chip[data-status="active"] {
  --chip: var(--success);
  --chip-wash: var(--success-wash);
}

.status-chip[data-status="ending"] {
  --chip: var(--warning);
  --chip-wash: var(--warning-wash);
}

.status-chip[data-status="booked"] {
  --chip: var(--info);
  --chip-wash: var(--info-wash);
}

/* ---- Notice: the tones beside the error one above ---- */

.notice[data-tone="success"] {
  border-color: var(--success);
  background: var(--success-wash);
  color: var(--ink);
}

.notice[data-tone="info"] {
  border-color: var(--line);
  background: var(--wash);
  color: var(--muted);
}

.notice[data-tone="success"] .link,
.notice[data-tone="info"] .link {
  color: var(--ink);
}

/* ---- Card ---- */

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.card-lead {
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.card-note {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--wash);
  color: var(--muted);
  font-size: 14px;
}

.card-when {
  font-size: 14px;
}

/* a line of figures under a card's heading */
.card-figures {
  color: var(--muted);
  font-size: 13px;
}

/* a form that is the card's content */
.card-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* the foot of a card: what to do or what happened, and the way on */
.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 500;
}

.card-result {
  color: var(--ink);
}

/* the buttons at a card's foot, side by side */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* something behind a subscription: an icon, what it is, and the way to it */
.offer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 24px;
}

.offer-icon {
  display: grid;
  flex: none;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 12px;
  background: var(--wash);
}

.offer-text {
  flex: 1 1 260px;
  min-width: 0;
}

/* rows in a card: a rule above each, the card's foot padding taken back */
.rows {
  margin-bottom: -12px;
  padding: 0;
  list-style: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.row-text {
  flex: 1 1 180px;
  min-width: 0;
}

/* a topic under a topic */
.row[data-depth="1"] .row-text {
  padding-left: 20px;
}

.row[data-depth="2"] .row-text {
  padding-left: 40px;
}

.row[data-depth="3"] .row-text {
  padding-left: 60px;
}

.row-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.row-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
}

.row-progress {
  flex: 1 1 160px;
  min-width: 0;
}

.row-figures {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

/* a row's action: one width down the list whatever it says ("Başla",
   "Davam et", "Bax"), so the bars beside it start and end together */
.row > .btn {
  min-width: 104px;
}

.person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* ---- Progress: the one place purple is used ---- */

.progress {
  display: block;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--wash);
  appearance: none;
}

.progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--wash);
}

.progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--progress);
}

.progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--progress);
}

/* ---- StatTiles ---- */

.stat-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 0;
  padding: 24px 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.stat-tile:not(:last-child) {
  margin-right: 28px;
  padding-right: 28px;
  border-right: 1px solid var(--line);
}

.stat-tile dt {
  color: var(--muted);
  font-size: 14px;
}

.stat-tile dd {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.3;
}

/* ---- DetailRows ---- */

.detail-rows {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.detail-row dt {
  flex: none;
  color: var(--muted);
}

.detail-row dd {
  font-weight: 500;
  text-align: right;
}

.detail-row dd.mono {
  font-weight: 400;
}

/* ---- Attempts ---- */

.attempts {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  font-size: 14px;
  list-style: none;
}

.attempt {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

/* the attempt on the page */
.attempt[aria-current="true"] {
  border-color: var(--ink);
}

.attempt-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
}

.attempt-name {
  font-weight: 600;
}

.attempt-note {
  color: var(--muted);
}

.attempt .link {
  padding: 4px 0;
}

/* ---- EmptyState ---- */

.empty-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  color: var(--muted);
  font-size: 14px;
}

/* ---- PageHeader ---- */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.page-header-text {
  min-width: 0;
}

.page-header-eyebrow {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.page-header h1 {
  margin: 2px 0 4px;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.page-header-subline {
  color: var(--muted);
  font-size: 16px;
}

.page-header-progress {
  flex: 0 1 280px;
  min-width: 200px;
}

.page-header-caption {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

/* ---- SectionTabs: the views of one section, under the page's header ---- */

/* the rule under the row is the nav's own, so it runs the page's width
   while the row scrolls sideways on a narrow screen; however long the row,
   it asks no width of what holds it (a grid would grow to fit it) */
.section-tabs {
  contain: inline-size;
  overflow-x: auto;
  box-shadow: inset 0 -1px 0 var(--line);
}

.section-tabs-list {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.section-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.section-tab:hover {
  color: var(--ink);
}

/* inside the scrolling row, so the ring is not cut off */
.section-tab:focus-visible {
  outline-offset: -2px;
}

/* the view on the page: the line under it and its weight, not colour alone */
.section-tab[aria-current] {
  border-bottom-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}

.section-tab-count {
  display: grid;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  place-items: center;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.section-tab[aria-current] .section-tab-count {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---- NavItem, Sidebar ---- */

.sidebar {
  position: sticky;
  top: 12px;
  display: flex;
  flex: 0 0 272px;
  flex-direction: column;
  gap: 4px;
  height: calc(100vh - 24px);
  height: calc(100dvh - 24px);
  padding: 20px 14px;
  overflow-y: auto;
  border-radius: 20px;
  border: 1px solid var(--chrome-edge);
  background: var(--chrome);
  color: var(--on-chrome);
  box-shadow: var(--shadow-panel);
}

.sidebar :focus-visible,
.tab-bar :focus-visible,
[data-ground="dark"] :focus-visible {
  outline-color: var(--on-chrome);
}

.sidebar-brand {
  padding: 0 8px 16px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--on-chrome-muted);
  font-weight: 500;
  text-decoration: none;
}

a.nav-item:hover {
  color: var(--on-chrome);
}

.nav-item[aria-current="page"] {
  background: var(--chrome-raised);
  color: var(--on-chrome);
  font-weight: 600;
}

.nav-item[aria-disabled="true"] {
  cursor: not-allowed;
}

.nav-label {
  min-width: 0;
}

.nav-count,
.nav-amount {
  margin-left: auto;
}

.nav-count {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--on-chrome);
  color: var(--chrome);
  font-size: 12px;
  font-weight: 600;
}

.nav-amount {
  color: var(--on-chrome);
  font-size: 13px;
  white-space: nowrap;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 18px 0 6px 8px;
  border-top: 1px solid var(--chrome-raised);
}

/* who is signed in: the way to their own page */
.sidebar-profile {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 48px;
  margin: -6px 0 -6px -8px;
  padding: 6px 8px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}

.sidebar-profile:hover,
.sidebar-profile[aria-current="page"] {
  background: var(--chrome-raised);
}

.sidebar-who {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.sidebar-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-role {
  color: var(--on-chrome-muted);
  font-size: 13px;
}

.sidebar .icon-btn {
  color: var(--on-chrome-muted);
}

.sidebar .icon-btn:hover {
  background: var(--chrome-raised);
  color: var(--on-chrome);
}

/* ---- TopBar and TabBar: the phone's shell, hidden on a computer ---- */

.top-bar,
.tab-bar {
  display: none;
}

.top-bar {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.top-bar-end {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-bar-balance {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--wash);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.top-bar-profile {
  display: grid;
  border-radius: 999px;
  text-decoration: none;
}

.top-bar-profile[aria-current="page"] {
  box-shadow: 0 0 0 2px var(--ground), 0 0 0 4px var(--accent);
}

.tab-bar {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 10;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  height: 64px;
  border-radius: 20px;
  border: 1px solid var(--chrome-edge);
  background: var(--chrome);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.18), 0 12px 32px rgb(0 0 0 / 0.18);
}

.tab-bar > * {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  color: var(--on-chrome-muted);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}

.tab-bar > [aria-current="page"] {
  color: var(--on-chrome);
  font-weight: 600;
}

/* ---- Choices: a question's answer options, to pick from and marked ---- */

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
}

.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  /* the border is 1px, or 2px once picked or marked: the padding makes up
     the difference, so nothing moves */
  padding: 9px 16px;
  border: 1px solid var(--control-line);
  border-radius: 12px;
  background: var(--surface);
}

label.choice {
  position: relative;
  cursor: pointer;
}

/* the radio button itself is the whole row: drawn as nothing, still the
   thing that takes the click and the keyboard */
.choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

label.choice:hover {
  background: var(--wash);
}

.choice:has(input:checked),
.choice[data-mark="right"],
.choice[data-mark="wrong"] {
  padding: 8px 15px;
  border-width: 2px;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-wash);
}

.choice:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.choice-badge {
  display: grid;
  flex: none;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--control-line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.choice:has(input:checked) .choice-badge {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.choice .tex {
  flex: 1 1 auto;
  min-width: 0;
}

.choice[data-mark="right"] {
  border-color: var(--success);
  background: var(--success-wash);
}

.choice[data-mark="right"] .choice-badge {
  border-color: var(--success);
  background: var(--success);
  color: var(--on-status);
}

.choice[data-mark="wrong"] {
  border-color: var(--danger);
  background: var(--danger-wash);
}

.choice[data-mark="wrong"] .choice-badge {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--on-status);
}

.choice[data-mark="other"] {
  border-color: var(--line);
  color: var(--muted);
}

.choice-tag {
  flex: none;
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
}

/* ---- QuestionMap: every question as a numbered link, by how it stands ---- */

/* The grid of questions (here and PaperMap below) sits on a panel of its
   own, with its own tokens (--grid*): quiet tiles for what is open, a solid
   fill with dark figures for what is answered, right or wrong. */
.question-map,
.paper-map {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--grid);
  color: var(--grid-ink);
}

.question-cells {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 10px;
  max-height: 320px;
  margin: 0;
  /* room for a cell's outline and corner mark inside the scrolling box */
  padding: 6px;
  overflow-y: auto;
  list-style: none;
}

.question-cell {
  position: relative;
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1.5px solid transparent;
  border-radius: 10px;
  background: var(--grid-cell);
  color: var(--grid-ink);
  font-family: var(--mono);
  font-size: 14px;
  text-decoration: none;
}

.question-cell:hover {
  border-color: var(--grid-ink);
}

.question-cell[data-state="right"] {
  background: var(--grid-right);
  color: var(--on-grid-fill);
}

.question-cell[data-state="wrong"] {
  background: var(--grid-wrong);
  color: var(--on-grid-fill);
}

/* left without an answer in a paper that is over */
.question-cell[data-state="skipped"] {
  border: 1.5px dashed var(--grid-line);
  background: none;
}

.question-cell[aria-current] {
  outline: 2px solid var(--grid-current);
  outline-offset: 2px;
  font-weight: 600;
}

/* the tick or cross on a cell's corner, and in the key */
.question-mark,
.question-key {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 999px;
  background: var(--on-grid-fill);
}

.question-mark {
  position: absolute;
  top: -5px;
  right: -5px;
  box-shadow: 0 0 0 2px var(--grid);
}

.question-mark svg,
.question-key svg {
  stroke-width: 3.2;
}

[data-state="right"] > .question-mark {
  color: var(--grid-right);
}

[data-state="wrong"] > .question-mark {
  color: var(--grid-wrong);
}

.question-key[data-state="right"] {
  background: var(--grid-right);
  color: var(--on-grid-fill);
}

.question-key[data-state="wrong"] {
  background: var(--grid-wrong);
  color: var(--on-grid-fill);
}

.question-key[data-state="open"] {
  background: var(--grid-cell);
  box-shadow: inset 0 0 0 1px var(--grid-ink);
}

.question-key[data-state="skipped"] {
  border: 1.5px dashed var(--grid-line);
  background: none;
}

.question-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0;
  padding: 0 6px;
  color: var(--grid-ink);
  font-size: 13px;
  list-style: none;
}

.question-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- Filters: the form that narrows a long list ---- */

.filters {
  display: grid;
  gap: 14px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.filters-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.filters-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.filters-field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--control-line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  text-overflow: ellipsis;
}

.select:disabled {
  border-color: var(--line);
  background: var(--wash);
  color: var(--muted);
}

.filters-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
}

.filters-summary {
  color: var(--muted);
  font-size: 13px;
}

.filters-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

/* ---- Pagination: the pages of a long list ---- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-top: 20px;
}

.pagination-summary {
  color: var(--muted);
  font-size: 13px;
}

.pagination-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pagination-pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pagination-page,
.pagination-gap {
  display: grid;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  font-family: var(--mono);
  font-size: 14px;
}

.pagination-page {
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
}

.pagination-page:hover {
  background: var(--wash);
}

.pagination-page[aria-current] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.pagination-gap {
  min-width: 20px;
  color: var(--muted);
}

/* ---- AmountPicker: a top-up's amount, picked or typed ---- */

.amounts {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.amounts legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 14px;
  font-weight: 500;
}

.amount-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.amount-choice {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 60px;
  /* the border is 1px, or 2px once picked: the padding makes up the
     difference, so nothing moves */
  padding: 7px 9px;
  border: 1px solid var(--control-line);
  border-radius: 10px;
  background: var(--surface);
  text-align: center;
  cursor: pointer;
}

/* the radio button is the whole tile, as in Choices */
.amount-choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.amount-choice:hover {
  background: var(--wash);
}

.amount-choice:has(input:checked) {
  padding: 6px 8px;
  border-width: 2px;
  border-color: var(--accent);
  background: var(--accent-wash);
}

.amount-choice:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.amount-money {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
}

.amount-buys {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

/* what may be typed, under a field */
.field-hint {
  color: var(--muted);
  font-size: 13px;
}

.field-error[hidden] {
  display: none;
}

/* ---- CardFields: where the payment provider draws the card's inputs ---- */

.card-fields-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

/* the provider's frame sits inside; the box around it is ours, as .input */
.card-field {
  min-height: 48px;
  padding: 14px 14px 0;
  border: 1px solid var(--control-line);
  border-radius: 10px;
  background: var(--surface);
}

.card-field.StripeElement--focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-field.StripeElement--invalid {
  border-color: var(--danger);
}

/* ---- Statement: the wallet's movements ---- */

.statement {
  min-width: 0;
  font-size: 14px;
}

.statement-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.statement-head,
.statement-row {
  display: grid;
  grid-template-columns: minmax(9.5em, 1fr) minmax(0, 2fr) minmax(7.5em, auto) minmax(7.5em, auto);
  gap: 4px 16px;
  align-items: baseline;
}

.statement-head {
  padding-bottom: 8px;
  color: var(--muted);
  font-weight: 500;
}

.statement-head span:nth-child(n + 3),
.statement-amount,
.statement-balance {
  text-align: right;
  white-space: nowrap;
}

.statement-row {
  padding-block: 14px;
  border-top: 1px solid var(--line);
}

.statement-when {
  white-space: nowrap;
}

.statement-what {
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* credits that came in: green beside the plus, never the colour alone */
.statement-amount[data-added] {
  color: var(--success);
  font-weight: 500;
}

/* a phone: each movement on two lines, what and how much over when and
   the balance after */
@media (max-width: 620px) {
  .statement-head {
    display: none;
  }

  .statement-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .statement-what {
    grid-area: 1 / 1;
  }

  .statement-amount {
    grid-area: 1 / 2;
  }

  .statement-when {
    grid-area: 2 / 1;
  }

  .statement-balance {
    grid-area: 2 / 2;
  }

  .statement-when,
  .statement-balance {
    color: var(--muted);
    font-size: 13px;
  }
}

/* ---- Tex: question text drawn from its LaTeX (assets/tex.js) ---- */

.tex {
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* the question itself */
.tex[data-size="lead"] {
  font-size: 19px;
  font-weight: 500;
  line-height: 1.5;
}

/* until the script has drawn it, the source as written */
.tex[data-tex]:not(.tex-done) {
  white-space: pre-wrap;
}

.tex-shown {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--wash);
}

.tex p,
.tex ul,
.tex ol,
.tex .tex-display,
.tex .tex-table-wrap,
.tex .tex-quote {
  margin: 0 0 10px;
}

.tex > :last-child,
.tex li > :last-child,
.tex div > :last-child {
  margin-bottom: 0;
}

.tex ul,
.tex ol {
  padding-left: 24px;
}

.tex li + li {
  margin-top: 4px;
}

.tex .tex-described,
.tex .tex-labelled {
  list-style: none;
}

.tex .tex-label {
  font-weight: 600;
}

.tex .tex-display,
.tex .tex-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.tex .tex-display {
  padding: 2px 0;
}

.tex .katex-display {
  margin: 0;
}

/* a formula inside a sentence stands on a faint box of its own, as a
   tcolorbox does on paper, so it is told apart from the words around it.
   The wash is see-through: the same box serves a card, a picked option and
   a right or wrong one. A box of its own (not a run of text) so the wash
   reaches behind a fraction; a long formula still breaks inside it. */
.tex .tex-math {
  display: inline-block;
  max-width: 100%;
  margin: 0 2px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--formula-wash);
}

/* an answer option is often nothing but its formula, and already has a box
   of its own: no second one inside it */
.choice .tex .tex-math {
  display: inline;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: none;
}

.tex .tex-center {
  text-align: center;
}

.tex .tex-left {
  text-align: left;
}

.tex .tex-right {
  text-align: right;
}

.tex .tex-quote {
  padding-left: 14px;
  border-left: 3px solid var(--line);
}

.tex .tex-bold {
  font-weight: 600;
}

.tex .tex-italic {
  font-style: italic;
}

.tex .tex-mono {
  font-family: var(--mono);
  font-size: 0.93em;
}

.tex .tex-sc {
  font-variant-caps: small-caps;
}

.tex .tex-underline {
  text-decoration: underline;
}

.tex .tex-nowrap {
  white-space: nowrap;
}

.tex .tex-small {
  font-size: 0.85em;
}

.tex .tex-large {
  font-size: 1.2em;
}

.tex .tex-larger {
  font-size: 1.45em;
}

.tex .tex-table {
  border-collapse: collapse;
}

.tex .tex-center > .tex-table-wrap > .tex-table {
  margin: 0 auto;
}

.tex .tex-table td {
  padding: 4px 12px;
}

.tex .tex-ruled td {
  border: 1px solid var(--control-line);
}

/* what could not be read, as written; the reason is its title */
.tex .tex-error {
  border-radius: 4px;
  background: var(--danger-wash);
  color: var(--danger);
  font-family: var(--mono);
  font-size: 0.9em;
}

.tex .tex-error-note {
  padding: 0 6px;
  font-family: var(--font);
}

.tex .tex-empty {
  color: var(--muted);
}

.answers {
  display: grid;
  gap: 8px;
  padding: 0;
  list-style: none;
  counter-reset: answer;
}

.answer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.answer::before {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  content: counter(answer, upper-alpha);
  counter-increment: answer;
}

.answer-correct {
  border-color: var(--ok-line);
  background: var(--ok-wash);
}

.answer-text {
  flex: 1 1 200px;
  min-width: 0;
}

.history {
  display: grid;
  gap: 12px;
  padding: 0;
  list-style: none;
}

.history li {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.history li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

/* ==== the signed-in pages' frame (templates/app_shell.html) ==== */

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* The line across the top while htmx waits for a page: the shell names it
   its `hx-indicator`, so it has `htmx-request` for as long as a request
   runs. A quick answer shows nothing: the line starts after 150 ms, then
   creeps towards the end without reaching it. Also in the staff portal. */

.page-loading {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  width: 100%;
  height: 3px;
  background: var(--progress);
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

.page-loading.htmx-request {
  opacity: 1;
  animation: page-loading 10s cubic-bezier(0.1, 0.7, 0.2, 1) 150ms both;
}

@keyframes page-loading {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(0.92);
  }
}

/* no movement asked for: the whole line, still, after the same wait */
@media (prefers-reduced-motion: reduce) {
  .page-loading.htmx-request {
    animation: none;
    transform: none;
    transition: opacity 0s linear 150ms;
  }
}

.app-shell {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 12px;
}

.page {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  max-width: 1180px;
  padding: 20px clamp(8px, 2vw, 24px) 40px;
}

.page:focus {
  outline: none;
}

/* a page's two columns: the lists, and the cards beside them */
.columns {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 24px;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.column-main {
  flex: 3 1 480px;
}

.column-side {
  flex: 2 1 320px;
}

/* a column that is one form on a page of its own: not the page's width */
.column-form {
  max-width: 640px;
}

/* a side column of facts beside one long thing, as a question */
.column-narrow {
  flex: 1 1 260px;
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
    padding: 0;
  }

  .sidebar {
    display: none;
  }

  .top-bar {
    display: flex;
  }

  .tab-bar {
    display: grid;
  }

  /* room for the floating tab bar under the last card */
  .page {
    gap: 16px;
    padding: 20px 16px 100px;
  }

  .columns,
  .column {
    gap: 16px;
  }

  .column-main,
  .column-side {
    flex-basis: 100%;
  }

  .page-header h1 {
    font-size: 28px;
  }

  .filters {
    padding: 16px;
  }

  .filters-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-header-subline {
    font-size: 15px;
  }

  .page-header-progress {
    flex-basis: 100%;
  }

  .page-header-caption {
    text-align: left;
  }

  .choice {
    gap: 12px;
  }

  /* the words under the option, not squeezed beside it */
  .choice[data-mark] {
    flex-wrap: wrap;
  }

  .choice-tag {
    flex-basis: 100%;
    margin-left: 40px;
  }

  .card {
    padding: 16px 18px;
  }

  .card-title {
    font-size: 17px;
  }

  /* three figures side by side, the number above its name; the balance is
     in the top bar */
  .stat-tiles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 16px 18px;
  }

  .stat-tile {
    flex-direction: column-reverse;
    justify-content: flex-end;
    gap: 2px;
  }

  .stat-tile:not(:last-child) {
    margin-right: 0;
    padding-right: 0;
    border-right: 0;
  }

  .stat-tile[data-desk-only] {
    display: none;
  }

  .stat-tile dt {
    font-size: 13px;
  }

  .stat-tile dd {
    font-size: 20px;
  }
}

/* ---- ExamBar: the dark bar of the timed exam, with the clock ---- */

.exam-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 14px 24px;
  border-radius: 20px;
  border: 1px solid var(--chrome-edge);
  background: var(--chrome);
  color: var(--on-chrome);
  box-shadow: var(--shadow-panel);
}

.exam-bar-text {
  flex: 1 1 240px;
  min-width: 0;
}

.exam-bar-eyebrow {
  color: var(--on-chrome-muted);
  font-size: 13px;
  font-weight: 500;
}

.exam-bar h1 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

/* the last save; while an answer is on its way; when it did not get through */
.exam-saved {
  color: var(--on-chrome-muted);
  font-size: 14px;
}

.exam-saved > span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exam-saved-done .icon {
  color: var(--on-chrome-success);
  stroke-width: 2.4;
}

.exam-saved > .exam-saved-busy,
.exam-saved > .exam-saved-failed,
.exam-saved.htmx-request > .exam-saved-done,
.exam-saved[data-state="failed"] > .exam-saved-done,
.exam-saved[data-state="failed"] > .exam-saved-busy {
  display: none;
}

.exam-saved.htmx-request:not([data-state="failed"]) > .exam-saved-busy,
.exam-saved[data-state="failed"] > .exam-saved-failed {
  display: flex;
}

.exam-saved-failed {
  color: var(--on-chrome-warning);
  font-weight: 600;
}

.exam-clock {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 16px;
  border: 1px solid var(--chrome-raised);
  border-radius: 12px;
  background: var(--chrome-raised);
}

.exam-clock .mono {
  font-size: 26px;
  font-weight: 500;
}

.exam-clock-word {
  color: var(--on-chrome-muted);
  font-size: 13px;
}

/* the last five minutes: a border, not colour alone */
.exam-clock[data-ending] {
  border-color: var(--on-chrome-warning);
}

/* on the graphite the main action is the white one */
.exam-bar .btn {
  border-color: var(--on-chrome);
  background: var(--on-chrome);
  color: var(--chrome);
  box-shadow: none;
}

.exam-bar .btn:hover {
  border-color: var(--on-chrome-muted);
  background: var(--on-chrome-muted);
}

/* ---- PaperMap: an exam paper's questions, answered or not, marked or not ---- */

.paper-cells {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  max-height: 320px;
  margin: 0;
  /* room for the current cell's outline inside the scrolling box */
  padding: 4px;
  overflow-y: auto;
  list-style: none;
}

.paper-cell {
  position: relative;
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1.5px solid transparent;
  border-radius: 10px;
  background: var(--grid-cell);
  color: var(--grid-ink);
  font-family: var(--mono);
  font-size: 14px;
  text-decoration: none;
}

.paper-cell:hover {
  border-color: var(--grid-ink);
}

.paper-cell[data-state="answered"] {
  background: var(--grid-answered);
  color: var(--on-grid-fill);
}

/* marked "look at this again": an edge as well as the dot */
.paper-cell:has(> .paper-flag) {
  border-color: var(--grid-flag);
}

.paper-cell[aria-current] {
  outline: 2px solid var(--grid-current);
  outline-offset: 2px;
  font-weight: 600;
}

.paper-flag {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--grid-flag);
}

.paper-cell > .paper-flag {
  position: absolute;
  top: 4px;
  right: 4px;
}

/* on a filled cell the dot keeps a dark ring, so it does not rest on colour */
.paper-cell[data-state="answered"] > .paper-flag {
  box-shadow: 0 0 0 2px var(--on-grid-fill);
}

.paper-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0;
  padding: 0 4px;
  color: var(--grid-ink);
  font-size: 13px;
  list-style: none;
}

.paper-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.paper-key {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--grid-cell);
  box-shadow: inset 0 0 0 1px var(--grid-ink);
}

.paper-key[data-state="answered"] {
  background: var(--grid-answered);
  box-shadow: none;
}

/* ---- FlagButton: "look at this again", pressed while the mark is on ---- */

.flag-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--control-line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.flag-btn:hover {
  background: var(--wash);
}

.flag-btn[aria-pressed="true"] {
  border-color: var(--warning);
  background: var(--warning-wash);
}

.flag-btn[aria-pressed="true"] .icon {
  fill: var(--warning);
  stroke: var(--warning);
}

/* ---- Dialog: a question asked over the page ---- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--backdrop);
}

.dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 440px;
  padding: 28px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.18);
}

.dialog h2 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
}

.dialog p {
  color: var(--muted);
}

.dialog p .mono {
  color: var(--ink);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.dialog-actions > * {
  flex: 1 1 140px;
}

.dialog-actions .btn {
  display: flex;
  width: 100%;
}

/* ==== the exams' pages (templates/exams.html, exam.html) ==== */

/* an amount at the end of a row */
.row-amount {
  font-size: 14px;
  white-space: nowrap;
}

/* a paragraph as it was written, line breaks kept */
.card-text {
  overflow-wrap: anywhere;
  white-space: pre-line;
}

/* ==== the timed exam's frame (templates/exam_paper.html) ==== */

.exam-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 12px 12px 0;
}

.exam-page {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px clamp(0px, 2vw, 20px) 40px;
}

.exam-page:focus {
  outline: none;
}

.exam-number {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

/* before and after, at the two ends */
.exam-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

.exam-map {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.exam-done {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  max-width: 640px;
  margin: 36px auto 0;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.exam-done h2 {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.exam-done p {
  color: var(--muted);
  font-size: 16px;
}

.exam-done p .mono {
  color: var(--ink);
}

.exam-done-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 999px;
  background: var(--success-wash);
  color: var(--success);
}

.exam-done-icon .icon {
  stroke-width: 2.4;
}

@media (max-width: 860px) {
  .exam-shell {
    padding: 8px 8px 0;
  }

  /* the clock stays in sight while the questions scroll under it */
  .exam-bar {
    position: sticky;
    top: 8px;
    z-index: 10;
    gap: 8px 12px;
    padding: 12px 16px;
    border-radius: 16px;
  }

  .exam-bar-text {
    flex-basis: 100%;
  }

  .exam-saved {
    flex-basis: 100%;
    order: 3;
    font-size: 13px;
  }

  .exam-clock {
    flex: 1;
    justify-content: center;
  }

  .exam-clock .mono {
    font-size: 22px;
  }

  .exam-page {
    gap: 16px;
    padding: 16px 0 32px;
  }

  .exam-steps .btn {
    flex: 1 1 140px;
    padding: 0 12px;
  }

  .exam-done {
    margin-top: 8px;
    padding: 24px 20px;
  }

  .dialog {
    padding: 24px 20px;
  }
}

/* ==== the top-up's own frame (templates/topup.html) ==== */

.checkout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.checkout-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.checkout-bar .link {
  font-size: 14px;
  font-weight: 500;
}

.checkout-main {
  display: flex;
  flex: 1;
  justify-content: center;
  padding: 40px 16px 64px;
}

.checkout-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 440px;
  height: max-content;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.checkout-heading {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.checkout-note {
  color: var(--muted);
  font-size: 13px;
}

/* the payment is with the provider: a turning ring beside the words */
.checkout-wait {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: var(--wash);
}

.checkout-spinner {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 2px solid var(--control-line);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: checkout-turn 0.9s linear infinite;
}

@keyframes checkout-turn {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .checkout-spinner {
    animation: none;
  }
}

@media (max-width: 520px) {
  .checkout-bar {
    padding: 12px 16px;
  }

  .checkout-main {
    padding: 16px 16px 40px;
  }

  .checkout-col {
    padding: 20px 16px;
  }
}

/* ==== the component gallery (/_ui) ==== */

.gallery {
  display: grid;
  gap: 32px;
  max-width: 960px;
  margin-inline: auto;
  padding: 32px 16px 64px;
}

.gallery-title {
  font-size: 28px;
  font-weight: 600;
}

.gallery-section {
  display: grid;
  gap: 16px;
}

.gallery-section h2 {
  font-size: 18px;
  font-weight: 600;
}

.gallery-case {
  display: grid;
  gap: 6px;
}

.gallery-case figcaption {
  color: var(--muted);
  font-size: 13px;
}

.gallery-cell {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.gallery-cell[data-ground="dark"] {
  max-width: 272px;
  border-color: var(--chrome);
  background: var(--chrome);
}

/* ---- Settings: the reader's own settings, the sections listed on the
   left and the chosen one beside them; a dialog over any page, or a panel
   on its own page ---- */

/* where the closed dialog waits in the app shell: no box of its own */
.settings-slot {
  display: contents;
}

/* the layout is on `.settings` inside: a closed dialog must stay unshown */
.settings-dialog {
  width: min(780px, calc(100vw - 32px));
  max-width: none;
  height: min(560px, calc(100dvh - 32px));
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-panel);
}

.settings-dialog::backdrop {
  background: var(--backdrop);
}

.settings {
  position: relative;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  min-width: 0;
}

.settings[data-frame="dialog"] {
  height: 100%;
}

.settings[data-frame="page"] {
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.settings-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 20px 12px;
  border-right: 1px solid var(--line);
  background: var(--wash);
}

.settings-title {
  padding: 0 12px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.settings-tab:hover {
  color: var(--ink);
}

/* the chosen one: a raised surface and its border, not colour alone */
.settings-tab[aria-current] {
  border-color: var(--control-line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-card);
}

.settings-body {
  min-width: 0;
  padding: 24px 28px 28px;
  overflow-y: auto;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-section[hidden] {
  display: none;
}

.settings-heading {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

/* room for the button that closes the dialog */
.settings[data-frame="dialog"] .settings-heading {
  padding-right: 44px;
}

.settings-person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.settings-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.settings-role {
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.settings-group > .detail-rows {
  align-self: stretch;
}

.settings-note {
  color: var(--muted);
  font-size: 14px;
}

.settings-action {
  display: flex;
}

.settings-close {
  position: absolute;
  top: 12px;
  right: 12px;
  margin: 0;
}

/* a phone: the dialog fills the screen, the sections are a row on top */
@media (max-width: 620px) {
  .settings-dialog {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .settings {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .settings[data-frame="page"] {
    min-height: 0;
  }

  .settings-side {
    padding: 16px 12px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .settings[data-frame="dialog"] .settings-title {
    padding-right: 48px;
  }

  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
  }

  .settings-tab {
    flex: none;
  }

  .settings-body {
    padding: 20px 16px 24px;
  }

  .settings[data-frame="dialog"] .settings-heading {
    padding-right: 0;
  }
}

/* ---- ThemePicker: light, dark or as the device is set ---- */

.theme-picker {
  margin: 0;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--wash);
}

/* the icon above the label, so "Cihaz kimi" stays on one line in a narrow
   column */
.theme-option {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 56px;
  padding: 6px 4px;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.theme-option:hover {
  color: var(--ink);
}

/* the chosen one: a raised surface and its border, not colour alone */
.theme-option[aria-pressed="true"] {
  border-color: var(--control-line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-card);
}

/* in the staff portal's sidebar, on the navy */
.theme-picker[data-ground="chrome"] .theme-options {
  padding: 0;
  border: 0;
  background: transparent;
}

.theme-legend {
  padding: 0 12px 4px;
  color: var(--on-chrome-muted);
  font-size: 12px;
}

.theme-picker[data-ground="chrome"] .theme-option {
  min-height: 44px;
  padding: 4px 2px;
  gap: 2px;
  color: var(--on-chrome-muted);
  font-size: 12px;
}

.theme-picker[data-ground="chrome"] .theme-option:hover {
  background: var(--chrome-raised);
  color: var(--on-chrome);
}

.theme-picker[data-ground="chrome"] .theme-option[aria-pressed="true"] {
  border-color: var(--chrome-raised);
  background: var(--chrome-raised);
  color: var(--on-chrome);
  box-shadow: none;
}

.theme-picker[data-ground="chrome"] :focus-visible {
  outline-color: var(--on-chrome);
}
