:root {
  /* Leitner logo palette — bulb gradient + ink from Linearity exports */
  --brand: #365fcf;
  --brand-hover: #2a4eb5;
  --brand-bright: #5b9aff;
  --brand-deep: #2849a8;
  --brand-soft: rgba(54, 95, 207, 0.1);
  --brand-ring: rgba(54, 95, 207, 0.22);
  --brand-glow: rgba(91, 154, 255, 0.28);
  --brand-gradient: linear-gradient(165deg, var(--brand-bright) 0%, var(--brand) 48%, var(--brand-deep) 100%);
  --growth: #3a9e62;
  --growth-soft: rgba(58, 158, 98, 0.12);
  --ink: #231f20;
  --bg: #f2f4fa;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --surface-glass: rgba(255, 255, 255, 0.74);
  --surface-glass-strong: rgba(255, 255, 255, 0.9);
  --text: var(--ink);
  --text-secondary: #5c5c62;
  --text-tertiary: #7a7a82;
  --success: #248a3d;
  --success-soft: rgba(36, 138, 61, 0.1);
  --error: #d70015;
  --error-soft: rgba(215, 0, 21, 0.08);
  --border: rgba(54, 95, 207, 0.08);
  --border-strong: rgba(54, 95, 207, 0.16);
  --shadow-sm: 0 2px 10px rgba(54, 95, 207, 0.06);
  --shadow-md: 0 10px 32px rgba(54, 95, 207, 0.09);
  --shadow-lg: 0 22px 56px rgba(54, 95, 207, 0.12);
  --shadow-brand: 0 8px 28px rgba(54, 95, 207, 0.18);
  --radius: 24px;
  --radius-sm: 16px;
  --radius-xs: 12px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  /* Type scale — keep secondary UI on the same steps */
  --text-lg: 1.05rem;
  --text-md: 0.95rem;
  --text-sm: 0.88rem;
  --text-xs: 0.78rem;
  --text-2xs: 0.68rem;
  --lh-tight: 1.3;
  --lh-body: 1.45;

  /* Chips / pills (filters, meta, related pairs) */
  --chip-font: 0.84rem;
  --chip-pad-y: 0.4rem;
  --chip-pad-x: 0.85rem;
  --chip-radius: 999px;
  --chip-min-h: 2.05rem;

  /* Status pills that show a short result (gloss, review match) */
  --status-font: 0.95rem;
  --status-pad-y: 0.4rem;
  --status-pad-x: 0.85rem;
  --status-min-h: 2.15rem;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  /* clip (not hidden) avoids killing position:sticky on Library jump chips */
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  overscroll-behavior-x: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  font-family: var(--font);
  background:
    radial-gradient(ellipse 85% 50% at 50% -10%, var(--brand-glow), transparent 70%),
    radial-gradient(ellipse 55% 42% at 100% 18%, rgba(54, 95, 207, 0.07), transparent 68%),
    radial-gradient(ellipse 45% 35% at 0% 62%, rgba(91, 154, 255, 0.05), transparent 72%),
    var(--bg);
  color: var(--text);
  line-height: 1.47059;
  letter-spacing: -0.022em;
  position: relative;
  overflow-x: clip;
  overscroll-behavior-x: none;
}

/* Ambient brand — soft glow */
.ambient-brand {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
}

.ambient-glow--primary {
  width: min(78vw, 720px);
  height: min(78vw, 720px);
  right: -18%;
  top: 6%;
  background: radial-gradient(circle, var(--brand-glow) 0%, transparent 68%);
}

.ambient-glow--secondary {
  width: min(52vw, 480px);
  height: min(52vw, 480px);
  left: -14%;
  bottom: 8%;
  background: radial-gradient(circle, rgba(54, 95, 207, 0.11) 0%, transparent 70%);
}

@media (max-width: 720px) {
  .ambient-glow--primary {
    width: 95vw;
    height: 95vw;
    right: -35%;
    top: 2%;
  }
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: min(780px, 100%);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Do not set overflow-x here — it breaks sticky Library jump chips. */
  box-sizing: border-box;
}

main,
.panel {
  max-width: 100%;
  min-width: 0;
}

/* Header */
.header {
  margin-bottom: 2.5rem;
  text-align: center;
}

/* Site footer */
.site-footer {
  margin-top: auto;
  padding-top: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.site-footer-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0.4rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-tertiary);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    color 0.2s var(--ease),
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.site-footer-btn:hover,
.site-footer-btn:focus-visible {
  color: var(--brand-deep);
  background: var(--brand-soft);
  border-color: var(--brand-ring);
  box-shadow: var(--shadow-sm);
  outline: none;
}

.site-footer-btn:active {
  transform: scale(0.98);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.brand-logo {
  display: block;
  width: min(300px, 78vw);
  height: auto;
  margin: 0 auto 0.5rem;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(54, 95, 207, 0.1));
}

.category-picker {
  position: relative;
  margin: 0 0 0.35rem;
}

.category-picker--welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1rem;
}

.category-picker--welcome .category-picker-menu {
  z-index: 210;
}

/*
 * Progress prefs bar: language left · voice right, above stats.
 * Set-and-forget chrome — quiet glass, shared height, never compete with numbers.
 */
.progress-prefs {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem 0.75rem;
  width: 100%;
  margin: 0 0 1rem;
  box-sizing: border-box;
}

.progress-language {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: flex-start;
  margin: 0;
}

.category-picker--progress {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0;
  display: block;
}

.category-picker--progress .category-picker-btn {
  width: 100%;
  max-width: 100%;
  min-height: 2.05rem;
  padding: 0.32rem 0.7rem 0.32rem 0.8rem;
  justify-content: space-between;
  gap: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-secondary);
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

.category-picker--progress .category-picker-btn:hover,
.category-picker--progress .category-picker-btn[aria-expanded="true"] {
  color: var(--brand-deep);
  background: var(--brand-soft);
  border-color: var(--brand-ring);
  box-shadow: none;
}

.category-picker--progress [data-category-picker-label] {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.category-picker--progress .category-picker-menu {
  left: 0;
  right: auto;
  transform: none;
  min-width: min(100%, 16rem);
  width: max-content;
  max-width: min(20rem, 92vw);
}

.progress-voice {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  min-width: 0;
}

.progress-voice-label {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  line-height: 1;
}

/* Same visual family as language pill — chip scale */
.voice-gender-control {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.12rem;
  width: auto;
  min-width: 8.75rem;
  padding: 0.14rem;
  border-radius: 999px;
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-strong);
  box-sizing: border-box;
}

.voice-gender-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.75rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    color 0.15s var(--ease),
    background 0.15s var(--ease),
    border-color 0.15s var(--ease),
    box-shadow 0.15s var(--ease);
}

.voice-gender-option:hover {
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.voice-gender-option[aria-pressed="true"] {
  color: #fff;
  background: var(--brand-gradient);
  border-color: transparent;
  box-shadow: none;
}

.voice-gender-option:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.voice-gender-option[aria-pressed="true"]:focus-visible {
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.category-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.16), rgba(54, 95, 207, 0.1));
  border: 1px solid var(--brand-ring);
  color: var(--brand-deep);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.category-picker-btn:hover,
.category-picker-btn[aria-expanded="true"] {
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.22), rgba(54, 95, 207, 0.14));
  border-color: rgba(54, 95, 207, 0.28);
  box-shadow: var(--shadow-sm);
}

.category-picker-chevron {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.2s var(--ease);
}

.category-picker-btn[aria-expanded="true"] .category-picker-chevron {
  transform: rotate(225deg) translateY(1px);
}

.category-picker-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 50%;
  transform: translateX(-50%);
  min-width: min(18rem, 88vw);
  background: var(--surface-glass-strong);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 0.35rem;
  z-index: 20;
}

.category-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.category-option:hover:not(:disabled) {
  background: var(--brand-soft);
}

.category-option.active {
  background: var(--brand-soft);
}

.category-option.unavailable {
  opacity: 0.55;
  cursor: not-allowed;
}

.category-option--soon,
.category-option--compact {
  padding: 0.5rem 0.85rem;
}

.category-option-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  text-transform: none;
}

.category-option-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0;
}

.category-option-soon {
  margin-top: 0.15rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.category-picker-group-label {
  margin: 0.45rem 0.85rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.category-picker-footer {
  margin: 0.35rem 0.85rem 0.45rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-tertiary);
}

@media (max-width: 720px) {
  .app {
    padding:
      calc(1rem + env(safe-area-inset-top, 0px))
      calc(1rem + env(safe-area-inset-right, 0px))
      calc(1rem + env(safe-area-inset-bottom, 0px))
      calc(1rem + env(safe-area-inset-left, 0px));
  }

  .header {
    margin-bottom: 1rem;
  }

  .site-footer {
    padding-top: 1.75rem;
  }

  .site-footer-btn {
    min-height: 44px;
  }

  .brand {
    margin-bottom: 0.85rem;
    gap: 0.3rem;
  }

  .brand-logo {
    width: min(200px, 58vw);
    margin-bottom: 0.15rem;
  }

  /* —— Mobile Review only: hero word, clear input, equal actions —— */
  .app.practice-focus .header {
    margin-bottom: 0.55rem;
  }

  .app.practice-focus .brand {
    margin-bottom: 0.4rem;
  }

  .app.practice-focus .brand-logo {
    width: min(140px, 42vw);
  }

  .app.practice-focus .practice-card {
    padding: 1.15rem 0.9rem 1.05rem;
  }

  .app.practice-focus .prompt,
  .app.practice-focus .prompt.norwegian {
    font-size: clamp(1.85rem, 8.5vw, 2.45rem);
    margin-bottom: 0.65rem;
  }

  .feedback-slot {
    min-height: 2.6rem;
    height: auto;
    margin-bottom: 0.35rem;
  }

  .feedback {
    max-height: none;
    padding: 0.35rem 0.7rem;
    font-size: clamp(0.95rem, 3.5vw, 1.2rem);
  }

  .practice-meta {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.55rem;
  }

  .app.practice-focus .practice-meta {
    margin-bottom: 0.5rem;
  }

  .daily-progress {
    max-width: 100%;
    margin: 0 auto 0.75rem;
    height: 0.35rem;
  }

  .app.practice-focus .daily-progress {
    margin-bottom: 0.75rem;
  }

  .meta-chip {
    font-size: var(--chip-font);
    padding: var(--chip-pad-y) 0.75rem;
    min-height: 40px;
  }

  .practice-card {
    padding: 1.15rem 0.9rem 1.05rem;
  }

  /* Direction only (voice lives on Progress); category under when present */
  .practice-card-top {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    margin-bottom: 0.85rem;
  }

  .practice-card-top .category-chip {
    align-self: center;
    min-height: 1.85rem;
  }

  .practice-card-top .direction-toggle {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    padding-inline: 0.65rem;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
  }

  .prompt {
    font-size: clamp(1.9rem, 8.8vw, 2.6rem);
    margin-bottom: 0.75rem;
  }

  .prompt.norwegian {
    min-height: 1.35em;
  }

  .prompt-hint {
    margin-bottom: 1rem;
    font-size: 0.9rem;
  }

  .answer-form {
    max-width: none;
    width: 100%;
  }

  .answer-form input[type="text"] {
    font-size: 16px; /* prevent iOS focus zoom */
    padding: 0.95rem 1rem;
    margin-bottom: 0.4rem;
  }

  .answer-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
    width: 100%;
  }

  .answer-actions .btn {
    min-height: 48px;
    width: 100%;
    touch-action: manipulation;
    padding-inline: 0.35rem;
    font-size: 0.88rem;
    font-weight: 600;
  }

  /* Empty Review: full-width actions, less dead air */
  #practice-panel.active #practice-empty:not(.hidden) {
    width: 100%;
    box-sizing: border-box;
  }

  .empty-state {
    padding: 1.75rem 1.1rem 1.5rem;
  }

  .empty-state--actions {
    padding: 1.35rem 1rem 1.25rem;
  }

  .empty-actions {
    width: 100%;
    max-width: none;
  }

  .empty-actions .btn,
  .read-bridge-btn {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
  }

  .page-float-top {
    right: max(0.85rem, env(safe-area-inset-right, 0px));
    bottom: max(0.95rem, env(safe-area-inset-bottom, 0px));
  }

  .header {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
  }

  main,
  .panel.active {
    width: 100%;
    min-width: 0;
  }

  .empty-state {
    padding: 2rem 1rem 1.65rem;
    width: 100%;
    box-sizing: border-box;
  }

  .empty-state--actions {
    padding: 1.5rem 1rem 1.35rem;
  }

  .empty-actions {
    max-width: 100%;
    width: 100%;
  }

  .welcome-modal,
  .confirm-modal,
  .about-modal,
  .goal-cap-modal {
    padding:
      max(1rem, env(safe-area-inset-top, 0px))
      max(1rem, env(safe-area-inset-right, 0px))
      max(1rem, env(safe-area-inset-bottom, 0px))
      max(1rem, env(safe-area-inset-left, 0px));
  }

  .about-card {
    width: min(100%, 24rem);
    max-height: calc(100dvh - 1.5rem);
  }

  .welcome-card {
    width: min(100%, 20rem);
    padding: 1.5rem 1.15rem 1.25rem;
  }

  .category-picker--welcome {
    width: 100%;
    max-width: 16rem;
  }

  .category-picker-menu {
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
}

