:root {
  color-scheme: dark;
  --bg: #08101c;
  --surface: #111c2c;
  --surface-2: #172438;
  --line: #29384d;
  --text: #eef5ff;
  --muted: #9baabd;
  --primary: #50a8ff;
  --primary-dark: #2187e8;
  --success: #38d39f;
  --warning: #ffca5c;
  --danger: #ff6f7d;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% -10%, rgba(52, 126, 207, .2), transparent 32rem),
    var(--bg);
  color: var(--text);
}

button, input { font: inherit; }
a { color: inherit; }

.topbar {
  min-height: 64px;
  padding: 12px max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(8,16,28,.88);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-weight: 800; text-decoration: none; letter-spacing: -.02em; }
.topbar nav { display: flex; gap: 17px; align-items: center; font-size: .92rem; }
.topbar nav a, .link-button { color: var(--muted); text-decoration: none; }
.topbar nav a:hover, .link-button:hover { color: var(--text); }
.topbar form { margin: 0; }
.link-button { border: 0; padding: 0; background: none; cursor: pointer; }

.page {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 34px max(18px, env(safe-area-inset-right)) calc(52px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.hero { margin-bottom: 28px; }
.hero.compact { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.85rem, 5vw, 3rem); letter-spacing: -.045em; }
h2 { letter-spacing: -.025em; }
.hero p:not(.eyebrow), .section-heading p { color: var(--muted); margin-bottom: 0; }
.eyebrow { color: var(--primary); text-transform: uppercase; letter-spacing: .13em; font-size: .76rem; font-weight: 800; margin-bottom: 8px; }

.capture-grid, .sample-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.capture-card, .sample-card, .history-card, .login-card, .empty-state {
  background: linear-gradient(160deg, rgba(255,255,255,.035), transparent 60%), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 45px rgba(0,0,0,.18);
}

.capture-card { padding: 24px; position: relative; overflow: hidden; }
.capture-card h2 { margin: 8px 0 6px; }
.capture-card > p { color: var(--muted); min-height: 24px; }
.step-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(80,168,255,.14);
  color: #8bc6ff;
  font-weight: 800;
}

.camera-button, .primary, .secondary, .button-link {
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid transparent;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 11px 17px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
}

.camera-button, .primary { background: var(--primary); color: #04111f; width: 100%; }
.camera-button:hover, .primary:hover { background: #7ec0ff; }
.primary:active, .secondary:active, .camera-button:active { transform: scale(.985); }
.primary:disabled { opacity: .38; cursor: not-allowed; }
.primary.large { width: min(420px, 100%); min-height: 54px; font-size: 1.03rem; }
.secondary { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.secondary:hover { background: #203049; }
.secondary.small { min-height: 38px; padding: 7px 13px; font-size: .86rem; }
.camera-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.preview-shell { margin-top: 15px; position: relative; }
.preview-shell img { width: 100%; height: 210px; display: block; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.preview-shell .retake { position: absolute; right: 10px; bottom: 10px; background: rgba(8,16,28,.9); }

.action-row { display: flex; justify-content: center; gap: 12px; margin: 24px 0 0; }
.action-row.split { justify-content: flex-end; }

.spinner {
  width: 19px;
  height: 19px;
  border: 3px solid rgba(4,17,31,.25);
  border-top-color: #04111f;
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.results { margin-top: 42px; border-top: 1px solid var(--line); padding-top: 34px; }
.section-heading { margin-bottom: 22px; }
.reading-time { max-width: 360px; margin-bottom: 18px; display: block; color: var(--muted); font-size: .85rem; font-weight: 700; }

.sample-grid { grid-template-columns: 1fr 1fr; }
.sample-card { padding: 20px; }
.sample-card.vetters { grid-column: 1 / -1; }
.sample-card header { display: flex; align-items: center; gap: 10px; margin-bottom: 17px; }
.sample-card header span {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(80,168,255,.14);
  color: #8bc6ff;
  display: grid;
  place-items: center;
  font-weight: 900;
}
.sample-card header h3 { margin: 0; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }

label { color: var(--muted); font-size: .82rem; font-weight: 700; }
input {
  width: 100%;
  min-height: 46px;
  margin-top: 7px;
  padding: 10px 12px;
  border: 1px solid #354862;
  border-radius: 10px;
  color: var(--text);
  background: #0a1422;
  outline: none;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(80,168,255,.15); }
input.needs-review { border-color: var(--warning); background: rgba(255,202,92,.07); }

.notice { padding: 13px 15px; border-radius: 11px; border: 1px solid var(--line); margin-bottom: 18px; background: var(--surface-2); }
.notice.error { border-color: rgba(255,111,125,.55); color: #ffb1b9; }
.notice.warning { border-color: rgba(255,202,92,.45); color: #ffe0a0; }
.notice.success { border-color: rgba(56,211,159,.45); color: #8af1ce; }
.notice ul { margin: 7px 0 0; padding-left: 20px; }

.login-page { display: grid; place-items: center; min-height: calc(100vh - 96px); }
.login-card { width: min(430px, 100%); padding: 30px; }
.login-card > p { color: var(--muted); }
.app-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: var(--primary); color: #04111f; font-size: .82rem; font-weight: 900; margin-bottom: 24px; }
.stack-form { display: grid; gap: 17px; }

.history-heading { margin-bottom: 24px; }
.history-list { display: grid; gap: 16px; }
.history-card { padding: 20px; }
.history-card > header { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 13px; margin-bottom: 16px; }
.history-card > header h2 { margin: 0; font-size: 1.08rem; }
.history-card > header span { color: var(--muted); }
.history-samples { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.history-samples section { background: rgba(0,0,0,.13); border-radius: 12px; padding: 14px; }
.history-samples h3 { margin-bottom: 9px; }
dl { margin: 0; }
dl div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; }
.empty-state { text-align: center; padding: 45px 20px; }
.empty-state p { color: var(--muted); }
.button-link { width: auto; }

[hidden] { display: none !important; }

@media (max-width: 720px) {
  .topbar { align-items: flex-start; }
  .brand { max-width: 130px; }
  .topbar nav { gap: 12px; font-size: .82rem; flex-wrap: wrap; justify-content: flex-end; }
  .page { padding-top: 24px; }
  .hero.compact { align-items: flex-start; }
  .capture-grid, .sample-grid { grid-template-columns: 1fr; }
  .sample-card.vetters { grid-column: auto; }
  .field-grid, .field-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-samples { grid-template-columns: 1fr; }
  .history-heading { flex-direction: column; }
  .preview-shell img { height: 185px; }
}

@media (max-width: 420px) {
  .field-grid, .field-grid.three { grid-template-columns: 1fr; }
  .capture-card, .sample-card, .login-card { padding: 18px; }
  .action-row.split { flex-direction: column-reverse; }
  .action-row.split button { width: 100%; }
}
