/* --------------------------------------------------------------------------
   Anki

   Two themes, one set of variables. Everything downstream reads the tokens,
   so switching theme is a single attribute change on the root element.
   -------------------------------------------------------------------------- */

:root {
  --bg: #14161a;
  --panel: #1b1e25;
  --panel-2: #22262f;
  --border: #2c313c;
  --text: #e7eaf0;
  --muted: #8b93a4;
  --accent: #4dd4b0;
  --accent-ink: #062018;

  --again: #f87171;
  --hard: #fbbf24;
  --good: #4ade80;
  --easy: #60a5fa;
  --new: #a78bfa;

  --radius: 12px;
  --shadow: 0 8px 30px rgb(0 0 0 / 35%);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --border: #d9dee6;
  --text: #1b1f27;
  --muted: #646c7b;
  /* Darker than the dark theme's accent, so links and button text on it
     clear 4.5:1 against white. */
  --accent: #0b7a62;
  --accent-ink: #ffffff;

  --again: #dc2626;
  --hard: #b45309;
  --good: #15803d;
  --easy: #1d4ed8;
  --new: #6d28d9;

  --shadow: 0 6px 24px rgb(15 23 42 / 10%);
  color-scheme: light;
}

* { box-sizing: border-box; }

/* The hidden attribute is how every script here shows and hides things, but
   the browser's own rule for it loses to any class that sets display — so a
   hidden .controls row or a hidden label would stay on screen. This makes
   hidden mean hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; letter-spacing: .01em; }
h3 { font-size: .9rem; margin: 1.5rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
b { font-weight: 650; }

/* ------------------------------------------------------------------ chrome */

/* How tall the top bar is, for anything that has to sit just below it. */
:root { --topbar-height: 56px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1rem 0 1.25rem;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar.simple { height: 56px; }

.brand {
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent);
}

nav { display: flex; gap: .25rem; }

/* The theme switch and the account button, always at the right-hand end. */
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: .4rem; flex: none; }

/*
 * Narrower than one row needs, the sections take a second row of their own,
 * spread across the full width. Everything stays visible: nothing is hidden
 * to make room, and nothing is pushed off the edge.
 */
@media (max-width: 960px) {
  :root { --topbar-height: 100px; }
  .topbar:not(.simple) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 54px 46px;
    grid-template-areas:
      "brand deck end"
      "nav   nav  nav";
    /* No gap between the rows: their heights already add up to the bar's. */
    gap: 0 .75rem;
    padding: 0 .75rem;
  }
  .topbar:not(.simple) .brand { grid-area: brand; }
  .topbar:not(.simple) #deck-switcher { grid-area: deck; justify-self: start; }
  .topbar:not(.simple) .topbar-end { grid-area: end; margin-left: 0; }
  .topbar:not(.simple) nav {
    grid-area: nav;
    align-items: center;
    margin: 0 -.75rem;
    padding: 0 .4rem;
    border-top: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .topbar:not(.simple) nav::-webkit-scrollbar { display: none; }
  .topbar:not(.simple) nav button { flex: 1 0 auto; justify-content: center; padding: .4rem .5rem; }
}

@media (max-width: 400px) {
  .topbar:not(.simple) nav button { padding: .4rem .3rem; font-size: .86rem; gap: .3rem; }
}

/* The smallest phones: all six sections still fit across without scrolling. */
@media (max-width: 359px) {
  .topbar:not(.simple) nav { gap: .1rem; padding: 0 .25rem; }
  .topbar:not(.simple) nav button { padding: .4rem .2rem; font-size: .8rem; gap: .2rem; }
  .topbar:not(.simple) nav .badge { padding: 0 .3rem; font-size: .7rem; }
}

