@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #F5F6F2;
  --paper: #FFFFFF;
  --ink: #16241F;
  --ink-soft: #4B5A54;
  --primary: #1F6F5C;
  --primary-dark: #123D32;
  --warn: #D97B4F;
  --good: #4C8C6B;
  --line: #D8DBD3;

  --font-display: 'Fraunces', serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

a { color: inherit; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 0.4em;
  letter-spacing: -0.01em;
}

p { margin: 0 0 1em; color: var(--ink-soft); }

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Nav ─────────────────────────────────────────── */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0;
}

.brand {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 92, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

/* ── Hero ────────────────────────────────────────── */

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 56px;
  align-items: center;
  padding: 56px 0 88px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
.eyebrow::before {
  content: '';
  width: 18px;
  height: 1px;
  background: var(--primary);
}

.hero h1 {
  font-size: 46px;
  line-height: 1.08;
  max-width: 560px;
}

.hero .lede {
  font-size: 18px;
  max-width: 460px;
  margin-bottom: 28px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.hero-note {
  font-size: 13px;
  color: var(--ink-soft);
}

/* ── Readout card (signature element) ───────────────── */

.readout-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 24px 48px -32px rgba(18, 61, 50, 0.35);
}

.readout-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.readout-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px dashed var(--line);
  font-family: var(--font-mono);
  font-size: 14px;
}
.readout-row:last-child { border-bottom: none; }

.readout-name { color: var(--ink); font-family: var(--font-body); font-size: 14px; }
.readout-value { text-align: right; color: var(--ink-soft); }

.flag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 500;
  min-width: 64px;
  text-align: center;
  transition: background 0.5s ease, color 0.5s ease;
}
.flag-high { background: rgba(217, 123, 79, 0.16); color: var(--warn); }
.flag-ok { background: rgba(76, 140, 107, 0.14); color: var(--good); }

.readout-foot {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.readout-foot .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 3px rgba(76, 140, 107, 0.18);
}

/* ── Sections ────────────────────────────────────── */

section { padding: 64px 0; }
.section-line { border-top: 1px solid var(--line); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 40px;
}
.section-head h2 { font-size: 30px; max-width: 480px; }
.section-head p { max-width: 360px; margin: 0; }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.feature-index {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary);
  margin-bottom: 14px;
}

.feature-card h3 { font-size: 17px; margin-bottom: 8px; }
.feature-card p { font-size: 14px; margin: 0; }

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
}
.step {
  padding: 26px 24px;
  border-right: 1px solid var(--line);
}
.step:last-child { border-right: none; }
.step-num { font-family: var(--font-mono); color: var(--primary); font-size: 13px; margin-bottom: 10px; }
.step h3 { font-size: 16px; margin-bottom: 6px; }
.step p { font-size: 14px; margin: 0; }

.disclaimer {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.cta {
  text-align: center;
  padding: 72px 0;
}
.cta h2 { font-size: 32px; }
.cta p { max-width: 420px; margin: 0 auto 28px; }

footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
}

/* ── Auth pages ──────────────────────────────────── */

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 32px;
}
.auth-card h1 { font-size: 24px; margin-bottom: 8px; }
.auth-card .lede { font-size: 14px; margin-bottom: 24px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
}
.field input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--paper);
}
.field input.code-input {
  font-family: var(--font-mono);
  letter-spacing: 0.4em;
  text-align: center;
  font-size: 20px;
}

.form-msg {
  font-size: 13px;
  margin-bottom: 14px;
  min-height: 18px;
}
.form-msg.error { color: var(--warn); }
.form-msg.ok { color: var(--good); }

.auth-card .btn { width: 100%; }
.auth-back {
  display: inline-block;
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
}
.auth-back:hover { color: var(--primary); }

/* ── LK ──────────────────────────────────────────── */

.lk-shell { min-height: 100vh; }
.lk-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.lk-user { font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 14px; }

.lk-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  padding: 28px 0 60px;
  align-items: start;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.panel h3 { font-size: 15px; margin-bottom: 14px; }
.panel + .panel { margin-top: 20px; }

.profile-form .field input,
.profile-form .field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
}
.profile-form .field label { font-size: 12px; }
.profile-badge {
  font-size: 13px;
  color: var(--good);
  display: flex;
  align-items: center;
  gap: 6px;
}
.profile-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); }

.upload-zone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--primary); background: rgba(31, 111, 92, 0.04); }
.upload-zone p { margin: 0; font-size: 13px; }
.upload-zone .upload-icon { font-size: 22px; margin-bottom: 8px; }
.upload-zone input { display: none; }

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 340px;
  max-height: 480px;
  overflow-y: auto;
  padding: 4px 2px 12px;
}
.bubble {
  max-width: 82%;
  padding: 12px 15px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.bubble.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--line);
  border-bottom-left-radius: 3px;
}
.bubble.system {
  align-self: center;
  color: var(--ink-soft);
  font-size: 12px;
  background: none;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.chat-input-row input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 14px;
}
.chat-input-row input:focus { outline: none; border-color: var(--primary); }
.chat-input-row .btn { padding: 12px 20px; }

.result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 14px;
  background: var(--bg);
  font-size: 14px;
}
.result-card .interpretation { white-space: pre-wrap; font-size: 14px; margin-top: 10px; }

.history-item {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  font-size: 13px;
}
.history-item:last-child { border-bottom: none; }
.history-item .h-date { color: var(--ink-soft); font-family: var(--font-mono); font-size: 12px; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 24px; }
  .grid-3 { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .step { border-right: none; border-bottom: 1px solid var(--line); }
  .step:last-child { border-bottom: none; }
  .lk-grid { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .flag, .spinner { animation: none !important; transition: none !important; }
}

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
