/* Hashcards — light and dark, one set of tokens for both.
 *
 * Sizes come from two scales and nothing else: --fs-* for type, --ctl-* for the
 * height of anything clickable. A button or a label that needs a size picks one
 * of those, so nothing drifts half a pixel away from its neighbours.
 */

:root {
  color-scheme: light dark;

  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f2f3f7;
  --border: #e4e6ec;
  --border-strong: #cfd4de;
  --text: #14161c;
  --muted: #656d7e;
  --accent: #5b5bd6;
  --accent-text: #ffffff;
  --accent-soft: #ecebfd;
  --success: #16794a;
  --success-soft: #e4f5ec;
  --danger: #c02626;
  --danger-soft: #fdeaea;

  /* type */
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-md: .9375rem;
  --fs-base: 1rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.25rem;

  /* control heights */
  --ctl: 40px;
  --ctl-sm: 34px;
  --ctl-lg: 48px;

  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(18, 21, 30, .04), 0 6px 20px -14px rgba(18, 21, 30, .3);
  --shadow-lg: 0 2px 6px rgba(18, 21, 30, .06), 0 24px 60px -22px rgba(18, 21, 30, .35);
  --ease: cubic-bezier(.22, .61, .36, 1);

  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg: #0e1016;
  --surface: #161923;
  --surface-2: #1c2029;
  --border: #262a36;
  --border-strong: #39404f;
  --text: #e8eaf0;
  --muted: #99a1b3;
  --accent: #8b8bf0;
  --accent-text: #10121a;
  --accent-soft: #24263c;
  --success: #52d6a0;
  --success-soft: #16281f;
  --danger: #f28b8b;
  --danger-soft: #2c1a1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px -14px rgba(0, 0, 0, .7);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .45), 0 24px 60px -22px rgba(0, 0, 0, .8);
}

/* Card palette. Each card keeps the colour it was born with; --c is the ink,
 * --c-soft the wash behind it, and the pair simply swaps over when a card is
 * due. Eight hues, far enough apart to tell a deck apart at a glance. */
:root {
  --card-0: #5b5bd6; --card-0-soft: #ecebfd;
  --card-1: #7c3aed; --card-1-soft: #f0e9fe;
  --card-2: #2563eb; --card-2-soft: #e5edfd;
  --card-3: #0e7490; --card-3-soft: #dcf0f6;
  --card-4: #15803d; --card-4-soft: #e3f5e9;
  --card-5: #b45309; --card-5-soft: #fbeedb;
  --card-6: #be123c; --card-6-soft: #fde8ed;
  --card-7: #a21caf; --card-7-soft: #fbe9fb;
}

:root[data-theme="dark"] {
  --card-0: #a5a4f5; --card-0-soft: #262a45;
  --card-1: #c4a6fd; --card-1-soft: #2b2246;
  --card-2: #93b4fb; --card-2-soft: #1e2a44;
  --card-3: #7dd3ec; --card-3-soft: #12303a;
  --card-4: #86e0a4; --card-4-soft: #16301f;
  --card-5: #f0c07a; --card-5-soft: #34260f;
  --card-6: #f5a3b4; --card-6-soft: #3a1a22;
  --card-7: #eda6ee; --card-7-soft: #351a35;
}

* { box-sizing: border-box; }

/* Author rules that set `display` would otherwise beat the UA stylesheet and
 * leave [hidden] elements on screen. Everything here toggles with `hidden`. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3 { line-height: 1.3; letter-spacing: -.015em; margin: 0; font-weight: 620; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-base); }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }

.muted { color: var(--muted); font-size: var(--fs-sm); line-height: 1.6; }
.center { text-align: center; }

/* ------------------------------------------------------------ fallbacks */

.fatal {
  display: block;
  max-width: 32rem;
  margin: 18vh auto;
  padding: 0 1.5rem;
  text-align: center;
}
.fatal h1 { font-size: var(--fs-xl); margin-bottom: .6rem; }
.fatal p { color: var(--muted); font-size: var(--fs-sm); }