/* A round button holding only an icon. */
.icon-button {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  justify-content: center;
  border-radius: 999px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.icon-button:hover { color: var(--text); background: var(--panel-2); border-color: var(--border); }
.icon-button svg { width: 1.15rem; height: 1.15rem; }

/* The theme button shows where it will take you: the sun in dark mode, the moon in light. */
[data-theme="dark"] .icon-moon,
[data-theme="light"] .icon-sun { display: none; }

/* The account button: the first letter of a name, or of the address. */
.avatar {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  justify-content: center;
  border-radius: 999px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
}
.avatar:hover { border-color: var(--accent); }

/* The account menu. It hangs from the right-hand end of the top bar's first
   row, which is in the same place at every width. */
.menu {
  position: fixed;
  inset: 3.3rem .75rem auto auto;
  margin: 0;
  width: min(17rem, calc(100vw - 1.5rem));
  padding: .35rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
}
.menu-who {
  display: grid;
  gap: .1rem;
  padding: .55rem .65rem .65rem;
  margin-bottom: .3rem;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.menu-item {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border-color: transparent;
  border-radius: 8px;
  padding: .55rem .65rem;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--panel-2); border-color: transparent; }
.menu-logout { color: var(--again); }

/*
 * A helper login: someone recording for another person's account. It has the
 * one screen, so no row of sections — just the name, whose decks, the deck
 * menu, and the theme and account buttons, on one line at every width.
 */
.role-badge {
  flex: none;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--accent-ink);
  background: var(--accent);
}
body.helper { --topbar-height: 56px; }
body.helper #nav { display: none; }
body.helper .topbar:not(.simple) { display: flex; height: 56px; gap: .6rem; padding: 0 .75rem 0 1rem; }
body.helper .topbar:not(.simple) .topbar-end { margin-left: auto; }

@media (max-width: 420px) {
  /* Room for the deck menu beside the badge on the smallest phones. */
  body.helper .brand { display: none; }
}

nav button {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  padding: .45rem .8rem;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}

nav button:hover { background: var(--panel-2); color: var(--text); }
nav button.active { background: var(--panel-2); color: var(--text); font-weight: 600; }

.badge {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 0 .45rem;
  font-size: .75rem;
  font-weight: 700;
  min-width: 1.3em;
  text-align: center;
}

main { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* ------------------------------------------------------------------ review */

.session-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.counts { display: flex; gap: .5rem; }

.chip {
  font-size: .8rem;
  padding: .3rem .65rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
}
.chip b { color: var(--text); }
.chip.new b { color: var(--new); }
.chip.due b { color: var(--easy); }
.chip.done b { color: var(--good); }

.session-controls { display: flex; gap: .5rem; align-items: center; }
.session-controls select { width: auto; margin: 0; }
.session-controls button { white-space: nowrap; }

.stage { max-width: 680px; margin: 0 auto; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  min-height: 230px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  position: relative;
}

.card-meta {
  position: absolute;
  top: .85rem;
  left: .85rem;
  right: .85rem;
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.dir-chip { font-weight: 600; }
.box-chip { color: var(--muted); }
.box-chip.is-new { color: var(--new); font-weight: 600; }

.prompt {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 600;
  line-height: 1.2;
  word-break: break-word;
  padding: .5rem 0;
}

.rule { height: 1px; background: var(--border); margin: 1.25rem 0; }

.answer-text {
  font-size: clamp(1.3rem, 3.5vw, 1.75rem);
  color: var(--accent);
  font-weight: 550;
  word-break: break-word;
}

.example { margin-top: .9rem; font-style: italic; color: var(--text); opacity: .85; }
.notes { margin-top: .5rem; color: var(--muted); font-size: .9rem; white-space: pre-wrap; }

.tags { display: flex; gap: .35rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }
.tag {
  font-size: .72rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.controls { margin-top: 1.25rem; display: flex; justify-content: center; }

/* Sized by however many ratings the server offers, not by a hard-coded count. */
.grades { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .5rem; }

.grade {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: .7rem .4rem .6rem;
  cursor: pointer;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  transition: transform .08s ease, border-color .12s ease, background .12s ease;
}
.grade:hover { transform: translateY(-1px); background: var(--panel-2); }
.grade .label { font-weight: 600; }
.grade .interval { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.grade .num {
  font-size: .68rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 .3rem;
}
.grade[data-rating="1"] { border-color: color-mix(in srgb, var(--again) 45%, var(--border)); }
.grade[data-rating="1"] .label { color: var(--again); }
.grade[data-rating="2"] { border-color: color-mix(in srgb, var(--hard) 45%, var(--border)); }
.grade[data-rating="2"] .label { color: var(--hard); }
.grade[data-rating="3"] { border-color: color-mix(in srgb, var(--good) 45%, var(--border)); }
.grade[data-rating="3"] .label { color: var(--good); }
.grade[data-rating="4"] { border-color: color-mix(in srgb, var(--easy) 45%, var(--border)); }
.grade[data-rating="4"] .label { color: var(--easy); }

.card-actions {
  margin-top: 1.25rem;
  display: flex;
  justify-content: center;
  gap: .5rem;
}

.empty { text-align: center; padding: 3rem 1rem; max-width: 480px; margin: 0 auto; }
.empty h2 { font-size: 1.5rem; }
.empty-actions { display: flex; gap: .5rem; justify-content: center; margin-top: 1.5rem; }
.empty-inline { padding: 2rem; text-align: center; }

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

button, .button {
  font: inherit;
  cursor: pointer;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: .5rem .9rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
button:hover, .button:hover { border-color: var(--muted); }
button:disabled { opacity: .4; cursor: not-allowed; }

.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.primary:hover { filter: brightness(1.07); }
.ghost { background: transparent; }
.danger { color: var(--again); border-color: color-mix(in srgb, var(--again) 40%, var(--border)); }
.big { padding: .8rem 1.6rem; font-size: 1.02rem; }
button.small, .button.small { padding: .35rem .65rem; font-size: .85rem; }

kbd {
  font: inherit;
  font-size: .74em;
  border: 1px solid currentColor;
  opacity: .55;
  border-radius: 4px;
  padding: 0 .3em;
  line-height: 1.4;
}

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

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 1.25rem; align-items: start; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

label { display: block; margin-bottom: .85rem; font-size: .85rem; color: var(--muted); }
label > span { margin-left: .35rem; font-size: .8em; }

input[type="text"], input[type="number"], input[type="search"], input[type="email"], input[type="password"], input:not([type]), textarea, select {
  display: block;
  width: 100%;
  margin-top: .3rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem .65rem;
}
textarea { resize: vertical; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88rem; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }

label.check { display: flex; align-items: center; gap: .5rem; color: var(--text); }
label.check input { width: auto; margin: 0; }

fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; margin: 0 0 .85rem; }
legend { font-size: .78rem; color: var(--muted); padding: 0 .35rem; }

.row { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.feedback { margin-top: .75rem; font-size: .87rem; border-radius: 8px; padding: .55rem .7rem; background: var(--panel-2); }
.feedback.ok { color: var(--good); }
.feedback.warn { color: var(--hard); }
.feedback.err { color: var(--again); }

/* ------------------------------------------------------------------ browse */

.toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input[type="search"] { flex: 1 1 240px; margin: 0; }
.toolbar select { width: auto; margin: 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--border); }
thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; position: sticky; top: var(--topbar-height); background: var(--panel); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
.num { text-align: center; width: 3.2rem; }
td.num { font-variant-numeric: tabular-nums; color: var(--muted); }
tr.suspended td { opacity: .45; font-style: italic; }
.row-actions { text-align: right; white-space: nowrap; }

table.mini { font-size: .8rem; margin-top: .5rem; }
table.mini th, table.mini td { padding: .3rem .5rem; text-align: center; }
table.mini tbody th { text-align: left; color: var(--muted); }

/* ------------------------------------------------------------------- stats */

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }

.metric {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
}
.metric .value { font-size: 1.7rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric .name { font-size: .78rem; color: var(--muted); margin-top: .15rem; }

.box-chart { display: flex; flex-direction: column; gap: .45rem; }
.box-row { display: grid; grid-template-columns: 4.5rem 1fr 3rem; align-items: center; gap: .6rem; font-size: .85rem; }
.box-row .bar { height: 20px; background: var(--panel-2); border-radius: 5px; overflow: hidden; }
.box-row .fill { height: 100%; background: var(--accent); border-radius: 5px; min-width: 2px; }
.box-row.is-learning .fill { background: var(--new); }
.box-row.is-learning .name { opacity: .8; }
.box-row .count { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.box-row .name { color: var(--muted); }

.history-chart { display: flex; align-items: flex-end; gap: .35rem; height: 130px; }
.history-day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .3rem; height: 100%; justify-content: flex-end; }
.history-day .stack { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; }
.history-day .correct { background: var(--good); }
.history-day .missed { background: var(--again); }
.history-day .label { font-size: .65rem; color: var(--muted); }

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

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 1.25rem;
  width: min(500px, 92vw);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(0 0 0 / 55%); }
.dialog-actions { display: flex; gap: .5rem; margin-top: 1rem; align-items: center; }

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

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .6rem 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: .88rem;
  z-index: 100;
}
.toast.err { border-color: var(--again); color: var(--again); }

/* ------------------------------------------------------------------ record */

/* One screen: the microphone, what is still to record, and what has been. */
.record-home { display: grid; gap: 1rem; max-width: 820px; margin: 0 auto; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem 1rem;
  margin-bottom: .6rem;
}
.panel-head h2 { margin: 0; }
.panel-head input[type="search"] { width: min(16rem, 100%); margin: 0; }
h2 .count { color: var(--muted); font-weight: 500; margin-left: .3rem; font-variant-numeric: tabular-nums; }
.explains { margin: 0; }
/* The space bar is only worth mentioning where there is a keyboard. */
.keys-hint { display: none; }
@media (hover: hover) and (pointer: fine) { .keys-hint { display: inline; } }

/* The microphone: one line while it works; what is wrong, and the fix, when not. */
.mic-panel { padding: .8rem 1.1rem; }
.mic-line { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .65rem; min-height: 2rem; }
.mic-icon { color: var(--muted); flex: none; }
.mic-heading { margin: 0; font-size: 1rem; }
.mic-state { color: var(--muted); font-size: .88rem; min-width: 0; overflow-wrap: anywhere; }
.mic-state.is-on { color: var(--text); }
.mic-meter { width: 6rem; }
#mic-test { margin-left: auto; }
.mic-line .mic-device { display: inline-block; width: auto; max-width: min(100%, 22rem); margin: 0; padding: .3rem .5rem; font-size: .88rem; }
.mic-problem {
  margin-top: .7rem;
  padding: .75rem .9rem;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--again) 45%, var(--border));
  background: color-mix(in srgb, var(--again) 7%, var(--panel));
}
.mic-problem-says { margin: 0 0 .3rem; font-weight: 600; color: var(--again); }
.mic-problem-hint { margin: 0; font-size: .87rem; color: var(--muted); overflow-wrap: anywhere; }
.mic-problem-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .65rem; font-size: .87rem; }

