:root {
  --color-bg: #f6f8fc;
  --color-surface: #ffffff;
  --color-surface-soft: #f8f9ff;
  --color-text: #172033;
  --color-text-soft: #667085;
  --color-text-faint: #8a94a6;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-soft: #eeedff;
  --color-primary-softer: #f7f6ff;
  --color-accent: #f59e0b;
  --color-accent-soft: #fff7e3;
  --color-success: #15803d;
  --color-success-soft: #eaf8ef;
  --color-danger: #c2413d;
  --color-danger-hover: #a93633;
  --color-danger-soft: #fff0ef;
  --color-warning: #a65f00;
  --color-warning-soft: #fff6df;
  --color-border: #d9dfea;
  --color-border-soft: #e9edf4;
  --shadow-xs: 0 1px 2px rgba(23, 32, 51, .04);
  --shadow-sm: 0 8px 24px rgba(45, 55, 89, .07);
  --shadow-md: 0 18px 50px rgba(45, 55, 89, .13);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --header-height: 64px;
  --bottom-nav-height: 68px;
  --content-max: 1180px;
  --font-sans: "Onest", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 4% -10%, rgba(79, 70, 229, .09), transparent 32rem),
    radial-gradient(circle at 96% 20%, rgba(245, 158, 11, .055), transparent 26rem),
    var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button,
label[for],
input[type="file"] {
  -webkit-tap-highlight-color: transparent;
}

button,
.button,
summary {
  touch-action: manipulation;
}

button,
.button {
  user-select: none;
}

button {
  border: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .56;
}

a {
  color: var(--color-primary);
}

svg {
  display: block;
}

.hidden {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--color-text);
  color: #fff;
  font-weight: 700;
  transform: translateY(-150%);
  transition: transform .16s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid rgba(79, 70, 229, .32);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(var(--header-height) + env(safe-area-inset-top));
}

.app-header {
  position: fixed;
  z-index: 50;
  top: 0;
  right: 0;
  left: 0;
  height: calc(var(--header-height) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid rgba(217, 223, 234, .78);
  background: rgba(255, 255, 255, .86);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.app-header.scrolled {
  border-bottom-color: rgba(202, 209, 221, .92);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 7px 22px rgba(32, 42, 68, .09);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, var(--content-max));
  height: var(--header-height);
  margin: 0 auto;
  padding: 0 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  text-align: left;
}

.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, .96);
  border-radius: 50%;
  background: #3c9bd0;
  box-shadow: 0 7px 18px rgba(31, 103, 148, .24);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  margin-left: 10px;
  line-height: 1.1;
}

.brand-copy strong {
  font-size: 17px;
  letter-spacing: -.02em;
}

.brand-copy small {
  display: none;
  margin-top: 4px;
  color: var(--color-text-soft);
  font-size: 11px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.demo-mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid #f2ca77;
  border-radius: 999px;
  background: #fff6d9;
  color: #815000;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 5px 10px 5px 6px;
  gap: 7px;
  border: 1px solid #d8d5ff;
  border-radius: 999px;
  background: linear-gradient(135deg, #f8f7ff, #eeedff);
  color: var(--color-primary);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.progress-pill:hover {
  border-color: #aaa4ff;
  box-shadow: 0 7px 18px rgba(79, 70, 229, .12);
}

.progress-pill:active {
  transform: scale(.97);
}

.progress-level-badge {
  --level-progress: 0%;
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 2px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#4f46e5 var(--level-progress), #d9d6ff 0);
  box-shadow: 0 5px 12px rgba(67, 56, 202, .24);
}

.progress-level-badge img {
  display: block;
  width: 36px;
  height: 36px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
}

.progress-level-number {
  position: absolute;
  right: -4px;
  bottom: -3px;
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 9px;
  font-weight: 850;
  line-height: 1;
}

.progress-pill-copy {
  display: flex;
  min-width: 31px;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}

.progress-pill-copy strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.progress-pill-copy small {
  margin-top: 3px;
  color: #7169bb;
  font-size: 9px;
}

.header-new {
  display: none !important;
}

.icon-button {
  display: inline-grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-soft);
  transition: background-color .16s ease, color .16s ease, transform .16s ease;
}

.icon-button:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.icon-button:active {
  transform: scale(.96);
}

.icon-button svg,
.button svg,
.connection-banner svg,
.bottom-nav svg,
.tip-card > svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.connection-banner {
  position: sticky;
  z-index: 45;
  top: calc(var(--header-height) + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  background: var(--color-warning-soft);
  color: #714300;
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

.connection-banner svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.main {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: 18px 16px calc(30px + env(safe-area-inset-bottom));
}

.has-bottom-nav .main {
  padding-bottom: calc(var(--bottom-nav-height) + 30px + env(safe-area-inset-bottom));
}

.page {
  animation: page-in .26s ease both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-loading,
.center-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: min(66vh, 620px);
  gap: 14px;
  color: var(--color-text-soft);
  text-align: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-primary-soft);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.hero {
  padding: 4px 0 18px;
}

.hero h1,
.page-heading h1 {
  max-width: 720px;
  margin: 0;
  color: var(--color-text);
  font-size: clamp(30px, 7vw, 48px);
  font-weight: 800;
  letter-spacing: -.045em;
  line-height: 1.06;
}

.hero p,
.page-heading > p {
  max-width: 650px;
  margin: 10px 0 0;
  color: var(--color-text-soft);
  font-size: clamp(15px, 4vw, 18px);
  line-height: 1.55;
}

.subject-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.demo-banner {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px 14px;
  gap: 11px;
  border: 1px solid #efd18d;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #fff9e9, #fff3cd);
  color: #704600;
  box-shadow: var(--shadow-xs);
}

.demo-banner-icon {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 12px;
  background: #fff;
  color: #b56c00;
}

.demo-banner-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.demo-banner strong,
.demo-banner span {
  display: block;
}

.demo-banner strong {
  font-size: 13px;
}

.demo-banner div > span {
  margin-top: 1px;
  font-size: 12px;
  line-height: 1.4;
}

.level-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  margin: 0 0 18px;
  padding: 17px;
  gap: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 92% -20%, rgba(245, 158, 11, .33), transparent 42%),
    linear-gradient(135deg, #302a8c, #5148d7 58%, #665dea);
  box-shadow: 0 15px 34px rgba(64, 55, 178, .2);
  color: #fff;
  text-align: left;
  transition: transform .18s ease, box-shadow .18s ease;
}

.level-card:hover {
  box-shadow: 0 18px 40px rgba(64, 55, 178, .27);
  transform: translateY(-1px);
}

.level-card:active {
  transform: scale(.992);
}

.level-emblem {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .36);
  border-radius: 18px;
  background: rgba(255, 255, 255, .16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
  font-size: 23px;
  font-weight: 850;
}

.level-card-copy {
  display: block;
  min-width: 0;
}

.level-card-kicker {
  display: block;
  margin-bottom: 2px;
  color: rgba(255, 255, 255, .72);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.level-card-copy > strong {
  display: block;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-card-meta {
  display: flex;
  justify-content: space-between;
  margin: 7px 0 6px;
  gap: 10px;
  color: rgba(255, 255, 255, .76);
  font-size: 10px;
}

.level-card-meta b {
  flex: 0 0 auto;
  color: #fff;
}

.level-card-meta > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-track {
  display: block;
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .2);
}

.level-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd36a, #fbbf24);
  box-shadow: 0 0 12px rgba(251, 191, 36, .45);
}

.level-card-arrow {
  color: rgba(255, 255, 255, .82);
}

.level-card-arrow svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.level-card.compact {
  margin: 14px 0 16px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 24px rgba(64, 55, 178, .16);
}

.level-card.compact .level-emblem {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 18px;
}

.level-card.compact .level-card-copy > strong {
  font-size: 14px;
  white-space: normal;
}

.subject-pill,
.subject-chip,
.category-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  min-height: 32px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
}

.subject-pill {
  border: 1px solid var(--color-border-soft);
  background: rgba(255, 255, 255, .8);
  color: var(--color-text-soft);
}

.subject-pill svg,
.subject-chip svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.input-card,
.surface-card,
.processing-card,
.review-card,
.quiz-card,
.result-hero {
  border: 1px solid rgba(217, 223, 234, .88);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-sm);
}

