:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #111418;
  --muted: #5b6470;
  --line: #e6e9ee;
  --brand: #145a4a;
  --brand-ink: #0b3a30;
  --accent: #c48a2e;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 20, 26, 0.06), 0 10px 30px rgba(16, 20, 26, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a21;
    --ink: #eef1f5;
    --muted: #9aa4b1;
    --line: #252b34;
    --brand: #3fae93;
    --brand-ink: #c7e9df;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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: 100;
}
.skip-link:focus { left: 0; }

header.site {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 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: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
}
.brand small { display: block; font-weight: 500; color: var(--muted); letter-spacing: 0; font-size: 0.8rem; }

.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) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
  padding: 6px 12px; border-radius: 999px;
}
.privacy-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: clamp(18px, 4vw, 36px);
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 860px) {
  main { grid-template-columns: 1fr 1fr; align-items: start; }
}
.intro { grid-column: 1 / -1; }
.intro h1 { font-size: clamp(1.35rem, 1rem + 2.2vw, 2.1rem); margin: 0 0 6px; letter-spacing: -0.015em; }
.intro p { color: var(--muted); margin: 0 0 6px; max-width: 68ch; }
.intro .disclaimer { font-size: 0.9rem; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 20px;
}
.card h2 { font-size: 1.02rem; margin: 0 0 12px; }
.card h3 { font-size: 0.92rem; margin: 16px 0 6px; }

label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 0.8rem; 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: 148px; cursor: pointer;
  border-style: dashed; color: var(--muted);
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); color: var(--brand-ink); }
.dropzone img { max-height: 168px; border-radius: 8px; display: block; }
.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 input { margin-top: 3px; }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px;
  background: var(--brand); color: #fff; transition: filter 0.12s ease, transform 0.04s 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.55; cursor: not-allowed; }

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

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.actions { margin-top: 4px; }
.sample-row select { max-width: 220px; }

.samples { margin-top: 10px; }
.samples h3 { font-size: 0.86rem; margin: 10px 0 6px; color: var(--muted); }

.result-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; justify-content: space-between; }
.result-size { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.result-size .size { font-size: 2.8rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.result-size .adj { color: var(--accent); font-weight: 600; font-size: 0.82rem; }

.conf-wrap { min-width: 220px; flex: 1 1 220px; }
.confidence { margin: 2px 0 4px; }
.confidence .bar { height: 9px; 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.8rem; color: var(--muted); margin-bottom: 5px; }
.confidence .num { font-variant-numeric: tabular-nums; }
.conf-hint { margin: 2px 0 0; font-size: 0.76rem; color: var(--muted); }

table.metrics {
  width: 100%; border-collapse: collapse; margin: 12px 0 6px; font-size: 0.9rem;
}
table.metrics th, table.metrics td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.metrics th { font-weight: 600; color: var(--muted); width: 22%; }
table.metrics td.val { font-variant-numeric: tabular-nums; font-weight: 600; }
table.metrics td.range { color: var(--muted); font-variant-numeric: tabular-nums; }

.why {
  margin-top: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.9rem;
}
.why h3 { margin: 0 0 6px; font-size: 0.88rem; }
.why p { margin: 4px 0; }
.why .why-foot { color: var(--muted); font-size: 0.82rem; }

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

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

.learning { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }

.privacy ul { margin: 8px 0 0; padding-left: 18px; }
.privacy li { margin: 4px 0; color: var(--muted); font-size: 0.88rem; }

footer { color: var(--muted); font-size: 0.78rem; text-align: center; padding: 22px 12px 28px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; clip: rect(0 0 0 0); overflow: hidden; }
