:root {
  color-scheme: light dark;
  --ink: #102a2f;
  --muted: #53676a;
  --paper: #f4f8f6;
  --panel: #ffffff;
  --line: #cbd8d5;
  --brand: #0b5260;
  --brand-dark: #073b45;
  --accent: #d7ff70;
  --danger: #a32727;
  --focus: #e47300;
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; max-width: 100%; overflow-x: hidden; background: var(--paper); }
body { min-height: 100vh; max-width: 100%; margin: 0; overflow-x: hidden; color: var(--ink); background: radial-gradient(circle at 80% 0%, #dff4ef 0, transparent 35rem), var(--paper); }
button, input, textarea { font: inherit; }
button, .file-button { min-height: 56px; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible, .file-button:focus-within { outline: 4px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; z-index: 30; top: .5rem; left: .5rem; transform: translateY(-160%); padding: .7rem 1rem; color: white; background: var(--brand); border-radius: .5rem; }
.skip-link:focus { transform: none; }
.center-card { display: grid; place-content: center; justify-items: center; min-height: 100vh; padding: 2rem; text-align: center; }
.logo { display: grid; place-items: center; width: 72px; height: 72px; color: var(--accent); background: var(--brand); border: 4px solid currentColor; border-radius: 50%; font-weight: 900; font-size: 2rem; }
.logo.small { width: 44px; height: 44px; border-width: 3px; font-size: 1.2rem; }
.eyebrow { margin: 0 0 .35rem; color: var(--brand); font-size: .78rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: .2rem 0 .75rem; font-size: clamp(2rem, 7vw, 3.5rem); line-height: 1.05; letter-spacing: -.04em; }
h2 { line-height: 1.2; }

.auth-layout { width: 100%; min-width: 0; min-height: 100vh; display: grid; grid-template-columns: minmax(18rem, 1fr) minmax(20rem, 32rem); gap: clamp(2rem, 8vw, 8rem); align-items: center; max-width: 1200px; margin: auto; padding: 2rem; }
.auth-layout > *, .auth-panel, label, input, textarea { min-width: 0; }
.brand-block { max-width: 36rem; }
.brand-block .logo { margin-bottom: 2rem; }
.brand-block p:last-child { max-width: 30rem; color: var(--muted); font-size: 1.15rem; line-height: 1.6; }
.panel, .result-card, .progress-card { padding: clamp(1.25rem, 4vw, 2rem); background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 18px 60px rgba(7, 59, 69, .08); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin-bottom: 1.5rem; padding: .3rem; background: var(--paper); border-radius: 14px; }
.tab { border: 0; border-radius: 11px; background: transparent; color: var(--ink); font-weight: 750; }
.tab.active { background: var(--panel); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.stack { display: grid; gap: 1rem; }
label { display: grid; gap: .4rem; font-weight: 750; }
input, textarea { width: 100%; padding: .9rem 1rem; color: var(--ink); background: var(--panel); border: 2px solid var(--line); border-radius: 12px; }
textarea { resize: vertical; line-height: 1.45; }
.primary, .secondary, .quiet, .danger-quiet, .text-button, .back-button { padding: .8rem 1.1rem; border-radius: 13px; font-weight: 800; }
.primary { color: #fff; background: var(--brand); border: 2px solid var(--brand); }
.primary, .secondary, .file-button { min-height: 64px; }
.primary:hover { background: var(--brand-dark); }
.secondary { color: var(--brand); background: var(--panel); border: 2px solid var(--brand); }
.quiet, .text-button, .back-button, .danger-quiet { color: var(--brand); background: transparent; border: 0; }
.text-button { min-height: 44px; text-decoration: underline; }
.danger-quiet { color: var(--danger); text-decoration: underline; }
.extra-large { min-height: 70px; font-size: 1.1rem; }
.message { min-height: 1.5rem; color: var(--danger); font-weight: 700; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 10; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 74px; padding: .65rem max(1rem, env(safe-area-inset-left)); background: color-mix(in srgb, var(--paper) 90%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--ink); font-size: 1.3rem; font-weight: 900; text-decoration: none; }
.top-actions { display: flex; align-items: center; gap: .25rem; }
.top-actions button { min-height: 48px; }
.screen { width: min(100% - 2rem, 920px); margin: auto; padding: clamp(2rem, 6vw, 5rem) 0 calc(4rem + env(safe-area-inset-bottom)); }
.screen.narrow { width: min(100% - 2rem, 680px); }
.hero-action { display: flex; align-items: center; gap: 1rem; width: 100%; min-height: 130px; margin: 2rem 0; padding: 1.4rem; color: white; text-align: left; background: linear-gradient(135deg, var(--brand), #0f7382); border: 0; border-radius: 25px; box-shadow: 0 18px 45px rgba(11, 82, 96, .25); }
.hero-action strong { display: block; font-size: 1.7rem; }
.hero-action small { display: block; margin-top: .35rem; font-size: .95rem; line-height: 1.35; }
.action-icon { display: grid; place-items: center; flex: 0 0 68px; height: 68px; color: var(--brand); background: var(--accent); border-radius: 50%; font-size: 2.2rem; }
.section-title { margin: 2.3rem 0 1rem; font-size: 1.25rem; }
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.preset-grid button { display: grid; align-content: center; justify-items: start; gap: .7rem; min-height: 116px; padding: 1rem; color: var(--ink); text-align: left; background: var(--panel); border: 2px solid var(--line); border-radius: 17px; font-weight: 800; }
.preset-grid button:hover { border-color: var(--brand); }
.preset-grid span { color: var(--brand); font-size: 1.35rem; font-weight: 900; }
.history-heading { display: flex; justify-content: space-between; align-items: end; }
.history-list { display: grid; gap: .7rem; }
.history-item { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; width: 100%; min-height: 76px; padding: .9rem 1rem; color: var(--ink); text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.history-item strong, .history-item small { display: block; }
.history-item small { margin-top: .25rem; color: var(--muted); }
.status-chip { padding: .3rem .55rem; color: var(--brand); background: #dff3ef; border-radius: 999px; font-size: .75rem; font-weight: 850; text-transform: capitalize; }
.empty-history { color: var(--muted); }

.back-button { margin: -1rem 0 1rem -.8rem; }
#capture-screen { padding-top: 1rem; }
#capture-screen .camera-frame { margin-top: 0; }
.camera-frame { position: relative; display: grid; place-items: center; aspect-ratio: 3 / 4; max-height: 58vh; overflow: hidden; margin: 1.5rem 0 .7rem; color: white; background: #0d1a1d; border-radius: 24px; }
.camera-frame video, .camera-frame img { width: 100%; height: 100%; object-fit: contain; }
.camera-placeholder { position: absolute; display: grid; justify-items: center; }
.camera-placeholder span { font-size: 4rem; }
.quality-message { min-height: 2rem; font-weight: 750; }
.quality-message.warning { color: #7d3d00; }
.voice-status { min-height: 2.8rem; margin: .75rem 0 0; color: var(--muted); font-weight: 700; line-height: 1.45; }
.capture-back { width: 100%; min-height: 64px; margin: 2rem 0 0; }
.actions { margin-top: 1rem; }
.file-button { display: grid; place-items: center; padding: .8rem; color: var(--brand); background: var(--panel); border: 2px solid var(--brand); border-radius: 13px; text-align: center; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.privacy-note { margin-top: 1.4rem; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.record-box { padding: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.record-box p { margin: .5rem 0 0; color: var(--muted); }

.progress-card { display: flex; align-items: center; gap: 1.2rem; }
.progress-card h1 { font-size: 1.75rem; }
.spinner { flex: 0 0 42px; height: 42px; border: 5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.result-card { display: grid; gap: 1.2rem; }
.result-card h1 { font-size: clamp(1.7rem, 5vw, 2.7rem); }
.result-card section { border-top: 1px solid var(--line); }
.result-card li { margin: .6rem 0; line-height: 1.5; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.risk-label { justify-self: start; margin: 0; padding: .35rem .6rem; color: var(--brand); background: #dff3ef; border-radius: 999px; font-size: .78rem; font-weight: 850; text-transform: uppercase; }
.risk-label.critical { color: #fff; background: var(--danger); }
.human-warning { padding: .2rem 1rem 1rem; background: #fff0e9; border: 2px solid #b5411d !important; border-radius: 14px; }
.followup { padding-top: 1rem; border-top: 1px solid var(--line); }
.full-action { width: 100%; min-height: 64px; margin: 1rem 0; }

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }
@media (max-width: 720px) {
  :root { font-size: 17px; }
  .auth-layout { grid-template-columns: 1fr; gap: 1rem; padding: 1rem; }
  .auth-layout > * { width: calc(100vw - 2rem); max-width: calc(100vw - 2rem); }
  .brand-block { padding-top: 2rem; }
  .brand-block .logo { margin-bottom: 1rem; }
  .preset-grid { grid-template-columns: 1fr 1fr; }
  .top-actions .quiet { padding-inline: .5rem; font-size: .85rem; }
}
@media (max-width: 390px) { .preset-grid, .result-actions { grid-template-columns: 1fr; } }
@media (prefers-color-scheme: dark) {
  :root { --ink: #f0f8f5; --muted: #adc1bc; --paper: #071a1e; --panel: #0d282e; --line: #345057; --brand: #5fd0dd; --brand-dark: #47b6c2; --accent: #d7ff70; --danger: #ff8c86; --focus: #ffb04a; }
  body { background: radial-gradient(circle at 80% 0%, #12363b 0, transparent 35rem), var(--paper); }
  .primary { color: #071a1e; }
  .logo { color: #071a1e; background: var(--accent); border-color: var(--accent); }
  .hero-action { color: #071a1e; background: linear-gradient(135deg, #62d4e0, #a4edf2); }
  .human-warning { background: #3d1f19; }
  .status-chip, .risk-label { background: #173d42; }
}