.input-card {
  overflow: hidden;
}

.segmented-wrap {
  padding: 12px 12px 0;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: #eef1f6;
}

.segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 12px;
  border-radius: 11px;
  background: transparent;
  color: var(--color-text-soft);
  font-size: 14px;
  font-weight: 750;
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
}

.segment svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.segment.active {
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
  color: var(--color-primary);
}

.input-panel {
  padding: 12px;
}

.upload-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 270px;
  padding: 22px 20px;
  overflow: hidden;
  border: 1.5px dashed #bbc3d2;
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(79, 70, 229, .025), rgba(245, 158, 11, .035)),
    var(--color-surface-soft);
  text-align: center;
  transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
}

.upload-zone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-softer);
  transform: scale(.995);
}

.upload-illustration {
  position: relative;
  display: grid;
  width: 64px;
  height: 64px;
  margin-bottom: 13px;
  place-items: center;
  border-radius: 24px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.upload-illustration::after {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  width: 30px;
  height: 30px;
  content: "+";
  place-items: center;
  border: 4px solid var(--color-surface-soft);
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
}

.upload-illustration svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.upload-zone h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.02em;
}

.upload-zone > p {
  max-width: 410px;
  margin: 6px 0 16px;
  color: var(--color-text-soft);
  font-size: 14px;
}

.upload-actions {
  display: flex;
  flex-direction: column;
  width: min(100%, 360px);
  gap: 9px;
}

.upload-meta {
  margin-top: 14px;
  color: var(--color-text-faint);
  font-size: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 11px 18px;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  transform-origin: center;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s cubic-bezier(.2, .8, .2, 1), filter .18s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  filter: brightness(.98);
  transform: translateY(1px) scale(.975);
}

.button-primary {
  border-color: var(--color-primary);
  background: var(--color-primary);
  box-shadow: 0 7px 18px rgba(79, 70, 229, .18);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  border-color: var(--color-primary-hover);
  background: var(--color-primary-hover);
}

.button-primary:active:not(:disabled) {
  box-shadow: 0 3px 9px rgba(79, 70, 229, .18);
}

.button-secondary {
  border-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

.button-secondary:hover:not(:disabled) {
  border-color: #bcc5d4;
  background: #f9fafc;
}

.button-quiet {
  background: transparent;
  color: var(--color-text-soft);
}

.button-quiet:hover:not(:disabled) {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.button-danger {
  background: var(--color-danger);
  color: #fff;
}

.button-danger:hover:not(:disabled) {
  background: var(--color-danger-hover);
}

.button-success {
  background: var(--color-success);
  color: #fff;
}

.button-block {
  width: 100%;
}

.button-large {
  min-height: 54px;
  padding: 14px 22px;
  font-size: 16px;
}

.button svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.text-entry {
  padding: 4px;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 750;
}

.textarea-wrap {
  position: relative;
}

.text-area {
  display: block;
  width: 100%;
  min-height: 270px;
  resize: vertical;
  padding: 16px 16px 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  background: #fcfdff;
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

.text-area:focus {
  border-color: var(--color-primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .1);
}

.text-area::placeholder {
  color: #98a2b3;
}

.char-count {
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(252, 253, 255, .88);
  color: var(--color-text-faint);
  font-size: 11px;
}

.field-hint,
.field-error {
  margin: 8px 0 0;
  font-size: 12px;
}

.field-hint {
  color: var(--color-text-faint);
}

.field-error {
  color: var(--color-danger);
  font-weight: 650;
}

.text-entry-actions {
  margin-top: 14px;
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 14px 4px 0;
  color: var(--color-text-faint);
  font-size: 12px;
}

.privacy-note svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin-top: 1px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.page-heading {
  margin-bottom: 20px;
}

.page-heading h1 {
  font-size: clamp(28px, 7vw, 42px);
}

.back-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: -8px 0 10px -10px;
  padding: 8px 10px;
  gap: 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-soft);
  font-size: 14px;
  font-weight: 700;
}

.back-button:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.back-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.processing-layout {
  display: grid;
  min-height: calc(100dvh - var(--header-height) - 80px);
  align-items: center;
}

.processing-card {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 24px;
  text-align: center;
}

.processing-visual {
  position: relative;
  width: 128px;
  height: 128px;
  margin: 0 auto 22px;
}

.processing-photo {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 6px solid #fff;
  border-radius: 28px;
  background: var(--color-primary-soft);
  box-shadow: var(--shadow-md);
}

.processing-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.processing-photo-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--color-primary);
}

.processing-photo-placeholder svg {
  width: 52px;
  height: 52px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.4;
}

.processing-orbit {
  position: absolute;
  inset: -8px;
  border: 2px solid transparent;
  border-top-color: var(--color-primary);
  border-right-color: rgba(79, 70, 229, .25);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

.processing-card h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -.03em;
}

.processing-card > p {
  margin: 9px auto 22px;
  color: var(--color-text-soft);
}

.progress-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9ecf3;
}

.progress-bar > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-primary), #756df0);
  transition: width .2s ease;
}

.progress-bar.indeterminate > span {
  width: 42%;
  animation: indeterminate 1.25s ease-in-out infinite;
}

@keyframes indeterminate {
  from { transform: translateX(-110%); }
  to { transform: translateX(245%); }
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  color: var(--color-text-faint);
  font-size: 12px;
}

.stage-list {
  display: grid;
  margin: 24px 0;
  padding: 0;
  gap: 11px;
  list-style: none;
  text-align: left;
}

.stage-list li {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 11px;
  gap: 10px;
  border-radius: 11px;
  color: var(--color-text-faint);
  font-size: 14px;
  font-weight: 650;
}

.stage-dot {
  display: grid;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid #d5dae4;
  border-radius: 50%;
  font-size: 12px;
}

.stage-list li.active {
  background: var(--color-primary-softer);
  color: var(--color-primary);
}

.stage-list li.active .stage-dot {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .08);
}

.stage-list li.done {
  color: var(--color-success);
}

.stage-list li.done .stage-dot {
  border-color: var(--color-success);
  background: var(--color-success);
  color: #fff;
}

.review-grid {
  display: grid;
  gap: 16px;
}

.photo-reference,
.review-card {
  overflow: hidden;
}

.photo-reference {
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  background: #e8ebf2;
}

