/*
 * Desk Light.
 *
 * Compact and cool: soft-shadowed white cards on a blue-grey ground. Every
 * colour, radius, shadow and size is a token here, so the light and dark sets
 * swap in one place and nothing downstream hard-codes a value.
 *
 * Three theme states, deliberately: no data-theme means follow the device,
 * data-theme="light" and data-theme="dark" are the reader's own choice and
 * must beat the device setting in both directions.
 */

:root {
  color-scheme: light;

  --bg: #eef1f5;
  --panel: #ffffff;
  --raised: #ffffff;
  --ink: #101623;
  --muted: #59617a;
  --line: #d6dbe4;
  --accent: #2a5bd7;
  --accent-ink: #ffffff;

  /* What you said, and the word being spoken aloud. */
  --user: #e7edfb;
  --user-ink: #101623;
  --ai: #ffffff;
  --mark: #d8e4ff;

  --error: #a52a1f;
  --error-bg: #fbeceb;

  /* A correction is a white card with an accent edge, not a warning colour.
     It is shown often, and red or amber every time would read as scolding. */
  --fix-bg: #ffffff;
  --fix-line: #d6dbe4;
  --fix-accent: #2a5bd7;
  --fix-badge: #e7edfb;
  --badge-ink: #1f4bb5;
  --fix-ink: #0f6b45;

  --shadow-1: 0 1px 2px rgb(16 22 35 / 8%);
  --shadow-2: 0 10px 28px -12px rgb(16 22 35 / 28%);
  --shadow-tab: 0 1px 2px rgb(16 22 35 / 12%);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-pill: 999px;

  /* Larger than the 14px the controls use, because this is the text you read
     along with while it is spoken — but only just. At 19px it towered over the
     buttons and selects beside it and read as a different application. */
  --text-transcript: 16px;
  --mic-size: 92px;
  --reading-width: 880px;

  /* Chart series: the Okabe-Ito set, separable for deuteran, protan and
     tritan readers. Three of these fall below 3:1 on white, so every chart
     also prints its value as text. */
  --series-1: #0072b2;
  --series-2: #e69f00;
  --series-3: #009e73;
  --series-4: #cc79a7;
  --series-5: #d55e00;
  --series-6: #56b4e9;
  --chart-other: #8b93a5;

  /* One hue, light to dark, for "how much practice on this day". */
  --chart-empty: #e2e7ef;
  --heat-1: #bcd0f6;
  --heat-2: #82a5ea;
  --heat-3: #4b7ede;
  --heat-4: #2a5bd7;
}

/*
 * Dark is its own set of steps, not an inversion. Cards lift by becoming
 * lighter than the ground, since a shadow cannot be seen against black.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0e1218;
    --panel: #171d26;
    --raised: #1f2833;
    --ink: #e6ebf2;
    --muted: #9aa5b8;
    --line: #2a3341;
    --accent: #83a9ff;
    --accent-ink: #0e1218;

    --user: #1c2c4d;
    --user-ink: #e6ebf2;
    --ai: #1f2833;
    --mark: #2f4570;

    --error: #ff9c90;
    --error-bg: #2a1a18;

    --fix-bg: #171d26;
    --fix-line: #2a3341;
    --fix-accent: #83a9ff;
    --fix-badge: #22304a;
    --badge-ink: #a8c3ff;
    --fix-ink: #6fdaa6;

    --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-2: 0 10px 28px -12px rgb(0 0 0 / 70%);
    --shadow-tab: 0 1px 2px rgb(0 0 0 / 45%);

    /* The design's own dark series failed the colourblind and chroma checks,
       so these are a validated set stepped for this surface instead. */
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --chart-other: #5a6473;

    --chart-empty: #1c232d;
    --heat-1: #26374f;
    --heat-2: #33507a;
    --heat-3: #4a71b0;
    --heat-4: #83a9ff;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e1218;
  --panel: #171d26;
  --raised: #1f2833;
  --ink: #e6ebf2;
  --muted: #9aa5b8;
  --line: #2a3341;
  --accent: #83a9ff;
  --accent-ink: #0e1218;

  --user: #1c2c4d;
  --user-ink: #e6ebf2;
  --ai: #1f2833;
  --mark: #2f4570;

  --error: #ff9c90;
  --error-bg: #2a1a18;

  --fix-bg: #171d26;
  --fix-line: #2a3341;
  --fix-accent: #83a9ff;
  --fix-badge: #22304a;
  --badge-ink: #a8c3ff;
  --fix-ink: #6fdaa6;

  --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-2: 0 10px 28px -12px rgb(0 0 0 / 70%);
  --shadow-tab: 0 1px 2px rgb(0 0 0 / 45%);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --chart-other: #5a6473;

  --chart-empty: #1c232d;
  --heat-1: #26374f;
  --heat-2: #33507a;
  --heat-3: #4a71b0;
  --heat-4: #83a9ff;
}

