/* Apni Awaaz — designed for older eyes, shaky hands and cheap phones:
   large text, big targets, high contrast, one main action per screen. */

:root {
  --bg: #fbf7f0;
  --surface: #ffffff;
  --surface-2: #f3eee5;
  --text: #1c1917;
  --muted: #655c53;
  --border: #e5dccf;
  --primary: #0f766e;
  --primary-strong: #0b5c56;
  --primary-ink: #ffffff;
  --primary-soft: #d5f5ef;
  --accent: #d97a00;
  --accent-soft: #fff0d4;
  --danger: #c2271b;
  --danger-soft: #fde4e1;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --shadow: 0 1px 2px rgb(28 25 23 / 6%), 0 6px 20px rgb(28 25 23 / 7%);
  --radius: 18px;
  --font: 'Noto Sans', 'Noto Sans Telugu', 'Noto Sans Devanagari', 'Nirmala UI', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12100e;
    --surface: #1c1917;
    --surface-2: #27221e;
    --text: #f5f1ea;
    --muted: #b3aaa1;
    --border: #3a342e;
    --primary: #2dd4bf;
    --primary-strong: #5eead4;
    --primary-ink: #042f2e;
    --primary-soft: #11403c;
    --accent: #fbbf24;
    --accent-soft: #3d2a07;
    --danger: #f87171;
    --danger-soft: #3f0d0b;
    --ok: #4ade80;
    --ok-soft: #0b2e17;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 35%);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.file-btn {
  position: relative;
  margin: 0;
}
.file-btn:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
  min-height: 100dvh;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin: 0.25rem 0 0.75rem;
}
h2 {
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
}
h3 {
  font-size: 1rem;
  margin: 0.25rem 0;
}
p {
  margin: 0.4rem 0;
}

a {
  color: var(--primary);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.875rem;
}
.center {
  text-align: center;
}
.danger-text {
  color: var(--danger);
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.boot {
  margin: auto;
  text-align: center;
  color: var(--muted);
}

/* ---------- header & nav ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
}

.header-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}
.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.pill.on .dot {
  background: var(--ok);
}
.pill.local .dot {
  background: var(--accent);
}
.pill.off {
  color: var(--muted);
}
.pill.lang {
  cursor: pointer;
}

main {
  flex: 1;
  padding: 8px 16px calc(96px + env(safe-area-inset-bottom));
}
/* main receives focus after each screen change (for screen readers); no ring. */
main:focus,
main:focus-visible {
  outline: none;
}
body[data-route='welcome'] main,
body[data-route='intro'] main,
body[data-route='teach'] main {
  padding-bottom: 32px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 10;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 2px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  min-height: 56px;
  justify-content: center;
}
.nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
}
.nav-label {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
}
.nav-sub {
  font-size: 0.6rem;
  opacity: 0.8;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.08s ease, background 0.2s ease;
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}
.btn.ghost {
  background: transparent;
}
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.danger-outline {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--surface);
}
.btn.big {
  min-height: 64px;
  font-size: 1.15rem;
  width: 100%;
}
.btn.small {
  min-height: 40px;
  padding: 6px 12px;
  font-size: 0.9rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  flex: none;
}
.icon-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}
.row > input,
.row > select {
  flex: 1 1 140px;
  margin: 0;
}

/* ---------- cards & forms ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}

label {
  display: block;
  font-weight: 600;
  margin: 10px 0 4px;
  font-size: 0.95rem;
}

input[type='text'],
input[type='tel'],
select {
  width: 100%;
  min-height: 50px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg);
}

.badge {
  display: inline-block;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  margin: 4px 4px 4px 0;
}
.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ---------- welcome / intro ---------- */

.welcome .hero {
  text-align: center;
  padding: 24px 8px 8px;
}
.hero-logo {
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.hero h1 {
  font-size: 2.2rem;
  margin: 12px 0 4px;
}
.hero-sub {
  font-size: 1.05rem;
  color: var(--primary);
  font-weight: 600;
}
.hero-copy {
  color: var(--muted);
}

.prompt-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}
.prompt-row .btn {
  font-size: 0.95rem;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.lang-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 72px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}
