/* ---------------------------------------------------------------- page structure */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 32px;
}
.page-head > div:first-child { min-width: 0; flex: 1 1 420px; }
.lede { color: var(--muted); font-size: var(--t-l); line-height: 1.55; max-width: 64ch; margin: 10px 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.group { margin-top: 28px; padding: 26px 28px 30px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-l); box-shadow: var(--shadow-s); }
.group-head { margin-bottom: 20px; }
.group-head h2 { margin: 0; font-size: var(--t-xl); }
.group-head p { margin: 4px 0 0; color: var(--muted); font-size: var(--t-s); max-width: 72ch; }
.group .section { margin-top: 28px; }
.group .section:first-of-type { margin-top: 0; }
.group .section-head h3 { margin: 0; font-size: var(--t-m); }
@media (max-width: 700px) { .group { padding: 20px 16px 22px; } }
.section { margin-top: 48px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 0; color: var(--muted); font-size: var(--t-s); }
.section-note { color: var(--muted); font-size: var(--t-s); max-width: 72ch; margin: 12px 0 0; }

.stack { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- buttons */

.btn {
  --btn-bg: var(--ink);
  --btn-fg: var(--on-ink);
  --btn-border: var(--ink);
  font: 600 var(--t-s)/1.2 var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1.5px solid var(--btn-border);
  border-radius: var(--r-s);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
.btn:hover { --btn-bg: color-mix(in srgb, var(--ink) 86%, var(--desk)); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.secondary { --btn-bg: var(--paper); --btn-fg: var(--ink); --btn-border: var(--rule-strong); }
.btn.secondary:hover { --btn-bg: var(--paper-2); --btn-border: var(--ink); }
.btn.ghost { --btn-bg: transparent; --btn-fg: var(--ink); --btn-border: transparent; }
.btn.ghost:hover { --btn-bg: var(--paper-3); }
.btn.danger { --btn-bg: var(--paper); --btn-fg: var(--bad); --btn-border: color-mix(in srgb, var(--bad) 55%, transparent); }
.btn.danger:hover { --btn-bg: var(--bad-bg); --btn-border: var(--bad); }
.btn.danger.solid { --btn-bg: var(--bad); --btn-fg: var(--on-bad); --btn-border: var(--bad); }
.btn.small { min-height: 32px; padding: 5px 11px; font-size: var(--t-s); }
.btn.large { min-height: 48px; padding: 12px 22px; font-size: var(--t-m); }
.btn .kbd { margin-left: 2px; }
.btn svg { width: 18px; height: 18px; flex: none; }

.link-btn {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  cursor: pointer;
}
.link-btn:hover { text-decoration-thickness: 2px; }
.link-btn.quiet { color: var(--muted); }
.link-btn:disabled { color: var(--muted); text-decoration: none; cursor: not-allowed; opacity: .6; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--r-s);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { background: var(--paper-3); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- form controls */

.field { display: grid; gap: 6px; margin: 0; min-width: 0; }
.field > .label, .field > span:first-child { font-weight: 600; font-size: var(--t-s); color: var(--ink-2); }
.field .hint-text { font-size: var(--t-s); color: var(--muted); margin: 0; }
.field > .seg, .field > .chips { justify-self: start; }
.fields { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: end; }

select, input[type="text"], input[type="password"], input[type="search"], input[type="date"], input[type="number"] {
  font: inherit;
  font-size: var(--t-s);
  min-height: 40px;
  padding: 7px 11px;
  border: 1.5px solid var(--rule-strong);
  border-radius: var(--r-s);
  background: var(--paper);
  color: var(--ink);
  max-width: 100%;
}
select:hover, input:hover { border-color: color-mix(in srgb, var(--ink) 45%, var(--rule-strong)); }
select:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 40%, transparent); outline-offset: 0; border-color: var(--focus); }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--t-s); }
.check input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }

/* Segmented control: one choice of a few */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  gap: 3px;
  border-radius: var(--r-s);
  background: var(--paper-3);
}
.seg button {
  font: 500 var(--t-s)/1.2 var(--font);
  min-height: 34px;
  padding: 6px 14px;
  border: 0;
  border-radius: var(--r-s);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); font-weight: 650; box-shadow: var(--shadow-s), 0 0 0 1px var(--rule); }

/* Choice cards: a radio group with a description per option */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.choice {
  display: grid;
  gap: 2px;
  text-align: left;
  font: inherit;
  padding: 14px 16px 14px 44px;
  position: relative;
  border: 1.5px solid var(--rule);
  border-radius: var(--r-m);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.choice::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 17px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--rule-strong);
  background: var(--paper);
}
.choice strong { font-weight: 650; }
.choice span { color: var(--muted); font-size: var(--t-s); }
.choice:hover { border-color: var(--rule-strong); }
.choice[aria-pressed="true"] { border-color: var(--ink); background: var(--paper-2); }
.choice[aria-pressed="true"]::before { border: 5px solid var(--ink); }

