:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #312315;
  --muted: #756454;
  --paper: rgba(255, 255, 255, 0.88);
  --cream: #fff7e8;
  --cream-strong: #fff0cf;
  --honey: #f8ad28;
  --honey-dark: #9a5b00;
  --berry: #ff3d6e;
  --mint: #e9f8ed;
  --line: #efd6ac;
  background: var(--cream);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 8%, rgba(255, 198, 82, 0.34), transparent 24rem),
    radial-gradient(circle at 88% 18%, rgba(126, 210, 255, 0.2), transparent 24rem),
    radial-gradient(circle at 62% 92%, rgba(255, 118, 150, 0.16), transparent 28rem),
    linear-gradient(180deg, #fffaf0 0%, #fff3dc 58%, #ffefd5 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(159, 106, 35, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(159, 106, 35, 0.045) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.42), transparent 68%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: clamp(40px, 7vw, 76px);
  line-height: 0.96;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 10px;
}

.shell {
  position: relative;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: stretch;
  padding: 18px 2px 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--honey-dark);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-copy {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.hero-badge {
  display: grid;
  place-content: center;
  gap: 7px;
  min-width: 172px;
  padding: 22px;
  border: 1px solid rgba(240, 208, 156, 0.86);
  border-radius: 30px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.94), rgba(255, 244, 219, 0.8)),
    radial-gradient(circle at top right, rgba(248, 173, 40, 0.28), transparent 8rem);
  box-shadow: 0 20px 60px rgba(94, 58, 13, 0.13);
}

.hero-badge strong {
  font-size: 24px;
}

.hero-badge span,
.hero-badge small,
.muted,
.hint {
  color: var(--muted);
}

.panel,
.status,
.workspace {
  margin-top: 18px;
  border: 1px solid rgba(239, 214, 172, 0.9);
  border-radius: 32px;
  background: var(--paper);
  box-shadow: 0 22px 70px rgba(94, 58, 13, 0.13);
  backdrop-filter: blur(16px);
}

.panel,
.status {
  padding: 20px;
}

.status {
  font-weight: 750;
}

.status-loading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-spinner,
.mini-spinner {
  flex: 0 0 auto;
  display: inline-block;
  border-radius: 999px;
  border: 3px solid rgba(154, 91, 0, 0.18);
  border-top-color: var(--honey-dark);
  animation: molly-spin 0.85s linear infinite;
}

.status-spinner {
  width: 26px;
  height: 26px;
}

.mini-spinner {
  width: 15px;
  height: 15px;
  border-width: 2px;
}

.status-loading {
  background: #fff8e8;
}

.status-success {
  background: #edf8ec;
  border-color: #b8ddb4;
}

.status-warning {
  background: #fff8dc;
}

.status-error {
  background: #fff0ec;
  border-color: #e8b5a8;
}

.capture-panel form {
  display: grid;
  gap: 16px;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.flow-steps span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 999px;
  background: #fff4d7;
  color: #875600;
  font-size: 14px;
  font-weight: 900;
}

.capture-button {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: 100%;
  min-height: 188px;
  border: 0;
  border-radius: 30px;
  padding: 26px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.42), transparent 8rem),
    linear-gradient(135deg, #ffd667, #ffad25 48%, #ff9447);
  color: var(--ink);
  box-shadow: inset 0 -2px rgba(91, 51, 0, 0.14), 0 18px 46px rgba(255, 157, 27, 0.28);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.capture-button:active {
  transform: scale(0.985);
  box-shadow: inset 0 -2px rgba(91, 51, 0, 0.14), 0 12px 30px rgba(255, 157, 27, 0.2);
}

.capture-icon {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.42);
  font-size: 42px;
}

.capture-button strong {
  font-size: clamp(27px, 5vw, 42px);
  line-height: 1;
}

.capture-button small {
  color: rgba(45, 36, 24, 0.72);
  font-weight: 750;
}

.photo-tips {
  display: grid;
  grid-template-columns: auto repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(184, 221, 180, 0.9);
  border-radius: 22px;
  padding: 14px;
  background: rgba(237, 248, 236, 0.82);
  color: #496944;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.45;
}

.photo-tips strong {
  color: #2f5f2b;
}

.photo-tips span {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.72);
}

.field {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.voice-box {
  display: grid;
  grid-template-columns: 1fr minmax(92px, auto);
  gap: 10px;
  align-items: stretch;
}

textarea {
  min-height: 96px;
  border: 1px solid #e4c899;
  border-radius: 20px;
  padding: 15px;
  background: #fffdf8;
  line-height: 1.55;
  resize: vertical;
}

textarea:focus {
  border-color: var(--honey);
  box-shadow: 0 0 0 4px rgba(248, 173, 40, 0.16);
  outline: none;
}

.voice-button {
  display: grid;
  place-items: center;
  gap: 6px;
  border: 1px solid #f2d49c;
  border-radius: 20px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #ffffff, #fff2d5);
  color: #7d4e00;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(127, 80, 0, 0.08);
}

.voice-button span {
  font-size: 24px;
}

.voice-button-active {
  border-color: var(--berry);
  background: linear-gradient(180deg, #fff1f5, #ffe2e9);
  color: #b7133e;
  animation: pulseMic 1s ease-in-out infinite;
}

.voice-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.voice-status-active {
  color: #b7133e;
}

.voice-status-warning {
  color: #885600;
}

@keyframes pulseMic {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 61, 110, 0.24);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 61, 110, 0.08);
  }
}