/* Tabs — pill segment, brand-active */
.tabs {
  display: inline-flex;
  gap: 0.2rem;
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  padding: 0.3rem;
  border-radius: 999px;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
}

.tab {
  min-height: 2.4rem;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: var(--chip-radius);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
  cursor: pointer;
  transition: all 0.25s var(--ease);
}

.tab:hover:not(.active) {
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.tab.active {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: var(--shadow-brand);
}

@media (max-width: 720px) {
  .tabs {
    display: flex;
    align-self: stretch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0.25rem;
    gap: 0.12rem;
  }

  .tab {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding: 0.55rem 0.15rem;
    font-size: clamp(0.68rem, 2.9vw, 0.78rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    text-align: center;
    white-space: nowrap;
    touch-action: manipulation;
  }
}

main {
  flex: 1;
}

.panel {
  display: none;
  animation: fadeIn 0.35s var(--ease);
}

.panel.active {
  display: block;
}

/* Beat any panel-specific display rules when the tab is not active */
.panel[hidden],
.panel:not(.active) {
  display: none !important;
}

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

.panel h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 0 0 0.5rem;
}

.panel h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.panel-intro {
  margin: 0 0 1.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Practice meta */
.practice-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--chip-min-h);
  font-size: var(--chip-font);
  font-weight: 600;
  padding: var(--chip-pad-y) var(--chip-pad-x);
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--chip-radius);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
}

.meta-chip.live {
  color: var(--brand-deep);
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.14), rgba(54, 95, 207, 0.08));
  border-color: var(--brand-ring);
}

.meta-chip.goal-met {
  color: #1f6b45;
  background: linear-gradient(135deg, rgba(72, 187, 120, 0.16), rgba(56, 161, 105, 0.08));
  border-color: rgba(56, 161, 105, 0.35);
}

#daily-goal-chip {
  min-width: 3.25rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.meta-chip--button {
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}

.meta-chip--button:hover {
  border-color: var(--brand-ring);
  color: var(--brand-deep);
}

.meta-chip--button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
  border-color: var(--brand-ring);
}

.goal-cap-modal {
  position: fixed;
  inset: 0;
  z-index: 215;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(18, 24, 38, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.goal-cap-modal.hidden {
  display: none;
}

.goal-cap-card {
  width: min(100%, 20rem);
  padding: 0.85rem 1rem 1rem;
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

.goal-cap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.goal-cap-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.25;
}

.goal-cap-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.goal-cap-option {
  min-height: 2.6rem;
  padding: 0.45rem 0.25rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-family: inherit;
  font-size: var(--text-md);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease);
}

.goal-cap-option:hover {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.goal-cap-option:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
  border-color: var(--brand-ring);
}

.goal-cap-option.is-selected {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.18), rgba(54, 95, 207, 0.1));
  color: var(--brand-deep);
  box-shadow: inset 0 0 0 1px rgba(54, 95, 207, 0.12);
}

.daily-progress {
  max-width: 18rem;
  height: 0.35rem;
  margin: -0.85rem auto 1.35rem;
  background: rgba(54, 95, 207, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.daily-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #5b9aff);
  transition: width 0.35s var(--ease);
}

.empty-state.goal-met .empty-icon--earned {
  background: linear-gradient(135deg, rgba(72, 187, 120, 0.2), rgba(56, 161, 105, 0.1));
  border-color: rgba(56, 161, 105, 0.35);
  color: #2f855a;
}

/* Practice card — hero focal */
.practice-card {
  position: relative;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem 1.35rem;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  text-align: center;
}

.app.practice-focus .practice-meta {
  margin-bottom: 1rem;
}

.app.practice-focus .daily-progress {
  margin-bottom: 1rem;
}

.practice-card-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.card-label {
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: var(--lh-tight);
  color: var(--text-tertiary);
}

.direction-toggle {
  display: inline-flex;
  align-items: center;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  border-radius: var(--chip-radius);
  padding: var(--chip-pad-y) var(--chip-pad-x);
  background: var(--surface-glass);
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
  touch-action: manipulation;
  min-height: var(--chip-min-h);
  line-height: var(--lh-tight);
}

.direction-toggle:hover,
.direction-toggle:focus-visible {
  color: var(--brand-deep);
  border-color: var(--brand-ring);
  background: var(--brand-soft);
  outline: none;
  box-shadow: var(--shadow-sm);
}

.direction-toggle[aria-pressed="true"] {
  color: var(--brand-deep);
  border-color: var(--brand-ring);
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.16), rgba(54, 95, 207, 0.1));
}

.category-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.28rem 0.65rem;
  border-radius: var(--chip-radius);
  line-height: var(--lh-tight);
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.16), rgba(54, 95, 207, 0.1));
  border: 1px solid var(--brand-ring);
  color: var(--brand-deep);
}

.category-chip.small {
  min-height: 1.5rem;
  font-size: var(--text-2xs);
  padding: 0.2rem 0.5rem;
}

.prompt {
  font-size: clamp(2.25rem, 6vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.28;
  margin-bottom: 1.25rem;
  word-break: break-word;
  color: var(--ink);
  overflow: visible;
}

.prompt.norwegian {
  display: inline-block;
  font-size: clamp(2.5rem, 7vw, 3.5rem);
  letter-spacing: -0.03em;
  line-height: 1.32;
  min-height: 1.32em;
  padding: 0 0.04em 0.14em;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.prompt-hint {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0 0 2rem;
  min-height: 1.35rem;
}

.prompt-hint.hidden {
  display: none;
}

.practice-card-top .category-chip.hidden {
  display: none;
}

.answer-form {
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.answer-form input[type="text"] {
  width: 100%;
  padding: 1rem 1.2rem;
  font-size: 1.1rem;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ink);
  margin-bottom: 0.35rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  text-align: center;
}

.answer-form input[type="text"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft), var(--shadow-sm);
  background: var(--surface);
}

.answer-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.answer-actions .btn {
  min-width: 5.25rem;
}

/* Buttons */
.btn {
  padding: 0.7rem 1.4rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: var(--shadow-brand);
}

.btn.primary:hover {
  background: linear-gradient(165deg, #6cabff 0%, var(--brand-hover) 48%, var(--brand-deep) 100%);
  box-shadow: 0 10px 28px rgba(54, 95, 207, 0.32);
}

.btn.secondary {
  background: var(--surface-glass-strong);
  color: var(--brand-deep);
  border: 1px solid var(--brand-ring);
  box-shadow: var(--shadow-sm);
}

.btn.secondary:hover {
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.btn.ghost {
  background: var(--surface-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.btn.ghost:hover {
  color: var(--brand-deep);
  border-color: var(--brand-ring);
  background: var(--brand-soft);
}

.btn.small {
  min-height: var(--chip-min-h);
  padding: var(--chip-pad-y) var(--chip-pad-x);
  font-size: var(--chip-font);
  line-height: var(--lh-tight);
}

.btn.danger {
  color: var(--error);
}

#speak-btn.listening {
  color: #fff;
  border-color: transparent;
  background: var(--brand-gradient);
  box-shadow: var(--shadow-brand);
  animation: speakPulse 1.6s ease-in-out infinite;
}

@keyframes speakPulse {
  0%,
  100% {
    box-shadow: var(--shadow-brand);
  }
  50% {
    box-shadow: 0 10px 28px rgba(54, 95, 207, 0.38);
  }
}

/* Feedback — fixed slot height (no layout shift); pill hugs the text */
.feedback-slot {
  width: 100%;
  height: 3.1rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 0.4rem;
  pointer-events: none;
}

.feedback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  font-size: clamp(1.1rem, 3.8vw, 1.5rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 600;
  border: 1px solid transparent;
  text-align: center;
  word-break: break-word;
  max-height: 3.1rem;
  overflow: hidden;
  box-sizing: border-box;
  transition: opacity 0.18s var(--ease), background 0.18s var(--ease), border-color 0.18s var(--ease);
}

.feedback.is-empty {
  opacity: 0;
  visibility: hidden;
  border-color: transparent;
  background: transparent;
  padding-inline: 0.85rem;
  min-width: 0;
  min-height: 0;
}

.feedback.correct {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(36, 138, 61, 0.28);
  box-shadow: 0 0 0 1px rgba(36, 138, 61, 0.06);
}

.feedback.incorrect {
  background: var(--error-soft);
  color: var(--error);
  border-color: rgba(215, 0, 21, 0.24);
  box-shadow: 0 0 0 1px rgba(215, 0, 21, 0.05);
}

.feedback.revealed {
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.12), rgba(54, 95, 207, 0.08));
  color: var(--brand-deep);
  border-color: var(--brand-ring);
}

.feedback.near {
  background: linear-gradient(135deg, rgba(255, 193, 70, 0.18), rgba(255, 149, 0, 0.1));
  color: #9a5b00;
  border-color: rgba(255, 149, 0, 0.28);
}

.answer-form input[type="text"].received {
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.16), rgba(54, 95, 207, 0.09));
  color: var(--brand-deep);
  border-color: var(--brand-ring);
  box-shadow: 0 0 0 3px rgba(54, 95, 207, 0.1);
  font-weight: 500;
}

.answer-form input[type="text"].received:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft), var(--shadow-sm);
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.2), rgba(54, 95, 207, 0.12));
}

.answer-form input[type="text"].near-miss {
  border-color: rgba(255, 149, 0, 0.55);
  box-shadow: 0 0 0 4px rgba(255, 193, 70, 0.22);
  background: rgba(255, 248, 235, 0.95);
}

/* Levels */
.level-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.5rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border-strong);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.levels {
  display: flex;
  gap: 0.4rem;
}

