:root {
  color-scheme: light;

  /* Palette — neutral with the faintest hint of warmth, never yellow */
  --bg:           #f6f5f2;
  --surface-1:    #f6f5f2;
  --surface-2:    #ffffff;
  --surface-3:    #fcfbf8;
  --surface-soft: #ecebe6;

  --ink:        #1a1815;
  --ink-strong: #060503;
  --ink-soft:   #463f37;
  --ink-muted:  #847d72;
  --ink-faint:  #c3bcaf;

  --rule:        rgba(26, 24, 21, 0.07);
  --rule-strong: rgba(26, 24, 21, 0.16);

  --shadow-soft:  0 1px 2px rgba(26, 24, 21, 0.04), 0 8px 24px -16px rgba(26, 24, 21, 0.12);
  --shadow-card:  0 1px 2px rgba(26, 24, 21, 0.05), 0 14px 36px -22px rgba(26, 24, 21, 0.16);
  --shadow-paper: 0 1px 1px rgba(26, 24, 21, 0.04), 0 32px 64px -36px rgba(26, 24, 21, 0.18);

  --serif: "Newsreader", "Iowan Old Style", "New York", Georgia, "Times New Roman", serif;
  --sans:  "Inter", "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;

  --radius:    8px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  font-family: var(--sans);
  font-feature-settings: "kern", "ss01";
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 360ms ease;
}

body.is-training {
  background: radial-gradient(ellipse 70% 60% at 50% 30%, #ffffff 0%, var(--bg) 90%);
  overflow: hidden;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}
button {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
h1, h2, h3, p { margin: 0; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 3px;
}

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 320ms ease;
}
body.is-training .app-shell {
  grid-template-columns: 1fr;
  min-height: 100dvh;
}
body.is-training .sidebar {
  display: none;
}

/* ─── Sidebar ───────────────────────────────────────── */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 36px;
  padding: 32px 18px 20px;
  border-right: 1px solid var(--rule);
  background: transparent;
  transition: opacity 240ms ease, transform 320ms ease;
  overflow: hidden;
}

.brand {
  display: grid;
  gap: 10px;
  padding: 4px 10px 0;
  justify-items: start;
}
.brand-mark {
  height: 38px;
  width: auto;
  display: block;
  opacity: 0.92;
}
.brand-word {
  height: 14px;
  width: auto;
  display: block;
  opacity: 0.84;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 2px;
}
.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background 160ms ease, color 160ms ease;
}
.nav-button .icon { width: 16px; height: 16px; }
.nav-button:hover,
.nav-button.active {
  background: rgba(24, 22, 18, 0.04);
  color: var(--ink);
}
.nav-button.action {
  margin-top: 14px;
  background: var(--ink);
  color: var(--surface-2);
}
.nav-button.action:hover { background: var(--ink-strong); color: var(--surface-2); }

.side-foot {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 12px 4px;
  color: var(--ink-muted);
  font-size: 11.5px;
}
.side-foot-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.side-foot-line .dot { color: var(--ink-faint); }
.side-foot-line small {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.side-foot-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}
.link-button {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
  transition: color 160ms ease;
}
.link-button:hover { color: var(--ink); }

.side-account {
  display: grid;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.signin-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-soft);
  transition: background 160ms ease, border-color 160ms ease;
}
.signin-button:hover { background: var(--surface-3); }
.google-g { flex: none; }
.account-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.account-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: var(--surface-soft);
}
.account-meta {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.account-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-info .link-button { justify-self: start; }
#sync-status[data-sync="saving"] { color: var(--ink-muted); }
#sync-status[data-sync="synced"] { color: #3b7d4f; }
#sync-status[data-sync="error"]  { color: #b3402f; }

/* ─── Workspace ─────────────────────────────────────── */

.workspace {
  min-width: 0;
  padding: 56px 64px 80px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}
body.is-training .workspace {
  padding: 24px 32px;
  max-width: none;
  height: 100dvh;
  display: grid;
}

.view { min-height: calc(100vh - 140px); }
.training-view.view { min-height: 0; }

.workspace-head,
.training-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
}
.workspace-head:has(.icon-button:first-child),
.training-head {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}
.training-head {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 14px;
}

.head-title { min-width: 0; }