.submit-button,
.ghost-button {
  border: 0;
  border-radius: 18px;
  padding: 15px 18px;
  font-weight: 850;
}

.submit-button {
  background: linear-gradient(135deg, #332416, #1f170f);
  color: #fff8ed;
  font-size: 18px;
  box-shadow: 0 16px 34px rgba(45, 36, 24, 0.18);
}

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

.ghost-button {
  background: #fff1d3;
  color: #825400;
}

.workspace {
  overflow: hidden;
}

.batch-workspace {
  padding: 20px;
}

.batch-pages {
  display: grid;
  gap: 18px;
}

.page-card {
  overflow: hidden;
  border: 1px solid #f0dfc2;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 16px 46px rgba(94, 58, 13, 0.09);
}

.page-card-header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #f0dfc2;
  background: linear-gradient(180deg, #fffaf0, #fff5e1);
}

.page-card-header h3 {
  margin: 0;
}

.page-card-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  padding: 18px;
}

.page-image-stage {
  position: sticky;
  top: 18px;
  align-self: start;
  overflow: hidden;
  min-height: 280px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(31, 23, 15, 0.94), rgba(81, 54, 26, 0.92));
}

.page-preview {
  display: block;
  width: 100%;
  max-height: 640px;
  object-fit: contain;
}

.page-overlay {
  position: absolute;
  inset: 0;
}

.page-preview-placeholder {
  display: grid;
  place-items: center;
  min-height: 320px;
  padding: 20px;
  color: #fff8ed;
  font-weight: 850;
  line-height: 1.55;
  text-align: center;
}

.page-analysis {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.progress-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.progress-strip span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 999px;
  background: #fff1d3;
  color: #8a5a03;
  font-size: 13px;
  font-weight: 900;
}

.progress-strip .step-active {
  background: linear-gradient(135deg, #332416, #1f170f);
  color: #fff8ed;
}

.page-summary {
  padding: 14px 16px;
  border-radius: 18px;
  background: #fffaf1;
  color: var(--muted);
  line-height: 1.62;
}

.image-stage {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, rgba(31, 23, 15, 0.94), rgba(81, 54, 26, 0.92));
}

.preview {
  display: block;
  width: 100%;
  max-height: 720px;
  object-fit: contain;
}

.overlay {
  position: absolute;
  inset: 0;
}

.empty-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(520px, 86%);
  transform: translate(-50%, -50%);
  border-radius: 22px;
  padding: 16px;
  background: rgba(255, 248, 237, 0.92);
  color: #4a3925;
  font-weight: 800;
  text-align: center;
}

.bbox {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 3px solid var(--berry);
  border-radius: 12px;
  background: rgba(255, 45, 85, 0.12);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.02), 0 10px 30px rgba(255, 45, 85, 0.28);
  color: inherit;
  cursor: pointer;
  transition: transform 160ms ease;
}

.bbox:hover {
  transform: scale(1.018);
}

.bbox span {
  position: absolute;
  left: -10px;
  top: -14px;
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--berry);
  color: white;
  font-weight: 900;
}

.bbox-low {
  border-style: dashed;
  border-color: #ffb000;
  background: rgba(255, 176, 0, 0.16);
}

.bbox-low span {
  background: #ffb000;
  color: var(--ink);
}

.bbox-active {
  outline: 4px solid rgba(255, 255, 255, 0.88);
}

.workspace-help {
  display: flex;
  gap: 8px 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 16px 18px;
  background: #fff9ed;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.summary-card {
  background:
    radial-gradient(circle at top right, rgba(126, 210, 255, 0.16), transparent 12rem),
    var(--paper);
}

.summary-card #overall-summary {
  font-size: 17px;
  line-height: 1.65;
}

.section-title {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.meta-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff1d3;
  color: #825400;
  font-size: 13px;
  font-weight: 850;
}

.pill-warning,
.uncertain {
  background: #fff2c2;
  color: #7b4c00;
}