/* Toggle chips: many-of-many */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: 500 var(--t-s)/1.2 var(--font);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  border: 1.5px solid var(--rule);
  border-radius: var(--r-m);
  background: var(--paper);
  color: var(--ink-2);
  cursor: pointer;
}
.chip:hover { border-color: var(--rule-strong); color: var(--ink); }
.chip[aria-pressed="true"] {
  border-color: var(--ink);
  background: color-mix(in srgb, var(--ink) 8%, var(--paper));
  color: var(--ink);
}
.chip[aria-pressed="true"]::before {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(-45deg);
}

/* ---------------------------------------------------------------- surfaces */

.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-l);
  padding: 22px 24px;
}
.panel > h3:first-child { margin-top: 0; }
.panel-section + .panel-section { border-top: 1px solid var(--rule); margin-top: 20px; padding-top: 20px; }
.panel-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; border-top: 1px solid var(--rule); margin: 22px -24px -22px; padding: 16px 24px; background: var(--paper-2); border-radius: 0 0 var(--r-l) var(--r-l); }

.callout {
  border-left: 3px solid var(--status-warning);
  background: var(--paper);
  padding: 12px 16px;
  border-radius: 0 var(--r-s) var(--r-s) 0;
  max-width: 76ch;
  font-size: var(--t-s);
  margin: 0 0 20px;
}
.callout p:last-child { margin: 0; }

.empty {
  display: grid;
  justify-items: start;
  gap: 6px;
  padding: 28px;
  border: 1.5px dashed var(--rule-strong);
  border-radius: var(--r-l);
  color: var(--muted);
}
.empty strong { color: var(--ink); font-size: var(--t-l); }
.empty p { margin: 0; max-width: 60ch; }
.empty .btn { margin-top: 10px; }

/* ---------------------------------------------------------------- data tables */

.grid > *, .main-col > *, main section { min-width: 0; } /* a wide table scrolls in its wrapper, not the page */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r-l); background: var(--paper); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--t-s); }
table.data th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: var(--t-xs);
  padding: 10px 14px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--paper-2); }
table.data .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data .actions { text-align: right; white-space: nowrap; width: 1%; }
table.data .topic-no { color: var(--muted); font-variant-numeric: tabular-nums; width: 1%; padding-right: 0; }

/* ---------------------------------------------------------------- meters and badges */

.meter { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.meter-bar { flex: 1; height: 6px; background: var(--paper-3); border-radius: var(--r-s); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: var(--r-s); background: var(--good); }
.meter-bar i.low { background: var(--margin); }
.meter-bar i.mid { background: var(--status-warning); }
.meter-bar i.neutral { background: var(--rule-strong); }
.meter > span { font-variant-numeric: tabular-nums; min-width: 3.4em; text-align: right; color: var(--muted); font-size: var(--t-s); }

.level, .tag, .reason {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: var(--r-m);
  font-size: var(--t-xs);
  font-weight: 650;
  white-space: nowrap;
  line-height: 1.5;
}
.level::before, .reason::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.level-new { color: var(--muted); background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--rule); }
.level-new::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.level-weak, .reason-confident { color: var(--bad); background: var(--bad-bg); }
.level-learning, .reason-wrong { color: var(--warn); background: var(--warn-bg); }
.level-strong { color: var(--good); background: var(--good-bg); }
.reason-guess { color: var(--muted); background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--rule); }

.tag { color: var(--muted); background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--rule); font-weight: 600; }
.tag-fix { color: var(--bad); background: var(--bad-bg); box-shadow: none; }

.count {
  font: 700 var(--t-xs)/1 var(--font);
  min-width: 22px;
  padding: 4px 7px;
  text-align: center;
  border-radius: var(--r-m);
  background: var(--bad-bg);
  color: var(--bad);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- feedback */

.verdict {
  border-radius: var(--r-m);
  padding: 14px 18px 14px 16px;
  margin: 0 0 18px;
  border: 1px solid;
  border-left-width: 4px;
}
.verdict.good { border-color: color-mix(in srgb, var(--good) 45%, transparent); border-left-color: var(--good); background: var(--good-bg); }
.verdict.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); border-left-color: var(--bad); background: var(--bad-bg); }
.verdict > strong { display: block; margin-bottom: 4px; font-size: var(--t-m); }
.verdict p { margin: 0; max-width: 72ch; }
.verdict p + p { margin-top: 8px; }
.verdict .verdict-note { font-weight: 600; }
.verdict .row { margin-top: 12px; }
/* After a mistake: where the book explains it. */
.book-link { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; font-weight: 600; }
.verdict p.book-link { margin-top: 10px; }
.book-link svg { flex: none; width: 16px; height: 16px; color: var(--muted); }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 14px 0; }
.loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--rule-strong);
  border-top-color: var(--ink);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: var(--r-m);
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: var(--on-bad); }