/* A live level: a bar scaled by how loud the microphone is. A muted
   microphone and a quiet room look the same until the take is played back,
   so the signal shows while it is happening. */
.meter { display: inline-block; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; flex: none; }
.meter-bar {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--good);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .06s linear;
}

/* The lists. A row is the word, what is happening to it, and its buttons;
   on wider screens the columns line up from one row to the next. */
.word-list {
  list-style: none;
  margin: .6rem 0 0;
  padding: 0;
  max-height: min(60vh, 36rem);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-content: start;
}
.word-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  column-gap: .75rem;
  padding: .45rem .7rem .45rem .8rem;
  min-height: 3rem;
}
@supports not (grid-template-columns: subgrid) {
  .word-row { grid-template-columns: minmax(0, 1fr) auto auto; }
}
.word-row + .word-row { border-top: 1px solid var(--border); }
.word-text { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 1rem; min-width: 0; }
.word-front { font-weight: 600; overflow-wrap: anywhere; }
.word-back { color: var(--muted); overflow-wrap: anywhere; }

.word-status { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; max-width: 15rem; }
.word-note { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.word-note.ok { color: var(--good); }
.word-note.warn { color: var(--hard); }
.word-note.err { color: var(--again); }
.word-note.is-live { display: inline-flex; align-items: center; gap: .35rem; color: var(--again); font-weight: 600; }
.word-note.is-live::before {
  content: "";
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--again);
  animation: pulse 1s ease-in-out infinite;
}
.word-meter { width: 4.5rem; }