.lang-btn .native {
  font-size: 1.35rem;
  font-weight: 700;
}
.lang-btn .en {
  font-size: 0.85rem;
  color: var(--muted);
}
.lang-btn.featured {
  grid-column: 1 / -1;
  border-color: var(--primary);
  background: var(--primary-soft);
}

.steps {
  padding-left: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 2px 12px;
  margin: 12px 0;
}
.steps li::before {
  content: counter(step);
  grid-row: span 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  display: grid;
  place-items: center;
  font-weight: 700;
}
.steps li span {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- phrase text ---------- */

.phrase-text .native {
  font-weight: 700;
  line-height: 1.3;
}
.phrase-text .roman {
  color: var(--primary);
  font-weight: 600;
}
.phrase-text .meaning {
  color: var(--muted);
  font-size: 0.95rem;
}
.phrase-text.lg .native {
  font-size: 1.5rem;
}
.phrase-text.xl .native {
  font-size: clamp(1.75rem, 7vw, 2.4rem);
}
.phrase-text.xl .roman {
  font-size: 1.15rem;
}

/* ---------- teach ---------- */

.teach-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.progress {
  flex: 1;
}
.progress-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  width: 0;
  transition: width 0.4s ease;
}
.progress-text {
  font-size: 0.8rem;
  color: var(--muted);
}

.teach-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 20px 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.teach-icon {
  font-size: 2.6rem;
  line-height: 1;
  margin-bottom: 6px;
}