/* ---------------------------------------------------------------- dialog */

dialog.modal {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--r-l);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
dialog.modal::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: pop .18s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal form { display: grid; gap: 14px; padding: 24px; }
.modal h2 { font-size: var(--t-xl); margin: 0; }
.modal p { margin: 0; color: var(--ink-2); }
.modal input { width: 100%; }
.modal .row { justify-content: flex-end; margin-top: 6px; }

/* ---------------------------------------------------------------- disclosure */

details.disclosure > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--ink-2);
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s;
}
details.disclosure[open] > summary::before { transform: rotate(45deg); }

pre.code {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  padding: 14px 18px;
  overflow-x: auto;
  margin: 0 0 20px;
  font-size: var(--t-s);
  line-height: 1.6;
}
pre.code code { font-size: inherit; background: none; border: 0; padding: 0; }
/* Highlighted SQL (core/sql-format.js) in code blocks and in answer options */
:is(pre.code, .sql-opt) .sql-k { color: var(--link); font-weight: 650; }
:is(pre.code, .sql-opt) .sql-s { color: var(--good); }
:is(pre.code, .sql-opt) .sql-c { color: var(--muted); font-style: italic; }

/* Language switch: the names of the languages, side by side (sign-in pages and the sidebar) */
.lang-switch { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r-s); background: var(--paper-3); }
.lang-switch button {
  font: 500 var(--t-s)/1.2 var(--font);
  min-height: 32px;
  padding: 4px 12px;
  border: 0;
  border-radius: var(--r-s);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.lang-switch button:hover { color: var(--ink); }
.lang-switch button[aria-pressed="true"] { background: var(--paper); color: var(--ink); font-weight: 650; box-shadow: var(--shadow-s), 0 0 0 1px var(--rule); }

/* Premium: what free accounts see but cannot use. */
.premium-tag { display: inline-flex; align-items: center; gap: 4px; font: 700 var(--t-xs)/1 var(--font); letter-spacing: .02em;
  text-transform: uppercase; color: var(--warn); background: var(--warn-bg); padding: 3px 7px 3px 6px; border-radius: var(--r-m);
  vertical-align: middle; white-space: nowrap; }
.premium-tag svg { width: 12px; height: 12px; flex: none; }
.premium-callout { display: flex; gap: 12px; align-items: flex-start; border-left-color: var(--warn); margin-bottom: 20px; }
.premium-callout svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--warn); }

.limit-panel > svg { width: 34px; height: 34px; color: var(--warn); }
.item-list button.locked { color: var(--muted); }

/* Touch targets: everything pressable is at least 24px high, a main action on a phone 44px. */
.link-btn, .example-data-btn, .predict-skip-btn { min-height: 24px; }
@media (max-width: 640px) {
  main .btn:not(.small):not(.ghost) { min-height: 44px; }
}
:where(main div, main section, main nav) > a:where(:not(.btn)) { padding-block: 1px; }

a[rel="next"], a[rel="prev"] { padding-block: 1px; }

/* The round picture of an account (js/ui/avatar.js). */
.avatar { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; color: var(--on-mark); font-weight: 800; font-size: var(--t-m); line-height: 1; background: linear-gradient(135deg, var(--avatar-from), var(--avatar-to)) var(--avatar-from); }
.avatar.large { width: 64px; height: 64px; font-size: var(--t-2xl); }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.profile-photo { display: flex; align-items: center; gap: 16px; min-height: calc(3 * var(--line)); }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); border: 0; white-space: nowrap; }

/* A date as dd-mm-yyyy: see js/ui/date-field.js. */
.date-field { position: relative; display: inline-grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; align-items: center; }
.date-field input[type="text"] { width: 9.5em; min-width: 0; }
.date-field .field-problem { grid-column: 1 / -1; max-width: 22ch; }
.date-open { display: grid; place-items: center; width: 40px; height: 40px; border: 1.5px solid var(--rule-strong); border-radius: var(--r-s); background: var(--paper-2); color: var(--ink); cursor: pointer; }
.date-open:hover { border-color: color-mix(in srgb, var(--ink) 45%, var(--rule-strong)); }
.date-native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }

/* The page behind the link in a study reminder. */
.unsubscribe { display: grid; gap: 16px; justify-items: start; max-width: 520px; margin: 12vh auto; padding-inline: 20px; }
.unsubscribe h1 { margin: 0; font-size: var(--t-2xl); }
.unsubscribe p { margin: 0; }