.eyebrow {
  margin-bottom: 8px;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

h2 {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-variant-numeric: oldstyle-nums;
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 430;
  line-height: 1.05;
  letter-spacing: -0.018em;
  color: var(--ink-strong);
}

h3 {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.muted {
  margin-top: 10px;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 400;
}

/* ─── Library ───────────────────────────────────────── */

.library-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.sort-tabs {
  display: flex;
  gap: 2px;
}
.sort-tab {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  padding: 6px 10px;
  border-radius: 4px;
  transition: color 160ms ease, background 160ms ease;
}
.sort-tab:hover { color: var(--ink-soft); }
.sort-tab.active {
  color: var(--ink);
  background: rgba(24, 22, 18, 0.05);
}

.search-shell {
  width: 260px;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-muted);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}
.search-shell:focus-within {
  border-color: var(--ink-soft);
  background: var(--surface-2);
  color: var(--ink);
}
.search-shell .icon { width: 14px; height: 14px; }
.search-shell input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }

.text-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.text-card {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--rule);
  transition: transform 220ms ease, box-shadow 240ms ease, border-color 220ms ease;
}
.text-card:hover {
  transform: translateY(-2px);
  border-color: var(--rule-strong);
  box-shadow: var(--shadow-card);
}
.card-open {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
  width: 100%;
  min-height: 152px;
  padding: 22px 22px 16px;
  color: var(--ink);
  text-align: left;
}
.card-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 22px;
  font-weight: 460;
  line-height: 1.22;
  letter-spacing: -0.008em;
  color: var(--ink-strong);
}
.card-meta {
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
}
.card-bar {
  height: 3px;
  background: var(--surface-soft);
}
.card-bar span {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  background: linear-gradient(90deg, var(--ink-soft), var(--ink));
  transition: width 400ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.empty {
  grid-column: 1 / -1;
  min-height: 320px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 56px 24px;
  text-align: center;
  border-radius: 6px;
  border: 1px dashed var(--rule);
  background: transparent;
  color: var(--ink-muted);
}
.empty h3 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 460;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--ink-strong);
}
.empty p {
  max-width: 380px;
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Editor ────────────────────────────────────────── */

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: 14px;
}
.field {
  display: grid;
  gap: 8px;
  padding: 18px 20px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
}
.title-field, .editor-actions, .language-field { grid-column: 1 / -1; }
.language-field {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
}
.language-field span {
  flex-shrink: 0;
  margin: 0;
}
.language-field select {
  appearance: none;
  -webkit-appearance: none;
  width: auto;
  min-width: 220px;
  padding: 8px 36px 8px 12px;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
  background-color: var(--surface-3);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23847d72' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.language-field select:hover {
  border-color: var(--ink-soft);
  background-color: var(--surface-2);
}
.language-field select:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
.field span {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

input, textarea {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 4px 0;
  font-size: 15px;
  line-height: 1.65;
}
textarea {
  resize: vertical;
  min-height: 240px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 430;
}

#title-input {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 28px;
  font-weight: 440;
  letter-spacing: -0.012em;
  padding: 2px 0;
}

.editor-actions, .button-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.editor-actions { padding-top: 2px; }

.primary-button,
.quiet-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease, border-color 160ms ease;
}
.primary-button {
  background: var(--ink);
  color: var(--surface-2);
}
.primary-button:hover {
  background: var(--ink-strong);
  transform: translateY(-1px);
}
.quiet-button,
.secondary-button {
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink-soft);
}
.quiet-button:hover,
.secondary-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink-soft);
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.icon-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.icon-button.danger:hover {
  color: var(--ink-strong);
  border-color: var(--ink-soft);
}

/* ─── Detail ────────────────────────────────────────── */

.parts-list { display: grid; gap: 12px; }
.part-group {
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
}
.part-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--rule);
}
.part-head h3 {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 480;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-strong);
}