.photo-reference img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.photo-reference-header,
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border-soft);
  background: rgba(255, 255, 255, .96);
}

.photo-reference-header strong,
.card-header strong {
  font-size: 14px;
}

.review-content {
  padding: 16px;
}

.recognized-text,
.source-text {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  color: var(--color-text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.68;
}

.recognized-text {
  min-height: 200px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: #fbfcfe;
}

.review-actions,
.sticky-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.review-edit .text-area {
  min-height: 320px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
}

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

.subject-chip {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.subject-chip.math {
  background: var(--color-accent-soft);
  color: #8b5500;
}

.result-hero {
  position: relative;
  padding: 22px;
  overflow: hidden;
}

.result-hero::after {
  position: absolute;
  right: -45px;
  bottom: -65px;
  width: 170px;
  height: 170px;
  content: "";
  border-radius: 50%;
  background: rgba(79, 70, 229, .07);
}

.result-hero.no-errors::after {
  background: rgba(21, 128, 61, .08);
}

.result-icon {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: 17px;
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.no-errors .result-icon {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.result-icon svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.result-hero h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(27px, 7vw, 40px);
  letter-spacing: -.04em;
  line-height: 1.1;
}

.result-hero p {
  position: relative;
  z-index: 1;
  max-width: 580px;
  margin: 10px 0 0;
  color: var(--color-text-soft);
}

.corrected-text-card {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid #b8dec5;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
}

.corrected-text-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 15px;
  gap: 14px;
  border-bottom: 1px solid #d9ecdf;
  background: linear-gradient(135deg, #f4fbf6, #fff);
}

.corrected-text-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.corrected-text-title h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -.02em;
}

.corrected-text-title p {
  margin: 2px 0 0;
  color: var(--color-text-soft);
  font-size: 12px;
  line-height: 1.35;
}

.corrected-text-icon {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--color-success-soft);
  color: var(--color-success);
}

.corrected-text-icon svg,
.corrected-copy svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.corrected-copy {
  flex: 0 0 auto;
  min-height: 44px;
}

.corrected-text {
  max-height: min(44dvh, 440px);
  margin: 0;
  overflow: auto;
  padding: 17px;
  background: #fff;
  color: var(--color-text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
  user-select: text;
}

.corrected-text-warning {
  margin: 0;
  padding: 11px 15px;
  border-top: 1px solid #f2d7a2;
  background: #fff8e8;
  color: #765018;
  font-size: 12px;
  line-height: 1.45;
}

.source-disclosure {
  margin-top: 16px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.source-disclosure summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 12px 15px;
  gap: 12px;
  cursor: pointer;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 750;
  list-style: none;
}

.source-disclosure summary::-webkit-details-marker {
  display: none;
}

.source-disclosure summary::after {
  width: 8px;
  height: 8px;
  content: "";
  border-right: 2px solid var(--color-text-faint);
  border-bottom: 2px solid var(--color-text-faint);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .16s ease;
}

.source-disclosure[open] summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
}

.source-text {
  max-height: 380px;
  overflow-y: auto;
  padding: 15px;
  border-top: 1px solid var(--color-border-soft);
  background: #fbfcfe;
}

.results-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 25px 0 12px;
  gap: 12px;
}

.results-section-heading h2,
.detail-heading h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.025em;
}

.results-section-heading p {
  margin: 3px 0 0;
  color: var(--color-text-soft);
  font-size: 13px;
}

.results-workspace {
  display: grid;
  gap: 16px;
}

.errors-list {
  display: grid;
  gap: 10px;
}

.error-card {
  position: relative;
  width: 100%;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
  color: var(--color-text);
  text-align: left;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.error-card:hover {
  border-color: #bfc7d6;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.error-card.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .09);
}

.error-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.category-chip {
  min-height: 26px;
  padding: 5px 9px;
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-size: 11px;
}

.error-card-title {
  margin: 10px 0 12px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.error-arrow {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--color-text-faint);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.correction-pair {
  display: grid;
  gap: 7px;
}

.correction-row {
  display: grid;
  grid-template-columns: 47px minmax(0, 1fr);
  align-items: start;
  gap: 7px;
  color: var(--color-text-soft);
  font-size: 13px;
}

.correction-row span:first-child {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.correction-row.before span:first-child {
  color: var(--color-danger);
}

.correction-row.after span:first-child {
  color: var(--color-success);
}

.correction-row del,
.correction-row ins {
  overflow-wrap: anywhere;
  color: var(--color-text);
  text-decoration: none;
}

.correction-row.before del {
  text-decoration: line-through;
  text-decoration-color: rgba(194, 65, 61, .45);
}

.show-more-wrap {
  margin-top: 12px;
}

.detail-panel {
  display: none;
  min-width: 0;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.detail-panel.mobile-open {
  display: block;
}

.results-workspace.detail-mobile .results-list-panel {
  display: none;
}

.detail-inner {
  padding: 18px;
}

.detail-heading {
  margin-bottom: 16px;
}

.detail-heading .category-chip {
  margin-bottom: 9px;
}

.detail-correction {
  display: grid;
  margin-bottom: 18px;
  gap: 10px;
}

.detail-correction-card {
  padding: 13px;
  border-radius: var(--radius-md);
  background: #f9fafc;
}

.detail-correction-card small {
  display: block;
  margin-bottom: 5px;
  color: var(--color-text-faint);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.detail-correction-card strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.detail-correction-card.before {
  border-left: 3px solid var(--color-danger);
}

.detail-correction-card.after {
  border-left: 3px solid var(--color-success);
}

.explanation-content {
  color: #273249;
  font-size: 15px;
  line-height: 1.72;
}

.explanation-content h2,
.explanation-content h3,
.explanation-content h4 {
  margin: 22px 0 8px;
  color: var(--color-text);
  font-size: 17px;
  line-height: 1.35;
}

.explanation-content p {
  margin: 10px 0;
}

.explanation-content ul,
.explanation-content ol {
  margin: 10px 0;
  padding-left: 22px;
}

.explanation-content li + li {
  margin-top: 6px;
}

.explanation-content code,
.math-text {
  padding: 2px 5px;
  border-radius: 5px;
  background: #f1f3f8;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: .92em;
}

.explanation-content blockquote {
  margin: 12px 0;
  padding: 10px 13px;
  border-left: 3px solid var(--color-primary);
  background: var(--color-primary-softer);
}

.detail-loading {
  display: grid;
  padding: 16px 0;
  gap: 12px;
}

.skeleton {
  height: 14px;
  overflow: hidden;
  border-radius: 6px;
  background: #edf0f5;
}

.skeleton::after {
  display: block;
  width: 45%;
  height: 100%;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.78), transparent);
  animation: shimmer 1.25s ease-in-out infinite;
}

@keyframes shimmer {
  from { transform: translateX(-120%); }
  to { transform: translateX(250%); }
}

.skeleton:nth-child(2) { width: 88%; }
.skeleton:nth-child(3) { width: 74%; }
.skeleton:nth-child(4) { width: 92%; }

.detail-error,
.inline-state {
  padding: 16px;
  border: 1px solid #f2c8c6;
  border-radius: var(--radius-md);
  background: var(--color-danger-soft);
  color: #7e2825;
}

.detail-error p,
.inline-state p {
  margin: 0 0 12px;
}

.quiz-landing,
.quiz-layout {
  width: min(100%, 740px);
  margin: 0 auto;
}

.quiz-landing-card {
  padding: 24px;
  text-align: center;
}

.quiz-illustration {
  display: grid;
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 24px;
  background: var(--color-accent-soft);
  color: #9b5b00;
}

.quiz-illustration svg {
  width: 39px;
  height: 39px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.quiz-landing h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -.035em;
}

.quiz-landing p {
  margin: 10px auto 20px;
  color: var(--color-text-soft);
}

.quiz-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 20px 0;
  padding: 14px 0;
  border-top: 1px solid var(--color-border-soft);
  border-bottom: 1px solid var(--color-border-soft);
}

.quiz-fact {
  padding: 2px 8px;
}

.quiz-fact + .quiz-fact {
  border-left: 1px solid var(--color-border-soft);
}

.quiz-fact strong {
  display: block;
  font-size: 18px;
}

.quiz-fact span {
  display: block;
  margin-top: 2px;
  color: var(--color-text-faint);
  font-size: 11px;
}

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

.quiz-counter {
  color: var(--color-text-soft);
  font-size: 13px;
  font-weight: 750;
}

.quiz-score-live {
  color: var(--color-success);
  font-size: 13px;
  font-weight: 750;
}

.quiz-progress {
  height: 7px;
  margin-bottom: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e9f0;
}

.quiz-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--color-primary);
  transition: width .28s ease;
}

