:root {
  color-scheme: light;
  --page: #eaf6ff;
  --page-deep: #d8edf9;
  --card: #ffffff;
  --ink: #10233f;
  --muted: #61738a;
  --line: #d7e5ef;
  --green: #2fa46f;
  --green-soft: #e6f6ee;
  --amber: #e7a93f;
  --amber-soft: #fff4dc;
  --red: #d8615d;
  --red-soft: #fdebea;
  --blue: #4da3d9;
  --blue-soft: #e9f6fd;
  --shadow: 0 16px 40px rgba(16, 35, 63, 0.12);
  --radius: 22px;
  font-family: "Atkinson Hyperlegible", Verdana, Tahoma, Arial, sans-serif;
}

body.dark {
  color-scheme: dark;
  --page: #0f1f34;
  --page-deep: #132a46;
  --card: #172d49;
  --ink: #f3f9ff;
  --muted: #b4c5d5;
  --line: #27425f;
  --green-soft: #173b30;
  --amber-soft: #45351c;
  --red-soft: #442525;
  --blue-soft: #15344d;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(77, 163, 217, 0.18), transparent 320px),
    linear-gradient(180deg, var(--page), var(--page-deep));
  color: var(--ink);
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(77, 163, 217, 0.55);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.app-header {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.brand {
  text-align: center;
}

.brand span,
.eyebrow,
.meta,
.stat-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: clamp(1.55rem, 7vw, 2.2rem);
  line-height: 1.08;
}

.icon-button {
  min-height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(16, 35, 63, 0.08);
  font-size: 0.78rem;
  font-weight: 900;
}

body.dark .icon-button {
  background: rgba(255, 255, 255, 0.08);
}

.hero-card,
.card,
.tile,
.quick-stats div,
.tabbar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

body.dark .hero-card,
body.dark .card,
body.dark .tile,
body.dark .quick-stats div,
body.dark .tabbar {
  background: rgba(23, 45, 73, 0.92);
}

.hero-card {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 16px;
  align-items: center;
  padding: 18px;
}

.hero-card p {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 900;
}

.hero-card strong {
  display: block;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1.2;
}

.hero-ring {
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--green) var(--ring, 0%), var(--blue-soft) 0);
  color: var(--ink);
}

.hero-ring span,
.hero-ring small {
  grid-area: 1 / 1;
}

.hero-ring span {
  align-self: center;
  font-size: 1.1rem;
  font-weight: 900;
}

.hero-ring small {
  align-self: end;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.quick-stats div {
  min-height: 78px;
  display: grid;
  place-items: center;
  padding: 10px;
}

.quick-stats span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.quick-stats strong {
  color: var(--ink);
  font-size: 1.2rem;
}

.screen {
  display: grid;
  gap: 14px;
}

.card {
  padding: 18px;
}

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

.section-head h2,
.question-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.35rem, 7vw, 2rem);
  line-height: 1.16;
}

.section-head span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tile {
  min-height: 132px;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 16px;
  color: var(--ink);
  text-align: left;
}

.tile strong {
  font-size: 1.08rem;
  line-height: 1.2;
}

.tile span,
.quiet,
.source-note {
  color: var(--muted);
  line-height: 1.55;
}

.tile-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 900;
}

.topic-list,
.badge-list {
  display: grid;
  gap: 10px;
}

.topic-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
  text-align: left;
}

body.dark .topic-row {
  background: rgba(255, 255, 255, 0.05);
}

.topic-row strong {
  display: block;
  line-height: 1.25;
}

.topic-row small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
}

.progress-track {
  grid-column: 1 / -1;
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--blue-soft);
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #74c995);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
}

.badge.gold {
  background: #fff2c7;
  color: #805c00;
}

.badge.silver {
  background: #edf2f7;
  color: #4e6478;
}

.badge.bronze {
  background: #f5dfca;
  color: #795131;
}

.badge.starter {
  background: var(--blue-soft);
  color: var(--blue);
}

.question-card {
  display: grid;
  gap: 14px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--blue-soft);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.question-title {
  font-size: clamp(1.55rem, 8vw, 2.28rem);
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  line-height: 1.6;
}

body.dark textarea {
  background: rgba(255, 255, 255, 0.06);
}

.primary,
.secondary,
.confidence {
  min-height: 58px;
  border-radius: 18px;
  padding: 14px 16px;
  font-weight: 900;
}

.primary {
  width: 100%;
  background: var(--green);
  color: #ffffff;
  box-shadow: 0 12px 22px rgba(47, 164, 111, 0.24);
}

.secondary {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
}

body.dark .secondary {
  background: rgba(255, 255, 255, 0.06);
}

.confidence-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.confidence {
  color: var(--ink);
  text-align: left;
}

.confidence.red {
  background: var(--red-soft);
  border: 2px solid rgba(216, 97, 93, 0.32);
}

.confidence.amber {
  background: var(--amber-soft);
  border: 2px solid rgba(231, 169, 63, 0.36);
}

.confidence.green {
  background: var(--green-soft);
  border: 2px solid rgba(47, 164, 111, 0.32);
}

.answer-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border-left: 6px solid var(--green);
  background: var(--green-soft);
}

.answer-card ul {
  margin: 0;
  padding-left: 22px;
  line-height: 1.6;
}

.answer-card p {
  margin: 0;
  line-height: 1.65;
}

.tabbar {
  position: sticky;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  margin-top: 6px;
}

.tabbar button {
  min-height: 46px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.tabbar button.active {
  background: var(--blue-soft);
  color: var(--ink);
}

.session-progress {
  display: grid;
  gap: 9px;
}

.session-progress .meta {
  display: flex;
  justify-content: space-between;
}

@media (max-width: 380px) {
  .action-grid {
    grid-template-columns: 1fr;
  }

  .hero-card {
    grid-template-columns: 1fr;
  }

  .hero-ring {
    justify-self: start;
  }
}