.level-dot,
.box-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(54, 95, 207, 0.12);
  transition: all 0.3s var(--ease);
}

.level-dot.active,
.box-dot.active {
  background: var(--brand-gradient);
  transform: scale(1.25);
  box-shadow: 0 0 0 3px rgba(91, 154, 255, 0.22);
}

.level-dot.passed,
.box-dot.passed {
  background: var(--brand);
  opacity: 0.42;
}

/* Word preview grid */
.word-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.preview-word {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  padding: 0.58rem 0.9rem;
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-sm);
  cursor: default;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}

.word-preview .preview-word {
  cursor: pointer;
}

.word-preview .preview-word:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-ring);
}

.preview-no {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: var(--brand-deep);
}

.preview-en {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.starter-preview {
  background: var(--surface-glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.35rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.starter-preview h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.starter-preview-lead {
  margin: 0 0 1rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

/* Wide screens: balance empty Review with space, not instructional copy */
@media (min-width: 721px) {
  /* Only while Review is the active tab — otherwise display:flex leaks over other tabs */
  #practice-panel.active:has(#practice-empty:not(.hidden)) {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: min(58vh, 32rem);
    justify-content: center;
    padding-block: 0.5rem 1.25rem;
  }

  #practice-panel.active:has(#practice-empty:not(.hidden)) .practice-meta,
  #practice-panel.active:has(#practice-empty:not(.hidden)) .daily-progress {
    width: min(100%, 26rem);
  }

  #practice-panel.active #practice-empty:not(.hidden) {
    width: min(100%, 28rem);
    margin-inline: auto;
    padding: 3rem 2.25rem 2.35rem;
  }

  #practice-panel.active:has(#practice-active:not(.hidden)) .practice-card {
    width: min(100%, 34rem);
    margin-inline: auto;
    padding: 2rem 2.15rem 1.65rem;
  }

  /* —— Desktop Review: calm hierarchy, balanced chrome —— */
  .app.practice-focus .header {
    margin-bottom: 1.65rem;
  }

  .app.practice-focus .brand {
    margin-bottom: 0.85rem;
  }

  .app.practice-focus .brand-logo {
    width: min(200px, 28vw);
  }

  .practice-meta {
    margin-bottom: 1.1rem;
    gap: 0.55rem;
  }

  .daily-progress {
    max-width: 20rem;
    height: 0.4rem;
    margin: -0.55rem auto 1.45rem;
  }

  .app.practice-focus .practice-meta {
    margin-bottom: 0.95rem;
  }

  .app.practice-focus .daily-progress {
    margin-bottom: 1.15rem;
  }

  /* Direction | category | voice — balanced three-zone toolbar */
  .practice-card-top {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.55rem 0.75rem;
    margin-bottom: 1.45rem;
  }

  .practice-card-top .direction-toggle {
    min-height: 2.15rem;
    padding: 0.4rem 0.95rem;
    font-size: 0.72rem;
  }

  .prompt {
    margin-bottom: 0.35rem;
  }

  .prompt.norwegian {
    font-size: clamp(2.65rem, 4.2vw, 3.35rem);
    margin-bottom: 0.5rem;
  }

  .prompt-hint {
    margin-bottom: 1.65rem;
  }

  .answer-form {
    max-width: 26rem;
  }

  .answer-form input[type="text"] {
    padding: 1.05rem 1.25rem;
    font-size: 1.12rem;
    margin-bottom: 0.45rem;
  }

  .feedback-slot {
    min-height: 2.75rem;
    margin-bottom: 0.35rem;
  }

  /* Hear / Speak / Show — equal, premium action row */
  .answer-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem;
    width: 100%;
    margin-top: 0.15rem;
  }

  .answer-actions .btn {
    min-width: 0;
    width: 100%;
    min-height: 2.7rem;
    padding-inline: 0.75rem;
    font-size: 0.92rem;
    font-weight: 600;
  }

  .empty-state h2 {
    font-size: 1.85rem;
  }

  .empty-state p {
    font-size: 1rem;
    margin-bottom: 1.4rem;
  }
}

.empty-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.empty-icon--idle {
  background: linear-gradient(145deg, rgba(91, 154, 255, 0.1), rgba(54, 95, 207, 0.05));
  border: 1.5px solid rgba(54, 95, 207, 0.14);
  box-shadow: none;
}

.empty-icon--idle::after {
  content: "";
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(91, 154, 255, 0.28), rgba(54, 95, 207, 0.16));
}

.empty-icon--earned {
  background: linear-gradient(145deg, rgba(91, 154, 255, 0.18), rgba(54, 95, 207, 0.1));
  border: 1px solid var(--brand-ring);
  color: var(--brand);
  font-size: 1.5rem;
  font-weight: 700;
}

.empty-state h2 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: var(--text-md);
  line-height: var(--lh-body);
  margin-bottom: 1.25rem;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

.empty-state .word-preview {
  margin-bottom: 1.5rem;
}

.empty-state .btn {
  min-height: 44px;
  touch-action: manipulation;
}

.empty-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  max-width: 16rem;
  margin: 0 auto;
}

.empty-actions .btn {
  width: 100%;
}

.empty-state--actions {
  padding: 2.25rem 1.5rem 2rem;
}

.empty-state--actions .empty-actions {
  margin-top: 0;
}

.empty-state--power-complete {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty-state--power-complete .empty-actions {
  order: 1;
}

.empty-state--power-complete #empty-message {
  order: 2;
  margin-top: 0.15rem;
  margin-bottom: 0;
}

.empty-power {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.power-on-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 6.5rem;
  height: 6.5rem;
  padding: 0;
  border: 1px solid rgba(35, 31, 32, 0.1);
  border-radius: 50%;
  background: linear-gradient(165deg, #ffffff 0%, #f3f5fa 100%);
  box-shadow:
    0 10px 28px rgba(54, 95, 207, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.18s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    background 0.18s var(--ease);
}

.power-on-btn__glow {
  position: absolute;
  inset: -0.35rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 154, 255, 0.28) 0%, rgba(91, 154, 255, 0) 72%);
  opacity: 0;
  transition: opacity 0.18s var(--ease);
  pointer-events: none;
}

.power-on-btn__icon {
  position: absolute;
  width: 2.35rem;
  height: auto;
  pointer-events: none;
  transition: opacity 0.16s var(--ease), transform 0.18s var(--ease);
}

.power-on-btn__icon--on {
  opacity: 0;
  transform: scale(0.96);
}

.power-on-btn:hover {
  border-color: rgba(54, 95, 207, 0.18);
  box-shadow:
    0 14px 32px rgba(54, 95, 207, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.power-on-btn:hover .power-on-btn__glow {
  opacity: 0.55;
}

.power-on-btn:active,
.power-on-btn:focus-visible {
  transform: scale(0.94);
  border-color: rgba(54, 95, 207, 0.32);
  background: linear-gradient(165deg, #f7faff 0%, #e8f0ff 100%);
  box-shadow:
    0 6px 18px rgba(54, 95, 207, 0.24),
    inset 0 2px 8px rgba(54, 95, 207, 0.08);
}

.power-on-btn:active .power-on-btn__glow,
.power-on-btn:focus-visible .power-on-btn__glow {
  opacity: 1;
}

.power-on-btn:active .power-on-btn__icon--off,
.power-on-btn:focus-visible .power-on-btn__icon--off {
  opacity: 0;
  transform: scale(0.92);
}

.power-on-btn:active .power-on-btn__icon--on,
.power-on-btn:focus-visible .power-on-btn__icon--on {
  opacity: 1;
  transform: scale(1);
}

.power-on-btn__icon--complete {
  opacity: 0;
  transform: scale(0.88);
}

.power-on-btn--complete:not(:disabled) {
  cursor: pointer;
}

.power-on-btn--complete:disabled {
  cursor: default;
}

.power-on-btn--complete {
  border-color: rgba(54, 95, 207, 0.45);
  background: linear-gradient(165deg, #5b9aff 0%, #365fcf 58%, #2d4fb8 100%);
  box-shadow:
    0 14px 36px rgba(54, 95, 207, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.power-on-btn--complete:hover {
  border-color: rgba(54, 95, 207, 0.45);
  box-shadow:
    0 14px 36px rgba(54, 95, 207, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.power-on-btn--complete .power-on-btn__glow {
  opacity: 0.75;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.32) 0%, rgba(91, 154, 255, 0) 72%);
}

.power-on-btn--complete .power-on-btn__icon--off,
.power-on-btn--complete .power-on-btn__icon--on {
  opacity: 0;
}

.power-on-btn--complete .power-on-btn__icon--complete {
  opacity: 1;
  transform: scale(1);
}

.power-on-btn--complete:disabled:active,
.power-on-btn--complete:disabled:focus-visible {
  transform: none;
}

.power-on-btn--complete:not(:disabled):active,
.power-on-btn--complete:not(:disabled):focus-visible {
  transform: scale(0.94);
}

.empty-power.power-on--celebrate .power-on-btn {
  animation: power-complete-rise 0.85s var(--ease) both;
}

.empty-power.power-on--celebrate .power-on-btn__glow {
  animation: power-complete-glow 1.5s ease-in-out 0.15s infinite alternate;
}

@keyframes power-complete-rise {
  0% {
    opacity: 0;
    transform: scale(0.82) translateY(14px);
  }
  55% {
    transform: scale(1.06) translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes power-complete-glow {
  from {
    opacity: 0.55;
    transform: scale(1);
  }
  to {
    opacity: 1;
    transform: scale(1.1);
  }
}

.empty-home-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  width: min(100%, 15rem);
  margin: 0 auto;
}

.empty-home-status:empty {
  display: none;
}

.home-stat {
  padding: 0.65rem 0.55rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.home-stat--highlight .home-stat__value {
  color: var(--brand);
}

.home-stat--risk {
  border-color: rgba(54, 95, 207, 0.34);
  box-shadow: 0 0 0 1px rgba(91, 154, 255, 0.12);
}

.home-stat--risk .home-stat__label {
  color: var(--brand);
}

.home-stat__value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.05;
}

.home-stat__label {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  line-height: 1.25;
}

.power-on-hint {
  margin: -0.35rem 0 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-tertiary);
}

.power-on-streak {
  margin: -0.15rem 0 0;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--brand);
}

.power-on-teaser {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-tertiary);
  line-height: 1.4;
  max-width: 16rem;
}

.read-bridge-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(54, 95, 207, 0.22);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, rgba(91, 154, 255, 0.14), rgba(54, 95, 207, 0.08));
  box-shadow: 0 8px 20px rgba(54, 95, 207, 0.12);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.16s var(--ease),
    border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease),
    background 0.16s var(--ease);
}

.read-bridge-btn:hover {
  border-color: rgba(54, 95, 207, 0.34);
  background: linear-gradient(145deg, rgba(91, 154, 255, 0.2), rgba(54, 95, 207, 0.12));
  box-shadow: 0 10px 24px rgba(54, 95, 207, 0.18);
}

.read-bridge-btn:active {
  transform: scale(0.98);
}

.read-bridge-btn__label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.read-bridge-btn__meta {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-state .btn + .btn {
  margin-top: 0;
}

.empty-state.session-complete .empty-icon--earned {
  background: linear-gradient(135deg, var(--brand-soft), var(--growth-soft));
  color: var(--brand);
}

.hidden {
  display: none !important;
}

.boot-error {
  text-align: center;
  padding: 2rem 1.25rem;
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.boot-error-detail {
  font-size: 0.88rem;
  color: var(--text-tertiary);
  margin-bottom: 1.25rem;
}

body.modal-open {
  overflow: hidden;
}

body.welcome-open .app {
  pointer-events: none;
  user-select: none;
}

.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(18, 24, 38, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
}

.welcome-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: min(100%, 22rem);
  overflow: visible;
  padding: 1.75rem 1.5rem 1.5rem;
  background: linear-gradient(145deg, var(--surface-glass-strong) 0%, rgba(248, 249, 253, 0.98) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.welcome-logo {
  display: block;
  width: min(220px, 68vw);
  height: auto;
  margin: 0 auto 0.85rem;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(54, 95, 207, 0.1));
}

.category-picker--welcome {
  width: 100%;
  margin-bottom: 1.1rem;
}

.category-picker--welcome .category-picker-menu {
  z-index: 220;
}

.welcome-actions {
  display: flex;
  justify-content: center;
  width: 100%;
}

.welcome-actions .btn {
  min-width: 9.5rem;
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(18, 24, 38, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.confirm-card {
  width: min(100%, 22rem);
  padding: 1.25rem 1.2rem 1.1rem;
  background: linear-gradient(145deg, var(--surface-glass-strong) 0%, rgba(248, 249, 253, 0.98) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.confirm-card--compact {
  width: fit-content;
  min-width: 10.5rem;
  max-width: min(100%, 15rem);
  padding: 0.8rem 0.85rem 0.7rem;
}

.confirm-card--compact .confirm-message {
  margin-bottom: 0.65rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.confirm-card--compact .confirm-actions {
  gap: 0.4rem;
}

.confirm-card--compact .confirm-actions .btn {
  min-height: 2.15rem;
  padding: 0.38rem 0.7rem;
  font-size: 0.86rem;
}

.confirm-message {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink);
  text-align: center;
  white-space: pre-line;
}

.confirm-story-title {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--brand);
}

.confirm-message-note {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* About — compact, one calm card */
.about-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(18, 24, 38, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.about-modal.hidden {
  display: none;
}

.about-card {
  display: flex;
  flex-direction: column;
  width: min(100%, 24rem);
  max-height: calc(100dvh - 2rem);
  overflow: hidden;
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

.about-card-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.45rem 0.65rem 0;
  flex-shrink: 0;
}

.about-logo {
  display: block;
  height: 3.25rem;
  width: auto;
  margin: 0.15rem auto 0.85rem;
  object-fit: contain;
}

.about-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 1rem 0.95rem;
}

.about-lead {
  margin: 0 0 0.95rem;
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  line-height: var(--lh-body);
  letter-spacing: -0.02em;
  color: var(--ink);
  text-align: center;
}

.about-section {
  margin-bottom: 0.75rem;
}

.about-section:last-of-type {
  margin-bottom: 0.6rem;
}

.about-section-title {
  margin: 0 0 0.3rem;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  line-height: var(--lh-tight);
}

.about-section p {
  margin: 0;
  font-size: var(--text-sm);
  line-height: var(--lh-body);
  color: var(--text-secondary);
}

.about-section strong {
  color: var(--ink);
  font-weight: 600;
}

.about-inline-link {
  color: var(--brand-deep);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent);
  text-underline-offset: 0.15em;
}

.about-inline-link:hover,
.about-inline-link:focus-visible {
  color: var(--brand);
  text-decoration-color: var(--brand);
  outline: none;
}

.about-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: var(--text-sm);
  line-height: var(--lh-body);
  color: var(--text-secondary);
}

.about-list li {
  position: relative;
  padding-left: 0.8rem;
}

.about-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0.55;
}

.about-note {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--text-sm) !important;
  line-height: var(--lh-body) !important;
  color: var(--text-secondary) !important;
}

.about-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.65rem;
}

.about-links li {
  padding: 0.05rem 0;
}

.about-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--brand-deep);
  text-decoration: none;
  line-height: var(--lh-tight);
}