.rep-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 4px;
}
.rep-dots .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--primary);
}
.rep-dots .dot.done {
  background: var(--primary);
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.rec-wrap {
  display: flex;
  justify-content: center;
  margin: 14px 0 6px;
}

.rec-btn,
.mic-btn {
  position: relative;
  border: none;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #19a597, var(--primary) 55%, var(--primary-strong));
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 10px 30px rgb(15 118 110 / 35%);
  transition: transform 0.15s ease, background 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
@media (prefers-color-scheme: dark) {
  .rec-btn,
  .mic-btn {
    background: radial-gradient(circle at 30% 25%, #2dd4bf, #0f766e 60%, #0b4f4a);
  }
}
.rec-btn {
  width: 156px;
  height: 156px;
}
.rec-label {
  font-weight: 700;
}
.rec-btn.recording,
.mic-btn.recording {
  background: radial-gradient(circle at 30% 25%, #f59e0b, #d97706 55%, #b45309);
  box-shadow: 0 10px 30px rgb(217 119 6 / 40%);
}

.ring {
  --level: 0;
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 6px solid var(--accent);
  opacity: 0;
  transform: scale(calc(1 + var(--level) * 0.28));
  transition: transform 0.08s linear, opacity 0.2s ease;
  pointer-events: none;
}
.recording .ring {
  opacity: 0.85;
}
.recording .ring.speaking {
  border-color: var(--ok);
}

.status {
  text-align: center;
  font-weight: 600;
  min-height: 1.5em;
}

.heard-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 0;
  font-size: 0.9rem;
}
.heard-box:not(:empty) {
  padding: 10px 12px;
}
.heard-label {
  color: var(--muted);
  font-weight: 600;
}
.heard-note {
  color: var(--primary);
  font-size: 0.82rem;
}

.file-row {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.teach-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}

.milestone {
  text-align: center;
}
.big-emoji {
  font-size: 3rem;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 12px auto;
  border-radius: 50%;
  border: 4px solid var(--surface-2);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- home ---------- */

.banner {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 8px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.banner.info {
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
}
.banner.soft {
  background: var(--accent-soft);
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
}
.banner p {
  margin: 2px 0 0;
  font-size: 0.95rem;
}
.banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mic-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0 8px;
}
.mic-btn {
  width: min(66vw, 280px);
  height: min(66vw, 280px);
  max-height: 42dvh;
  max-width: 42dvh;
  min-width: 200px;
  min-height: 200px;
}
.mic-label {
  font-size: 1.45rem;
  font-weight: 800;
  text-align: center;
  padding: 0 18px;
  line-height: 1.2;
}
.mic-sub {
  font-size: 0.9rem;
  opacity: 0.85;
}
.mic-btn.busy {
  animation: breathe 1.4s ease-in-out infinite;
  cursor: progress;
}
@keyframes breathe {
  50% {
    transform: scale(0.96);
    opacity: 0.85;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mic-btn.busy,
  .spinner {
    animation: none;
  }
}

.mic-status {
  margin-top: 18px;
  text-align: center;
  font-weight: 600;
  font-size: 1.05rem;
}
.live-heard {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  min-height: 1.2em;
  margin: 0;
}

.pipeline {
  list-style: none;
  padding: 12px;
  margin: 8px 0 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.stage {
  display: grid;
  grid-template-columns: 18px auto 1fr;
  align-items: center;
  gap: 4px 10px;
  padding: 6px 2px;
  font-size: 0.9rem;
}
.stage-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
}
.stage.run .stage-dot {
  background: var(--accent);
  animation: breathe 0.8s infinite;
}
.stage.done .stage-dot {
  background: var(--ok);
}
.stage.fail .stage-dot {
  background: var(--danger);
}
.stage.skip {
  opacity: 0.6;
}
.stage-name {
  font-weight: 600;
}
.stage-detail {
  color: var(--muted);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick {
  margin-top: 16px;
}
.tile-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 96px;
  padding: 12px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow);
}
.tile.urgent {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: var(--danger-soft);
}
.tile-icon {
  font-size: 1.6rem;
  line-height: 1.2;
}
.tile-text {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.25;
}
.tile-roman {
  font-size: 0.78rem;
  color: var(--muted);
}
.tile-count {
  font-size: 0.75rem;
  color: var(--primary);
}
.tile-count.none {
  color: var(--muted);
}

.typed {
  margin-top: 18px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 10px 14px;
}
.typed summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.95rem;
}
.typed-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.typed-form input {
  flex: 1;
}

/* ---------- confirm ---------- */

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
  margin-top: 8px;
}
.label-sub {
  font-weight: 500;
  opacity: 0.85;
}

.answer-card {
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.answer-card.urgent {
  border-color: var(--danger);
}
.answer-icon {
  font-size: 2.2rem;
  line-height: 1.1;
}

.meter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.meter-track {
  flex: 1;
  height: 10px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--ok);
}
.meter.medium .meter-fill {
  background: var(--accent);
}
.meter.low .meter-fill {
  background: var(--danger);
}
.meter-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.compare {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: stretch;
  margin: 12px 0;
}
.compare-col {
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.compare-col.standard {
  background: var(--surface-2);
}
.compare-col.ours {
  background: var(--primary-soft);
}
.compare-head {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
.compare-text {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.compare-col.standard .compare-text {
  color: var(--muted);
  font-weight: 500;
}
.compare-col.standard.struck .compare-text {
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--danger) 60%, transparent);
}
.compare-arrow {
  align-self: center;
  font-size: 1.4rem;
  color: var(--primary);
}
.compare-line {
  color: var(--muted);
}

.yes-no {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0 6px;
}
.btn.yes,
.btn.no {
  min-height: 96px;
  flex-direction: column;
  gap: 2px;
  font-size: 1.3rem;
  border-radius: 20px;
}
.btn.yes {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.btn.no {
  background: var(--surface);
  border: 2px solid var(--danger);
  color: var(--danger);
}
.btn.yes small,
.btn.no small {
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.9;
}
@media (prefers-color-scheme: dark) {
  .btn.yes {
    color: #052e16;
  }
}

.voice-hint {
  text-align: center;
  color: var(--primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  animation: breathe 1.6s ease-in-out infinite;
}

.options {
  margin-top: 8px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.options.expanded {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.options-title {
  font-weight: 700;
  margin: 0 0 6px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 600;
  text-align: left;
}
.chip.ghost {
  background: transparent;
  border-style: dashed;
}
.chip.static {
  min-height: 40px;
  cursor: default;
  font-weight: 500;
}
.chip-score {
  font-size: 0.78rem;
  color: var(--muted);
}
.chip-x {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 2px;
  color: var(--muted);
}

.explain {
  margin-top: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 14px;
}
.explain summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
}
.explain-block {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.explain-block:last-child {
  border-bottom: none;
}

.bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  margin: 6px 0;
}
.bar-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
}
.bar.grey .bar-fill {
  background: var(--muted);
}
.bar.saffron .bar-fill {
  background: var(--accent);
}
.bar-label {
  font-size: 0.82rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.bar-title {
  font-weight: 600;
  margin: 10px 0 0;
  font-size: 0.95rem;
}

ul.plain,
ol.plain {
  list-style: none;
  padding: 0;
  margin: 6px 0;
}
ol.numbered {
  list-style: decimal;
  padding-left: 22px;
}
ul.plain li {
  padding: 3px 0;
}

/* ---------- done ---------- */

.done {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 8px;
}
.done-card {
  background: var(--surface);
  border: 2px solid var(--ok);
  border-radius: 22px;
  padding: 20px 18px;
  box-shadow: var(--shadow);
}
.done-check {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}
.emergency {
  background: var(--danger-soft);
  border: 2px solid var(--danger);
  border-radius: 20px;
  padding: 14px;
}
.emergency-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--danger);
  font-weight: 800;
  font-size: 1.15rem;
}
.emergency .row .btn {
  flex: 1;
}
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 104px;
  border-radius: 18px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--primary);
  box-shadow: var(--shadow);
}
.label {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}
.label-main {
  font-weight: 700;
  color: var(--text);
}
.label .label-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------- progress ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
}
.chart {
  width: 100%;
  height: auto;
  margin-top: 8px;
}
.chart .grid {
  stroke: var(--border);
  stroke-width: 1;
}
.chart .axis {
  fill: var(--muted);
  font-size: 10px;
}
.chart .bar-count {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 0.5;
}
.chart .line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.5;
  stroke-linejoin: round;
}
.chart .pt {
  fill: var(--primary);
}
.big-number {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--primary);
}
.confusion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- family ---------- */

