: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: 72px;
  --bottom-nav-height: 72px;
  --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 {
  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;
}

.app-header {
  position: sticky;
  z-index: 50;
  top: 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);
}

.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: 48px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  text-align: left;
}

.brand-mark {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  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;
}

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

.icon-button {
  display: inline-grid;
  width: 48px;
  height: 48px;
  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: 24px 16px calc(32px + 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: 8px 0 22px;
}

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

.hero p,
.page-heading > p {
  max-width: 650px;
  margin: 14px 0 0;
  color: var(--color-text-soft);
  font-size: clamp(16px, 4.2vw, 19px);
  line-height: 1.55;
}

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

.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: 300px;
  padding: 28px 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: 76px;
  height: 76px;
  margin-bottom: 18px;
  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: 38px;
  height: 38px;
  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: 8px 0 20px;
  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: 48px;
  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;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}

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

.button:active:not(:disabled) {
  transform: translateY(0) scale(.985);
}

.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-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);
}

.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);
}

.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-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-card h1 {
  margin: 0;
  font-size: 29px;
  letter-spacing: -.04em;
}

.score-card > 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);
}

.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;
}

.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.active {
  color: var(--color-primary);
}

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

.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 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); }
}

.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;
}

@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: 768px) {
  .header-inner,
  .main {
    padding-right: 28px;
    padding-left: 28px;
  }

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

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

  .hero {
    padding-top: 24px;
    padding-bottom: 30px;
  }

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

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

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

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

  .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 {
    padding: 30px;
  }

  .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);
  }

  .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);
  }
}

@media (min-width: 980px) {
  .header-new:not(.hidden) {
    display: inline-flex !important;
  }

  .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: 82px;
    display: block;
    max-height: calc(100vh - 105px);
    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,
  .toast-region {
    display: none !important;
  }

  body,
  .main {
    background: #fff;
  }

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

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