.word-actions { display: flex; align-items: center; justify-content: flex-end; gap: .35rem; }
.word-actions button { white-space: nowrap; }
.word-actions .mark { display: inline-flex; }
/* Delete is there when wanted, not shouting from every row. */
.delete-button { color: var(--muted); }
.delete-button:hover { color: var(--again); border-color: color-mix(in srgb, var(--again) 45%, var(--border)); }
.delete-button .label { display: none; }

/* Record is a red dot; Stop, a white square on red. The next word to do
   has the solid button, so the eye knows where to go. */
.record-button .mark { width: .6rem; height: .6rem; border-radius: 50%; background: var(--again); flex: none; }
.record-button.is-busy .mark { display: none; }
.record-button.is-busy { opacity: .7; cursor: progress; }
.record-button.is-stop { background: var(--again); color: #fff; border-color: transparent; font-weight: 600; }
.record-button.is-stop .mark { border-radius: 2px; background: #fff; }
.word-row.is-next .record-button.is-record {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}

.word-row.is-next { box-shadow: inset 3px 0 0 var(--accent); }
.word-row.is-recording {
  background: color-mix(in srgb, var(--again) 10%, transparent);
  box-shadow: inset 3px 0 0 var(--again);
}
.word-row.is-ticked .word-front::before { content: "✓"; color: var(--good); font-weight: 700; margin-right: .4rem; }

/* While one word records, every other button in the lists rests: another
   Record would be ambiguous, and a Play would be recorded. And on a page that
   cannot record at all, no Record button pretends otherwise. */
.record-home.is-recording .word-row:not(.is-recording) .word-actions button,
.record-home.cannot-record .record-button {
  opacity: .35;
  pointer-events: none;
}

@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) {
  .word-note.is-live::before { animation: none; }
  .meter-bar { transition: none; }
}

/* On a phone the meaning goes under the word. A lone Record button stays
   beside them; two or more buttons get a line of their own underneath, next
   to what is happening, so the words keep the full width. Play and Cancel
   become icons there. */
@media (max-width: 560px) {
  .word-list { display: block; }
  .word-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: .35rem; column-gap: .6rem; }
  .word-text { grid-template-columns: minmax(0, 1fr); grid-column: 1; grid-row: 1; }
  .word-actions { grid-column: 2; grid-row: 1; }
  .word-status { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; max-width: none; }
  .word-status.is-empty { display: none; }
  .word-row.has-many .word-text { grid-column: 1 / -1; }
  .word-row.has-many .word-status { grid-column: 1; }
  .word-row.has-many .word-actions { grid-column: 2; grid-row: 2; }
  .play-button .label, .cancel-button .label { display: none; }
}

/* Thumbs need bigger targets than pointers do. */
@media (pointer: coarse) {
  .word-actions button { min-height: 2.6rem; min-width: 2.6rem; justify-content: center; }
}

/* The microphone check page's level bar. */
.level {
  margin: 1.25rem auto 0;
  width: 60%;
  height: 6px;
  border-radius: 3px;
  background: var(--panel-2);
  overflow: hidden;
}
.level-bar {
  height: 100%;
  width: 0%;
  background: var(--good);
  border-radius: 3px;
  transition: width .06s linear;
}

.play-cell { padding: .1rem .45rem; line-height: 1.2; }