.review-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  margin: 8px 0;
  background: var(--bg);
}
.review-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.phrase-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.phrase-icon {
  font-size: 1.3rem;
  width: 28px;
  text-align: center;
}
.phrase-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.count {
  font-size: 0.8rem;
  color: var(--primary);
  white-space: nowrap;
}
.count.none {
  color: var(--muted);
}
.add-phrase {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
label.check input {
  width: 22px;
  height: 22px;
}

/* ---------- settings ---------- */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  margin: 0;
}
.switch-row > span {
  display: flex;
  flex-direction: column;
}
.switch-row input {
  width: 28px;
  height: 28px;
  accent-color: var(--primary);
  flex: none;
}
.slider-row {
  padding: 8px 0;
}
.slider-row label {
  display: flex;
  justify-content: space-between;
  font-weight: 400;
}
.slider-row input {
  width: 100%;
  accent-color: var(--primary);
  height: 32px;
}
.engine-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}
.engine {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 0 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.engine .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}
.engine.on .dot {
  background: var(--ok);
}
.engine-name {
  font-weight: 600;
}
.engine-state {
  grid-column: 2;
  font-size: 0.82rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}

/* ---------- overlays ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 14px;
  max-width: calc(100% - 32px);
  width: max-content;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  font-size: 0.95rem;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error {
  background: var(--danger);
  color: #fff;
}

.modal-overlay,
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
}
.modal-text {
  font-size: 1.05rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.sheet-overlay {
  align-items: flex-end;
  padding: 0;
}
.sheet {
  background: var(--bg);
  width: 100%;
  max-width: 560px;
  max-height: 86dvh;
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: -16px;
  background: var(--bg);
  padding: 4px 0;
  z-index: 1;
}

@media (max-width: 360px) {
  body {
    font-size: 17px;
  }
  .brand span {
    white-space: nowrap;
  }
  .pill .pill-text {
    display: none;
  }
  .tile-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .compare {
    grid-template-columns: 1fr;
  }
  .compare-arrow {
    display: none;
  }
}