.about-links a:hover,
.about-links a:focus-visible {
  color: var(--brand);
  outline: none;
}

.about-link-ext {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.55;
}

.about-contact-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.55rem;
  margin: 0;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  line-height: var(--lh-tight);
}

.about-contact-label {
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.about-contact-line a {
  color: var(--brand-deep);
  font-weight: 600;
  text-decoration: none;
  word-break: break-all;
}

.about-contact-line a:hover,
.about-contact-line a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.15em;
  outline: none;
}

.read-story-source {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Vision & deck info */
.vision-card {
  background: linear-gradient(145deg, var(--surface-glass-strong) 0%, rgba(248, 249, 253, 0.95) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.75rem 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-md);
}

.vision-card h2 {
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 0.65rem;
}

.vision-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.55;
}

.deck-info {
  background: linear-gradient(145deg, rgba(91, 154, 255, 0.14) 0%, rgba(54, 95, 207, 0.07) 55%, rgba(58, 158, 98, 0.05) 100%);
  border: 1px solid var(--brand-ring);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.deck-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.deck-info h3 {
  margin: 0;
}

.deck-source {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--brand);
  opacity: 0.85;
}

.deck-info p {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  line-height: 1.55;
}

.deck-info a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}

.deck-info a:hover {
  text-decoration: underline;
}

.deck-bands {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.band-pill {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-strong);
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.band-pill strong {
  color: var(--brand);
  font-weight: 700;
}

.add-card-form {
  position: relative;
  z-index: 30;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.95rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.add-card-form.is-suggesting {
  z-index: 40;
}

.add-card-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

/* No empty header bar when not editing */
.add-card-form-head:not(:has(:not(.hidden))) {
  display: none;
  margin: 0;
}

.add-card-mode-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brand-deep);
}

.add-card-field {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
}

.add-card-field:focus-within {
  z-index: 2;
}

.add-card-field-nb .add-card-label {
  color: var(--brand-deep);
}

.add-card-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.add-card-field-join {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 0.55rem;
  color: var(--text-tertiary);
  user-select: none;
}

.add-card-field-join-mark {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  opacity: 0.55;
}

.library-suggest {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 11rem;
  overflow-y: auto;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-lg);
  padding: 0.3rem;
}

.library-suggest-option {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.4rem;
  width: 100%;
  padding: 0.42rem 0.55rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s var(--ease);
}

.library-suggest-option.is-selectable {
  cursor: pointer;
  touch-action: manipulation;
}

.library-suggest-option.is-selectable:hover,
.library-suggest-option.is-selectable:focus-visible {
  background: var(--brand-soft);
  outline: none;
}

.library-suggest-option.is-info {
  cursor: default;
  opacity: 0.82;
}

/* English first, then Norwegian — same order as the form */
.library-suggest-option-native {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.library-suggest-option-foreign {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--brand-deep);
}

.library-suggest-option-sep {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  opacity: 0.7;
}

.library-suggest-option-meta {
  flex-basis: 100%;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.add-card-review {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--brand-ring);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.add-card-review-pair {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.45rem 0.55rem;
  margin-bottom: 0.65rem;
}

.add-card-review-side {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  flex: 1 1 8rem;
  min-width: 0;
}

.add-card-review-join {
  display: flex;
  align-items: center;
  align-self: center;
  padding-top: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-tertiary);
  opacity: 0.55;
  user-select: none;
  flex: 0 0 auto;
}

.add-card-review-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.add-card-review-side.is-nb .add-card-review-label {
  color: var(--brand-deep);
}

.add-card-review-value {
  margin: 0;
  padding: 0.48rem 0.72rem;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  word-break: break-word;
}

.add-card-review-side.is-nb .add-card-review-value {
  border-color: var(--brand-ring);
  color: var(--brand-deep);
  background: rgba(239, 246, 255, 0.85);
}

.add-card-review-context {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.55rem;
}

.review-context-loading {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

/* Same idea as practice .feedback: chip hugs the text, not a full-width bar */
.review-context-block {
  box-sizing: border-box;
  width: fit-content;
  max-width: 100%;
  padding: 0.55rem 0.85rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
}

.review-context-block.is-warning {
  border-color: rgba(154, 52, 18, 0.28);
  background: rgba(254, 242, 242, 0.75);
}

.review-context-block.is-match {
  border-color: rgba(47, 179, 82, 0.28);
  background: rgba(240, 253, 244, 0.8);
}

/* Title-only green/red status — true pill like practice feedback */
.review-context-block.is-match:not(:has(.review-context-copy)):not(:has(.review-context-hint)),
.review-context-block.is-differs:not(:has(.review-context-copy)):not(:has(.review-context-hint)),
.review-context-block.is-warning:not(:has(.review-context-copy)):not(:has(.review-context-hint)) {
  display: inline-flex;
  align-items: center;
  min-height: var(--status-min-h);
  padding: var(--status-pad-y) var(--status-pad-x);
  border-radius: var(--chip-radius);
}

.review-context-block.is-match:not(:has(.review-context-copy)):not(:has(.review-context-hint)) .review-context-title,
.review-context-block.is-differs:not(:has(.review-context-copy)):not(:has(.review-context-hint)) .review-context-title,
.review-context-block.is-warning:not(:has(.review-context-copy)):not(:has(.review-context-hint)) .review-context-title {
  margin: 0;
}

.review-context-block.is-differs {
  border-color: rgba(185, 28, 28, 0.32);
  background: rgba(254, 226, 226, 0.82);
}

.review-context-block.is-differs .review-context-title {
  color: #991b1b;
}

.review-context-block.is-actionable {
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.review-context-block.is-actionable:hover,
.review-context-block.is-actionable:focus-visible {
  border-color: rgba(185, 28, 28, 0.5);
  background: rgba(254, 226, 226, 0.95);
  box-shadow: var(--shadow-sm);
  outline: none;
}

.review-context-hint {
  margin: 0.45rem 0 0;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #991b1b;
}

.review-context-block.is-clear {
  background: rgba(255, 255, 255, 0.42);
}

.review-context-block.is-info {
  width: 100%;
  border-color: rgba(37, 99, 235, 0.18);
  background: rgba(239, 246, 255, 0.65);
  border-radius: 1rem;
  padding: 0.65rem 0.8rem;
}

.review-context-block.is-info .review-context-title {
  color: #1e40af;
}

.review-context-block.is-info .review-context-list {
  margin-top: 0.4rem;
}

.review-context-title {
  margin: 0 0 0.3rem;
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: var(--lh-tight);
  color: var(--text-secondary);
}

.review-context-copy {
  margin: 0;
  font-size: var(--text-sm);
  line-height: var(--lh-body);
  color: var(--ink);
}

.review-context-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.4rem;
}

.review-context-item {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: var(--chip-min-h);
  padding: var(--chip-pad-y) var(--chip-pad-x);
  border-radius: var(--chip-radius);
  border: 1px solid rgba(37, 99, 235, 0.16);
  background: rgba(255, 255, 255, 0.72);
  box-sizing: border-box;
}

.review-context-item-pair {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem;
  font-size: var(--chip-font);
  line-height: var(--lh-tight);
  color: var(--ink);
}

.review-context-item-pair .review-context-nb {
  font-weight: 600;
  color: var(--brand-deep);
}

.add-card-review-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

/* Hug the label — not a full-width bar */
.add-card-review-actions .btn {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  min-height: var(--chip-min-h);
  padding: var(--chip-pad-y) var(--chip-pad-x);
  font-size: var(--chip-font);
  line-height: var(--lh-tight);
}

.add-card-review-actions .btn.primary {
  flex: 0 0 auto;
}

.card-item.is-editing {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand-ring);
}