* {
  box-sizing: border-box;
}

/* Several elements here set display, which would otherwise beat [hidden]. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/*
 * Three zones: title left, tabs centred, actions right.
 *
 * Grid rather than flex, because the tabs must sit in the middle of the
 * window, not in the middle of whatever space the title and buttons leave
 * over. The two 1fr columns are equal whatever they hold, so the centre column
 * lands on the true centre; minmax(0, …) lets them shrink instead of pushing
 * the tabs off-centre when the title or the buttons get wide.
 */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 20px;
  background: var(--panel);
  box-shadow: var(--shadow-1);
  /* Above the scrolling panes, so its shadow falls on them. */
  position: relative;
  z-index: 5;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.topbar .ghost {
  min-height: 44px;
}

/* A shadow is invisible against a dark ground, so the bar takes a hairline
   instead — the same separation by a different means. */
:root[data-theme="dark"] .topbar {
  border-bottom: 1px solid var(--line);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar {
    border-bottom: 1px solid var(--line);
  }
}

/* A square button holding one glyph: the theme switch. */
.icon-button {
  width: 44px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
}

.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}

.conversation {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: var(--reading-width);
  width: 100%;
  margin: 0 auto;
}

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

/* Transcript type stays large: it is read while speaking out loud. */
.turn {
  max-width: 74%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: var(--text-transcript);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.turn.user {
  align-self: flex-end;
  background: var(--user);
  color: var(--user-ink);
}

.turn.ai {
  align-self: flex-start;
  background: var(--ai);
  box-shadow: var(--shadow-1);
}

.turn.error {
  align-self: flex-start;
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error);
  font-size: 15px;
}

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

.corrections {
  align-self: flex-end;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 74%;
}

.correction {
  padding: 10px 14px;
  background: var(--fix-bg);
  border-left: 3px solid var(--fix-accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  font-size: 16px;
}

/* The header is a button, but it should read as part of the card. */
.correction-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0;
  font: inherit;
  text-align: left;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

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

.correction-hint {
  font-size: 13px;
  color: var(--muted);
}

/* Closed, the card is only its badge: shorter, and level with the bubble. */
.correction.closed {
  padding-top: 4px;
  padding-bottom: 4px;
}

.correction .badge {
  display: inline-block;
  padding: 4px 8px;
  font: 600 11px/1 ui-monospace, Menlo, monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--badge-ink);
  background: var(--fix-badge);
  border-radius: 4px;
}

.correction .fix {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.correction .fix s {
  color: var(--muted);
  text-decoration-thickness: 1px;
}

.correction .fix strong {
  color: var(--fix-ink);
}

.correction .why {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.live {
  max-width: var(--reading-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 8px;
  color: var(--muted);
  font-style: italic;
}

.live-label {
  font-style: normal;
  font-weight: 600;
  margin-right: 6px;
}

.status {
  max-width: var(--reading-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 22px;
  font-size: 14px;
  color: var(--muted);
}

.status.error {
  color: var(--error);
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 20px;
  background: var(--panel);
  box-shadow: 0 -1px 2px rgb(16 22 35 / 8%);
}

:root[data-theme="dark"] .controls {
  box-shadow: 0 -1px 2px rgb(0 0 0 / 40%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .controls {
    box-shadow: 0 -1px 2px rgb(0 0 0 / 40%);
  }
}

/* The one thing that dominates this screen. The button itself is invisible;
   the circle inside it is the object, with the label sitting underneath. */
.mic {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
}

.mic:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mic-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--mic-size);
  height: var(--mic-size);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--shadow-2);
  transition: background 0.15s;
}

.mic-icon::after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-ink);
}

