:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --ink: #15181d;
  --muted: #5b6470;
  --line: #e3e7ec;
  --brand: #1d6f5c;
  --brand-ink: #0d4034;
  --accent: #c9963f;
  --danger: #b3261e;
  --warn: #b07a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 29, 0.06), 0 12px 32px rgba(20, 24, 29, 0.07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1f242c;
    --ink: #eef1f5;
    --muted: #9aa4b1;
    --line: #262c34;
    --brand: #3fae93;
    --brand-ink: #bdeadd;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 8px 14px;
  border-radius: 0 0 8px 0;
  z-index: 10;
}
.skip-link:focus { left: 0; }

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.2px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
}
.brand-text small { display: block; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.privacy-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--brand-ink);
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  padding: 6px 12px; border-radius: 999px;
}
.privacy-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }

main {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px);
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 820px) { main { grid-template-columns: 1fr 1fr; align-items: start; } }

.intro { grid-column: 1 / -1; }
.intro h1 { font-size: clamp(1.5rem, 1rem + 2.4vw, 2.3rem); margin: 0 0 8px; letter-spacing: -0.02em; }
.intro p { color: var(--muted); margin: 0; max-width: 64ch; }

.trust {
  list-style: none; margin: 14px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  font-size: 0.86rem; color: var(--brand-ink);
}
.trust li { display: inline-flex; align-items: center; gap: 6px; }
.trust li span { color: var(--brand); font-weight: 700; }

.tier-line {
  margin: 14px 0 0; font-size: 0.82rem; color: var(--muted);
  display: inline-flex; align-items: center; gap: 8px;
}
.tier-line .badge {
  font-size: 0.74rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h2 { font-size: 1.05rem; margin: 0 0 14px; }
.card h3 { font-size: 0.95rem; margin: 18px 0 8px; }

label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }

input[type="number"], select, .dropzone {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; min-height: 132px; cursor: pointer;
  border-style: dashed; color: var(--muted);
  position: relative; overflow: hidden;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); color: var(--brand-ink); }
.dropzone img { max-height: 180px; border-radius: 8px; }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }

.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 0.86rem; color: var(--muted); }
.consent label { font-weight: 500; margin-bottom: 0; color: var(--ink); }
.consent input { margin-top: 3px; }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 10px; padding: 11px 16px;
  background: var(--brand); color: #fff; transition: filter 0.15s ease, transform 0.05s ease;
}
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(1px); }
button.secondary { background: transparent; color: var(--brand); border-color: var(--line); }
button[disabled] { opacity: 0.5; cursor: not-allowed; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 60%, transparent); outline-offset: 2px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.sample-row select { max-width: 240px; }

.result-size { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.result-size .size { font-size: 3rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.result-size .adj { color: var(--accent); font-weight: 600; font-size: 0.9rem; }

.confidence { margin: 14px 0; }
.confidence .bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.confidence .bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--brand)); }
.confidence .lbl { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.confidence .verdict { font-weight: 600; color: var(--ink); }
.confidence.low .verdict { color: var(--warn); }

table.metrics { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.92rem; }
table.metrics th, table.metrics td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.metrics th[scope="col"] { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: none; }
table.metrics td.val { font-variant-numeric: tabular-nums; font-weight: 600; }
table.metrics td.range { color: var(--muted); font-variant-numeric: tabular-nums; }
table.metrics td.driver { color: var(--brand-ink); font-weight: 600; font-size: 0.78rem; }

.why { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 0.9rem; }
.why strong { color: var(--brand-ink); }
.why ul { margin: 8px 0 0; padding-left: 18px; }
.why li { margin: 2px 0; }
.why em { color: var(--muted); }

.alert {
  border-radius: 10px; padding: 12px 14px; font-size: 0.9rem;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}
.alert.warn {
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  color: var(--warn);
}

.learn-state { font-size: 0.85rem; color: var(--muted); margin-top: 10px; }
.learn-state b { color: var(--ink); }

footer { color: var(--muted); font-size: 0.8rem; text-align: center; padding: 24px; }
footer .foot-hint { margin-top: 4px; font-size: 0.74rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; clip: rect(0 0 0 0); overflow: hidden; }

.thinking { font-size: 0.85rem; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.thinking .spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .thinking .spinner { animation: none; } }