@media (max-width: 560px) {
  .add-card-review-join {
    display: none;
  }

  .add-card-field-join {
    display: none;
  }
}

.add-card-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.add-card-form-actions .btn {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  min-height: var(--chip-min-h);
  padding: var(--chip-pad-y) var(--chip-pad-x);
  font-size: var(--chip-font);
  line-height: var(--lh-tight);
}

.add-card-form-actions .btn.ghost {
  min-width: 0;
}

.add-card-form-actions .btn.primary {
  margin-top: 0;
}

.add-card-form input {
  width: 100%;
  padding: 0.55rem 0.8rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-glass);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.add-card-form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.add-card-field-nb input:focus {
  box-shadow: 0 0 0 3px rgba(54, 95, 207, 0.14);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.form-row.add-card-fields {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.45rem 0.55rem;
  margin-bottom: 0;
  align-items: end;
}

@media (max-width: 560px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .form-row.add-card-fields {
    grid-template-columns: 1fr;
  }
}

.add-card-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.add-card-form input {
  padding: 0.55rem 0.8rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-glass);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.add-card-form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.form-hint {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  margin: 0 0 1.25rem;
}

.form-hint code {
  background: var(--brand-soft);
  color: var(--brand-deep);
  padding: 0.12rem 0.38rem;
  border-radius: 6px;
  font-size: 0.85em;
}

.panel-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.library-controls {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

#stats-panel .stats-summary {
  margin-bottom: 1.1rem;
}

.library-search {
  width: 100%;
  padding: 0.82rem 1.05rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-glass-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.library-search:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.library-search.library-search--ready {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.library-search::placeholder {
  color: var(--text-tertiary);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--chip-min-h);
  padding: var(--chip-pad-y) var(--chip-pad-x);
  border: 1px solid var(--border-strong);
  border-radius: var(--chip-radius);
  background: var(--surface-glass);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--chip-font);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.filter-chip:hover {
  color: var(--brand-deep);
  border-color: var(--brand-ring);
  background: var(--brand-soft);
}

.filter-chip.active {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-brand);
}



.count-badge {
  font-size: 0.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.18), rgba(54, 95, 207, 0.1));
  border: 1px solid var(--brand-ring);
  color: var(--brand-deep);
  padding: 0.22rem 0.58rem;
  border-radius: 999px;
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
}

/* Library section jump — sticky index for long decks.
   Full-width white bar (matches search / cards).
   Chips keep natural width; free space is split evenly between them
   (space-between) so labels stay complete and the active blue pill
   sits fully inside the bar padding. */
.library-jump {
  position: sticky;
  top: 0.45rem;
  z-index: 20;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0 0 1rem;
  /* Inset: blue bubble never meets the outer rounded edge */
  padding: 0.38rem 0.5rem;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.library-jump.hidden {
  display: none;
}

.library-jump-track {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  gap: 0.15rem;
  overflow: visible;
}

.library-jump-track::after {
  display: none;
  content: none;
}

.library-jump-chip {
  flex: 0 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.32rem 0.45rem;
  border: 1px solid transparent;
  border-radius: var(--chip-radius);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    color 0.2s var(--ease),
    background 0.2s var(--ease),
    border-color 0.2s var(--ease);
}

.library-jump-chip:hover,
.library-jump-chip:focus-visible {
  color: var(--brand-deep);
  background: var(--brand-soft);
  border-color: var(--brand-ring);
  outline: none;
}

.library-jump-chip.is-active {
  color: #fff;
  background: var(--brand-gradient);
  border-color: transparent;
  box-shadow: none;
}

/* —— Desktop Library: calm stack, clear filters vs jump, readable list —— */
@media (min-width: 721px) {
  #cards-panel.active {
    width: min(100%, 40rem);
    margin-inline: auto;
  }

  .library-header {
    margin-bottom: 1.15rem;
  }

  .library-header .panel-title {
    font-size: 1.35rem;
  }

  .library-header .btn {
    min-height: 2.25rem;
  }

  .add-card-form {
    padding: 1.05rem 1.15rem 1rem;
    margin-bottom: 1rem;
  }

  .form-row.add-card-fields {
    gap: 0.55rem 0.75rem;
  }

  .add-card-form input {
    padding: 0.65rem 0.95rem;
    font-size: 0.98rem;
  }

  .add-card-form-actions {
    margin-top: 0.7rem;
    gap: 0.5rem;
  }

  .add-card-form-actions .btn {
    min-height: 2.25rem;
    padding: 0.4rem 0.95rem;
  }

  .library-controls {
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .library-search {
    padding: 0.9rem 1.15rem;
    font-size: 0.98rem;
  }

  /* All / Phrases / Yours — equal segments, not a loose chip pile */
  .filter-chips {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    width: 100%;
  }

  .filter-chip {
    width: 100%;
    min-height: 2.35rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.84rem;
  }

  .library-jump {
    top: 0.55rem;
    padding: 0.4rem 0.55rem;
    margin-bottom: 1.15rem;
  }

  .library-jump-track {
    gap: 0.2rem;
  }

  .library-jump-chip {
    min-height: 2.15rem;
    padding: 0.35rem 0.4rem;
    font-size: 0.76rem;
  }

  .card-list {
    gap: 1.85rem;
  }

  .card-group-title {
    margin-bottom: 0.65rem;
    font-size: 0.74rem;
    letter-spacing: 0.07em;
  }

  .card-group-list {
    gap: 0.55rem;
  }

  .card-item {
    padding: 1rem 1.2rem;
    gap: 1.15rem;
    transition:
      border-color 0.2s var(--ease),
      box-shadow 0.2s var(--ease);
  }

  .card-item:hover {
    box-shadow: var(--shadow-md);
  }

  .card-item-foreign {
    font-size: 1.15rem;
  }

  .card-item-native {
    font-size: 0.94rem;
  }

  .card-item-actions {
    gap: 0.4rem;
  }

  .card-item-actions .btn {
    min-height: 2.15rem;
    padding: 0.35rem 0.75rem;
  }

  .library-empty {
    padding: 2.75rem 2rem;
  }
}

/* —— Mobile Library: must follow base library + card-item so overrides win —— */
@media (max-width: 720px) {
  #cards-panel.active {
    width: 100%;
    min-width: 0;
  }

  /* Header: title + reset on one row — less vertical waste */
  .library-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
  }

  .library-header .panel-title {
    justify-content: flex-start;
    font-size: 1.2rem;
  }

  .library-header .btn {
    width: auto;
    max-width: none;
    min-height: 44px;
    padding-inline: 0.85rem;
    flex-shrink: 0;
  }

  /* Add form: stacked fields, full-width primary action */
  .add-card-form {
    padding: 0.95rem 0.9rem 0.9rem;
    margin-bottom: 0.85rem;
  }

  .form-row.add-card-fields {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .add-card-field-join {
    display: none;
  }

  .add-card-form input {
    font-size: 16px; /* prevent iOS focus zoom */
    min-height: 48px;
    padding: 0.7rem 0.95rem;
  }

  .add-card-form-actions {
    margin-top: 0.7rem;
    gap: 0.45rem;
  }

  .add-card-form-actions .btn {
    min-height: 48px;
    padding-inline: 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
  }

  .add-card-form-actions .btn.primary {
    flex: 1 1 auto;
  }

  .library-suggest-option {
    min-height: 44px;
    padding: 0.55rem 0.65rem;
    align-items: center;
  }

  /* Confirm pair: full-width action row */
  .add-card-review {
    padding: 0.9rem 0.85rem;
    margin-bottom: 0.85rem;
  }

  .add-card-review-join {
    display: none;
  }

  .add-card-review-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.7rem;
    justify-content: stretch;
  }

  .add-card-review-actions .btn {
    flex: 1 1 calc(50% - 0.2rem);
    min-width: calc(50% - 0.2rem);
    width: auto;
    min-height: 48px;
    justify-content: center;
    font-weight: 600;
  }

  .add-card-review-actions .btn.primary {
    flex: 1 1 100%;
  }

  .add-card-review-actions .btn.hidden {
    display: none;
  }

  /* Search + filters */
  .library-controls {
    gap: 0.55rem;
    margin-bottom: 0.75rem;
  }

  .library-search {
    font-size: 16px; /* prevent iOS focus zoom */
    min-height: 48px;
    padding: 0.8rem 1rem;
  }

  .filter-chips {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
    max-width: 100%;
    margin: 0;
    overflow: visible;
  }

  .filter-chip {
    width: 100%;
    min-height: 48px;
    padding-inline: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    touch-action: manipulation;
  }

  /* Swipeable jump strip — don’t crush band labels into equal columns */
  .library-jump {
    top: 0.3rem;
    padding: 0.3rem 0.35rem;
    margin-bottom: 0.85rem;
    border-radius: 999px;
  }

  .library-jump-track {
    justify-content: flex-start;
    gap: 0.2rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding-inline-end: 0.25rem;
    scroll-padding-inline: 0.4rem;
  }

  .library-jump-track::-webkit-scrollbar {
    display: none;
  }

  .library-jump-track::after {
    display: block;
    content: "";
    flex: 0 0 0.3rem;
    width: 0.3rem;
    min-width: 0.3rem;
  }

  .library-jump-chip {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    overflow: visible;
    text-overflow: unset;
  }

  .card-group {
    scroll-margin-top: 3.75rem;
  }

  .card-list {
    gap: 1.35rem;
  }

  .card-group-title {
    margin-bottom: 0.5rem;
    font-size: 0.7rem;
  }

  .card-group-list {
    gap: 0.45rem;
  }

  /*
   * Card rows: stretch text (no zigzag). Actions = equal 3-up like Review.
   * align-items: stretch must beat base align-items: center.
   */
  .card-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
    padding: 0.95rem 0.9rem 0.85rem;
  }

  .card-item-text {
    width: 100%;
    flex: none;
  }

  .card-item-foreign {
    font-size: 1.08rem;
  }

  .card-item-native {
    font-size: 0.9rem;
    margin-top: 0.15rem;
  }

  .card-item-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
    width: 100%;
  }

  .card-item-actions .btn {
    min-height: 48px;
    width: 100%;
    touch-action: manipulation;
    padding-inline: 0.3rem;
    font-size: 0.82rem;
    font-weight: 600;
  }

  .library-empty {
    padding: 2rem 1.15rem;
  }

  .page-float-top-btn {
    min-height: 48px;
    min-width: 48px;
    padding: 0.6rem 1.05rem;
  }
}

/* Shared Top control for long Library / Progress pages */
.page-float-top {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1.15rem, env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: flex;
  align-items: center;
}

.page-float-top.hidden {
  display: none;
}

.page-float-top-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--brand-deep);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    opacity 0.2s var(--ease),
    transform 0.2s var(--ease),
    background 0.2s var(--ease),
    border-color 0.2s var(--ease);
}

.page-float-top-btn:hover,
.page-float-top-btn:focus-visible {
  background: var(--brand-soft);
  border-color: var(--brand-ring);
  outline: none;
}

