/* Quiet study: one cool ground, ink type and hairline rules, a single cobalt accent for action
   and focus. Anki's state colours (blue new, ochre learning, green due) appear only as small dots
   beside figures. Card text is set in Source Serif 4, which sits well beside KaTeX's maths. */
:root {
  --bg: #f7f8f9;
  --surface: #ffffff;
  --surface-2: #eef0f2;
  --hover: #f0f2f4;
  --border: #e4e6e9;
  --border-strong: #cdd1d6;
  --text: #15171a;
  --muted: #5d636c;
  --accent: #2b4fb7;
  --accent-hover: #213f97;
  --link: #2b4fb7;
  --accent-soft: #e7ecfa;
  --on-accent: #ffffff;
  --answer: color-mix(in srgb, var(--text) 82%, var(--bg));
  --new: #2f63d1;
  --new-soft: #e6edfb;
  --learning: #ad620c;
  --learning-soft: #f8ecdc;
  --review: #1d7b4d;
  --review-soft: #e1f1e8;
  --danger: #c3313c;
  --danger-soft: #fbe8e9;
  --chart-new: #3a6cd6;
  --chart-learning: #c27618;
  --chart-young: #2b9160;
  --chart-mature: #1f5a3c;
  --shadow-lg: 0 2px 6px rgb(20 24 32 / 0.06), 0 24px 60px rgb(20 24 32 / 0.18);
  --radius: 10px;
  --radius-sm: 7px;
  --font: 'Hanken Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-card: 'Source Serif 4', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme='dark'] {
  --bg: #111315;
  --surface: #181a1d;
  --surface-2: #202327;
  --hover: #1b1e21;
  --border: #26292e;
  --border-strong: #363a41;
  --text: #e8e9eb;
  --muted: #9ba1a9;
  --accent: #3e62d4;
  --accent-hover: #4b6fe0;
  --link: #93acff;
  --accent-soft: #1c2440;
  --on-accent: #ffffff;
  --answer: #b9c9ff;
  --new: #7ea6ff;
  --new-soft: #17233d;
  --learning: #e3a258;
  --learning-soft: #33261a;
  --review: #5dc78f;
  --review-soft: #14301f;
  --danger: #f0767e;
  --danger-soft: #3a1a1e;
  --chart-new: #5b8cf0;
  --chart-learning: #d08a35;
  --chart-young: #46ad78;
  --chart-mature: #2f7a54;
  --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.3), 0 24px 60px rgb(0 0 0 / 0.55);
}

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

html {
  color-scheme: light;
  scrollbar-color: var(--border-strong) transparent;
}
html[data-theme='dark'] {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--accent);
}

::selection {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

/* No double-tap zoom on controls, so taps register at once. */
button,
a,
input,
select,
summary,
label {
  touch-action: manipulation;
}

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

.icon {
  display: inline-flex;
  flex: none;
}
.icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ---- Layout ------------------------------------------------------------ */

.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 32px 96px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 64px;
  border-bottom: 1px solid var(--border);
}
.topbar .spacer {
  flex: 1;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  margin-right: 28px;
  display: inline-flex;
  align-items: baseline;
  gap: 0.45em;
}
/* The Urdu name, in the phone's own Nastaliq font where it has one. */
.brand-ur {
  font-family: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', 'Urdu Typesetting', 'Noto Naskh Arabic', serif;
  font-weight: 400;
  font-size: 0.95em;
  letter-spacing: 0;
  color: var(--muted);
}

.nav {
  display: flex;
  align-self: stretch;
  gap: 24px;
}
.nav a {
  display: flex;
  align-items: center;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 550;
  transition: color 0.15s;
}
.nav a:hover {
  color: var(--text);
}
.nav a[aria-current='page'] {
  color: var(--text);
  border-bottom-color: var(--text);
}
.nav .icon {
  display: none;
}

.save-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: default;
}
.save-chip .icon svg {
  width: 15px;
  height: 15px;
}
.save-chip.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.page-head {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin: 40px 0 24px;
}
.page-head h1 {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 650;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.page-head .sub {
  color: var(--muted);
  margin-top: 6px;
}
.page-head .counts {
  margin-top: 12px;
}
.page-head .actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 20px;
  padding: 4px 8px 4px 4px;
  margin-left: -4px;
  border-radius: var(--radius-sm);
}
.back:hover {
  color: var(--text);
  background: var(--hover);
}

/* ---- Buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover {
  background: var(--hover);
  border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text));
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
:root[data-theme='dark'] .btn.danger {
  color: #1d0a0c;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
}
.btn.ghost:hover {
  background: var(--hover);
}
.btn.lg {
  height: 48px;
  padding: 0 26px;
  font-size: 16px;
  border-radius: var(--radius);
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

kbd {
  font: 600 11px/1 var(--font);
  padding: 3px 5px;
  border-radius: 4px;
  border: 1px solid currentColor;
  opacity: 0.6;
}

/* ---- Counts and states ------------------------------------------------- */