.pill-working {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

@media (prefers-reduced-motion: reduce) {
  .status-spinner,
  .mini-spinner {
    animation: none;
  }
}

.question-list,
.weak-list,
.review-list {
  display: grid;
  gap: 14px;
}

.question-card,
.weak-card,
.review-card {
  border: 1px solid #f0dfc2;
  border-radius: 22px;
  background: #fffaf1;
  overflow: hidden;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.question-card:hover,
.weak-card:hover,
.review-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(94, 58, 13, 0.1);
}

.question-card-active {
  border-color: var(--berry);
  box-shadow: 0 0 0 3px rgba(255, 45, 85, 0.12);
}

.question-card-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 0;
  padding: 16px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.question-card-header small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.marker {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--berry);
  color: #fff;
  font-weight: 900;
}

.question-card-body,
.weak-card,
.review-card {
  padding: 16px;
}

.question-card-body p {
  line-height: 1.62;
}

.practice-block {
  margin-top: 16px;
  border-top: 1px solid #ead7b7;
  border-radius: 18px;
  padding: 14px;
  background: #fffdf8;
}

.practice-block h3 {
  margin-bottom: 10px;
}

.review-panel {
  background:
    radial-gradient(circle at top right, rgba(233, 248, 237, 0.9), transparent 16rem),
    var(--paper);
}

.review-panel + .review-panel {
  background:
    radial-gradient(circle at top right, rgba(255, 214, 103, 0.28), transparent 16rem),
    var(--paper);
}

.review-card {
  background: linear-gradient(180deg, #ffffff, #f6fff7);
}

li + li {
  margin-top: 8px;
}

details {
  margin-top: 12px;
  border-radius: 14px;
  padding: 12px;
  background: #fff3dc;
}

summary {
  cursor: pointer;
  font-weight: 850;
}

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

  .flow-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .voice-box {
    grid-template-columns: 1fr;
  }

  .photo-tips {
    grid-template-columns: 1fr;
  }

  .section-title,
  .question-card-header {
    align-items: start;
  }

  .question-card-header {
    grid-template-columns: auto 1fr;
  }

  .question-card-header .pill {
    grid-column: 2;
    justify-self: start;
  }

  .batch-workspace {
    padding: 14px;
  }

  .page-card-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .page-image-stage {
    position: relative;
    top: auto;
  }

  .progress-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.login-body {
  min-height: 100vh;
  overflow-x: hidden;
}

.login-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  gap: 28px;
  align-items: center;
  width: min(1080px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
}

.login-hero h1 {
  max-width: 620px;
  margin-bottom: 18px;
  font-size: clamp(48px, 8vw, 86px);
}

.login-hero p {
  max-width: 560px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.7;
}

.login-install-tip {
  display: grid;
  gap: 7px;
  max-width: 560px;
  margin-top: 28px;
  padding: 18px 20px;
  border: 1px solid rgba(184, 221, 180, 0.9);
  border-radius: 24px;
  background: rgba(237, 248, 236, 0.86);
  box-shadow: 0 16px 42px rgba(48, 92, 43, 0.1);
}

.login-install-tip span {
  color: #526b4f;
  line-height: 1.55;
}

.login-card {
  position: relative;
  padding: 28px;
  border: 1px solid rgba(239, 214, 172, 0.95);
  border-radius: 34px;
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 214, 103, 0.32), transparent 10rem),
    rgba(255, 255, 255, 0.92);
  box-shadow: 0 28px 82px rgba(94, 58, 13, 0.18);
  backdrop-filter: blur(18px);
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 12px;
  z-index: -1;
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(255, 214, 103, 0.22), rgba(255, 255, 255, 0));
}

.login-card-top {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.login-avatar {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 24px;
  background: linear-gradient(135deg, #ffd667, #ffad25);
  box-shadow: 0 14px 34px rgba(255, 157, 27, 0.28);
  font-size: 34px;
}

.login-card h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.login-form {
  display: grid;
  gap: 15px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 850;
}

.login-form input {
  width: 100%;
  min-height: 58px;
  border: 1px solid #e4c899;
  border-radius: 20px;
  padding: 0 16px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 18px;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.login-form input:focus {
  border-color: var(--honey);
  background: #fffaf0;
  box-shadow: 0 0 0 5px rgba(248, 173, 40, 0.16);
}

.login-submit {
  min-height: 62px;
  margin-top: 8px;
  border: 0;
  border-radius: 22px;
  background: linear-gradient(135deg, #ffd667, #ffad25 52%, #ff9447);
  color: var(--ink);
  font-size: 18px;
  font-weight: 950;
  box-shadow: 0 18px 44px rgba(255, 157, 27, 0.24);
  transition: transform 180ms ease, opacity 180ms ease;
}

.login-submit:active {
  transform: scale(0.985);
}

.login-submit:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.login-status {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.5;
}

.login-status-success {
  color: #2f7c38;
}

.login-status-error {
  color: #b33d2f;
}

.login-status-loading {
  color: var(--honey-dark);
}

@media (max-width: 820px) {
  .login-shell {
    grid-template-columns: 1fr;
    align-content: center;
  }

  .login-card {
    padding: 22px;
  }
}