.page-float-top-btn:active {
  transform: scale(0.97);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.card-group {
  scroll-margin-top: 4.25rem;
}

.card-group-title {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.card-group-range {
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  opacity: 0.75;
}

.card-group-range::before {
  content: "·";
  margin: 0 0.35em;
  opacity: 0.7;
}

.card-group-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.library-empty {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-secondary);
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.95rem 1.1rem;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s var(--ease);
}

.card-item:hover {
  border-color: var(--brand-ring);
}

.card-item-text {
  min-width: 0;
  flex: 1 1 auto;
  text-align: left;
}

.card-item-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.card-item-foreign {
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  color: var(--brand-deep);
  word-break: break-word;
  line-height: 1.25;
  text-align: left;
}

.card-item-native {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  line-height: 1.35;
  text-align: left;
}

/* Progress tab */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 1.1rem;
  width: 100%;
}

.progress-coverage {
  margin-bottom: 1.1rem;
  padding: 0.9rem 1rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.progress-coverage-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.progress-coverage-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.progress-coverage-value {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.progress-coverage-total {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-coverage-bar {
  height: 0.45rem;
  border-radius: 999px;
  background: rgba(54, 95, 207, 0.08);
  overflow: hidden;
}

.progress-coverage-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #5b9aff);
  transition: width 0.35s var(--ease);
}

.progress-coverage-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}



.progress-daily {
  margin-bottom: 1.35rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-glass-strong);
  border: 1px solid var(--border-strong);
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.progress-daily.is-complete {
  border-color: rgba(47, 179, 82, 0.28);
  background: rgba(240, 253, 244, 0.82);
  color: #1f6b45;
  font-weight: 500;
}

.progress-daily.is-quiet {
  background: rgba(255, 255, 255, 0.42);
}

.progress-section {
  margin-bottom: 1.5rem;
}

.progress-section:last-child {
  margin-bottom: 0;
}

.progress-section-title {
  margin: 0 0 0.75rem;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: var(--lh-tight);
  color: var(--text-tertiary);
}

.progress-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.progress-section-head .progress-section-title {
  margin-bottom: 0;
}

.progress-read-reset-all {
  flex-shrink: 0;
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-glass-strong);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    border-color 0.15s var(--ease),
    background 0.15s var(--ease),
    color 0.15s var(--ease);
}

.progress-read-reset-all:hover {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
  color: var(--brand);
}

.stat-card {
  background: var(--surface-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.5rem 0.85rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-card.highlight {
  background: linear-gradient(145deg, rgba(91, 154, 255, 0.16) 0%, rgba(54, 95, 207, 0.08) 100%);
  border-color: var(--brand-ring);
  box-shadow: var(--shadow-brand);
}

.stat-card--risk .stat-label {
  color: var(--brand);
}

.stat-card--action {
  width: 100%;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.15s var(--ease),
    box-shadow 0.15s var(--ease),
    background 0.15s var(--ease),
    border-color 0.15s var(--ease);
}

.stat-card--action:hover {
  border-color: var(--brand-ring);
  box-shadow: var(--shadow-md);
}

.stat-card--action:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-sm);
}

.stat-card--action.highlight:hover {
  background: linear-gradient(145deg, rgba(91, 154, 255, 0.22) 0%, rgba(54, 95, 207, 0.12) 100%);
}

.stat-value {
  display: block;
  font-size: clamp(1.75rem, 6vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1.05;
}

.stat-card.highlight .stat-value {
  color: var(--brand);
}

.stat-label {
  display: block;
  margin-top: 0.4rem;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: var(--lh-tight);
  color: var(--text-tertiary);
  line-height: 1.3;
}

/* —— Desktop Progress: glanceable stats, calm sections —— */
@media (min-width: 721px) {
  #stats-panel.active {
    width: min(100%, 40rem);
    margin-inline: auto;
  }

  .stats-summary {
    gap: 0.75rem;
    margin-bottom: 1.35rem;
  }

  .stat-card {
    padding: 1.35rem 0.9rem 1.2rem;
    border-radius: var(--radius-sm);
    transition:
      border-color 0.2s var(--ease),
      box-shadow 0.2s var(--ease),
      transform 0.15s var(--ease);
  }

  .stat-card--action:hover {
    transform: translateY(-1px);
  }

  .stat-value {
    font-size: clamp(1.85rem, 2.4vw, 2.25rem);
  }

  .stat-label {
    margin-top: 0.45rem;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
  }

  .progress-prefs {
    gap: 0.85rem;
    margin-bottom: 1.15rem;
  }

  .category-picker--progress .category-picker-btn {
    min-height: 2.15rem;
    padding: 0.35rem 0.85rem 0.35rem 0.9rem;
    font-size: 0.78rem;
  }

  .voice-gender-control {
    min-width: 9.25rem;
  }

  .voice-gender-option {
    min-height: 1.85rem;
    padding: 0.22rem 0.65rem;
    font-size: 0.76rem;
  }

  .progress-coverage {
    margin-bottom: 1.35rem;
    padding: 1.05rem 1.15rem 1rem;
  }

  .progress-coverage-head {
    margin-bottom: 0.65rem;
  }

  .progress-coverage-label {
    font-size: 0.7rem;
  }

  .progress-coverage-value {
    font-size: 1.25rem;
  }

  .progress-coverage-bar {
    height: 0.5rem;
  }

  .progress-coverage-meta {
    margin-top: 0.65rem;
    font-size: 0.84rem;
  }

  .progress-daily {
    margin-bottom: 1.5rem;
    padding: 0.95rem 1.15rem;
    font-size: 0.92rem;
  }

  .progress-section {
    margin-bottom: 1.75rem;
    padding: 1.1rem 1.15rem 1.05rem;
    border-radius: var(--radius-sm);
    background: var(--surface-glass-strong);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-sm);
  }

  .progress-section:last-child {
    margin-bottom: 0.5rem;
  }

  .progress-section-title {
    margin: 0 0 0.85rem;
    font-size: 0.72rem;
    letter-spacing: 0.07em;
  }

  .progress-section-head {
    margin-bottom: 0.85rem;
  }

  .progress-read-reset-all {
    padding: 0.35rem 0.7rem;
    font-size: 0.7rem;
  }

  .box-stats,
  .read-progress-stats {
    gap: 0.55rem;
    margin-bottom: 0;
  }

  .box-stat-row,
  .band-stat-row,
  .read-stat-row {
    gap: 1rem;
    padding: 0.35rem 0.25rem;
    border-radius: var(--radius-xs);
  }

  .read-stat-row--link:hover {
    background: var(--brand-soft);
  }

  .box-stat-bar-wrap {
    height: 8px;
  }

  .read-stat-group {
    column-gap: 0.85rem;
    row-gap: 0.4rem;
  }

  .read-stat-group + .read-stat-group {
    margin-top: 1.15rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
  }

  .read-stat-group-title {
    margin-bottom: 0.45rem;
    font-size: 0.74rem;
  }

  .read-stat-title {
    font-size: 0.92rem;
  }

  .read-stat-count {
    font-size: 0.88rem;
  }
}

/*
 * Tablet soft band (iPad portrait / small landscape).
 * Same desktop structure; only fix real mid-width pain: touch targets,
 * Progress 4-up density, Read options wrap, Library jump label density.
 */
@media (min-width: 721px) and (max-width: 1024px) {
  .app {
    padding:
      calc(1.5rem + env(safe-area-inset-top, 0px))
      calc(1.25rem + env(safe-area-inset-right, 0px))
      calc(1.5rem + env(safe-area-inset-bottom, 0px))
      calc(1.25rem + env(safe-area-inset-left, 0px));
  }

  /* Tabs: comfortable touch without looking like phone */
  .tab {
    min-height: 2.55rem;
    padding: 0.5rem 1rem;
  }

  /* Review: larger hit areas on chrome + actions */
  .practice-card-top .direction-toggle {
    min-height: 2.55rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.7rem;
  }

  .answer-actions .btn {
    min-height: 2.85rem;
  }

  /* Read: footer can wrap on mid widths without crowding */
  .read-footer {
    flex-wrap: wrap;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 0.85rem;
  }

  .read-options {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem;
  }

  .read-options .btn.small,
  .read-options .read-toggle-en {
    min-height: 2.55rem;
    min-width: 6.5rem;
  }

  .read-nav-btn {
    min-height: 2.55rem;
  }

  .read-trail-btn,
  .read-story-select {
    min-height: 2.75rem;
  }

  /* Progress: 2×2 stats — 4-up is cramped at ~768 content width */
  .stats-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .stat-card {
    padding: 1.2rem 0.85rem 1.05rem;
  }

  .stat-card--action,
  .stat-card--action:hover {
    transform: none; /* touch: no hover-lift dependency */
  }

  /* Library: equal filters already; denser jump chips + full touch height */
  .filter-chip {
    min-height: 2.65rem;
  }

  .library-jump-chip {
    min-height: 2.55rem;
    padding: 0.35rem 0.32rem;
    font-size: 0.72rem;
  }

  .card-item-actions .btn {
    min-height: 2.55rem;
  }
}

@media (max-width: 720px) {
  /* —— Mobile Progress only: glanceable 2×2, section cards, touch rows —— */
  #stats-panel.active {
    width: 100%;
    min-width: 0;
  }

  .stats-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
    margin-bottom: 1rem;
  }

  .stat-card {
    min-width: 0;
    padding: 1.05rem 0.55rem 0.95rem;
    box-sizing: border-box;
    border-radius: var(--radius-sm);
  }

  .stat-value {
    font-size: clamp(1.5rem, 6.5vw, 1.9rem);
  }

  .stat-label {
    margin-top: 0.35rem;
    font-size: clamp(0.6rem, 2.5vw, 0.7rem);
    letter-spacing: 0.03em;
    line-height: 1.2;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
    text-wrap: balance;
  }

  .progress-prefs {
    gap: 0.45rem;
    margin-bottom: 0.85rem;
  }

  .category-picker--progress .category-picker-btn {
    min-height: 2.1rem;
    padding: 0.32rem 0.6rem 0.32rem 0.7rem;
    font-size: 0.7rem;
  }

  .progress-voice-label {
    /* On narrow screens the segment labels are enough */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .voice-gender-control {
    min-width: 8.25rem;
  }

  .voice-gender-option {
    min-height: 1.85rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
  }

  .progress-section {
    margin-bottom: 0.85rem;
    padding: 0.95rem 0.9rem 0.9rem;
    border-radius: var(--radius-sm);
    background: var(--surface-glass-strong);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-sm);
  }

  .progress-section:last-child {
    margin-bottom: 0.35rem;
  }

  .progress-section-title {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    margin-bottom: 0.65rem;
  }

  .progress-section-head {
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
  }

  .progress-read-reset-all {
    min-height: 44px;
    padding: 0.4rem 0.75rem;
    font-size: 0.7rem;
  }

  .progress-coverage {
    padding: 0.9rem 0.9rem 0.85rem;
    margin-bottom: 0.85rem;
  }

  .box-stats {
    gap: 0.45rem;
    margin-bottom: 0;
  }

  /* Level rows: label | bar | count — stay one line on phones */
  .box-stat-row {
    grid-template-columns: minmax(0, 5.5rem) 1fr 1.85rem;
    gap: 0.5rem;
    min-height: 2.65rem;
    align-items: center;
    padding: 0.15rem 0;
  }

  .box-stat-name {
    font-size: 0.86rem;
  }

  .box-stat-interval {
    font-size: 0.68rem;
  }

  .box-stat-bar-wrap {
    height: 8px;
  }

  .box-stat-count {
    text-align: right;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
  }

  .read-progress-stats {
    gap: 0.75rem;
    margin-bottom: 0;
  }

  .read-stat-group {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 0.45rem;
    row-gap: 0.4rem;
  }

  .read-stat-group + .read-stat-group {
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
  }

  .read-stat-group-title {
    margin-bottom: 0.4rem;
    font-size: 0.72rem;
  }

  /* Story row: title above bar; count + reset beside */
  .read-stat-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
    padding: 0.4rem 0.2rem;
  }

  .read-stat-row--link {
    min-height: 48px;
    touch-action: manipulation;
  }

  .read-stat-actions {
    grid-template-columns: auto 2.5rem;
    gap: 0.35rem;
    align-self: center;
  }

  .read-stat-count {
    text-align: right;
    font-size: 0.82rem;
  }

  .read-stat-reset-btn {
    width: 2.5rem;
    height: 2.5rem;
    min-height: 44px;
    min-width: 44px;
    font-size: 1.05rem;
  }

  .read-stat-reset-spacer {
    width: 2.5rem;
    height: 2.5rem;
  }

  .empty-home-status {
    width: 100%;
    max-width: 100%;
    gap: 0.5rem;
  }

  .home-stat {
    min-width: 0;
    padding: 0.6rem 0.35rem 0.55rem;
    box-sizing: border-box;
  }

  .home-stat__value {
    font-size: clamp(1.1rem, 4.5vw, 1.35rem);
  }

  .home-stat__label {
    font-size: clamp(0.56rem, 2.4vw, 0.66rem);
    letter-spacing: 0.02em;
    line-height: 1.15;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
    text-wrap: balance;
  }

  .meta-chip {
    font-size: var(--chip-font);
    padding: var(--chip-pad-y) 0.7rem;
    max-width: 100%;
    box-sizing: border-box;
  }

  .count-badge {
    font-size: var(--text-2xs);
    padding: 0.2rem 0.45rem;
  }
}

