:root {
  color-scheme: light;
  --ink: #172019;
  --muted: #637066;
  --canvas: #f3f0e7;
  --paper: #fffdf7;
  --line: #d7d4c9;
  --leaf: #285c3b;
  --leaf-dark: #193e29;
  --moss: #dce7d7;
  --amber: #9a5b13;
  --amber-soft: #f4e6cf;
  --danger: #8b352f;
  --danger-soft: #f5dfdc;
  --radius: 4px;
  --shadow: 0 18px 50px rgb(34 45 37 / 8%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input { font: inherit; }
button { color: inherit; }
img { display: block; max-width: 100%; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: .65rem 1rem;
  background: var(--ink);
  color: white;
}
.skip-link:focus { top: 1rem; }

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 0 clamp(1.25rem, 4vw, 4.5rem);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font: 700 .7rem/1 "SFMono-Regular", Consolas, monospace;
  letter-spacing: -.04em;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: .95rem; letter-spacing: .01em; }
.brand small { color: var(--muted); font: .68rem/1.35 "SFMono-Regular", Consolas, monospace; }
.model-state { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .78rem; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: #aa781f; box-shadow: 0 0 0 4px rgb(170 120 31 / 12%); }
.model-state.ready .state-dot { background: var(--leaf); box-shadow: 0 0 0 4px rgb(40 92 59 / 12%); }
.model-state.unavailable .state-dot { background: var(--danger); box-shadow: 0 0 0 4px rgb(139 53 47 / 12%); }

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, .82fr) minmax(480px, 1.18fr);
  gap: clamp(2rem, 6vw, 7rem);
  align-items: start;
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 7rem) clamp(1.25rem, 4vw, 4.5rem) 5rem;
}
.brief { position: sticky; top: 2rem; }
.eyebrow, .step-label {
  margin: 0 0 .9rem;
  color: var(--leaf);
  font: 700 .67rem/1.2 "SFMono-Regular", Consolas, monospace;
  letter-spacing: .13em;
  text-transform: uppercase;
}
h1 {
  max-width: 700px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.65rem, 5vw, 5.4rem);
  font-weight: 500;
  line-height: .99;
  letter-spacing: -.045em;
}
.lede { max-width: 37rem; margin: 1.8rem 0 2.3rem; color: var(--muted); font-size: 1rem; }
.scope-list { margin: 0; border-top: 1px solid var(--line); }
.scope-list div { display: grid; grid-template-columns: 105px 1fr; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.scope-list dt { color: var(--muted); font-size: .75rem; }
.scope-list dd { margin: 0; font-size: .82rem; font-weight: 600; }
.boundary-note { margin-top: 2rem; padding: 1rem 1.1rem; border: 1px solid #c7b58e; background: var(--amber-soft); }
.boundary-note strong { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.boundary-note p { margin: .35rem 0 0; color: #67451f; font-size: .78rem; }

.console { min-width: 0; padding: clamp(1.4rem, 3vw, 2.4rem); background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.console-head, .result-head { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
h2, h3, h4 { margin: 0; }
h2 { font: 500 clamp(1.55rem, 3vw, 2rem)/1.1 Georgia, serif; }
h3 { font: 500 1.45rem/1.2 Georgia, serif; }
h4 { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.text-button { min-height: 44px; border: 0; background: transparent; color: var(--leaf); font-size: .78rem; text-decoration: underline; cursor: pointer; }

#upload-form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.drop-zone {
  display: grid;
  place-items: center;
  min-height: 245px;
  padding: 2rem;
  border: 1px dashed #8e978f;
  background: #faf8f1;
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}
.drop-zone:hover, .drop-zone.dragging { border-color: var(--leaf); background: #f2f6ef; }
.drop-zone input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
.drop-index { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: .8rem; border: 1px solid var(--line); border-radius: 50%; color: var(--leaf); font-size: 1.4rem; }
.drop-title { font-family: Georgia, serif; font-size: 1.1rem; }
.drop-help { margin-top: .35rem; color: var(--muted); font-size: .72rem; }
.preview-shell { position: relative; background: #101512; }
.preview-shell img { width: 100%; max-height: 330px; object-fit: contain; }
.preview-meta { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem .8rem; background: #1d261f; color: #dce5dd; font-size: .7rem; }
.preview-meta span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.primary-button {
  min-height: 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.1rem;
  border: 1px solid var(--leaf-dark);
  border-radius: var(--radius);
  background: var(--leaf-dark);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
.primary-button:disabled { border-color: var(--line); background: #e7e5dc; color: #8c918d; cursor: not-allowed; }
.primary-button:not(:disabled):hover { background: var(--leaf); }
.primary-button[aria-busy="true"] { cursor: wait; }

.message { min-height: 1.5rem; margin-top: .8rem; color: var(--danger); font-size: .78rem; }
.result { margin-top: 1.5rem; padding-top: 1.6rem; border-top: 1px solid var(--line); }
.decision-badge { padding: .35rem .55rem; border: 1px solid currentColor; color: var(--leaf); font: 700 .64rem/1 "SFMono-Regular", Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; }
.decision-badge.abstained { color: var(--amber); }
.decision-copy { padding: 1.5rem 0 1.2rem; }
.result-label { margin: 0; font: 500 clamp(1.8rem, 4vw, 3rem)/1 Georgia, serif; text-transform: capitalize; }
.result-reason { margin: .6rem 0 0; color: var(--muted); font-size: .82rem; }
.measure-grid { display: grid; grid-template-columns: repeat(4, 1fr); border-block: 1px solid var(--line); }
.measure-grid div { min-width: 0; padding: .8rem .65rem; border-right: 1px solid var(--line); }
.measure-grid div:last-child { border-right: 0; }
.measure-grid span, .measure-grid strong { display: block; }
.measure-grid span { color: var(--muted); font-size: .62rem; }
.measure-grid strong { margin-top: .25rem; font: 700 .9rem/1.2 "SFMono-Regular", Consolas, monospace; }
.result-section { padding: 1.25rem 0; border-bottom: 1px solid var(--line); }
.result-section > p { margin: .55rem 0 0; color: var(--muted); font-size: .8rem; }
.score-list { display: grid; gap: .65rem; margin-top: .85rem; }
.score-row { display: grid; grid-template-columns: minmax(0, 135px) minmax(0, 1fr) 48px; gap: .65rem; align-items: center; font-size: .7rem; }
.score-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: capitalize; }
.score-track { height: 6px; overflow: hidden; background: #e4e7e0; }
.score-fill { height: 100%; background: var(--leaf); }
.score-value { text-align: right; font-family: "SFMono-Regular", Consolas, monospace; }
.quality-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: .9rem 0 0; background: var(--line); }
.quality-metrics div { padding: .65rem; background: var(--paper); }
.quality-metrics dt { color: var(--muted); font-size: .6rem; text-transform: uppercase; }
.quality-metrics dd { margin: .15rem 0 0; font: 700 .75rem/1.3 "SFMono-Regular", Consolas, monospace; }
.trace { margin-top: 1.1rem; font-size: .72rem; }
.trace summary { min-height: 44px; display: flex; align-items: center; color: var(--leaf); cursor: pointer; }
.trace dl { margin: .4rem 0 0; }
.trace dl div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 1rem; padding: .45rem 0; border-top: 1px solid var(--line); }
.trace dt { color: var(--muted); }
.trace dd { margin: 0; overflow-wrap: anywhere; font-family: "SFMono-Regular", Consolas, monospace; }

footer { display: flex; justify-content: space-between; gap: 2rem; padding: 1.4rem clamp(1.25rem, 4vw, 4.5rem); border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
footer p { margin: 0; }
footer a { color: var(--leaf-dark); }
noscript { display: block; padding: 1rem; background: var(--danger-soft); color: var(--danger); text-align: center; }

:focus-visible { outline: 3px solid #d29642; outline-offset: 3px; }
[hidden] { display: none !important; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; gap: 2.5rem; }
  .brief { position: static; }
  h1 { max-width: 680px; font-size: clamp(2.7rem, 10vw, 4.8rem); }
}

@media (max-width: 560px) {
  .topbar { min-height: 68px; padding-inline: 1rem; }
  .brand small { display: none; }
  .model-state { max-width: 155px; font-size: .68rem; text-align: right; }
  .workspace { padding: 2.7rem 1rem 3.5rem; }
  h1 { font-size: clamp(2.35rem, 13vw, 3.4rem); }
  .lede { margin: 1.25rem 0 1.8rem; }
  .console { padding: 1.1rem; }
  .drop-zone { min-height: 205px; padding: 1.25rem; }
  .measure-grid { grid-template-columns: repeat(2, 1fr); }
  .measure-grid div:nth-child(2) { border-right: 0; }
  .measure-grid div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .score-row { grid-template-columns: minmax(0, 105px) minmax(0, 1fr) 42px; gap: .45rem; }
  .quality-metrics { grid-template-columns: 1fr 1fr; }
  footer { flex-direction: column; gap: .6rem; }
}

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