.quiz-card {
  padding: 20px;
}

.quiz-question {
  margin: 0 0 20px;
  font-size: clamp(20px, 5.6vw, 27px);
  letter-spacing: -.025em;
  line-height: 1.35;
}

.quiz-options {
  display: grid;
  gap: 10px;
}

.quiz-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 24px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  gap: 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--color-text);
  text-align: left;
  transition: border-color .16s ease, background-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .07);
  transform: translateY(-1px);
}

.segment:active:not(:disabled),
.nav-item:active:not(:disabled),
.quiz-option:active:not(:disabled),
.error-card:active:not(:disabled),
.history-card:active:not(:disabled),
.back-button:active:not(:disabled) {
  transform: scale(.975);
}

.option-letter {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  background: #f0f2f7;
  color: var(--color-text-soft);
  font-size: 13px;
  font-weight: 800;
}

.option-text {
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
}

.option-state-icon {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
}

.option-state-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.quiz-option.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-softer);
}

.quiz-option.correct {
  border-color: #75bb8e;
  background: var(--color-success-soft);
  color: #105e30;
}

.quiz-option.correct .option-letter {
  background: var(--color-success);
  color: #fff;
}

.quiz-option.incorrect {
  border-color: #e6a4a1;
  background: var(--color-danger-soft);
  color: #852d29;
}

.quiz-option.incorrect .option-letter {
  background: var(--color-danger);
  color: #fff;
}

.quiz-option:disabled {
  opacity: 1;
}

.feedback-card {
  margin-top: 15px;
  padding: 16px;
  border-radius: var(--radius-md);
  animation: feedback-in .22s ease both;
}

@keyframes feedback-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.feedback-card.correct {
  border: 1px solid #9ed2af;
  background: var(--color-success-soft);
}

.feedback-card.incorrect {
  border: 1px solid #ebbbb8;
  background: var(--color-danger-soft);
}

.feedback-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.feedback-title svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.feedback-card.correct .feedback-title {
  color: var(--color-success);
}

.feedback-card.incorrect .feedback-title {
  color: var(--color-danger);
}

.feedback-card p {
  margin: 8px 0 0;
  color: #364158;
  font-size: 14px;
  line-height: 1.6;
}

.quiz-next {
  margin-top: 14px;
}

.score-card {
  padding: 24px;
  text-align: center;
}

.score-summary {
  display: grid;
  justify-items: center;
}

.score-ring {
  --score: 0;
  position: relative;
  display: grid;
  width: 148px;
  height: 148px;
  margin: 0 auto 20px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color, var(--color-primary)) calc(var(--score) * 1%), #e9ecf2 0);
}

.score-ring::before {
  position: absolute;
  inset: 10px;
  content: "";
  border-radius: 50%;
  background: var(--color-surface);
}

.score-value {
  position: relative;
  z-index: 1;
}

.score-value strong {
  display: block;
  font-size: 35px;
  letter-spacing: -.045em;
  line-height: 1;
}

.score-value span {
  display: block;
  margin-top: 5px;
  color: var(--color-text-soft);
  font-size: 12px;
}

.score-copy h1 {
  margin: 0;
  font-size: 29px;
  letter-spacing: -.04em;
}

.score-copy p {
  max-width: 500px;
  margin: 10px auto 20px;
  color: var(--color-text-soft);
}

.score-actions {
  display: grid;
  gap: 10px;
}

.incorrect-review {
  margin-top: 20px;
}

.incorrect-review h2 {
  margin: 0 0 12px;
  font-size: 20px;
  letter-spacing: -.025em;
}

.incorrect-list {
  display: grid;
  gap: 10px;
}

.incorrect-item {
  padding: 16px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.incorrect-item h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.incorrect-item p {
  margin: 6px 0 0;
  color: var(--color-text-soft);
  font-size: 13px;
}

.incorrect-item strong {
  color: var(--color-text);
}

.survey-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 24px;
  padding: 22px;
  border: 1px solid #ddd9ff;
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, var(--color-primary-softer), var(--color-surface));
}

.survey-copy {
  min-width: 0;
}

.survey-copy h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.3;
}

.survey-copy p {
  max-width: 560px;
  margin: 0;
  color: var(--color-text-soft);
  font-size: 14px;
  line-height: 1.6;
}

.survey-button {
  flex-shrink: 0;
  min-height: 48px;
  color: var(--color-primary);
  text-decoration: none;
}

@media (max-width: 979px) {
  .results-workspace.detail-mobile + .survey-card {
    display: none;
  }
}

@media (max-width: 600px) {
  .survey-card {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 18px;
  }

  .survey-button {
    width: 100%;
  }
}

.install-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: 16px;
  padding: 16px;
  gap: 12px;
  border: 1px solid #d8d5ff;
  border-radius: var(--radius-md);
  background: var(--color-primary-softer);
}

.install-card-copy {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.install-card-copy svg {
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  color: var(--color-primary);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.install-card h3 {
  margin: 0;
  font-size: 15px;
}

.install-card p {
  margin: 3px 0 0;
  color: var(--color-text-soft);
  font-size: 12px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: min(65vh, 580px);
  justify-content: center;
  text-align: center;
}

.empty-state-icon {
  display: grid;
  width: 72px;
  height: 72px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 22px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.empty-state-icon svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.empty-state h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -.035em;
}

.empty-state p {
  max-width: 460px;
  margin: 9px 0 20px;
  color: var(--color-text-soft);
}

.bottom-nav {
  position: fixed;
  z-index: 40;
  right: 0;
  bottom: 0;
  left: 0;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid rgba(217, 223, 234, .88);
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(100%, 560px);
  height: var(--bottom-nav-height);
  margin: 0 auto;
}

.nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 7px 4px;
  gap: 4px;
  background: transparent;
  color: var(--color-text-faint);
  font-size: 10px;
  font-weight: 750;
  transition: color .18s ease, transform .18s cubic-bezier(.2, .8, .2, 1);
}

.nav-item::before {
  position: absolute;
  top: 5px;
  width: 42px;
  height: 30px;
  content: "";
  border-radius: 12px;
  background: transparent;
  transition: background-color .16s ease;
}

.nav-item svg {
  position: relative;
  z-index: 1;
  width: 23px;
  height: 23px;
}

.nav-item > span:not(.nav-badge) {
  position: relative;
  z-index: 1;
}

.nav-item.active {
  color: var(--color-primary);
}

.nav-item.active::before {
  background: var(--color-primary-soft);
}

.nav-item.active svg {
  animation: nav-pop .24s cubic-bezier(.2, .85, .3, 1.2);
}

@keyframes nav-pop {
  50% { transform: scale(1.12); }
}

.nav-item:disabled {
  opacity: .4;
}

.nav-badge {
  position: absolute;
  z-index: 2;
  top: 7px;
  left: calc(50% + 8px);
  display: grid;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--color-danger);
  color: #fff;
  font-size: 9px;
  line-height: 1;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 12px;
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}