.box-stats,
.band-stats {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 2rem;
}

.box-stat-row {
  display: grid;
  grid-template-columns: minmax(0, 130px) 1fr 36px;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.9rem;
}

.band-stat-row {
  display: grid;
  grid-template-columns: 1fr 100px 32px;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.88rem;
}

.box-stat-label,
.band-stat-label,
.read-stat-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.box-stat-name,
.read-stat-title {
  color: var(--text);
  font-weight: 600;
  line-height: 1.25;
}

.box-stat-interval,
.read-stat-trail {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  line-height: 1.3;
}

.read-stat-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7rem;
  column-gap: 0.65rem;
  row-gap: 0.35rem;
  align-items: center;
}

.read-stat-row-wrap {
  display: contents;
}

.read-stat-row-wrap .read-stat-row {
  grid-column: 1;
  min-width: 0;
}

.read-stat-actions {
  grid-column: 2;
  display: grid;
  grid-template-columns: 4.35rem 1.65rem;
  gap: 0.45rem;
  align-items: center;
}

.read-stat-reset-spacer {
  width: 1.65rem;
  height: 1.65rem;
}

.read-stat-row-wrap--completed .read-stat-title,
.read-stat-row-wrap--completed .read-stat-count {
  color: #2f855a;
}

.read-stat-reset-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-glass-strong);
  color: var(--text-tertiary);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    border-color 0.15s var(--ease),
    background 0.15s var(--ease),
    color 0.15s var(--ease);
}

.read-stat-reset-btn:hover {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
  color: var(--brand);
}

.read-stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 1fr;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.9rem;
}

.read-stat-row--link {
  width: 100%;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.read-stat-row--link:hover {
  background: var(--brand-soft);
}

.read-stat-group + .read-stat-group {
  margin-top: 1rem;
}

.read-stat-group-title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  grid-column: 1 / -1;
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.read-stat-group-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.35rem;
}

.read-stat-count {
  text-align: right;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.band-stat-desc {
  color: var(--text-tertiary);
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

.box-stat-bar-wrap {
  height: 7px;
  background: rgba(54, 95, 207, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.box-stat-bar {
  height: 100%;
  background: var(--brand-gradient);
  border-radius: 999px;
  transition: width 0.5s var(--ease);
  box-shadow: 0 0 12px rgba(91, 154, 255, 0.35);
}

.box-stat-count {
  text-align: right;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.how-it-works {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.how-it-works li {
  margin-bottom: 0.5rem;
}

.how-it-works strong {
  font-weight: 600;
  color: var(--text);
}

/* Read tab — parallel text */
.app.read-focus .header {
  margin-bottom: 0.85rem;
}

.app.read-focus .brand {
  margin-bottom: 0.45rem;
  gap: 0.25rem;
}

.app.read-focus .brand-logo {
  width: min(168px, 44vw);
}

.read-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 0.95rem;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}

.read-header {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.read-shell--menu-open .read-header {
  z-index: 30;
}

.read-title-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  min-width: 0;
}

.read-trail-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 2.35rem;
  min-height: 2.35rem;
  padding: 0 0.55rem 0 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-glass-strong);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.1s var(--ease);
  touch-action: manipulation;
}

.read-trail-btn__label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}

.read-trail-btn:hover {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
}

.read-trail-btn.is-pressed {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.16), rgba(54, 95, 207, 0.1));
  box-shadow: inset 0 2px 4px rgba(54, 95, 207, 0.12);
  transform: translateY(1px);
}

.read-trail-btn .read-trail-symbol--green-circle,
.read-trail-btn .read-trail-symbol--blue-square {
  width: 0.95rem;
  height: 0.95rem;
}

.read-trail-btn .read-trail-symbol--black-diamond {
  width: 0.75rem;
  height: 0.75rem;
}

.read-trail-btn .read-trail-symbol--double-black-diamond .read-trail-diamond {
  width: 0.58rem;
  height: 0.58rem;
}

.read-story-select {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  min-width: 0;
  min-height: 2.35rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-glass-strong);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
  touch-action: manipulation;
}

.read-story-select:hover {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
}

.read-story-select[aria-expanded="true"] {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.12), rgba(54, 95, 207, 0.06));
}

.read-story-select-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.read-story-select-meta {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.read-story-select-pct {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.read-story-select-chevron {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--text-tertiary);
  border-bottom: 2px solid var(--text-tertiary);
  transform: rotate(45deg) translateY(-1px);
  opacity: 0.7;
}

/* Bar + fixed reset slot — never grows/shrinks the footer when you advance */
.read-progress-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1.75rem;
  align-items: center;
  gap: 0.4rem;
  min-height: 1.75rem;
}

.read-progress-bar {
  height: 3px;
  border-radius: 999px;
  background: rgba(54, 95, 207, 0.1);
  overflow: hidden;
  min-width: 0;
}

.read-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--brand-gradient);
  transition: width 0.35s var(--ease), background 0.35s var(--ease);
}

.read-progress-bar.is-complete .read-progress-fill {
  background: linear-gradient(90deg, #3db87a, #2f855a);
}

.read-progress-row .read-reset-btn {
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--text-tertiary);
  opacity: 1;
  transition:
    opacity 0.2s var(--ease),
    color 0.15s var(--ease),
    background 0.15s var(--ease),
    border-color 0.15s var(--ease);
}

.read-progress-row .read-reset-btn.is-idle {
  opacity: 0;
  pointer-events: none;
}

.read-progress-row .read-reset-btn:not(.is-idle):hover {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
  color: var(--brand);
}

.read-progress-bar.is-complete ~ .read-reset-btn:not(.is-idle) {
  color: #2f855a;
}

.read-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  max-height: min(16rem, 50vh);
  overflow-y: auto;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 0.35rem;
  z-index: 40;
}

.read-menu-empty {
  margin: 0;
  padding: 0.85rem 0.7rem 0.95rem;
  font-size: 0.84rem;
  color: var(--text-tertiary);
  text-align: center;
}

.read-menu-back {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.2rem;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  background: transparent;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
}

.read-menu-back:hover {
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.read-menu-back-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
}

.read-menu-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.65rem 0.7rem;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s var(--ease);
  touch-action: manipulation;
}

.read-menu-option:hover {
  background: var(--brand-soft);
}

.read-menu-option.active {
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.14), rgba(54, 95, 207, 0.08));
}

.read-menu-option-symbol {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
}

.read-menu-option-text {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
  flex: 1;
}