/* --------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem max(.85rem, env(safe-area-inset-left)) .6rem max(.85rem, env(safe-area-inset-right));
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color .2s var(--ease);
}
.topbar.scrolled { border-bottom-color: var(--border); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  color: inherit;
  text-decoration: none;
  font-size: var(--fs-base);
  font-weight: 620;
  letter-spacing: -.02em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
}
.brand-mark svg { width: 17px; height: 17px; }
.topbar-actions { display: flex; gap: .15rem; }

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.25rem max(.85rem, env(safe-area-inset-left))
           calc(3rem + env(safe-area-inset-bottom)) max(.85rem, env(safe-area-inset-right));
}

.view { animation: rise .28s var(--ease); }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.view-head { display: flex; align-items: center; gap: .35rem; margin-bottom: 1.15rem; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  height: var(--ctl);
  padding: 0 1rem;
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 560;
  line-height: 1;
  white-space: nowrap;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s var(--ease), background .15s var(--ease),
              border-color .15s var(--ease), opacity .15s;
}
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: scale(.985); }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.06); }

.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, var(--border)); }
.btn.danger:hover { background: var(--danger-soft); }

.btn.block { width: 100%; height: var(--ctl-lg); font-size: var(--fs-base); }
.btn.small { height: var(--ctl-sm); padding: 0 .75rem; font-size: var(--fs-sm); }
.btn.small svg { width: 15px; height: 15px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  display: grid;
  place-items: center;
  width: var(--ctl);
  height: var(--ctl);
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- home */

/* One surface split in three, rather than three cards fighting for attention. */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stat { padding: .85rem .4rem; text-align: center; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 640;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.stat-label { display: block; font-size: var(--fs-xs); color: var(--muted); }
.stat.is-due .stat-value { color: var(--accent); }

.start-block { display: grid; gap: .5rem; margin-bottom: 1.9rem; }
#caught-up { margin-top: .1rem; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .65rem;
}
.section-head h2 { font-size: var(--fs-lg); }

/* minmax(0, 1fr) rather than the default auto column: without it the column is
 * sized to the widest row's min-content, so one long line of metadata pushes
 * every row past the edge of the screen. */
.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .45rem;
}

.card-row {
  --c: var(--accent);
  --c-soft: var(--accent-soft);
  display: flex;
  align-items: center;
  gap: .15rem;
  padding: 0 .35rem 0 .4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .15s var(--ease);
}
.card-row:hover { border-color: color-mix(in srgb, var(--c) 35%, var(--border)); }

/* The whole left side is the review button, so a card is one tap away. */
.card-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .4rem .6rem .55rem;
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.box-pip {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: var(--fs-xs);
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  color: var(--c);
  background: var(--c-soft);
  transition: transform .15s var(--ease);
}
/* Due cards invert: the wash becomes the ink and the ink the background. */
.card-row.is-due .box-pip { color: var(--c-soft); background: var(--c); }
.card-open:hover .box-pip { transform: scale(1.06); }

/* A hairline of the card's colour down the leading edge. */
.card-row::before {
  content: '';
  align-self: stretch;
  width: 3px;
  margin: .5rem 0;
  border-radius: 999px;
  background: var(--c);
  opacity: .85;
}

