:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #151515;
  background: #f4f3ef;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f4f3ef; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 56px 0 96px; }
.app-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 32px; margin-bottom: 30px; }
.eyebrow, .step-kicker { margin: 0 0 8px; font-size: 12px; letter-spacing: .16em; font-weight: 800; text-transform: uppercase; }
.app-header h1 { margin: 0; max-width: 780px; font-size: clamp(34px, 6vw, 72px); line-height: .98; letter-spacing: -.055em; }
.lede { max-width: 680px; margin: 18px 0 0; font-size: 17px; line-height: 1.7; color: #5c5b57; }
.status-pill, .version-badge { flex: 0 0 auto; border: 1px solid #c8c6be; border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 800; letter-spacing: .08em; background: #fff; }

.auth-panel {
  margin-bottom: 20px;
  border: 1px solid #d8d5cd;
  border-radius: 20px;
  padding: 20px 24px;
  background: rgba(255,255,255,.72);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.auth-panel h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.auth-status { margin: 7px 0 0; color: #6c6a64; font-size: 13px; }
.auth-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.auth-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }


.usage-summary {
  margin-bottom: 20px;
  border: 1px solid #d8d5cd;
  border-radius: 20px;
  padding: 20px 24px;
  background: rgba(255,255,255,.72);
}
.usage-summary-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 16px; }
.usage-summary-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.usage-summary-status { margin: 0; font-size: 12px; font-weight: 800; color: #6c6a64; }
.usage-summary-grid { margin: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.usage-summary-grid div { min-width: 0; border: 1px solid #e3e0d9; border-radius: 14px; padding: 12px 14px; background: #fff; }
.usage-summary-grid dt { margin-bottom: 5px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: #77736b; font-weight: 800; }
.usage-summary-grid dd { margin: 0; overflow-wrap: anywhere; font-weight: 850; font-variant-numeric: tabular-nums; }

.panel { background: #fff; border: 1px solid #d8d5cd; border-radius: 24px; padding: clamp(22px, 4vw, 42px); box-shadow: 0 16px 50px rgba(20,20,20,.05); }
.panel + .panel { margin-top: 20px; }
.section-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.section-heading h2 { margin: 0; font-size: clamp(24px, 4vw, 38px); letter-spacing: -.035em; }
.field-label { display: block; margin-bottom: 9px; font-weight: 800; }
textarea, input { width: 100%; border: 1px solid #c9c6bd; border-radius: 16px; background: #faf9f6; color: inherit; outline: none; }
textarea { resize: vertical; min-height: 132px; padding: 18px; font-size: clamp(18px, 2.4vw, 25px); line-height: 1.45; }
input { padding: 12px 14px; }
textarea:focus, input:focus { border-color: #151515; box-shadow: 0 0 0 3px rgba(21,21,21,.09); }
.field-error { margin: 8px 0 0; font-weight: 700; }
.optional-fields { margin-top: 18px; border-top: 1px solid #ebe8e0; padding-top: 16px; }
.optional-fields summary { cursor: pointer; font-weight: 750; }
.optional-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.optional-grid label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
.form-actions, .result-actions { display: flex; align-items: center; gap: 14px; margin-top: 24px; }
.primary-button, .secondary-button { border-radius: 999px; min-height: 48px; padding: 0 22px; font-weight: 850; border: 1px solid #151515; }
.primary-button { background: #151515; color: #fff; }
.secondary-button { background: #fff; color: #151515; }
.primary-button:disabled { opacity: .45; cursor: wait; }
.cost-note { color: #6c6a64; font-size: 12px; }

.progress-count { font-variant-numeric: tabular-nums; font-weight: 800; }
.progress-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.progress-item { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: center; padding: 14px 16px; border: 1px solid #e3e0d9; border-radius: 14px; color: #77736b; }
.progress-item::before { content: "○"; font-size: 20px; }
.progress-item.is-active { color: #151515; border-color: #151515; background: #f6f5f1; font-weight: 750; }
.progress-item.is-active::before { content: "●"; }
.progress-item.is-complete { color: #151515; }
.progress-item.is-complete::before { content: "✓"; font-weight: 900; }
.progress-item.is-failed { color: #151515; border-style: dashed; font-weight: 800; }
.progress-item.is-failed::before { content: "!"; font-weight: 900; }

.result-heading-row { align-items: center; }
.result-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(220px, .6fr); gap: 20px; }
.figure-preview { min-height: 340px; display: grid; place-items: center; align-content: center; gap: 10px; border: 1px solid #d9d6ce; border-radius: 20px; background: linear-gradient(145deg, #faf9f5, #efede5); padding: 28px; text-align: center; overflow: hidden; }
.figure-preview-image { display: block; width: 100%; max-height: 620px; object-fit: contain; }
.preview-fallback { color: #6c6a64; font-weight: 700; }
.mock-node { border: 1px solid #151515; border-radius: 999px; padding: 8px 18px; font-size: 12px; font-weight: 900; letter-spacing: .08em; background: #fff; }
.mock-arrow { font-size: 24px; }
.mock-title { max-width: 520px; padding: 26px; border-radius: 16px; background: #151515; color: #fff; font-size: clamp(20px, 4vw, 34px); font-weight: 850; letter-spacing: -.03em; }
.result-meta { border: 1px solid #e2dfd7; border-radius: 20px; padding: 20px; }
.result-meta dl { margin: 0; display: grid; gap: 18px; }
.result-meta dl div { display: grid; gap: 5px; }
.result-meta dt { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #77736b; font-weight: 800; }
.result-meta dd { margin: 0; font-weight: 800; }
.medical-disclaimer { margin-top: 20px; border: 2px solid #151515; border-radius: 18px; padding: 18px 20px; background: #f7f5ef; }
.medical-disclaimer strong { display: block; margin-bottom: 7px; }
.medical-disclaimer p { margin: 0; line-height: 1.75; }
.medical-disclaimer small { display: block; margin-top: 8px; color: #595959; }
.history-panel, .export-message { margin-top: 16px; padding: 16px; border-radius: 14px; background: #f6f5f1; }
.history-panel h3 { margin: 0 0 8px; }
.history-panel ol { margin: 0; padding-left: 22px; }
.export-message { margin-bottom: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

[hidden] { display: none !important; }

@media (max-width: 720px) {
  .app-shell { width: min(100% - 24px, 1120px); padding: 28px 0 60px; }
  .app-header { display: block; }
  .status-pill { display: inline-block; margin-top: 18px; }
  .panel { border-radius: 18px; }
  .optional-grid, .result-grid { grid-template-columns: 1fr; }
  .auth-panel { display: block; }
  .auth-actions { margin-top: 14px; align-items: stretch; flex-direction: column; }
  .auth-link, .auth-actions .secondary-button { width: 100%; }
  .usage-summary-heading { display: block; }
  .usage-summary-status { margin-top: 8px; }
  .usage-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions, .result-actions { align-items: stretch; flex-direction: column; }
  .primary-button, .secondary-button { width: 100%; }
  .cost-note { text-align: center; }
  .figure-preview { min-height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