.read-menu-option-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.read-menu-option-meta {
  font-size: 0.74rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.read-menu-option-pct {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.read-trail-symbol {
  display: block;
  flex-shrink: 0;
}

.read-trail-symbol--green-circle {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: #2fb352;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.read-trail-symbol--blue-square {
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 0.12rem;
  background: #2f7fd4;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.read-trail-symbol--black-diamond {
  width: 0.9rem;
  height: 0.9rem;
  background: #1c1c1e;
  transform: rotate(45deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.read-trail-symbol--double-black-diamond {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.read-trail-symbol--double-black-diamond .read-trail-diamond {
  width: 0.72rem;
  height: 0.72rem;
  background: #1c1c1e;
  transform: rotate(45deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.read-context--before {
  margin-bottom: 0.4rem;
  height: 1.85rem;
  overflow: hidden;
  border-radius: var(--radius-xs);
  background: rgba(54, 95, 207, 0.04);
  padding: 0 0.5rem;
}

.read-context-anchor {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.read-context-anchor::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1.75rem;
  background: linear-gradient(to right, rgba(54, 95, 207, 0.04), transparent);
  pointer-events: none;
  z-index: 1;
}

.read-context-track {
  position: absolute;
  top: 50%;
  left: 0;
  display: inline-block;
  min-width: min-content;
  max-width: none;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--text-secondary);
  white-space: nowrap;
  will-change: transform;
}

.read-context-sentence {
  display: inline;
}

.read-focus {
  flex-shrink: 0;
  text-align: center;
  padding: 0.9rem 0.75rem 0.8rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 249, 253, 0.88));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.read-focus-nb {
  min-height: clamp(7.5rem, 24vw, 10.25rem);
  padding: 0.2rem 0;
  font-size: clamp(1.3rem, 4.8vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.45;
  color: var(--ink);
  overflow-wrap: break-word;
}

.read-unit {
  display: inline;
}

.read-unit--glued {
  white-space: nowrap;
}

/* Status pill: hugs text, same scale as other compact chips (a step above filters) */
.read-gloss-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--status-min-h);
  margin-top: 0.35rem;
}

.read-gloss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: 100%;
  min-height: var(--status-min-h);
  padding: var(--status-pad-y) var(--status-pad-x);
  border-radius: var(--chip-radius);
  background: linear-gradient(135deg, rgba(91, 154, 255, 0.12), rgba(54, 95, 207, 0.06));
  border: 1px solid var(--brand-ring);
  text-align: center;
  box-sizing: border-box;
}

.read-gloss.is-collapsed {
  visibility: hidden;
}

.read-gloss-meaning {
  margin: 0;
  font-size: var(--status-font);
  line-height: var(--lh-tight);
  letter-spacing: -0.015em;
  color: var(--brand-deep);
  font-weight: 600;
  word-break: break-word;
}

.read-focus-en-slot {
  min-height: 2.75rem;
  margin: 0.55rem 0 0;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

.read-focus-en-slot.is-collapsed {
  border-top-color: rgba(54, 95, 207, 0.06);
}

.read-focus-en {
  margin: 0;
  font-size: var(--text-md);
  line-height: var(--lh-body);
  color: var(--text-secondary);
}

.read-focus-en-slot.is-collapsed .read-focus-en {
  visibility: hidden;
}

.read-word {
  display: inline;
  border: none;
  background: none;
  padding: 0.08em 0.04em;
  margin: 0;
  font: inherit;
  color: inherit;
  border-radius: 0.35rem;
  cursor: default;
  vertical-align: baseline;
  transition: background 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.read-word--tappable {
  cursor: pointer;
  text-underline-offset: 0.18em;
}

/* Deck words: solid brand underline + light wash (ties Read to Review) */
.read-word--deck {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(54, 95, 207, 0.48);
  background: color-mix(in srgb, var(--brand) 9%, transparent);
  border-radius: 0.28rem;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.read-word--deck:hover,
.read-word--deck:focus-visible {
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  text-decoration-color: var(--brand);
  outline: none;
}

/* Story-only words: dotted underline, no wash */
.read-word--extra {
  text-decoration: underline dotted;
  text-decoration-thickness: 1.25px;
  text-decoration-color: color-mix(in srgb, var(--text-secondary) 55%, transparent);
}

.read-word--extra:hover,
.read-word--extra:focus-visible {
  background: color-mix(in srgb, var(--text-secondary) 8%, transparent);
  text-decoration-color: var(--text-secondary);
  outline: none;
}

.read-word--active {
  text-decoration-thickness: 2px;
  text-decoration-color: var(--brand);
}

.read-word--deck.read-word--active {
  background: color-mix(in srgb, var(--brand) 20%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 24%, transparent);
}

.read-word--extra.read-word--active {
  background: color-mix(in srgb, var(--text-secondary) 12%, transparent);
  text-decoration-style: solid;
}

.read-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.read-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.read-nav-btn {
  min-width: 3rem;
  min-height: 44px;
  padding-inline: 0.85rem;
  font-size: 1.1rem;
  touch-action: manipulation;
}

.read-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.read-progress {
  min-width: 4.5rem;
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: var(--lh-tight);
  color: var(--text-secondary);
}

.read-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  align-items: center;
  min-height: 2.75rem;
}

.read-reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.read-reset-btn:hover:not(:disabled) {
  background: var(--brand-soft);
  color: var(--brand);
}

.read-reset-btn:disabled {
  cursor: default;
}

@media (min-width: 721px) {
  /* —— Desktop Read: sentence is hero; chrome stays calm and aligned —— */
  .app.read-focus {
    padding-top: 1.5rem;
  }

  .app.read-focus .header {
    margin-bottom: 1.15rem;
  }

  .app.read-focus .brand {
    margin-bottom: 0.55rem;
  }

  .app.read-focus .brand-logo {
    width: min(188px, 26vw);
  }

  .read-shell {
    width: min(100%, 40rem);
    margin-inline: auto;
    padding: 1.35rem 1.5rem 1.2rem;
  }

  .read-header {
    gap: 0.5rem;
    margin-bottom: 0.85rem;
  }

  .read-title-row {
    gap: 0.6rem;
  }

  .read-trail-btn {
    min-width: 2.6rem;
    min-height: 2.6rem;
    padding: 0 0.65rem 0 0.55rem;
  }

  .read-story-select {
    min-height: 2.6rem;
    padding: 0.5rem 0.85rem;
  }

  .read-story-select-title {
    font-size: 1.02rem;
  }

  .read-progress-row {
    min-height: 1.85rem;
    gap: 0.45rem;
  }

  .read-progress-bar {
    height: 4px;
  }

  .read-context--before {
    height: 2rem;
    margin-bottom: 0.55rem;
    padding: 0 0.65rem;
  }

  .read-context-track {
    font-size: 0.92rem;
  }

  /* Sentence stage — more air, clearer focal card */
  .read-focus {
    padding: 1.35rem 1.5rem 1.2rem;
    border-radius: var(--radius-sm);
  }

  .read-focus-nb {
    min-height: clamp(8.5rem, 18vh, 11rem);
    font-size: clamp(1.45rem, 2.1vw, 1.85rem);
    line-height: 1.5;
    padding: 0.35rem 0.25rem;
  }

  .read-gloss-slot {
    margin-top: 0.35rem;
  }

  .read-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: nowrap;
    margin-top: 0.95rem;
    padding-top: 0.15rem;
  }

  .read-controls {
    flex: 0 0 auto;
    gap: 0.85rem;
  }

  .read-nav-btn {
    min-width: 3.25rem;
    min-height: 2.55rem;
    font-size: 1.15rem;
  }

  .read-progress {
    min-width: 4.75rem;
    font-size: 0.9rem;
  }

  /* Show English + Hear — equal pair, right-aligned */
  .read-options {
    flex: 0 1 auto;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: stretch;
    gap: 0.45rem;
    margin-top: 0;
    min-height: 0;
  }

  .read-options .btn.small,
  .read-options .read-toggle-en {
    min-height: 2.5rem;
    min-width: 8.25rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    justify-content: center;
  }

  .read-menu {
    max-height: min(18rem, 48vh);
    padding: 0.4rem;
  }

  .read-menu-option {
    padding: 0.7rem 0.75rem;
  }

  .read-menu-option-title {
    font-size: 0.92rem;
  }
}

@media (max-width: 720px) {
  /* —— Mobile Read only: hero sentence, equal nav, 3-up options —— */
  .app.read-focus .header {
    margin-bottom: 0.55rem;
  }

  .app.read-focus .brand {
    margin-bottom: 0.4rem;
  }

  .app.read-focus .brand-logo {
    width: min(140px, 42vw);
  }

  .read-shell {
    padding: 1rem 0.85rem 0.9rem;
  }

  .read-header {
    margin-bottom: 0.6rem;
    gap: 0.4rem;
  }

  .read-title-row {
    gap: 0.4rem;
  }

  .read-trail-btn {
    min-width: 2.65rem;
    min-height: 44px;
    padding: 0 0.55rem 0 0.5rem;
  }

  .read-story-select {
    min-height: 44px;
    padding: 0.45rem 0.7rem;
  }

  .read-story-select-title {
    font-size: 0.95rem;
  }

  .read-progress-bar {
    height: 4px;
  }

  .read-context--before {
    height: 1.7rem;
    margin-bottom: 0.45rem;
    padding: 0 0.45rem;
  }

  .read-context-track {
    font-size: 0.82rem;
  }

  /* Sentence stage — primary focus, more air than chrome */
  .read-focus {
    padding: 1.15rem 0.85rem 1rem;
  }

  .read-focus-nb {
    min-height: clamp(6.5rem, 22vh, 9rem);
    font-size: clamp(1.28rem, 5.6vw, 1.55rem);
    line-height: 1.48;
    padding: 0.25rem 0.1rem;
  }

  .read-gloss-slot {
    margin-top: 0.45rem;
  }

  .read-focus-en-slot {
    min-height: 2.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
  }

  .read-focus-en {
    font-size: 0.95rem;
  }

  .read-progress-row {
    min-height: 2rem;
    grid-template-columns: minmax(0, 1fr) 2rem;
  }

  .read-progress-row .read-reset-btn {
    width: 2rem;
    height: 2rem;
    font-size: 1.05rem;
  }

  .read-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    margin-top: 0.65rem;
    padding-top: 0;
  }

  /* Nav: equal prev/next thumbs, counter centered */
  .read-controls {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.45rem;
  }

  .read-nav-btn {
    width: 100%;
    min-height: 48px;
    max-width: none;
    font-size: 1.2rem;
    font-weight: 600;
  }

  .read-progress {
    flex: none;
    min-width: 3.75rem;
    font-size: 0.88rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  /* Options: Show English + Hear — equal pair */
  .read-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
    width: 100%;
    margin-top: 0;
    min-height: 0;
    justify-content: stretch;
  }

  .read-options .btn,
  .read-options .btn.small,
  .read-options .read-toggle-en {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    justify-content: center;
    padding: 0.4rem 0.5rem;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.15;
    white-space: nowrap;
    text-align: center;
  }

  .read-menu {
    max-height: min(15rem, 46vh);
  }

  .read-menu-option {
    min-height: 48px;
    padding: 0.65rem 0.7rem;
  }

  .read-menu-back {
    min-height: 44px;
  }
}

/*
 * Short landscape (phones often >720px wide, so desktop rules also apply).
 * Collapse chrome so Review/Read primary UI fits above the fold.
 */
@media (max-height: 500px) and (orientation: landscape) {
  .app {
    padding:
      max(0.4rem, env(safe-area-inset-top, 0px))
      max(0.75rem, env(safe-area-inset-right, 0px))
      max(0.4rem, env(safe-area-inset-bottom, 0px))
      max(0.75rem, env(safe-area-inset-left, 0px));
    min-height: 100svh;
  }

  .header {
    margin-bottom: 0.4rem;
  }

  .brand {
    margin-bottom: 0.2rem;
    gap: 0.1rem;
  }

  .brand-logo {
    width: min(88px, 18vw);
    height: auto;
    margin-bottom: 0;
  }

  .app.practice-focus .brand-logo,
  .app.read-focus .brand-logo {
    width: min(72px, 15vw);
  }

  .tabs {
    padding: 0.18rem;
  }

  .tab {
    min-height: 2rem;
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
  }

  .practice-meta {
    margin-bottom: 0.35rem;
  }

  .daily-progress {
    margin-bottom: 0.35rem;
  }

  /* Cancel wide-screen empty Review vertical centering (eats height) */
  #practice-panel.active:has(#practice-empty:not(.hidden)) {
    min-height: 0;
    justify-content: flex-start;
    padding-block: 0;
  }

  #practice-panel.active #practice-empty:not(.hidden) {
    width: min(100%, 22rem);
  }

  .site-footer {
    padding-top: 0.5rem;
  }

  .site-footer-btn {
    min-height: 2rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.65rem;
  }

  .welcome-modal {
    padding: 0.4rem 0.65rem;
  }

  .welcome-logo {
    width: min(100px, 24vw);
    height: auto;
    margin-bottom: 0.4rem;
  }

  .welcome-card {
    padding: 0.7rem 0.9rem 0.75rem;
    width: min(100%, 18rem);
  }

  .category-picker--welcome {
    margin-bottom: 0.55rem;
  }

  .empty-state {
    padding: 0.75rem 0.85rem 0.8rem;
  }

  .empty-state--actions {
    padding: 0.7rem 0.85rem 0.7rem;
  }

  .empty-icon {
    width: 2.15rem;
    height: 2.15rem;
    margin-bottom: 0.4rem;
  }

  .empty-state h2 {
    font-size: 1.15rem;
    margin-bottom: 0.25rem;
  }

  .empty-state p {
    margin-bottom: 0.55rem;
  }

  .empty-actions {
    gap: 0.35rem;
  }

  .empty-home-status {
    gap: 0.4rem;
  }

  .home-stat {
    padding: 0.45rem 0.5rem 0.4rem;
  }

  .home-stat__value {
    font-size: 1.1rem;
  }

  .about-logo {
    width: 2.35rem;
    height: auto;
    margin: 0 auto 0.4rem;
  }

  .about-card {
    max-height: min(94svh, 100%);
  }

  .about-card-head {
    margin-bottom: 0.15rem;
  }

  .about-body {
    padding-top: 0;
  }

  .about-lead {
    margin-bottom: 0.5rem;
    font-size: 1rem;
  }

  .about-section {
    margin-bottom: 0.5rem;
  }

  .about-section-title {
    margin-bottom: 0.25rem;
  }

  .read-shell {
    padding: 0.65rem 0.75rem 0.55rem;
  }

  .read-focus-nb {
    min-height: 4.5rem;
  }

  .library-header {
    margin-bottom: 0.5rem;
  }

  .stats-summary {
    gap: 0.4rem;
  }

  .stat-card {
    padding: 0.65rem 0.4rem;
  }
}