.card-main { min-width: 0; flex: 1; }
.card-name {
  display: block;
  font-size: var(--fs-md);
  font-weight: 560;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-meta {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-meta .dot { opacity: .5; margin: 0 .3rem; }
.card-actions { display: flex; gap: 0; flex: none; }
.card-actions .icon-btn { width: var(--ctl-sm); height: var(--ctl-sm); }
.card-actions .icon-btn svg { width: 16px; height: 16px; }

.empty {
  text-align: center;
  padding: 2.4rem 1.3rem;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty-mark { display: inline-grid; place-items: center; color: var(--accent); margin-bottom: .5rem; }
.empty-mark svg { width: 30px; height: 30px; }
.empty h3 { margin-bottom: .35rem; font-size: var(--fs-lg); }
.empty p { color: var(--muted); font-size: var(--fs-sm); max-width: 28rem; margin: 0 auto 1.15rem; }

/* --------------------------------------------------------------- study */

.study-top { display: flex; align-items: center; gap: .5rem; margin-bottom: 1.4rem; }
.progress { flex: 1; display: flex; align-items: center; gap: .7rem; }
.progress-track {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width .35s var(--ease);
}
.progress-label { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }

.flashcard {
  --c: var(--accent);
  --c-soft: var(--accent-soft);
  position: relative;
  padding: 1.9rem 1.35rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  overflow: hidden;
  transition: border-color .25s var(--ease);
}
/* The card under review wears its own colour along the top. */
.flashcard::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--c);
}
.flashcard.is-correct::before { background: var(--success); }
.flashcard.is-wrong::before { background: var(--danger); }
.flashcard.is-correct { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.flashcard.is-wrong { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.flashcard.shake { animation: shake .4s var(--ease); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}

.question {
  font-size: var(--fs-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .09em;
}
.account {
  font-size: clamp(1.4rem, 5.5vw, 1.85rem);
  font-weight: 640;
  letter-spacing: -.03em;
  margin: .3rem 0 1.25rem;
  overflow-wrap: anywhere;
}

.code-step {
  display: inline-block;
  margin: -.9rem 0 1.1rem;
  padding: .2rem .7rem;
  font-size: var(--fs-xs);
  font-weight: 560;
  letter-spacing: .02em;
  color: var(--c);
  background: var(--c-soft);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.code-step + .hint-area { margin-top: 0; }

.hint-area { margin: -.75rem 0 1.1rem; }
.hint-area .btn { color: var(--c); background: var(--c-soft); border-color: transparent; box-shadow: none; }
.hint-area .btn:hover { filter: brightness(.97); }
.hint {
  display: inline-block;
  margin-top: .2rem;
  padding: .3rem .75rem;
  font-size: var(--fs-sm);
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
}

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  min-height: var(--ctl);
  padding: .55rem .8rem;
  font: inherit;
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
input[type="password"] { font-family: var(--mono); letter-spacing: .04em; }
input:focus, textarea:focus, select:focus { background: var(--surface); border-color: var(--accent); }
input:disabled { opacity: .6; }
textarea { resize: vertical; font-family: var(--mono); font-size: var(--fs-sm); }
select { cursor: pointer; }

/* The wrapper carries the border and the reveal button sits inside it, so the
 * field reads as one control the same width as the button below — but the input
 * itself still ends before the icon, and a long value cannot run underneath it.
 * Declared after the plain input rules so it wins the specificity tie. */
.password-field {
  display: flex;
  align-items: center;
  gap: .2rem;
  min-height: var(--ctl);
  padding-right: .2rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
}
.password-field:focus-within {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.password-field input,
.password-field input:focus {
  flex: 1;
  min-width: 0;
  min-height: calc(var(--ctl) - 2px);
  background: none;
  border: 0;
  border-radius: 0;
}
.password-field input:focus-visible { outline: 0; }
.icon-btn.inline { flex: none; width: 32px; height: 32px; }
.icon-btn.inline svg { width: 17px; height: 17px; }

#study-form { display: grid; gap: .6rem; }
#study-form input { text-align: center; }
/* A spacer as wide as the reveal button, so centred text sits in the middle of
 * the field rather than pushed left by the icon. */
#study-form .password-field::before { content: ''; flex: none; width: 32px; }

.feedback {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  margin-top: 1.1rem;
  padding: .75rem .85rem;
  border-radius: var(--radius-sm);
  text-align: left;
  animation: rise .25s var(--ease);
}
.feedback.ok { background: var(--success-soft); color: var(--success); }
.feedback.no { background: var(--danger-soft); color: var(--danger); }
.feedback-mark { flex: none; display: grid; place-items: center; height: 1.4rem; }
.feedback-mark svg { width: 18px; height: 18px; }
.feedback-title { font-size: var(--fs-md); font-weight: 600; }
.feedback-help { font-size: var(--fs-sm); opacity: .85; }

/* Skip sits left, Next right — and Next stays right once Skip is gone. */
.study-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; }
.study-actions #btn-skip { margin-right: auto; }
.study-actions .btn.primary { min-width: 7.5rem; }

/* ---------------------------------------------------------------- done */

.center-view { text-align: center; padding-top: 2.5rem; }
.done-mark { display: inline-grid; place-items: center; color: var(--accent); margin-bottom: .7rem; }
.done-mark svg { width: 40px; height: 40px; }
.done-score { color: var(--muted); font-size: var(--fs-sm); margin-top: .3rem; }
.done-actions { display: flex; justify-content: center; gap: .5rem; margin-top: 1.6rem; flex-wrap: wrap; }

/* ------------------------------------------------------------ settings */

.panel {
  padding: 1rem 1.05rem;
  margin-bottom: .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel > h3 { margin-bottom: .7rem; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .45rem 0;
}
.row + .row { border-top: 1px solid var(--border); }
.row > label, .row > .row-label { font-size: var(--fs-md); }
.row select { width: auto; min-width: 9rem; height: var(--ctl); font-size: var(--fs-md); }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.segmented button {
  height: calc(var(--ctl) - 10px);
  padding: 0 .7rem;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.action-row { padding: .65rem 0; }
.action-row + .action-row { border-top: 1px solid var(--border); }
.action-row .btn { margin-bottom: .4rem; }
.action-row .muted { margin: 0; }

.link { font-size: var(--fs-sm); }

/* ------------------------------------------------------------- dialogs */

dialog {
  width: min(28rem, calc(100vw - 1.6rem));
  padding: 1.25rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(10, 12, 18, .45); backdrop-filter: blur(2px); }
dialog[open] { animation: pop .22s var(--ease); }
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}
dialog h2 { font-size: var(--fs-lg); margin-bottom: .9rem; }
dialog > form > p { color: var(--muted); font-size: var(--fs-sm); line-height: 1.6; }

/* The card dialog is two halves — the password and the codes that go with it —
 * separated by a rule so it reads as one account rather than a list of fields. */
.card-section { padding-top: .9rem; margin-top: .9rem; border-top: 1px solid var(--border); }
.section-title {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  margin-bottom: .6rem;
  font-size: var(--fs-md);
}

.field { display: block; margin-bottom: .9rem; border: 0; padding: 0; }
.field-label {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  margin-bottom: .3rem;
  font-size: var(--fs-sm);
  font-weight: 560;
}
.optional { font-style: normal; font-weight: 400; color: var(--muted); font-size: var(--fs-xs); }
.field-help { display: block; margin-top: .3rem; font-size: var(--fs-xs); color: var(--muted); line-height: 1.55; }

/* The native file control renders differently in every browser and cannot be
 * styled to match; a real button driving a hidden input can. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.file-picker { display: flex; align-items: center; gap: .6rem; }
.file-name {
  min-width: 0;
  font-size: var(--fs-sm);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.radio, .checkbox {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  padding: .35rem 0;
  font-size: var(--fs-sm);
  line-height: 1.5;
  cursor: pointer;
}
.radio input, .checkbox input { margin: .25rem 0 0; accent-color: var(--accent); flex: none; }
.radio small { display: block; font-size: var(--fs-xs); }
.password-choice { margin-bottom: .9rem; }

.form-error {
  margin: 0 0 .9rem;
  padding: .5rem .7rem;
  font-size: var(--fs-sm);
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin: 1.1rem 0 0;
  padding: 0;
}

/* --------------------------------------------------------------- toast */

.toast-area {
  position: fixed;
  left: 50%;
  bottom: max(1.1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: grid;
  gap: .4rem;
  justify-items: center;
  pointer-events: none;
}
.toast {
  padding: .5rem .95rem;
  font-size: var(--fs-sm);
  color: var(--surface);
  background: var(--text);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .25s var(--ease);
}
.toast.leaving { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

/* Anything wearing a card colour picks it up from these two variables. Declared
 * after .card-row and .flashcard, which both set a fallback: same specificity,
 * so the one that comes last is the one that wins. */
.c0 { --c: var(--card-0); --c-soft: var(--card-0-soft); }
.c1 { --c: var(--card-1); --c-soft: var(--card-1-soft); }
.c2 { --c: var(--card-2); --c-soft: var(--card-2-soft); }
.c3 { --c: var(--card-3); --c-soft: var(--card-3-soft); }
.c4 { --c: var(--card-4); --c-soft: var(--card-4-soft); }
.c5 { --c: var(--card-5); --c-soft: var(--card-5-soft); }
.c6 { --c: var(--card-6); --c-soft: var(--card-6-soft); }
.c7 { --c: var(--card-7); --c-soft: var(--card-7-soft); }

/* -------------------------------------------------------------- mobile */

/* Fingers need more room than cursors, whatever the viewport is. */
@media (pointer: coarse) {
  .icon-btn, .card-actions .icon-btn { width: 44px; height: 44px; }
  .card-open { padding-top: .7rem; padding-bottom: .7rem; }
}

@media (max-width: 30rem) {
  .stat-value { font-size: 1.3rem; }
  .flashcard { padding: 1.5rem 1rem 1.2rem; }
  .row { flex-direction: column; align-items: stretch; gap: .45rem; }
  .row select { width: 100%; }
  .segmented { display: flex; }
  .segmented button { flex: 1; }
  .done-actions .btn { flex: 1; }

  /* Dialogs become sheets: full width, anchored to the bottom, within thumb
   * reach and never taller than the screen. */
  dialog {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    margin: auto 0 0;
    padding: 1.15rem 1rem calc(1.15rem + env(safe-area-inset-bottom));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 0;
    overflow-y: auto;
  }
  dialog[open] { animation: sheet-up .26s var(--ease); }
  @keyframes sheet-up {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
  }
  .dialog-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