/* Progress bar — shared across detail title, group head, and unit row */
.progress-bar {
  display: inline-block;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ink) var(--p, 0%), var(--rule-strong) 0);
  transition: background 320ms ease;
}
.progress-bar--lg {
  display: block;
  width: 240px;
  max-width: 100%;
  height: 6px;
  border-radius: 3px;
  margin-top: 14px;
}
.progress-bar--md {
  width: 84px;
  height: 4px;
}
.detail-progress { line-height: 0; }
.unit-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 18px;
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  text-align: left;
  transition: background 140ms ease;
}
.unit-dot {
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ink) var(--p, 0%), var(--rule-strong) 0);
  justify-self: end;
  align-self: center;
  font-style: normal;
  transition: background 240ms ease;
}
.unit-row:last-child { border-bottom: 0; }
.unit-row:hover { background: rgba(24, 22, 18, 0.025); }
.unit-row span {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  align-self: center;
}
.unit-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 440;
  color: var(--ink-soft);
}

/* ─── Training ──────────────────────────────────────── */

.training-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 20px;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  min-height: 0;
  height: 100%;
  animation: fadeIn 360ms ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.training-head {
  margin-bottom: 0;
  padding-bottom: 14px;
}

.level-control {
  display: grid;
  gap: 6px;
  justify-items: end;
}
.level-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-button-small {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--ink-muted);
  font-size: 16px;
  line-height: 1;
  transition: color 160ms ease, background 160ms ease;
}
.icon-button-small:hover {
  color: var(--ink);
  background: rgba(24, 22, 18, 0.05);
}
.icon-button-small:disabled {
  opacity: 0.35;
  cursor: default;
}

.level-track {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  width: 200px;
  padding: 8px 0;
}
.level-seg {
  height: 3px;
  background: var(--rule-strong);
  border-radius: 1px;
  cursor: pointer;
  transition: background 200ms ease, transform 200ms ease;
}
.level-seg:hover { background: var(--ink-muted); }
.level-seg.past { background: var(--ink-soft); }
.level-seg.active {
  background: var(--ink);
  transform: scaleY(2);
}

.level-label {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  text-align: right;
}
.level-label strong {
  color: var(--ink);
  font-weight: 600;
}

.masked-text {
  position: relative;
  min-height: 0;
  padding: clamp(36px, 5vw, 64px) clamp(28px, 5vw, 64px);
  border-radius: var(--radius-lg);
  background: var(--surface-3);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-paper);
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-variant-numeric: oldstyle-nums;
  font-size: clamp(19px, 1.85vw, 23px);
  font-weight: 440;
  line-height: 1.78;
  letter-spacing: 0.002em;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  overflow-y: auto;
  hyphens: auto;
  transition: opacity 240ms ease;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-faint) transparent;
}
.masked-text.changing { opacity: 0.25; }

.masked-text .word {
  display: inline-block;
  white-space: nowrap;
}
.masked-text .blank {
  display: inline-block;
  color: transparent;
  border-bottom: 1px solid var(--ink-faint);
  vertical-align: baseline;
  transition: color 240ms ease, border-color 240ms ease;
}
.masked-text.revealed .blank {
  color: var(--ink);
  border-bottom-color: transparent;
}

.training-foot {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 4px 0 8px;
}
.manual-panel,
.voice-panel {
  display: grid;
  justify-items: center;
  gap: 14px;
  width: 100%;
}

/* Voice toggle button in training-head */
.voice-toggle {
  width: 38px;
  height: 38px;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
}
.voice-toggle.active {
  background: var(--ink);
  color: var(--surface-2);
  border-color: var(--ink);
}

/* Voice panel — recording state */
.voice-record { background: var(--ink); }
.voice-listening {
  display: grid;
  justify-items: center;
  gap: 14px;
  width: 100%;
  max-width: 520px;
  text-align: center;
}
.voice-pulse {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #c0392b;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.1);  }
}
.voice-transcript {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink-soft);
  min-height: 1.5em;
  max-width: 520px;
}