.counts {
  display: flex;
  gap: 18px;
}
.count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13.5px;
}
.count b {
  color: var(--text);
  font-weight: 650;
}
.count.new .dot {
  color: var(--new);
}
.count.learning .dot {
  color: var(--learning);
}
.count.review .dot {
  color: var(--review);
}
.count.zero .dot {
  color: var(--border-strong);
}
.count.zero b {
  color: var(--muted);
  font-weight: 500;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.status.new .dot {
  color: var(--new);
}
.status.learning .dot {
  color: var(--learning);
}
.status.review .dot {
  color: var(--review);
}
.status.review {
  color: var(--text);
}
.status.zero .dot {
  color: var(--border-strong);
}

/* ---- Home -------------------------------------------------------------- */

/* Today's figures in one quiet strip, also used on the statistics and upcoming pages. */
.summary {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  margin-bottom: 36px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 20px 16px 0;
  color: var(--muted);
  font-size: 13.5px;
}
.stat + .stat {
  padding-left: 20px;
  border-left: 1px solid var(--border);
}
.stat b {
  color: var(--text);
  font-size: 26px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Today: the day's headline and the way in, beside the day's figures. */
.today {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 48px;
  margin: 52px 0 48px;
}
.today-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.today-when {
  color: var(--muted);
  font-weight: 550;
}
.today h1 {
  font-family: var(--font-card);
  font-size: clamp(38px, 5.4vw, 58px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.today-go {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin-top: 16px;
  color: var(--muted);
}
.today-go .btn {
  height: 52px;
}
.today-go .icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
.today-figures {
  display: flex;
  flex-direction: column;
  margin: 0;
}
.today-figures > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 8px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.today-figures > div:first-child {
  padding-top: 4px;
}
.today-figures > div:last-child {
  border-bottom: 0;
}
.today-figures dd {
  margin: 0;
  font-size: 34px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.today-figures dt {
  color: var(--muted);
}
.streak-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  width: 100%;
  margin-bottom: 12px;
}
.streak-days i {
  height: 22px;
  border-radius: 5px;
  background: var(--surface-2);
}
.streak-days i.on {
  background: var(--accent);
}
.streak-days i.now {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--link);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 {
  flex: 1;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.section-head .actions {
  display: flex;
  gap: 8px;
}

/* Decks are blocks on the ground: name and meta, the day's counts, then the way in. */
.deck-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.deck {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 240px;
  align-items: center;
  column-gap: 28px;
  padding: 6px 18px 6px 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 0.15s;
}
.deck:hover {
  border-color: var(--border-strong);
}
.deck-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px 0;
  min-width: 0;
}
.deck-name {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.deck-main:hover .deck-name {
  color: var(--link);
}
.deck-meta {
  color: var(--muted);
  font-size: 13.5px;
  text-wrap: pretty;
}
/* Who gave a deck, under its name. */
.deck-from {
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 550;
}
.page-head .deck-from {
  display: block;
  margin-top: 4px;
}
.deck-meta.tomorrow {
  margin-top: 10px;
}
.deck-meta.tomorrow a {
  color: var(--link);
  font-weight: 560;
  white-space: nowrap;
}
.deck-meta.tomorrow a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.deck .count {
  font-size: 14px;
}
.deck .count b {
  font-size: 16px;
}
.deck-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}
.deck-actions > :last-child {
  margin-left: 8px;
  min-width: 96px;
}
.deck-actions .icon-btn {
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.deck:hover .deck-actions .icon-btn,
.deck:focus-within .deck-actions .icon-btn {
  opacity: 1;
}
.caught-up {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
}
.caught-up .icon {
  color: var(--review);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 80px 24px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.empty h2 {
  color: var(--text);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.empty p {
  max-width: 440px;
}
.empty .row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

/* ---- Deck / card browser ------------------------------------------------ */

.reserve {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 28px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.reserve-text {
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  font-size: 13.5px;
  line-height: 1.4;
}
.reserve-text b {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}
.reserve input {
  width: 72px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.reserve .btn:not(.primary) {
  color: var(--text);
}
.reserve input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.search {
  position: relative;
  flex: 1;
  max-width: 340px;
}
.search .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.search input::placeholder {
  color: var(--muted);
}
.toolbar .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 13.5px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  height: 30px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip b {
  font-weight: 500;
  opacity: 0.8;
}
.chip:hover {
  color: var(--text);
  background: var(--hover);
}
.chip[aria-pressed='true'] {
  color: var(--text);
  background: var(--surface);
  border-color: var(--text);
}
.filters label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13.5px;
}
.filters label select {
  color: var(--text);
  max-width: 190px;
}
.filters .btn {
  height: 32px;
  padding: 0 10px;
}
.filter-toggle,
.reserve-narrow {
  display: none;
}

.menu {
  position: relative;
}
.menu summary {
  list-style: none;
}
.menu summary .icon svg {
  stroke-width: 3;
}
.menu summary::-webkit-details-marker {
  display: none;
}
.menu[open] summary {
  background: var(--hover);
  color: var(--text);
}
.menu-items {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: reveal 0.2s var(--ease);
}
.menu-items > * {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 5px;
  background: none;
  text-align: left;
  font-weight: 500;
  cursor: pointer;
}
.menu-items > *:hover {
  background: var(--hover);
}
.menu-items .icon {
  color: var(--muted);
}
.menu-items .danger {
  color: var(--danger);
}
.menu-items .danger .icon {
  color: inherit;
}
.filters label.on select {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.card-list {
  border-top: 1px solid var(--border-strong);
}
.card-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) 132px auto;
  align-items: center;
  gap: 16px;
  min-height: 40px;
  padding: 4px 6px 4px 2px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.card-row:hover {
  background: var(--hover);
}
.card-row.read-only {
  cursor: default;
}
.card-row.selected {
  background: var(--accent-soft);
}
.select-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px 6px 6px 2px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 550;
}
.select-bar .btn {
  height: 32px;
  padding: 0 11px;
}
.select-bar .btn.danger {
  margin-left: auto;
}
.select-bar .hint {
  margin-left: auto;
  font-weight: 400;
}
.grip {
  display: inline-flex;
  margin-right: -8px;
  color: var(--muted);
  cursor: grab;
}
.card-row.drop-before {
  box-shadow: inset 0 2px 0 var(--accent);
}
.card-row.drop-after {
  box-shadow: inset 0 -2px 0 var(--accent);
}
.pick {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.pick input {
  width: 16px;
  height: 16px;
  margin: 10px;
  accent-color: var(--accent);
  cursor: pointer;
}
.card-row .text {
  font-family: var(--font-card);
  font-size: 16px;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.card-row .text.back-text {
  color: var(--muted);
}
.card-row .row-actions {
  display: flex;
  margin-block: -4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.card-row .row-actions .icon-btn {
  width: 30px;
  height: 30px;
}
.card-row .pick input {
  margin: 6px 10px;
}
.card-row:hover .row-actions,
.card-row:focus-within .row-actions {
  opacity: 1;
}
.list-more {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 2px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 13.5px;
}
.list-more .btn {
  color: var(--text);
}
.list-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

/* ---- Study ------------------------------------------------------------- */

.study {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px max(32px, env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.study-top {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
}
.study-top .icon-btn {
  margin-left: -8px;
}
.study-title {
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.study-top .counts {
  margin: 0 0 0 auto;
  gap: 14px;
}
.progress {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}
.progress > div {
  height: 100%;
  border-radius: 2px;
  background: var(--link);
  transition: width 0.5s var(--ease);
}
/* A short session: one segment per card, filled as each is answered. */
.progress.segments {
  display: flex;
  gap: 4px;
  background: none;
}
.progress.segments i {
  flex: 1;
  border-radius: 2px;
  background: var(--border-strong);
  transition: background 0.3s;
}
.progress.segments i.done {
  background: var(--link);
}

/* The card is not boxed: its words, set large, are the only object on the screen. */
.flashcard {
  flex: 1;
  padding: 48px 0 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  animation: rise 0.4s var(--ease);
}
.study-top .tools {
  display: flex;
  margin-right: -8px;
  padding-left: 6px;
  border-left: 1px solid var(--border);
}

.face {
  font-family: var(--font-card);
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.face.question {
  font-size: clamp(28px, 4.4vw, 44px);
  line-height: 1.25;
  font-weight: 400;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.face.answer {
  font-size: clamp(21px, 2.8vw, 28px);
  line-height: 1.45;
  color: var(--answer);
  text-wrap: pretty;
  animation: reveal 0.35s var(--ease);
}
/* A word or short phrase is set as large as the screen allows. */
.face.question.short {
  font-size: clamp(44px, 7vw, 80px);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.face.answer.short {
  font-size: clamp(30px, 4.4vw, 44px);
  line-height: 1.2;
}
/* Maths and images on a card. */
.math {
  white-space: normal;
}
.katex-display {
  margin: 0.4em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}
.flashcard .katex-display {
  margin-inline: calc(50% - min(50vw - 24px, 560px));
}
.katex-display.overflows {
  mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent);
}
.card-image {
  display: inline-block;
  vertical-align: middle;
  max-width: 100%;
  max-height: 55vh;
  border-radius: var(--radius-sm);
  background: #fff;
}
.face .card-image {
  margin: 6px 0;
}
.image-missing {
  display: inline-block;
  padding: 4px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}
.card-row .card-image,
.import-preview .card-image {
  max-height: 2.6em;
  border-radius: 4px;
}
.card-row .katex-display,
.import-preview .katex-display {
  display: inline;
  margin: 0;
}
.card-row .katex-display > .katex,
.import-preview .katex-display > .katex {
  display: inline;
}

.speak {
  align-self: center;
  width: 40px;
  height: 40px;
  margin-top: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.speak:hover {
  background: var(--hover);
  color: var(--link);
}
.flashcard hr {
  width: 56px;
  border: 0;
  border-top: 1px solid var(--border-strong);
  margin: 36px auto 32px;
}

.answer-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 132px;
}

/* The interval ruler: a time line from a minute to a year, with each answer's next review marked. */
.ruler {
  width: 100%;
  margin-bottom: 14px;
  padding: 0 4px;
  animation: reveal 0.35s var(--ease);
}
.ruler-line {
  position: relative;
  height: 9px;
  background: linear-gradient(var(--border-strong), var(--border-strong)) center / 100% 1px no-repeat;
}
/* On reveal each mark travels out from "now" to where its answer would send the card. */
.ruler .mark {
  position: absolute;
  top: 0;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--muted);
  transition: transform 0.25s var(--ease), background 0.25s, border-color 0.25s;
  animation: travel 0.7s var(--ease) both;
  animation-delay: calc(var(--i) * 40ms);
}
.ruler .mark::after {
  content: attr(data-n);
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10.5px;
  font-style: normal;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
  display: none;
}
@keyframes travel {
  from {
    left: 0;
  }
}
.ruler-ticks {
  position: relative;
  height: 18px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.ruler-ticks span {
  position: absolute;
  transform: translateX(-50%);
}
.ruler-ticks span:first-child {
  transform: none;
}
.ruler-ticks span:last-child {
  transform: translateX(-100%);
}
.answer-bar:has(.rate.again:is(:hover, :focus-visible)) .mark.again,
.answer-bar:has(.rate.hard:is(:hover, :focus-visible)) .mark.hard,
.answer-bar:has(.rate.good:is(:hover, :focus-visible)) .mark.good,
.answer-bar:has(.rate.easy:is(:hover, :focus-visible)) .mark.easy {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}
/* Good, the answer Space gives, is ringed in the link colour until another is pointed at. */
.ruler .mark.good {
  border-color: var(--link);
}

/* Without hover, each mark carries its rating's number instead. */
@media (hover: none) {
  .ruler {
    padding-top: 14px;
  }
  .ruler .mark::after {
    display: block;
  }
}

.ratings {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  animation: reveal 0.35s var(--ease);
}
.rate {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  row-gap: 2px;
  min-height: 72px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.rate:hover {
  border-color: var(--border-strong);
  background: var(--hover);
}
.rate:active {
  transform: translateY(1px);
}
.rate .label {
  font-weight: 650;
}
/* Again is the one answer worth a second look; Good is the one Space gives. */
.rate.again .label {
  color: var(--danger);
}
.rate.good {
  border-color: var(--link);
  background: var(--accent-soft);
}
.rate.good:hover {
  background: color-mix(in srgb, var(--accent-soft) 70%, var(--link));
}
.rate.good .label,
.rate.good .ivl,
.rate.good kbd {
  color: var(--link);
}
.rate .ivl {
  grid-column: 1;
  font-size: 13.5px;
  color: var(--muted);
}
.rate kbd {
  grid-column: 2;
  grid-row: 1 / span 2;
  color: var(--muted);
}

.done {
  margin: auto;
  padding: 40px 0 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  color: var(--muted);
}
.done .badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  color: var(--review);
  margin-bottom: 10px;
}
.done .badge svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}
.done h1 {
  color: var(--text);
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.025em;
}
.done .btn {
  margin-top: 16px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* ---- Dialogs ----------------------------------------------------------- */

dialog.modal {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: rise 0.3s var(--ease);
}
dialog.modal.narrow {
  width: min(420px, calc(100vw - 32px));
}
dialog.modal::backdrop {
  background: rgb(12 14 18 / 0.4);
}
.modal-body {
  padding: 22px 24px 24px;
}
.modal-head {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}
.modal-head h2 {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin-right: auto;
}
.modal-head .icon-btn {
  margin: -4px -8px -4px 0;
}
.modal p.message {
  color: var(--muted);
}

.field {
  display: block;
  margin-bottom: 16px;
}
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.field small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 5px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.field textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}
.field input:focus,
.field textarea:focus,
.field select:focus,
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.field-head span {
  font-size: 13px;
  font-weight: 600;
}
.field-tools {
  display: flex;
  gap: 2px;
}
.btn.sm {
  height: 28px;
  padding: 0 9px;
  font-size: 13px;
  gap: 5px;
}
.btn.sm .icon svg {
  width: 15px;
  height: 15px;
}
.side-preview {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: var(--font-card);
  font-size: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.side-preview .card-image {
  max-height: 220px;
}
.math.editable {
  cursor: pointer;
  border-radius: 4px;
}
.math.editable:hover {
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* The equation editor. */
math-field.math-input {
  display: block;
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  --caret-color: var(--accent);
  --selection-background-color: var(--accent-soft);
  --contains-highlight-background-color: var(--accent-soft);
}
math-field.math-input:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.math-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.math-tools .btn {
  min-width: 40px;
  justify-content: center;
  font-family: 'KaTeX_Main', 'Times New Roman', serif;
  font-size: 16px;
}
/* The maths keyboard fills this layer and sits at its foot; only the keys take clicks. */
.math-keyboard {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
.math-keyboard .ML__keyboard {
  pointer-events: none;
}
.math-keyboard .MLK__plate {
  pointer-events: auto;
}
.modal.with-keyboard {
  margin-top: 12px;
  margin-bottom: auto;
}
.math-help {
  margin: 0 0 12px;
}

.field-note {
  display: block;
  margin-top: -8px;
  color: var(--muted);
  font-size: 12.5px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  cursor: pointer;
}
.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.import-preview {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 13.5px;
}
.import-preview table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.import-preview th,
.import-preview td {
  padding: 7px 12px;
  text-align: left;
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-preview th {
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.import-preview td {
  border-top: 1px solid var(--border);
}
.import-more {
  padding: 7px 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}
.import-summary {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13.5px;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
}
.modal-foot .note {
  margin-right: auto;
  color: var(--muted);
  font-size: 13px;
}
.modal-foot .note.ok {
  color: var(--review);
  font-weight: 560;
}
.modal-foot .btn:first-of-type {
  margin-left: auto;
}

/* ---- Toasts ------------------------------------------------------------ */

#toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  animation: rise 0.3s var(--ease);
}

/* ---- Statistics -------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.filters select {
  max-width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.segmented {
  display: flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.segmented button {
  padding: 4px 12px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--muted);
  font-weight: 550;
  cursor: pointer;
}
.segmented button:hover {
  color: var(--text);
}
.segmented button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.panel {
  padding: 28px 0 32px;
  border-top: 1px solid var(--border);
}
.summary + .panel,
.summary + * > .panel:first-child {
  border-top: 0;
  padding-top: 0;
}
.panel-head {
  margin-bottom: 20px;
}
.panel-head h2 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.panel-head p,
.panel-note,
.panel-empty {
  color: var(--muted);
  font-size: 13.5px;
}
.panel-note {
  margin-top: 16px;
}

.chart-tip {
  position: fixed;
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: 12.5px;
  line-height: 1.35;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  white-space: nowrap;
}
.chart-tip[hidden] {
  display: none;
}
.chart-tip b {
  font-size: 13.5px;
  font-weight: 650;
}
.chart-tip span {
  opacity: 0.75;
}

.chart {
  padding-left: 34px;
  font-size: 12px;
  color: var(--muted);
}
.chart-plot {
  position: relative;
  height: 180px;
}
.chart-tick {
  position: absolute;
  inset-inline: 0;
  border-top: 1px solid var(--border);
}
.chart-tick:first-child {
  border-color: var(--border-strong);
}
.chart-tick span {
  position: absolute;
  right: 100%;
  top: -0.75em;
  padding-right: 8px;
}
.chart-cols,
.chart-x {
  display: flex;
}
.chart-cols {
  position: absolute;
  inset: 0;
}
.chart-col {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.chart-col:hover {
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}
.chart-bar {
  width: min(22px, 100% - 2px);
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--chart-young);
}
.chart-x {
  margin-top: 8px;
  height: 1.5em;
}
.chart-x span {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  white-space: nowrap;
}

.chart-bar.split {
  display: flex;
  flex-direction: column-reverse;
  gap: 1px;
  overflow: hidden;
  background: none;
}
.chart-bar.split i {
  min-height: 1px;
}

.table-scroll {
  overflow-x: auto;
}
table.upcoming {
  width: 100%;
  border-collapse: collapse;
}
.upcoming th,
.upcoming td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
.upcoming th:first-child {
  padding-left: 0;
  text-align: left;
}
.upcoming td:last-child {
  padding-right: 0;
}
.upcoming thead th {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 560;
  border-bottom-color: var(--border-strong);
}
.upcoming tbody th {
  font-weight: 560;
}
.upcoming tbody th span {
  margin-left: 8px;
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}
.upcoming td {
  color: var(--muted);
}
.upcoming td.new,
.upcoming td.learning,
.upcoming td.review {
  color: var(--text);
}
.upcoming td b {
  color: var(--text);
  font-weight: 650;
}
.upcoming tr.none th,
.upcoming tr.none td b {
  color: var(--muted);
  font-weight: 400;
}
.upcoming tr.week-start > * {
  border-top: 1px solid var(--border-strong);
}
.upcoming tbody tr:last-child > * {
  border-bottom: 0;
}

.heat-wrap {
  width: max-content;
  max-width: 100%;
}
.heatmap {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.heat-days {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  gap: 3px;
  margin-top: 21px;
  line-height: 12px;
}
.heat-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}
.heat-months {
  display: grid;
  grid-template-columns: repeat(53, 12px);
  gap: 3px;
  height: 18px;
  margin-bottom: 3px;
  white-space: nowrap;
}
.heat-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 12px;
  grid-template-rows: repeat(7, 12px);
  gap: 3px;
  width: max-content;
}
.heat {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--surface-2);
}
.heat.l1 {
  background: color-mix(in srgb, var(--chart-young) 28%, var(--surface-2));
}
.heat.l2 {
  background: color-mix(in srgb, var(--chart-young) 52%, var(--surface-2));
}
.heat.l3 {
  background: color-mix(in srgb, var(--chart-young) 76%, var(--surface-2));
}
.heat.l4 {
  background: var(--chart-young);
}
.heat-grid .heat:hover {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}
.heat-key {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.heat-key .heat:first-of-type {
  margin-left: 4px;
}
.heat-key .heat:last-of-type {
  margin-right: 4px;
}

.k-new {
  background: var(--chart-new);
}
.k-learning {
  background: var(--chart-learning);
}
.k-young {
  background: var(--chart-young);
}
.k-mature {
  background: var(--chart-mature);
}
.stack {
  display: flex;
  gap: 2px;
  height: 14px;
}
.stack div {
  min-width: 3px;
}
.stack div:first-child {
  border-radius: 3px 0 0 3px;
}
.stack div:last-child {
  border-radius: 0 3px 3px 0;
}
.stack div:only-child {
  border-radius: 3px;
}
.stack div:hover {
  filter: brightness(1.12);
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 26px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}
.legend li {
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.legend b {
  color: var(--text);
  font-weight: 650;
}
.legend .share {
  font-size: 12.5px;
}

.answers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
}
.answer-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}
.answer-head b {
  color: var(--text);
  font-weight: 650;
}
.answer-cols {
  display: flex;
  height: 150px;
  font-size: 12px;
  color: var(--muted);
}
.answer-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  border-radius: 4px;
}
.answer-col:hover {
  background: var(--hover);
}
.answer-col .chart-bar {
  background: var(--chart-mature);
}
.answer-col .cap {
  color: var(--text);
  font-weight: 600;
  margin-bottom: 4px;
}
.answer-col span:last-child {
  width: 100%;
  padding-top: 5px;
  border-top: 1px solid var(--border-strong);
  text-align: center;
}

/* ---- Small screens ----------------------------------------------------- */

/* ---- Signing in ---------------------------------------------------------- */

.auth {
  max-width: 380px;
  margin: 0 auto;
  padding: 40px 16px calc(48px + env(safe-area-inset-bottom));
}
.auth .brand {
  margin: 0 0 56px;
}
.auth h1 {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 650;
  text-wrap: balance;
}
.auth .sub {
  color: var(--muted);
  margin: 8px 0 28px;
}
/* 16px or more, so phones do not zoom in on a field when it is tapped. */
.auth .field input {
  height: 44px;
  font-size: 16px;
}
.auth .btn.primary {
  width: 100%;
  height: 44px;
  margin-top: 8px;
  font-size: 15px;
}
.auth-error {
  color: var(--danger);
  font-weight: 500;
}
.auth-error:empty {
  display: none;
}
.auth-switch {
  margin-top: 20px;
  text-align: center;
}
.auth-switch a {
  display: inline-block;
  padding: 10px 4px;
  color: var(--link);
  font-weight: 550;
}
.auth-switch a:hover {
  text-decoration: underline;
}
.auth.offline h1 {
  margin-bottom: 28px;
}

/* The account menu: the user's name in the top bar, opening Admin and Log out. */
.account summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  max-width: 200px;
  margin-left: 4px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 550;
  cursor: pointer;
}
.account summary:hover {
  background: var(--hover);
  color: var(--text);
}
.account-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.menu-items > .menu-who {
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  margin-bottom: 6px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  cursor: default;
}
.menu-items > .menu-who:hover {
  background: none;
}
.menu-who span {
  color: var(--muted);
  font-size: 13.5px;
}
.phone-only {
  display: none !important;
}

/* The admin screen: ruled lists of people, invite codes and decks. */
.admin-section + .admin-section {
  margin-top: 40px;
}
/* ---- Progress (admin) ---------------------------------------------------- */

.progress-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto auto auto auto;
  align-items: center;
  gap: 18px;
  min-height: 56px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.progress-row:hover {
  background: var(--hover);
}
.progress-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.progress-fact {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--muted);
}
.day-strip {
  display: inline-flex;
  gap: 3px;
}
.day-strip i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--border);
}
.day-strip i.on {
  background: var(--chart-young);
}
.prog-bar {
  display: flex;
  height: 12px;
  margin: 8px 0 6px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--border);
}
.prog-bar i {
  flex-basis: 0;
  min-width: 2px;
}
.prog-known {
  background: var(--chart-mature);
}
.prog-learning {
  background: var(--chart-young);
}
.prog-struggling {
  background: var(--danger);
}
.prog-waiting {
  background: var(--chart-new);
}
.prog-reserve {
  background: var(--border-strong);
}
.person-deck {
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--border);
}
.person-deck h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.person-deck p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}
.person-search {
  margin: 4px 0 12px;
}
.person-cards {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border-strong);
}
.person-cards li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.person-card-text {
  min-width: 0;
  overflow-wrap: anywhere;
}
.person-card-status {
  color: var(--muted);
  white-space: nowrap;
}
.status-struggling {
  color: var(--danger);
}
.status-known {
  color: var(--review);
}
@media (max-width: 640px) {
  .progress-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
  }
  .progress-row .day-strip {
    grid-column: 1 / -1;
    order: 5;
  }
  .person-card-status {
    white-space: normal;
  }
}

.admin-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border-strong);
}
.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--border);
}
.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.admin-main b {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.admin-meta {
  color: var(--muted);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}
.admin-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.admin-empty {
  padding: 20px 2px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.invite-code {
  font-size: 17px;
  letter-spacing: 0.06em;
}
.invite-new {
  align-items: center;
}
.uses {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 550;
}
.uses input {
  width: 64px;
  height: 36px;
  padding: 0 8px 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.uses input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.give-list {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.give-list .check {
  min-height: 36px;
}
.give-user {
  color: var(--muted);
  font-size: 13.5px;
}

@media (max-width: 760px) {
  .today {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    margin: 36px 0 36px;
  }
  .today-figures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }
  .today-figures > div,
  .today-figures > div:first-child {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 0 14px 14px;
    border-bottom: 0;
    border-left: 1px solid var(--border);
  }
  .today-figures > div:first-child {
    padding-left: 0;
    border-left: 0;
  }
  .today-figures dd {
    font-size: 24px;
  }
  .today-figures dt {
    font-size: 13px;
  }
  .streak-days {
    display: none;
  }
  .deck {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 8px;
    padding: 14px 14px 14px 18px;
  }
  .deck-main {
    padding: 0;
  }
  .deck .counts {
    grid-row: 2;
    grid-column: 1;
    gap: 14px;
  }
  .deck-actions {
    grid-row: 1 / span 2;
    grid-column: 2;
  }
  .deck-actions .icon-btn {
    display: none;
  }
  .deck-actions > :last-child {
    margin-left: 0;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .upcoming th,
  .upcoming td {
    padding-inline: 6px;
  }
  .upcoming tbody th span {
    display: none;
  }
  .page {
    padding: 0 16px calc(96px + env(safe-area-inset-bottom));
  }
  /* The main links become a tab bar along the bottom, in reach of the thumb. */
  .nav {
    position: fixed;
    z-index: 10;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    padding: 6px 8px env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
  }
  .nav a {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    margin: 0;
    border: 0;
    font-size: 12px;
  }
  .nav a[aria-current='page'] {
    color: var(--link);
  }
  .nav .icon {
    display: inline-flex;
  }
  .nav .icon svg {
    width: 21px;
    height: 21px;
  }
  .section-head .actions .btn {
    padding: 0 12px;
  }
  .topbar {
    height: 56px;
  }
  .brand {
    margin-right: 16px;
  }
  .page-head {
    margin-top: 28px;
  }
  .page-head h1 {
    font-size: 26px;
  }
  .card-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 4px 6px;
  }
  .card-row .pick {
    grid-column: 1;
    grid-row: 1 / span 3;
  }
  .card-row .text {
    grid-column: 2;
  }
  .card-row .back-text {
    grid-row: 2;
  }
  .card-row .due {
    grid-column: 2;
    grid-row: 3;
    justify-self: start;
    margin-top: 4px;
  }
  .card-row .row-actions {
    grid-column: 3;
    grid-row: 1 / span 3;
    opacity: 1;
  }
  .card-row {
    padding-block: 8px;
  }
  .filter-toggle {
    display: inline-flex;
    margin-bottom: 12px;
  }
  .filters:not(.open) {
    display: none;
  }
  .reserve-text span,
  .reserve-wide {
    display: none;
  }
  .reserve-narrow {
    display: block;
  }
  .reserve {
    flex-wrap: nowrap;
  }
  .reserve-text {
    flex: 1 1 auto;
    min-width: 0;
  }
  .reserve > .icon {
    display: none;
  }
  .study-top .state {
    display: none;
  }
  .study {
    padding: 0 16px max(20px, env(safe-area-inset-bottom));
  }
  .flashcard {
    padding: 64px 0 28px;
  }
  .stat {
    padding: 12px 10px 12px 0;
    font-size: 12.5px;
    line-height: 1.3;
  }
  .stat + .stat {
    padding-left: 10px;
  }
  .stat b {
    font-size: 21px;
  }
  .ratings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .rate {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 64px;
    text-align: center;
    padding: 10px 4px;
    border-radius: 14px;
  }
  body:has(.nav) #toasts {
    bottom: calc(88px + env(safe-area-inset-bottom));
  }
  .rate kbd,
  .btn kbd {
    display: none;
  }
  .study-top .count span {
    display: none;
  }
  .save-chip:not(.error) {
    display: none;
  }
  .save-chip {
    margin-right: 0;
  }
  /* The account menu stays in the top bar: just its icon, the name shown inside. */
  .account summary {
    width: 34px;
    padding: 0;
    justify-content: center;
  }
  .account-name,
  .wide-only {
    display: none;
  }
  .phone-only {
    display: flex !important;
  }
  .auth {
    padding-top: 24px;
  }
  .auth .brand {
    margin-bottom: 40px;
  }
  .auth h1 {
    font-size: 26px;
  }
  .page-head .actions {
    flex-wrap: wrap;
    margin-left: 0;
  }
  .answers {
    grid-template-columns: 1fr;
  }
  .admin-row {
    gap: 10px;
  }
  .admin-row .btn {
    padding: 0 12px;
  }
  .uses input {
    font-size: 16px;
  }
  /* The new-code controls take their own line under the heading. */
  .invite-new {
    flex-basis: 100%;
  }
  .invite-new .btn {
    margin-left: auto;
  }
}


/* Touch screens: every control is at least 44px to the finger, without changing the look on a desktop. */
@media (pointer: coarse) {
  .btn,
  .select-bar .btn,
  .filters .btn {
    height: 44px;
  }
  .icon-btn,
  .card-row .row-actions .icon-btn {
    width: 44px;
    height: 44px;
  }
  .card-row .row-actions {
    margin-block: 0;
  }
  .reserve input,
  .search input {
    height: 44px;
  }
  .speak {
    width: 44px;
    height: 44px;
  }
  .chips {
    gap: 8px;
  }
  .chip {
    height: 44px;
  }
  .pick input,
  .card-row .pick input {
    width: 22px;
    height: 22px;
    margin: 11px;
  }
  .back {
    min-height: 44px;
  }
  .brand {
    display: flex;
    align-items: center;
    min-height: 44px;
  }
  .tomorrow a {
    display: inline-block;
    padding-block: 12px;
    margin-block: -12px;
  }
  .menu-items > * {
    min-height: 44px;
  }
  .account summary {
    min-width: 44px;
    height: 44px;
  }
  .uses input {
    height: 44px;
  }
  .give-list .check {
    min-height: 44px;
  }
  .give-list .check input {
    width: 22px;
    height: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ---- Study by topic ------------------------------------------------------ */

.btn.topic-pick {
  max-width: 200px;
}
.btn.topic-pick > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reserve select.reserve-topic {
  height: 36px;
  max-width: 190px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.reserve select.reserve-topic:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.pick-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13.5px;
}
.pick-list {
  max-height: min(60vh, 420px);
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.pick-row.nested {
  padding-left: 28px;
}
.pick-row input {
  flex: none;
  margin: 0;
  accent-color: var(--accent);
}
.pick-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.pick-count {
  flex: none;
  color: var(--muted);
  font-size: 12.5px;
}
.pick-head {
  display: flex;
  align-items: stretch;
}
.pick-head .pick-row {
  flex: 1;
  min-width: 0;
}
.pick-toggle {
  flex: none;
  align-self: center;
}
.pick-toggle[aria-expanded='true'] .icon {
  transform: rotate(180deg);
}
.pick-topics[hidden] {
  display: none;
}
.pick-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
@media (max-width: 640px) {
  .reserve select.reserve-topic {
    flex: 1 1 100%;
    max-width: none;
  }
}

/* ---- See and change topics ----------------------------------------------- */

.field[hidden] {
  display: none;
}
.card-row .topic-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-row.has-topic {
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) minmax(0, 120px) 132px auto;
}
.topics-edit {
  max-height: min(65vh, 520px);
  overflow-y: auto;
}
.topic-group {
  margin-bottom: 14px;
}
.topic-group-head,
.topic-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 2px;
  border-bottom: 1px solid var(--border);
}
.topic-group-head {
  padding-bottom: 6px;
}
.topic-row {
  padding-left: 14px;
}
.topic-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.topic-group-head input,
.topic-row input[type='text'],
.topic-row select {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
}
.topic-row select {
  flex: 0 1 140px;
  border-color: var(--border-strong);
  background: var(--surface);
}
.topic-group-head input {
  font-weight: 600;
}
.topic-group-head input:hover,
.topic-row input[type='text']:hover {
  border-color: var(--border-strong);
}
.topic-group-head input:focus,
.topic-row input[type='text']:focus,
.topic-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.topic-row .pick-count {
  white-space: nowrap;
}
.topic-row.topic-add {
  padding-left: 2px;
  border-bottom: 0;
}
.topic-row.topic-add input[type='text'] {
  border-color: var(--border-strong);
}
.topics-sub {
  margin: 14px 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
}
@media (max-width: 640px) {
  .card-row.has-topic {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .card-row.has-topic .pick {
    grid-row: 1 / span 4;
  }
  .card-row.has-topic .topic-name {
    grid-column: 2;
    grid-row: 3;
  }
  .card-row.has-topic .due {
    grid-row: 4;
  }
  .card-row.has-topic .row-actions {
    grid-row: 1 / span 4;
  }
  .topic-row {
    flex-wrap: wrap;
  }
}