.mic[aria-pressed="true"] .mic-icon {
  background: var(--error);
}

/* Pulses only while recording, so the recording state is obvious at a glance. */
.mic[aria-pressed="true"] .mic-icon::after {
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(1.35);
  }
}

.audio-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  font-size: 13px;
  color: var(--muted);
}

.audio-row .ghost,
.audio-row .toggle {
  min-height: 44px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.audio-row select {
  padding: 7px 8px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 220px;
}

.audio-row .ghost {
  padding: 6px 12px;
  font-size: 14px;
}

/* Marks the reply currently being read aloud. */
.turn.speaking {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.turn mark {
  background: var(--mark);
  color: var(--ink);
  border-radius: 3px;
  padding: 0 2px;
}

.typed {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 560px;
}

.typed input {
  flex: 1;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: inherit;
}

.typed input:focus-visible,
.mic:focus-visible,
.ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.ghost:hover {
  background: var(--bg);
}

@media (prefers-reduced-motion: reduce) {
  .mic[aria-pressed="true"] .mic-icon::after {
    animation: none;
  }
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--bg);
  border-radius: var(--radius-pill);
}

.tab {
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.tab[aria-selected="true"] {
  color: var(--ink);
  background: var(--panel);
  font-weight: 600;
  box-shadow: var(--shadow-tab);
}

/* In dark the card is lighter than the ground, not shadowed. */
:root[data-theme="dark"] .tab[aria-selected="true"] {
  background: var(--raised);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tab[aria-selected="true"] {
    background: var(--raised);
  }
}

/* ---------- report ---------- */

.report {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

/*
 * Panels sit in two columns on a wide screen. The mistake log and the heatmap
 * run full width: both are long, and halving them would only add scrolling.
 */
@media (min-width: 900px) {
  #report-body {
    display: grid;
    /* minmax(0, ...) or a wide chart inside a column sets that column's
       minimum and the two stop being equal. */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }

  #report-body > .tiles,
  #report-body > .panel.wide {
    grid-column: 1 / -1;
  }

  #report-body > .panel {
    margin-bottom: 0;
  }
}