.edit-audio {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin: .75rem 0 0;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

.diag {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .25rem .75rem;
  margin: .6rem 0 0;
  font-size: .82rem;
}
.diag dt { color: var(--muted); }
.diag dd { margin: 0; font-variant-numeric: tabular-nums; }
.diag dd.bad { color: var(--again); }
.diag dd.good { color: var(--good); }

/* Read by screen readers, not shown: "Recording …", "Saved …". */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------------------------------------------- deck switcher */

#deck-switcher {
  width: auto;
  margin: 0;
  padding: .3rem 1.6rem .3rem .6rem;
  font-size: .9rem;
  background: var(--panel-2);
  border-radius: 999px;
  max-width: 11rem;
}

.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }

@media (max-width: 560px) {
  #deck-switcher { max-width: 9rem; }
  .cols-2 { grid-template-columns: 1fr; }
}

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

/* One column of short sections. Wide screens get no more columns: a settings
   page is read top to bottom, and side-by-side panels made it look like more. */
.settings { max-width: 720px; margin: 0 auto; display: grid; gap: 1rem; }
.settings .panel > h2 { margin-bottom: .3rem; }
.settings .panel > p { margin-bottom: .75rem; }
.deck-name { color: var(--muted); font-weight: 500; }

/* A setting is a line: what it is on the left, its control on the right. When
   there is not room for both, the control drops underneath. */
.settings-form > .setting,
.settings-form > label.check { margin: 0; padding: .65rem 0; }
.settings-form > * + * { border-top: 1px solid var(--border); }
.settings-form > .row { border-top: 0; margin-top: .75rem; }

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem 1rem;
}
.setting > label,
.setting-name { margin: 0; color: var(--text); font-size: .95rem; }
.setting > label > span { display: block; margin: .1rem 0 0; font-size: .8rem; }
.setting input[type="number"] { width: 6.5rem; margin: 0; text-align: right; }
.setting select { width: auto; margin: 0; }

.settings-form label.check { font-size: .95rem; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; }
.checks label.check { margin: 0; }
.checks label.check > span { margin: 0; font-size: inherit; }

/* Three choices side by side, the chosen one filled in. Real radio buttons
   underneath, so the arrow keys and screen readers work as they always do. */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
}
.segmented label { position: relative; margin: 0; font-size: .88rem; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.segmented span {
  display: block;
  margin: 0;
  padding: .35rem .85rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.segmented label:hover span { color: var(--text); }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }

/* "More options" and the like: shut until wanted. */
details.more { border-top: 1px solid var(--border); margin-top: .75rem; }
.settings-form > details.more { margin-top: 0; }
details.more > summary {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .65rem 0;
  color: var(--muted);
  font-size: .92rem;
  cursor: pointer;
  list-style: none;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before {
  content: "";
  width: .45rem;
  height: .45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s ease;
}
details.more[open] > summary::before { transform: rotate(45deg); }
details.more > summary:hover,
details.more[open] > summary { color: var(--text); }
details.more[open] { padding-bottom: .5rem; }
details.more > :not(summary) { margin-left: 1rem; }
details.more > label.check { margin-top: .25rem; margin-bottom: .85rem; }
details.more > .setting { padding: .25rem 0 .5rem; }

@media (prefers-reduced-motion: reduce) {
  details.more > summary::before { transition: none; }
}

.deck-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.deck-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  padding: .65rem .85rem;
}
.deck-row + .deck-row { border-top: 1px solid var(--border); }
.deck-row.current { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.deck-title { font-weight: 600; }
.deck-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.deck-list .here {
  font-size: .7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-left: .5rem;
  font-weight: 600;
}

#import-file { margin: .25rem 0 0; }

/* ------------------------------------------------------------ prose cards */

.prompt.prose {
  font-size: clamp(1.1rem, 2.6vw, 1.4rem);
  font-weight: 550;
  line-height: 1.4;
  text-align: left;
}

.answer-text.prose {
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  font-weight: 450;
  line-height: 1.55;
  text-align: left;
  color: var(--text);
}

/* A card holding prose needs room to breathe and a left edge to start from. */
.card:has(.prose) { text-align: left; }
.card:has(.prose) .tags { justify-content: flex-start; }

/* ------------------------------------------------------------ sign-in pages */

/* One narrow card in the middle of the screen: nothing to read around it,
   nothing to navigate to until you are in. */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-page main.auth { width: 100%; max-width: 420px; margin: 0; padding: 0; }

.auth-brand {
  display: block;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent);
  text-align: center;
  text-decoration: none;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}
.auth-brand:hover { text-decoration: underline; }
.auth-theme { position: fixed; top: .75rem; right: .75rem; }

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.auth-card h1 { font-size: 1.35rem; margin: 0 0 1rem; }
.auth-card form .primary.big { width: 100%; justify-content: center; margin-top: .25rem; }
.auth-card a:not(.button) { color: var(--accent); }
.auth-card code { font-size: .85em; }
.auth-links { margin: 1.1rem 0 0; font-size: .88rem; color: var(--muted); text-align: center; }

/* ----------------------------------------------------------------- welcome */

/* The home page for someone not signed in: what this is, a picture of a card,
   and the two ways in. */
.welcome-page { min-height: 100vh; display: flex; flex-direction: column; }
.welcome-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem clamp(1rem, 4vw, 2.5rem);
}
.welcome-bar .brand { font-size: 1.15rem; }
.welcome-bar-end { display: flex; align-items: center; gap: .5rem; }