.has-bottom-nav ~ .toast-region,
body:has(.bottom-nav:not(.hidden)) .toast-region {
  bottom: calc(var(--bottom-nav-height) + 12px + env(safe-area-inset-bottom));
}

.toast {
  display: flex;
  align-items: center;
  width: min(100%, 440px);
  min-height: 48px;
  padding: 11px 14px;
  gap: 9px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-md);
  background: #20293b;
  box-shadow: var(--shadow-md);
  color: #fff;
  font-size: 13px;
  font-weight: 650;
  pointer-events: auto;
  animation: toast-in .2s ease both;
}

.toast.error {
  background: #842e2a;
}

.toast.success {
  background: #146233;
}

.toast.points {
  border-color: rgba(255, 211, 106, .35);
  background: linear-gradient(135deg, #4038a6, #5b50dc);
}

.toast.level-up {
  border-color: rgba(255, 219, 127, .46);
  background: linear-gradient(135deg, #76520b, #b77806);
}

.toast svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.toast.leaving {
  animation: toast-out .18s ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(.98); }
}

.level-celebration {
  position: fixed;
  z-index: 99;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.level-celebration i {
  position: absolute;
  top: 24%;
  left: 50%;
  width: 9px;
  height: 15px;
  border-radius: 3px;
  background: var(--confetti-color);
  opacity: 0;
  animation: level-confetti 1.55s cubic-bezier(.18, .75, .36, 1) var(--confetti-delay) both;
}

.level-celebration i:nth-child(3n) {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

@keyframes level-confetti {
  0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(0); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--confetti-x), 68vh, 0) rotate(var(--confetti-turn)); }
}

.modal {
  width: calc(100% - 24px);
  max-width: 440px;
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: var(--radius-xl);
  background: transparent;
  color: var(--color-text);
}

.modal::backdrop {
  background: rgba(17, 24, 39, .52);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.modal[open] {
  animation: modal-in .2s ease both;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-wide {
  max-width: 580px;
}

.modal-card {
  position: relative;
  max-height: calc(100dvh - 32px);
  padding: 25px;
  overflow-y: auto;
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.modal-close {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
}

.modal-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 4px auto 16px;
  place-items: center;
  border-radius: 18px;
}

.modal-icon-warning {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.modal-icon svg {
  width: 31px;
  height: 31px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.modal-card h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -.035em;
}

.modal-card > p {
  margin: 9px 0 20px;
  color: var(--color-text-soft);
}

.modal-actions {
  display: grid;
  gap: 9px;
}

.help-card {
  text-align: left;
}

.help-card > .eyebrow {
  margin-top: 5px;
}

.help-steps {
  display: grid;
  margin: 22px 0;
  padding: 0;
  gap: 16px;
  list-style: none;
}

.help-steps li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.help-steps li > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 800;
}

.help-steps strong {
  font-size: 14px;
}

.help-steps p {
  margin: 3px 0 0;
  color: var(--color-text-soft);
  font-size: 13px;
}

.tip-card {
  display: flex;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 13px;
  gap: 10px;
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  color: #704500;
}

.tip-card > svg {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  margin-top: 1px;
}

.tip-card p {
  margin: 0;
  font-size: 12px;
}

.progress-sheet {
  text-align: left;
}

.progress-sheet > .modal-close {
  position: sticky;
  top: 0;
  float: right;
  margin: -8px -8px -46px 0;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-xs);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.progress-modal {
  max-width: 720px;
}

.progress-sheet > div > .eyebrow {
  margin-top: 5px;
}

.progress-sheet h2 {
  padding-right: 34px;
}

.progress-hero {
  display: flex;
  align-items: center;
  margin-top: 20px;
  padding: 17px;
  gap: 14px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 95% -15%, rgba(245, 158, 11, .34), transparent 46%),
    linear-gradient(135deg, #302a8c, #5b51de);
  box-shadow: 0 14px 30px rgba(64, 55, 178, .2);
  color: #fff;
}

.progress-hero-level {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .38);
  border-radius: 50%;
  background: rgba(255, 255, 255, .15);
  font-weight: 850;
}

.progress-hero-level img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgba(28, 19, 93, .2));
}

.progress-hero-level b {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #f59e0b;
  color: #3b226a;
  font-size: 12px;
  line-height: 1;
}

.progress-hero div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.progress-hero strong {
  font-size: 21px;
  letter-spacing: -.025em;
}

.progress-hero div span {
  margin-top: 2px;
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
}

.progress-hero-copy em {
  margin-top: 6px;
  color: #fff3c4;
  font-size: 12px;
  font-style: normal;
  font-weight: 750;
}

.progress-dialog-track {
  display: flex;
  align-items: center;
  margin: 14px 2px 0;
  gap: 10px;
}

.progress-dialog-track .level-track {
  height: 9px;
  background: #e7e5ff;
}

.progress-dialog-track small {
  flex: 0 0 auto;
  color: var(--color-text-soft);
  font-size: 11px;
  font-weight: 750;
}