/* Voice panel — result state */
.voice-result {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: 100%;
  max-width: 520px;
  text-align: center;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--rule);
}
.voice-result-outcome {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 480;
  color: var(--ink-strong);
}
.voice-result-outcome span:first-child {
  display: inline-block;
  width: 1.6em;
  text-align: center;
  margin-right: 6px;
  opacity: 0.85;
}
.voice-result[data-outcome="good"] .voice-result-outcome span:first-child { color: #2d6f4a; }
.voice-result[data-outcome="mid"] .voice-result-outcome span:first-child { color: #b08436; }
.voice-result[data-outcome="bad"] .voice-result-outcome span:first-child { color: #b14a3b; }
.voice-result-score {
  font-size: 13px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}
.voice-result-detail {
  width: 100%;
  margin-top: 4px;
}
.voice-result-detail summary {
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.voice-result-heading {
  margin-top: 8px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.voice-heard {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin-top: 4px;
}
.voice-result-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
.voice-override-detail summary {
  cursor: pointer;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: 6px;
}
.voice-override-buttons {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}
.voice-override-buttons button {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--rule-strong);
  color: var(--ink-soft);
  background: transparent;
}
.voice-override-buttons button:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}
.training-hint {
  font-size: 10.5px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}
.self-score kbd {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  border: 1px solid currentColor;
  border-radius: 3px;
  opacity: 0.55;
}

.reveal-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 26px;
  border-radius: 22px;
  background: var(--ink);
  color: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  box-shadow: var(--shadow-soft);
  transition: background 180ms ease, transform 180ms ease;
}
.reveal-button:hover {
  background: var(--ink-strong);
  transform: translateY(-1px);
}
.reveal-button .icon { width: 16px; height: 16px; }

.self-score {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  animation: scoreIn 280ms ease both;
}
@keyframes scoreIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.self-score button {
  min-height: 40px;
  padding: 0 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease,
    transform 180ms ease;
}
.self-score button[data-score="missed"] {
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--ink-muted);
}
.self-score button[data-score="missed"]:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}
.self-score button[data-score="almost"] {
  background: transparent;
  border: 1px solid var(--ink-soft);
  color: var(--ink);
}
.self-score button[data-score="almost"]:hover {
  background: rgba(24, 22, 18, 0.05);
}
.self-score button[data-score="remembered"] {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--surface-2);
}
.self-score button[data-score="remembered"]:hover {
  background: var(--ink-strong);
  transform: translateY(-1px);
}

/* ─── Toast ─────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface-2);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-paper);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease, transform 240ms ease;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Reduced motion ────────────────────────────────── */

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

/* ─── Responsive ────────────────────────────────────── */

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; }
  body.is-training .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 12px;
    padding: 14px 22px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
  .brand {
    grid-auto-flow: column;
    grid-template-columns: auto auto;
    align-items: center;
    gap: 12px;
    padding: 0;
  }
  .brand-mark { height: 26px; }
  .brand-word { height: 11px; }
  .side-nav {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }
  /* No topo (mobile/tablet): mostra só a conta; contagem e export/import
     ficam fora pra não lotar a barra. O footer vira uma faixa enxuta. */
  .side-foot {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 0;
  }
  .side-account {
    border-bottom: 0;
    padding-bottom: 0;
  }
  .signin-button { width: auto; }
  .side-foot-line,
  .side-foot-actions { display: none; }
  body.is-training .sidebar { display: none; }
  .workspace { padding: 36px 28px 64px; }
  .editor-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .workspace { padding: 24px 18px 56px; }
  body.is-training .workspace { padding: 16px 16px; }
  .training-view { gap: 14px; }
  .workspace-head,
  .training-head {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 14px;
  }
  .workspace-head:has(.icon-button:first-child),
  .training-head {
    grid-template-columns: auto 1fr;
  }
  .training-head {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
  }
  .training-head .voice-toggle { grid-row: 1; grid-column: 3; }
  .training-head .level-control { grid-row: 2; grid-column: 1 / -1; }
  .library-controls { justify-content: stretch; }
  .search-shell { width: 100%; }
  .level-control {
    justify-items: start;
    grid-column: 1 / -1;
  }
  .level-label { text-align: left; }
  .level-track { width: 100%; max-width: 240px; }
  .text-list { grid-template-columns: 1fr; }
  h2 { font-size: 28px; }
  .masked-text {
    min-height: 360px;
    padding: 40px 28px;
    font-size: 18px;
    line-height: 1.85;
  }
  .self-score {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    width: 100%;
  }
  .self-score button { padding: 0 6px; }
  .unit-row { grid-template-columns: 1fr 32px; gap: 6px 12px; }
  .unit-row strong { white-space: normal; grid-column: 1; }
  .unit-row span { grid-column: 1; }
  .unit-dot { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .detail-head .button-row {
    grid-column: 1 / -1;
    justify-content: stretch;
  }
  .detail-head .button-row .primary-button { flex: 1; }
}