.welcome {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 4rem) clamp(1rem, 4vw, 2.5rem) 4rem;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.1;
  letter-spacing: -.01em;
  margin: 0 0 1rem;
}
.lede { font-size: clamp(1.02rem, 1.6vw, 1.15rem); color: var(--muted); max-width: 34rem; margin-bottom: 1.75rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
#welcome-invite { margin-top: .9rem; }

.hero-card { display: grid; gap: .75rem; }
.sample-card { min-height: 0; padding: 2.5rem 1.5rem 1.6rem; }
.sample-grades .grade { cursor: default; }
.sample-grades .grade:hover { transform: none; background: var(--panel); }

.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: clamp(2.5rem, 7vw, 5rem);
}
.feature {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.feature h2 { font-size: 1rem; margin-bottom: .4rem; }
.feature p { color: var(--muted); margin: 0; font-size: .93rem; }

@media (max-width: 820px) {
  .hero, .features { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------------------- tour */

/* driver.js draws the tour; these rules dress its popover in the app's own
   colours so it follows the dark and light themes like everything else. */
.driver-popover.anki-tour {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: var(--font);
  max-width: 340px;
  padding: 1.1rem 1.1rem .95rem;
}
.driver-popover.anki-tour .driver-popover-title { font-size: 1.05rem; font-weight: 650; color: var(--text); }
.driver-popover.anki-tour .driver-popover-description { color: var(--muted); font-size: .92rem; line-height: 1.55; margin-top: .35rem; }
.driver-popover.anki-tour .driver-popover-description b { color: var(--text); font-weight: 600; }
.driver-popover.anki-tour .driver-popover-progress-text { color: var(--muted); font-size: .8rem; }
.driver-popover.anki-tour .driver-popover-close-btn { color: var(--muted); }
.driver-popover.anki-tour .driver-popover-close-btn:hover { color: var(--text); }
.driver-popover.anki-tour .driver-popover-footer button {
  font: inherit;
  font-size: .85rem;
  text-shadow: none;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .35rem .85rem;
}
.driver-popover.anki-tour .driver-popover-footer .driver-popover-next-btn {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}
/* The arrow is a border triangle: only the side facing the target is coloured. */
.driver-popover.anki-tour .driver-popover-arrow-side-left { border-left-color: var(--panel); }
.driver-popover.anki-tour .driver-popover-arrow-side-right { border-right-color: var(--panel); }
.driver-popover.anki-tour .driver-popover-arrow-side-top { border-top-color: var(--panel); }
.driver-popover.anki-tour .driver-popover-arrow-side-bottom { border-bottom-color: var(--panel); }

/* Shown until a temporary password has been replaced. */
.notice-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .6rem 1.25rem;
  font-size: .9rem;
  background: color-mix(in srgb, var(--hard) 14%, var(--panel));
  border-bottom: 1px solid color-mix(in srgb, var(--hard) 45%, var(--border));
}