.level-journey {
  position: relative;
  margin-top: 18px;
  padding: 15px;
  overflow: hidden;
  border: 1px solid #d9d6fb;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 95% 2%, rgba(251, 191, 36, .2), transparent 24%),
    radial-gradient(circle at 8% 24%, rgba(56, 189, 248, .14), transparent 22%),
    linear-gradient(180deg, #fbfaff 0%, #f5f7ff 100%);
}

.level-journey-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.level-journey-heading > div {
  min-width: 0;
}

.level-journey-heading > div > span {
  color: var(--color-primary);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.level-journey-heading h3 {
  margin: 2px 0 0;
  color: #282059;
  font-size: 20px;
  letter-spacing: -.025em;
}

.level-journey-count {
  display: grid;
  flex: 0 0 auto;
  min-width: 53px;
  min-height: 49px;
  padding: 5px 9px;
  place-items: center;
  border: 1px solid #d9d6fb;
  border-radius: 16px;
  background: rgba(255, 255, 255, .82);
  color: var(--color-primary);
  box-shadow: var(--shadow-xs);
}

.level-journey-count strong {
  font-size: 18px;
  line-height: 1;
}

.level-journey-count small {
  font-size: 10px;
  font-weight: 750;
}

.level-journey-lead {
  margin: 10px 0 0;
  color: var(--color-text-soft);
  font-size: 12px;
  line-height: 1.45;
}

.next-level-goal {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: center;
  min-height: 84px;
  margin-top: 13px;
  padding: 10px 12px 10px 9px;
  gap: 10px;
  border: 1px solid #f5d483;
  border-radius: 17px;
  background: linear-gradient(135deg, #fff9df, #fff);
  box-shadow: 0 9px 22px rgba(129, 86, 9, .08);
}

.next-level-goal.complete {
  border-color: #b7e4c7;
  background: linear-gradient(135deg, #ecfdf3, #fff);
}

.next-level-symbol {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
}

.next-level-symbol img {
  width: 62px;
  height: 62px;
  object-fit: contain;
  filter: drop-shadow(0 5px 7px rgba(67, 48, 10, .18));
}

.next-level-goal > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.next-level-goal > div > span {
  color: #9a6700;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.next-level-goal.complete > div > span {
  color: var(--color-success);
}

.next-level-goal strong {
  margin-top: 2px;
  color: #442d00;
  font-size: 13px;
}

.next-level-goal p {
  margin: 3px 0 0;
  color: #78643c;
  font-size: 11px;
  line-height: 1.35;
}

.level-road {
  display: grid;
  margin: 15px 0 0;
  padding: 0;
  gap: 11px;
  list-style: none;
}

.level-node {
  position: relative;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.level-node:not(:last-child)::after {
  position: absolute;
  z-index: 0;
  top: 60px;
  bottom: -15px;
  left: 30px;
  width: 4px;
  border-radius: 999px;
  background: #d9dbea;
  content: "";
}

.level-node.done::after {
  background: linear-gradient(#54b977, #a8dcb9);
}

.level-node-marker {
  position: relative;
  z-index: 1;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 2px solid #d9dbea;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 6px 14px rgba(44, 42, 78, .1);
}

.level-node-marker img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.level-node-marker b {
  position: absolute;
  right: -3px;
  bottom: -2px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #737789;
  color: #fff;
  font-size: 10px;
  line-height: 1;
}

.level-node-card {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid #e0e2ec;
  border-radius: 14px;
  background: rgba(255, 255, 255, .88);
}

.level-node-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 7px;
}

.level-node-heading strong {
  min-width: 0;
  color: #29283a;
  font-size: 14px;
  line-height: 1.25;
}

.level-node-heading span {
  flex: 0 0 auto;
  padding: 3px 6px;
  border-radius: 999px;
  background: #edeef3;
  color: #555a6c;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.level-node-goal,
.level-node-secret {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.35;
}

.level-node-goal {
  color: #56586a;
}

.level-node-secret {
  color: #5f6274;
}

.level-node-secret.revealed {
  color: var(--color-success);
  font-weight: 750;
}

.level-node.done .level-node-marker {
  border-color: #75c68f;
}

.level-node.done .level-node-marker b {
  background: var(--color-success);
}

.level-node.done .level-node-card {
  border-color: #b8e0c6;
  background: #f3fbf6;
}

.level-node.done .level-node-heading span {
  background: #dff5e7;
  color: #12612e;
}

.level-node.current .level-node-marker {
  border-color: #635bdb;
  box-shadow: 0 0 0 5px rgba(99, 91, 219, .13), 0 9px 20px rgba(67, 56, 181, .22);
  animation: level-arrive .55s ease-out both;
}

.level-node.current .level-node-marker b {
  background: var(--color-primary);
}

.level-node.current .level-node-card {
  border-color: #9a94ec;
  background: #f0efff;
  box-shadow: 0 7px 17px rgba(67, 56, 181, .1);
}

.level-node.current .level-node-heading span {
  background: var(--color-primary);
  color: #fff;
}

.level-node.next .level-node-marker {
  border-color: #e7b54f;
}

.level-node.next .level-node-marker b {
  background: #b77905;
}

.level-node.next .level-node-card {
  border-color: #f0d28e;
  background: #fffaf0;
}

.level-node.next .level-node-heading span {
  background: #fff0bd;
  color: #825600;
}

.level-node.future .level-node-marker img {
  filter: grayscale(.16) saturate(.82) brightness(.96);
}

.level-node.future .level-node-card {
  background: rgba(250, 250, 252, .92);
}

@keyframes level-arrive {
  from { transform: scale(.86); }
  70% { transform: scale(1.05); }
  to { transform: scale(1); }
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 20px;
  overflow: hidden;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: var(--color-surface-soft);
}

.progress-stats > div {
  display: flex;
  min-width: 0;
  padding: 13px 7px;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.progress-stats > div + div {
  border-left: 1px solid var(--color-border-soft);
}

.progress-stats strong {
  font-size: 19px;
}

.progress-stats span {
  color: var(--color-text-soft);
  font-size: 10px;
  line-height: 1.25;
}

.reward-rules {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: #fafbfe;
}

.reward-rules summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 11px 13px;
  gap: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  list-style: none;
}

.reward-rules summary::-webkit-details-marker {
  display: none;
}

.reward-rules summary span {
  color: var(--color-text-faint);
  font-size: 10px;
  font-weight: 750;
}

.reward-rules ul {
  display: grid;
  margin: 0;
  padding: 8px 10px 11px;
  gap: 7px;
  border-top: 1px solid var(--color-border-soft);
  list-style: none;
}

.reward-rules li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 8px 11px;
  gap: 12px;
  border-radius: 11px;
  background: #f7f7fc;
  color: var(--color-text-soft);
  font-size: 12px;
}

.reward-rules li strong {
  color: var(--color-primary);
  font-size: 12px;
}

.progress-storage-note {
  display: flex;
  align-items: flex-start;
  margin: 16px 0 0 !important;
  padding: 11px;
  gap: 8px;
  border-radius: 11px;
  background: var(--color-primary-softer);
  color: var(--color-text-soft);
  font-size: 11px;
  line-height: 1.4;
}

.progress-storage-note svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--color-primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.history-preview,
.history-detail-section {
  margin-top: 22px;
}

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

.history-section-heading h3,
.history-detail-section h3 {
  margin: 0;
  font-size: 15px;
}

.history-section-heading p,
.history-lead,
.history-attempts,
.history-truncated-note {
  margin: 2px 0 0;
  color: var(--color-text-soft);
  font-size: 11px;
}

.history-all-button {
  min-height: 44px;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 800;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-list.full {
  margin-top: 18px;
}

.history-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 18px;
  align-items: center;
  width: 100%;
  min-height: 76px;
  padding: 10px 11px;
  gap: 10px;
  border: 1px solid var(--color-border-soft);
  border-radius: 13px;
  background: #fafbfe;
  color: var(--color-text);
  text-align: left;
  transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}

.history-card:hover {
  border-color: #c6c2ff;
  background: var(--color-primary-softer);
  transform: translateY(-1px);
}

.history-subject-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.history-subject-icon.math {
  background: var(--color-accent-soft);
  color: #9a5d00;
}

.history-subject-icon svg,
.history-card-arrow svg,
.progress-back svg,
.history-delete svg,
.history-success > svg,
.history-empty > svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.history-card-copy {
  display: block;
  min-width: 0;
}

.history-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.history-card-top strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card-top time {
  flex: 0 0 auto;
  color: var(--color-text-faint);
  font-size: 9px;
}

.history-excerpt {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--color-text-soft);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card-meta {
  display: flex;
  align-items: center;
  margin-top: 6px;
  gap: 5px;
  overflow: hidden;
  font-size: 9px;
  white-space: nowrap;
}

.history-card-meta span {
  padding: 3px 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0f2f7;
  color: var(--color-text-soft);
  text-overflow: ellipsis;
}

.history-card-meta b {
  margin-left: auto;
  color: var(--color-primary);
  font-size: 10px;
}

.history-card-arrow {
  color: var(--color-text-faint);
}

.history-empty {
  display: flex;
  align-items: center;
  padding: 14px;
  gap: 11px;
  border: 1px dashed #d9d6ff;
  border-radius: 13px;
  background: var(--color-primary-softer);
  color: var(--color-primary);
}

.history-empty.large {
  margin-top: 18px;
  padding: 24px 16px;
}

.history-empty > svg {
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
}

.history-empty div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.history-empty strong {
  font-size: 12px;
}

.history-empty span {
  color: var(--color-text-soft);
  font-size: 10px;
  line-height: 1.35;
}

.progress-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: -7px 0 14px;
  padding: 5px 9px 5px 4px;
  gap: 5px;
  border-radius: 10px;
  background: transparent;
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 750;
}

.progress-back:hover {
  background: var(--color-primary-soft);
}

.history-lead {
  margin-top: 7px;
  padding-right: 32px;
  font-size: 12px;
  line-height: 1.45;
}

.history-detail-chips {
  display: flex;
  flex-wrap: wrap;
  margin-top: 13px;
  gap: 7px;
}

.history-points-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--color-accent-soft);
  color: #825000;
  font-size: 12px;
  font-weight: 800;
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: var(--color-surface-soft);
}

.history-summary > div {
  display: flex;
  min-width: 0;
  padding: 13px 6px;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.history-summary > div + div {
  border-left: 1px solid var(--color-border-soft);
}

.history-summary strong {
  font-size: 18px;
}

.history-summary span {
  color: var(--color-text-soft);
  font-size: 9px;
  line-height: 1.25;
}

.history-source {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: #fbfcfe;
}

.history-source summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 10px 12px;
  gap: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.history-source summary span {
  color: var(--color-text-soft);
  font-size: 9px;
  font-weight: 650;
}

.history-source pre {
  max-height: 280px;
  margin: 0;
  padding: 13px;
  overflow: auto;
  border-top: 1px solid var(--color-border-soft);
  color: var(--color-text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.history-source > p {
  margin: 0;
  padding: 0 13px 12px;
  color: var(--color-text-soft);
  font-size: 10px;
}

.history-error-list,
.history-quiz-review {
  display: grid;
  margin-top: 10px;
  gap: 8px;
}

.history-error-item,
.history-quiz-review article {
  padding: 12px;
  border: 1px solid var(--color-border-soft);
  border-radius: 12px;
  background: #fbfcfe;
  overflow-wrap: anywhere;
}

.history-error-item > span {
  color: var(--color-danger);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.history-error-item > strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

.history-error-item > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr);
  align-items: center;
  margin-top: 9px;
  gap: 6px;
  font-size: 10px;
}

.history-error-item del,
.history-error-item ins {
  padding: 7px;
  border-radius: 8px;
  text-decoration: none;
}

.history-error-item del {
  background: var(--color-danger-soft);
  color: #8e302d;
}

.history-error-item ins {
  background: var(--color-success-soft);
  color: #12622f;
}

.history-error-item svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--color-text-faint);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.history-success {
  display: flex;
  align-items: center;
  margin-top: 10px;
  padding: 13px;
  gap: 10px;
  border-radius: 12px;
  background: var(--color-success-soft);
  color: var(--color-success);
}

.history-success > span {
  display: flex;
  flex-direction: column;
}

.history-success strong {
  font-size: 12px;
}

.history-success small {
  color: #3a7850;
  font-size: 10px;
}

.history-attempts {
  margin-top: 3px;
}

.history-truncated-note {
  margin: 8px 0 0;
}

.history-quiz-review article strong,
.history-quiz-review article span {
  display: block;
  font-size: 11px;
}

.history-quiz-review article span {
  margin-top: 5px;
  color: var(--color-success);
  font-weight: 700;
}

.history-quiz-review article p {
  margin: 5px 0 0;
  color: var(--color-text-soft);
  font-size: 10px;
}

.history-quiz-empty {
  margin-top: 10px;
  padding: 13px;
  border-radius: 12px;
  background: #f7f8fb;
  color: var(--color-text-soft);
  font-size: 11px;
}

.history-delete {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 22px;
  padding: 8px 11px;
  gap: 7px;
  border-radius: 11px;
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-size: 11px;
  font-weight: 750;
}

.history-current-note {
  margin: 20px 0 0;
  padding: 11px;
  border-radius: 11px;
  background: var(--color-surface-soft);
  color: var(--color-text-soft);
  font-size: 10px;
}

@media (max-width: 767px) {
  .main {
    padding: 13px 14px calc(24px + env(safe-area-inset-bottom));
  }

  .has-bottom-nav .main {
    padding-bottom: calc(var(--bottom-nav-height) + 20px + env(safe-area-inset-bottom));
  }

  .hero {
    padding: 1px 2px 14px;
  }

  .hero .eyebrow {
    display: none;
  }

  .hero h1,
  .page-heading h1 {
    font-size: clamp(28px, 8.5vw, 34px);
    line-height: 1.08;
  }

  .hero p,
  .page-heading > p {
    margin-top: 7px;
    font-size: 14px;
    line-height: 1.48;
  }

  .segmented-wrap {
    padding: 10px 10px 0;
  }

  .segment {
    min-height: 48px;
  }

  .input-panel {
    padding: 10px;
  }

  .upload-zone {
    min-height: 0;
    padding: 18px 14px 16px;
  }

  .upload-illustration {
    width: 56px;
    height: 56px;
    margin-bottom: 10px;
    border-radius: 19px;
  }

  .upload-illustration::after {
    width: 27px;
    height: 27px;
    border-width: 3px;
    font-size: 18px;
  }

  .upload-zone h2 {
    font-size: 18px;
  }

  .upload-zone > p {
    margin: 5px 0 13px;
    font-size: 13px;
    line-height: 1.45;
  }

  .upload-actions {
    gap: 8px;
  }

  .upload-actions .button {
    min-height: 52px;
  }

  .upload-meta {
    margin-top: 10px;
    font-size: 10px;
  }

  .privacy-note {
    margin-top: 10px;
    font-size: 10px;
    line-height: 1.4;
  }

  .page-heading {
    margin-bottom: 14px;
  }

  .result-hero {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    padding: 15px;
    column-gap: 12px;
  }

  .result-icon {
    width: 44px;
    height: 44px;
    margin: 0;
    border-radius: 14px;
  }

  .result-icon svg {
    width: 23px;
    height: 23px;
  }

  .result-hero h1 {
    font-size: 25px;
  }

  .result-hero p {
    grid-column: 1 / -1;
    margin-top: 9px;
    font-size: 13px;
  }

  .quiz-next {
    position: sticky;
    z-index: 18;
    bottom: calc(var(--bottom-nav-height) + 8px + env(safe-area-inset-bottom));
    box-shadow: 0 10px 25px rgba(79, 70, 229, .24);
  }
}

@media (max-width: 559px) {
  .brand-copy {
    display: none;
  }

  .progress-modal {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 12px);
    margin: auto 0 0;
  }

  .progress-modal .progress-sheet {
    max-height: calc(100dvh - 12px);
    padding: 23px 18px calc(20px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
  }

  .level-card-meta > span {
    display: none;
  }

  .corrected-text-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .corrected-copy {
    width: 100%;
  }

  .corrected-text {
    max-height: 46dvh;
    padding: 15px;
    font-size: 14px;
  }
}

@media (max-width: 390px) {
  .demo-mode-badge {
    display: none;
  }

  .header-inner {
    padding-right: 12px;
    padding-left: 12px;
  }

  .header-actions {
    gap: 4px;
  }

  .progress-pill {
    padding-right: 8px;
  }

  .level-card {
    padding: 14px;
    gap: 11px;
  }

  .level-emblem {
    width: 46px;
    height: 46px;
    border-radius: 15px;
    font-size: 20px;
  }
}

@media (min-width: 560px) {
  .brand-copy small {
    display: block;
  }

  .upload-actions,
  .review-actions,
  .score-actions,
  .modal-actions {
    grid-template-columns: 1fr 1fr;
  }

  .upload-actions {
    flex-direction: row;
  }

  .upload-actions .button {
    flex: 1;
  }

  .processing-card,
  .quiz-card,
  .quiz-landing-card,
  .score-card {
    padding: 30px;
  }

  .detail-correction {
    grid-template-columns: 1fr 1fr;
  }

  .install-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

@media (min-width: 680px) {
  .level-road {
    position: relative;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 18px;
  }

  .level-road::before {
    position: absolute;
    z-index: 0;
    top: 29px;
    bottom: 29px;
    left: 50%;
    width: 4px;
    border-radius: 999px;
    background: linear-gradient(
      #76c78f 0 var(--journey-progress),
      #dadbea var(--journey-progress) 100%
    );
    content: "";
    transform: translateX(-50%);
  }

  .level-node::after {
    display: none;
  }

  .level-node:nth-child(odd) {
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  .level-node:nth-child(odd) .level-node-marker {
    grid-row: 1;
    grid-column: 2;
  }

  .level-node:nth-child(odd) .level-node-card {
    grid-row: 1;
    grid-column: 1;
  }
}

@media (min-width: 900px) {
  .progress-modal {
    max-width: 800px;
  }

  .level-journey .next-level-goal {
    display: none;
  }
}

@media (min-width: 768px) {
  .header-inner,
  .main {
    padding-right: 28px;
    padding-left: 28px;
  }

  .main {
    padding-top: 24px;
    padding-bottom: 52px;
  }

  .has-bottom-nav .main {
    padding-bottom: 52px;
  }

  .hero {
    padding-top: 8px;
    padding-bottom: 18px;
  }

  .input-card {
    max-width: 860px;
  }

  .segmented-wrap,
  .input-panel {
    padding-right: 18px;
    padding-left: 18px;
  }

  .input-panel {
    padding-bottom: 18px;
  }

  .upload-zone {
    min-height: 310px;
  }

  .review-grid {
    grid-template-columns: minmax(260px, .75fr) minmax(0, 1.25fr);
    align-items: start;
  }

  .photo-reference {
    position: sticky;
    top: calc(var(--header-height) + 22px);
  }

  .photo-reference img {
    max-height: calc(100vh - 160px);
  }

  .result-hero {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    padding: 18px 20px;
    column-gap: 15px;
  }

  .result-icon {
    grid-row: 1 / 3;
    width: 48px;
    height: 48px;
    margin: 0;
  }

  .result-hero h1 {
    font-size: 30px;
  }

  .result-hero p {
    margin-top: 4px;
  }

  .detail-inner {
    padding: 24px;
  }

  .bottom-nav {
    position: sticky;
    top: calc(var(--header-height) + env(safe-area-inset-top));
    bottom: auto;
    padding: 0;
    border-top: 0;
    border-bottom: 1px solid rgba(217, 223, 234, .78);
    background: rgba(246, 248, 252, .91);
  }

  .connection-banner:not(.hidden) + .bottom-nav {
    top: calc(var(--header-height) + env(safe-area-inset-top) + 40px);
  }

  .bottom-nav-inner {
    height: 58px;
  }

  .nav-item {
    flex-direction: row;
    gap: 8px;
    font-size: 12px;
  }

  .nav-item::before {
    top: 8px;
    width: calc(100% - 16px);
    height: 42px;
  }

  .nav-item svg {
    width: 21px;
    height: 21px;
  }

  .nav-badge {
    top: 8px;
    left: calc(50% - 2px);
  }

  .score-summary {
    grid-template-columns: 148px minmax(0, 1fr);
    align-items: center;
    justify-items: stretch;
    gap: 26px;
    text-align: left;
  }

  .score-ring {
    margin: 0;
  }

  .score-copy p {
    margin: 8px 0 0;
  }

  .score-actions {
    grid-template-columns: 1fr 1fr;
    margin-top: 22px;
  }
}

@media (min-width: 980px) {
  .check-page {
    display: grid;
    grid-template-columns: minmax(280px, .7fr) minmax(540px, 1.3fr);
    grid-template-areas:
      "hero input"
      ". privacy";
    align-items: start;
    gap: 14px 32px;
  }

  .check-page > .hero {
    grid-area: hero;
    padding-top: 12px;
  }

  .check-page > .input-card {
    grid-area: input;
    max-width: none;
  }

  .check-page > .privacy-note {
    grid-area: privacy;
    margin: -4px 2px 0;
  }

  .check-page .hero h1 {
    font-size: clamp(38px, 4vw, 48px);
  }

  .check-page .upload-zone {
    min-height: 300px;
  }

  .header-new:not(.hidden) {
    display: inline-flex !important;
  }

  .results-new-top,
  .results-new-inline,
  .score-new-inline {
    display: none;
  }

  .no-error-actions,
  .score-actions {
    grid-template-columns: minmax(300px, 430px);
  }

  .results-workspace {
    grid-template-columns: 380px minmax(0, 1fr);
    align-items: start;
  }

  .results-workspace.detail-mobile .results-list-panel {
    display: block;
  }

  .detail-panel,
  .detail-panel.mobile-open {
    position: sticky;
    top: calc(var(--header-height) + 74px + env(safe-area-inset-top));
    display: block;
    max-height: calc(100dvh - var(--header-height) - 90px - env(safe-area-inset-top));
    overflow-y: auto;
  }

  .detail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 360px;
    padding: 30px;
    color: var(--color-text-soft);
    text-align: center;
  }

  .detail-placeholder svg {
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
    color: var(--color-primary);
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
  }

  .detail-mobile-back {
    display: none;
  }
}

@media (max-width: 979px) {
  .detail-panel.mobile-open {
    border: 0;
    box-shadow: none;
  }

  .detail-panel.mobile-open .detail-inner {
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .app-header,
  .bottom-nav,
  .header-actions,
  .button,
  .connection-banner,
  .demo-banner,
  .level-card,
  .toast-region {
    display: none !important;
  }

  body,
  .app-shell,
  .main {
    background: #fff;
  }

  .app-shell {
    padding-top: 0;
  }

  .main {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .result-hero,
  .error-card,
  .detail-panel {
    break-inside: avoid;
    box-shadow: none;
  }
}