.report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.report-head h2 {
  margin: 0;
  font-size: 20px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: var(--panel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}

.tile-value {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
}

.tile-name {
  font-size: 12px;
  color: var(--muted);
}

.panel {
  margin-bottom: 16px;
  padding: 18px;
  background: var(--panel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h3 {
  margin: 0;
}

.panel-head select {
  padding: 6px 8px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.bars,
.recurring,
.log {
  margin: 0;
  padding: 0;
  list-style: none;
}

.bars li + li {
  margin-top: 10px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 4px;
}

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

.bar-track {
  height: 6px;
  background: var(--bg);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.recurring li,
.log li {
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.recurring li:first-child,
.log li:first-child {
  border-top: none;
}

.log-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.log-meta .when,
.recurring .times {
  font-size: 12px;
  color: var(--muted);
}

.panel .badge {
  display: inline-block;
  padding: 4px 8px;
  font: 600 11px/1 ui-monospace, Menlo, monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--badge-ink);
  background: var(--fix-badge);
  border-radius: 4px;
}

.panel .fix {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.panel .fix s {
  color: var(--muted);
}

.panel .fix strong {
  color: var(--fix-ink);
}

.panel .why {
  margin: 4px 0 0;
  color: var(--muted);
}

.panel .said {
  margin: 6px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.trend {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 150px;
  overflow-x: auto;
}

.trend-col {
  display: flex;
  flex: 1;
  min-width: 40px;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.trend-bar {
  width: 100%;
  max-width: 40px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
}

.trend-value,
.trend-date {
  font-size: 11px;
  color: var(--muted);
}

/*
 * Too narrow for three zones side by side: the title takes the first row with
 * the buttons, and the tabs get a full row of their own underneath.
 */
@media (max-width: 720px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 8px;
  }

  .topbar h1 {
    grid-row: 1;
    grid-column: 1;
  }

  .topbar-actions {
    grid-row: 1;
    grid-column: 2;
  }

  .tabs {
    grid-row: 2;
    grid-column: 1 / -1;
    /* Centred, and only as wide as the three pills: a stretched pill group
       would draw one long bar across the window. */
    justify-self: center;
  }

  /* Thumbs need a bigger target than a cursor does. */
  .tab {
    min-height: 44px;
  }
}

/*
 * A phone cannot hold the title and three buttons on one line: at 375px the
 * buttons alone take most of the width, and the app name was being cut off
 * mid-word behind them. Each zone gets its own row instead.
 */
@media (max-width: 620px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 6px;
    padding-bottom: 10px;
  }

  .topbar h1 {
    grid-row: 1;
    grid-column: 1;
    font-size: 15px;
  }

  .tabs {
    grid-row: 2;
    grid-column: 1;
  }

  .topbar-actions {
    grid-row: 3;
    grid-column: 1;
  }
}

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

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.field-row input,
.field-row select {
  flex: 1;
  min-width: 200px;
  min-height: 44px;
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ghost.danger {
  margin-top: 10px;
  color: var(--error);
  border-color: var(--line);
}

.hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.key-status {
  margin: 0 0 12px;
  font-size: 14px;
}

.pill {
  display: inline-block;
  padding: 1px 8px;
  margin-right: 6px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
}

.pill.ok {
  color: var(--fix-ink);
  background: var(--fix-badge);
}

.pill.warn {
  color: var(--badge-ink);
  background: var(--fix-badge);
}

.settings-note {
  margin: 0 0 12px;
  min-height: 20px;
  font-size: 14px;
  color: var(--muted);
}

.settings-note.ok {
  color: var(--fix-ink);
}

.settings-note.error {
  color: var(--error);
}

.usage-head {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.bar-fill.warn {
  background: var(--series-2);
}

.bar-fill.danger {
  background: var(--error);
}

.day-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.day-list li {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.day-list li:first-child {
  border-top: none;
}

/* ---------- session bar and summary ---------- */

.session-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: 12px 20px 0;
}

.picker {
  display: inline-flex;
}

.session-bar select {
  min-height: 44px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.session-bar select:disabled,
.session-bar button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.session-bar #end-session {
  margin-left: auto;
  min-height: 44px;
  padding: 7px 12px;
  font-size: 13px;
}

.summary {
  align-self: stretch;
  margin-top: 8px;
  padding: 18px;
  background: var(--panel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}

.summary h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

.summary-stats dt {
  font-size: 12px;
  color: var(--muted);
}

.summary-stats dd {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 600;
}

.summary-line {
  margin: 6px 0 0;
  font-size: 14px;
}

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

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

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 32px 16px;
  background: var(--bg);
}

.auth-panel {
  width: 100%;
  max-width: 460px;
  text-align: center;
}

.auth-panel h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.auth-intro {
  margin: 0 auto 20px;
  max-width: 380px;
  color: var(--muted);
  font-size: 14px;
}

.auth-tabs {
  display: inline-flex;
  gap: 3px;
  margin-bottom: 16px;
  padding: 3px;
  background: var(--panel);
  box-shadow: var(--shadow-1);
  border-radius: var(--radius-pill);
}

#clerk-sign-in,
#clerk-sign-up {
  display: flex;
  justify-content: center;
}

.auth-error {
  margin-top: 16px;
  color: var(--error);
  font-size: 14px;
}

/* ---------- get an API key ---------- */

.get-key {
  margin: 0 0 14px;
  padding: 14px;
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.get-key-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

a.get-key-button {
  display: inline-block;
  text-decoration: none;
}

a.get-key-button:hover {
  filter: brightness(1.08);
}

.get-key .hint {
  margin-top: 8px;
}

/* ---------- model warning ---------- */

.model-warning {
  margin-top: 12px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border-left: 3px solid var(--fix-accent);
  border-radius: var(--radius-sm);
}

.model-warning p {
  margin: 0;
}


/* A refetch dims what is already on screen instead of replacing it. */
#report-body.busy {
  opacity: 0.55;
  pointer-events: none;
}

/* ---------- charts ---------- */

.type-split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 24px;
}

.donut {
  width: 180px;
  height: 180px;
  flex: none;
}

.donut-total {
  font-size: 30px;
  font-weight: 700;
  fill: var(--ink);
}

.donut-caption {
  font-size: 12px;
  fill: var(--muted);
}

.type-split .bars {
  flex: 1 1 220px;
  min-width: 200px;
}

.bar-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

/* Its own natural width, so the squares stay square and the strip scrolls on
   a narrow screen rather than stretching to fit. */
.heatmap {
  display: block;
  flex: none;
}

.heat-label {
  font-size: 9px;
  fill: var(--muted);
}

.heat-cell.clickable {
  cursor: pointer;
}

.heat-cell.clickable:hover {
  stroke: var(--ink);
  stroke-width: 1.5;
}

.heat-cell.picked {
  stroke: var(--accent);
  stroke-width: 2;
}

.heat-key {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
}

.heat-key .hint {
  margin: 0;
}

.heat-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* ---------- date filter ---------- */

.log-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.date-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}

.date-button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.chip-clear {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.chip-clear:hover {
  color: var(--error);
  border-color: var(--error);
}

.calendar {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 268px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.calendar-month {
  font-weight: 600;
}

.calendar-step {
  padding: 2px 10px;
  font-size: 18px;
  line-height: 1.2;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendar-weekday {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding-bottom: 4px;
}

.calendar-blank {
  height: 32px;
}

.calendar-day {
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  position: relative;
}

.calendar-day:disabled {
  color: var(--muted);
  opacity: 0.45;
  cursor: default;
}

/* A dot marks a day you practised, so the shape of the month is readable
   before anything is clicked. */
.calendar-day.has-mistakes::after,
.calendar-day.clean::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.calendar-day.has-mistakes::after {
  background: var(--series-5);
}

.calendar-day.clean::after {
  background: var(--fix-ink);
}

.calendar-day:not(:disabled):hover {
  background: var(--ai);
}

.calendar-day.picked {
  background: var(--user);
}

.calendar-day.edge {
  background: var(--accent);
  color: var(--accent-ink);
}

.calendar-day.edge::after {
  background: #ffffff;
}

.calendar-day.pending {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.calendar-hint {
  margin: 10px 0 8px;
  font-size: 12px;
  color: var(--muted);
}

.calendar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.calendar-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}

.calendar-legend .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.calendar-legend .dot.has-mistakes {
  background: var(--series-5);
}

.calendar-legend .dot.clean {
  background: var(--fix-ink);
}

/* On a phone the button sits mid-row, so a popover anchored to it hangs off
   the screen. There it drops below the whole header instead. */
@media (max-width: 560px) {
  .panel-head {
    position: relative;
  }

  .date-picker {
    position: static;
  }

  .calendar {
    left: 0;
    right: 0;
    width: auto;
  }
}

/* ---------- voices ---------- */

.voice-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.voice-button-face {
  display: inline-flex;
  line-height: 0;
}

.voice-button-face .avatar {
  border-radius: 50%;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgb(16 22 35 / 55%);
}

.modal-panel {
  width: min(680px, 100%);
  max-height: 82vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 20px 22px 24px;
  box-shadow: var(--shadow-2);
}

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

.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.modal-close {
  font-size: 20px;
  line-height: 1;
  padding: 2px 10px;
}

.modal-note {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.voice-group + .voice-group {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.voice-group-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.voice-group-note {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.voice-group-note.error {
  color: var(--error);
}

.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 12px;
}

.voice-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}

.voice-tile:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-1);
  transform: translateY(-2px);
}

.voice-tile.picked {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.voice-face {
  line-height: 0;
}

.voice-face .avatar {
  border-radius: 50%;
  display: block;
}

/* A photograph and a drawn face share the class, so both crop to the circle.
   object-fit stops a portrait that is not perfectly square from squashing. */
img.avatar {
  object-fit: cover;
  background: var(--bg);
}

.voice-name {
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  overflow-wrap: anywhere;
}

.voice-detail {
  font-size: 11px;
  color: var(--muted);
}

/* While the model downloads, the tiles stay visible but cannot be picked:
   removing them would make the window jump and hide what is being waited for. */
.voice-grid.waiting .voice-tile {
  opacity: 0.5;
  pointer-events: none;
}

.voice-progress {
  height: 4px;
  margin: 0 0 14px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.voice-progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s;
}
