:root {
  --ink: #1b2620;
  --ink-soft: #4a564c;
  --canopy: #1f3d2b;
  --moss: #4c7a57;
  --sage-bg: #eef1e8;
  --panel: #ffffff;
  --line: #dde3d5;
  --gold: #c99a2e;

  /* Class colors — image classifier's 4 leaf-condition classes */
  --c-healthy: #3f8a52;           /* green */
  --c-mild-moderate: #f2b93d;     /* solid orange/yellow blend, for charts & dots */
  --c-mild-moderate-gradient: linear-gradient(90deg, #f4a340 0%, #f6d743 100%); /* light orange -> yellow, for the probability bar */
  --c-deficiency: #f2c94c;        /* yellow */
  --c-severe: #c0392b;            /* red */

  --font-display: "Fraunces", serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--sage-bg);
  position: relative;
  min-height: 100vh;
}

.canopy-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(76,122,87,0.16), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(201,154,46,0.10), transparent 55%);
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(238,241,232,0.85);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  color: var(--canopy);
  text-decoration: none;
  flex-shrink: 0;
}
.brand-mark { width: 24px; height: 24px; color: var(--moss); flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 600; font-size: 1.05rem; }
.brand-tagline {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.68rem;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.model-status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--moss); }
.dot-err { background: var(--c-severe); }

/* Main stage */
.stage {
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 28px 40px;
}

.intro { max-width: 640px; margin-bottom: 44px; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--moss);
}
.intro h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
  line-height: 1.15;
  color: var(--canopy);
  margin: 12px 0 14px;
}
.lede { color: var(--ink-soft); font-size: 1.02rem; line-height: 1.6; margin: 0; }

/* Workspace grid */
.workspace {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 800px) {
  .workspace { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}

/* Dropzone */
.dropzone {
  border: 1.5px dashed #b9c5ac;
  border-radius: 10px;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  position: relative;
  overflow: hidden;
  background: #fbfcf8;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--moss);
  background: #f2f6ec;
  outline: none;
}
.dropzone-empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 32px;
}
.dz-icon { width: 40px; height: 40px; color: var(--moss); margin-bottom: 10px; }
.dropzone-empty p { margin: 4px 0; }
.dz-sub { font-size: 0.82rem; color: #8a9583; }

.preview-img {
  width: 100%;
  height: 100%;
  max-height: 400px;
  object-fit: contain;
  display: block;
}
.preview-img[hidden] { display: none; }

.upload-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 11px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.1s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--canopy);
  color: #f4f7ee;
}
.btn-primary:hover:not(:disabled) { background: #17301f; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--canopy);
  border: 1px solid var(--line);
}
.btn-ghost:hover { border-color: var(--moss); }

.error-msg {
  color: var(--c-severe);
  font-size: 0.85rem;
  margin-top: 12px;
}

/* Results panel */
.results-panel { min-height: 320px; display: flex; flex-direction: column; }
.results-empty {
  margin: auto;
  text-align: center;
  color: #9aa693;
  max-width: 260px;
}
.empty-icon { width: 34px; height: 34px; margin-bottom: 10px; }
.results-empty p { font-size: 0.9rem; margin: 0; }

.results-content { display: flex; flex-direction: column; gap: 22px; }
.results-content[hidden] { display: none; }

.verdict {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.verdict-label {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--canopy);
}
.verdict-confidence {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.verdict-label.is-uncertain { color: var(--c-mild-moderate); }
.verdict-uncertain-note {
  margin-top: -8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fdf6e3;
  border: 1px solid #f2e3b0;
  color: #7a5d1e;
  font-size: 0.85rem;
  line-height: 1.45;
}

.prob-list { display: flex; flex-direction: column; gap: 12px; }
.prob-row { display: grid; grid-template-columns: 100px 1fr 52px; align-items: center; gap: 12px; }
.prob-name { font-size: 0.85rem; font-weight: 500; color: var(--ink); }
.prob-track {
  height: 8px;
  background: #eef1e8;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  forced-color-adjust: none;
}
.prob-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  width: 0%;
  forced-color-adjust: none;
}
.prob-fill-canvas {
  display: block;
  width: 100%;
  height: 100%;
  forced-color-adjust: none;
}
.prob-row.is-winner .prob-name { color: var(--canopy); font-weight: 700; }

.meta-row {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #9aa693;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.meta-row span + span::before { content: "·"; margin-right: 8px; }

/* Footer */
.site-footer {
  margin-top: 40px;
  padding: 18px 28px 22px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.site-footer p {
  max-width: 1080px;
  margin: 0 auto;
  color: #9aa693;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
}

/* ============================================================
   Nav bar (logged in)
   ============================================================ */
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  order: 3;
  flex-basis: 100%;
}
.nav-links a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--canopy); }
.nav-links a.active { color: var(--canopy); border-color: var(--moss); }

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  order: 2;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.username { font-size: 0.85rem; font-weight: 500; color: var(--ink); white-space: nowrap; }
.role-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 100px;
  background: #e6ecdc;
  color: var(--canopy);
  white-space: nowrap;
}
.role-badge.role-admin { background: #f3e6c8; color: #8a6a15; }
.role-badge.role-scientist { background: #dbe9df; color: var(--canopy); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; white-space: nowrap; }

@media (max-width: 960px) {
  .header-inner { padding: 12px 20px; }
  .brand-tagline { display: none; }
}

@media (max-width: 640px) {
  .header-inner { padding: 12px 16px; }
  .nav-links { gap: 6px 14px; font-size: 0.84rem; }
  .username { display: none; }
  .user-menu { gap: 8px; }
}

/* ============================================================
   Flash messages
   ============================================================ */
.flash-stack {
  max-width: 1080px;
  margin: 16px auto 0;
  padding: 0 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  border: 1px solid transparent;
}
.flash-success { background: #e6f0e3; color: #2c5b32; border-color: #c7ddc0; }
.flash-error { background: #fbe9e5; color: #8a3220; border-color: #f0c9be; }
.flash-info { background: #eaf1f7; color: #2a5876; border-color: #cfe1ec; }

/* ============================================================
   Auth pages (login / register)
   ============================================================ */
.auth-page .flash-stack {
  max-width: 420px;
  width: 100%;
  margin: 40px auto -16px;
  padding: 0 20px;
  box-sizing: content-box;
}
.auth-page .flash {
  animation: flash-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.auth-page .flash-error {
  animation: flash-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both,
             auth-alert-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) 0.35s both;
}
@keyframes auth-alert-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.auth-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.auth-stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px -30px rgba(31,61,43,0.25);
}
.auth-page .site-footer { margin-top: 0; flex-shrink: 0; }
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.auth-brand .brand-mark { width: 26px; height: 26px; color: var(--moss); }
.auth-kicker {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--moss);
  margin-bottom: 3px;
}
.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--canopy);
  margin: 0;
}
.auth-sub { color: var(--ink-soft); font-size: 0.9rem; margin: 0 0 26px; }

.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: 12px;
}
.auth-form input, .auth-form select {
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
}
.auth-form input:focus, .auth-form select:focus {
  outline: none;
  border-color: var(--moss);
  background: #fff;
}
.btn-block { width: 100%; margin-top: 22px; padding: 12px; }

.field-hint-link {
  text-align: right;
  margin: 4px 0 0;
}
.field-hint-link a {
  font-size: 0.78rem;
  color: var(--moss);
  text-decoration: none;
  font-weight: 500;
}
.field-hint-link a:hover { color: var(--canopy); text-decoration: underline; }

.auth-switch {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 20px;
}
.auth-switch a { color: var(--canopy); font-weight: 600; text-decoration: none; }

.password-requirements {
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}
.strength-meter {
  height: 6px;
  border-radius: 3px;
  background: #eef1e8;
  overflow: hidden;
}
.strength-meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: var(--c-severe);
  transition: width 0.15s ease, background 0.15s ease;
}
.strength-meter-fill.weak { background: var(--c-severe); }
.strength-meter-fill.medium { background: var(--c-mild-moderate); }
.strength-meter-fill.strong { background: var(--c-healthy); }

.strength-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin: 6px 0 8px;
  color: var(--ink-soft);
}
.strength-label.weak { color: var(--c-severe); }
.strength-label.medium { color: #a8790f; }
.strength-label.strong { color: var(--c-healthy); }

.requirements-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.requirements-list li {
  font-size: 0.8rem;
  color: var(--ink-soft);
  padding-left: 20px;
  position: relative;
}
.requirements-list li::before {
  content: "○";
  position: absolute;
  left: 0;
  color: var(--line);
}
.requirements-list li.met {
  color: var(--c-healthy);
}
.requirements-list li.met::before {
  content: "✓";
  color: var(--c-healthy);
  font-weight: 700;
}
.auth-switch a:hover { text-decoration: underline; }
.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--canopy);
  font-weight: 600;
  cursor: pointer;
}
.link-btn:hover:not(:disabled) { text-decoration: underline; }
.link-btn:disabled { color: #9aa693; cursor: default; }

.auth-hint {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.auth-hint p { font-size: 0.8rem; color: var(--ink-soft); margin: 4px 0 0; }
.auth-hint code {
  font-family: var(--font-mono);
  background: #eef1e8;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
}

/* ============================================================
   Landing page — model selection cards
   ============================================================ */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
@media (max-width: 760px) { .model-grid { grid-template-columns: 1fr; } }

.model-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  text-decoration: none;
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.model-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 24px 50px -28px rgba(31,61,43,0.35);
  border-color: var(--moss);
}
.model-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 90% -10%, rgba(76,122,87,0.14), transparent 60%);
  pointer-events: none;
}
.model-card-icon {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: #eef1e8;
  color: var(--moss);
}
.model-card-icon svg { width: 28px; height: 28px; }
.model-card--dna .model-card-icon { background: #f3ecdd; color: var(--gold); }

.model-card-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--moss);
}
.model-card-eyebrow--pending { color: var(--gold); }
.model-card-body h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 6px 0 8px;
  color: var(--canopy);
}
.model-card-body p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.55; }
.model-card-cta {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--canopy);
}

.model-card--pending {
  border-style: dashed;
  background: #fbf9f2;
}
.model-card--pending .model-card-icon { background: #f3ecdd; color: var(--gold); }
.model-card--pending .model-card-cta { color: var(--gold); }

.dna-placeholder { text-align: center; padding: 20px 10px; }
.dna-icon { width: 40px; height: 40px; color: var(--gold); margin-bottom: 12px; }
.dna-placeholder h2 { font-family: var(--font-display); color: var(--canopy); margin: 0 0 10px; }
.dna-placeholder p { color: var(--ink-soft); max-width: 440px; margin: 0 auto 22px; line-height: 1.6; }

/* ============================================================
   Dashboard
   ============================================================ */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}
@media (max-width: 700px) { .stat-row { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  color: var(--canopy);
}
.stat-label {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 800px) { .dash-grid { grid-template-columns: 1fr; } }

.panel-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--canopy);
  margin: 0 0 16px;
}

.recent-list { display: flex; flex-direction: column; gap: 10px; }
.recent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s ease;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.recent-row:hover { background: #f5f7f0; }
.recent-thumb {
  width: 42px; height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: #eef1e8;
  flex-shrink: 0;
}
.recent-info { display: flex; flex-direction: column; gap: 2px; }
.recent-class { font-weight: 600; font-size: 0.9rem; color: var(--ink); }
.recent-meta { font-family: var(--font-mono); font-size: 0.72rem; color: #9aa693; }

/* ============================================================
   Admin — user table
   ============================================================ */
.user-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.user-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.user-table td { padding: 12px; border-bottom: 1px solid var(--line); }
.user-table tr:last-child td { border-bottom: none; }
.mono { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-soft); }
.you-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--moss);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 100px;
}
.role-select {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fbfcf8;
  color: var(--ink);
}
.btn-danger { color: var(--c-severe); border-color: #f0c9be; }
.btn-danger:hover { background: #fbe9e5; }

/* ============================================================
   Page-load transition
   ============================================================ */
body.page-enter {
  opacity: 0;
  transform: translateY(8px);
}
body.page-entered {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
@media (prefers-reduced-motion: reduce) {
  body.page-enter, body.page-entered { opacity: 1; transform: none; transition: none; }
}

/* Ambient drifting leaves in the background */
.leaf-drift {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.drift-leaf {
  position: absolute;
  width: 26px;
  height: 26px;
  color: var(--moss);
  opacity: 0.08;
  animation: drift-fall linear infinite;
}
.drift-leaf-1 { left: 8%;  top: -8%; animation-duration: 34s; animation-delay: 0s; }
.drift-leaf-2 { left: 46%; top: -12%; animation-duration: 44s; animation-delay: 8s; width: 34px; height: 34px; }
.drift-leaf-3 { left: 82%; top: -10%; animation-duration: 38s; animation-delay: 4s; width: 20px; height: 20px; }
@keyframes drift-fall {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); }
  50%  { transform: translateY(52vh) translateX(24px) rotate(160deg); }
  100% { transform: translateY(112vh) translateX(-16px) rotate(320deg); }
}
@media (prefers-reduced-motion: reduce) { .drift-leaf { animation: none; } }

/* ============================================================
   Scroll reveal
   ============================================================ */
[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--reveal-delay, 0ms);
}
[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* ============================================================
   Header scroll state + nav polish
   ============================================================ */
.site-header { transition: box-shadow 0.25s ease, padding 0.25s ease; }
.site-header.is-scrolled { box-shadow: 0 8px 24px -18px rgba(31,61,43,0.35); }
.brand-mark { transition: transform 0.3s ease; }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.08); }
.nav-links a { position: relative; }
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--moss);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}
.nav-links a:hover::after { transform: scaleX(1); }
.role-badge { transition: transform 0.15s ease; }
.role-badge:hover { transform: translateY(-1px) scale(1.04); }

/* ============================================================
   Button ripple + micro-interactions
   ============================================================ */
.btn { position: relative; overflow: hidden; }
.btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transform: scale(0);
  pointer-events: none;
  animation: ripple-expand 0.55s ease-out forwards;
}
.btn-ghost .btn-ripple { background: rgba(31,61,43,0.15); }
@keyframes ripple-expand {
  to { transform: scale(1); opacity: 0; }
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn-danger-solid { background: var(--c-severe); color: #fff; border: none; }
.btn-danger-solid:hover { background: #93381f; }

/* Model cards / stat cards get a little lift + icon nudge already via hover;
   add a gentle entrance-friendly icon float. */
.model-card-icon { transition: transform 0.25s ease; }
.model-card:hover .model-card-icon { transform: translateY(-2px) rotate(-4deg); }
.stat-card { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -30px rgba(31,61,43,0.3); }

/* Dropzone breathing hint when idle */
.dz-icon { animation: dz-bob 3.2s ease-in-out infinite; }
@keyframes dz-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) { .dz-icon { animation: none; } }

/* ============================================================
   Flash messages — slide/fade in + animated auto-dismiss
   ============================================================ */
.flash {
  animation: flash-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--flash-delay, 0ms);
}
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.flash-out {
  animation: flash-out 0.35s ease forwards;
}
@keyframes flash-out {
  to { opacity: 0; transform: translateY(-8px) scale(0.98); }
}

/* ============================================================
   Login lockout banner
   ============================================================ */
.lock-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fbe9e5;
  border: 1px solid #f0c9be;
  color: #8a3220;
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 18px;
  animation: lock-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
.lock-banner strong { display: block; font-size: 0.9rem; }
.lock-banner p { margin: 2px 0 0; font-size: 0.82rem; }
.lock-icon { width: 32px; height: 32px; flex-shrink: 0; animation: lock-pulse 1.8s ease-in-out infinite; }
.lock-shackle { transform-origin: 24px 16px; }
.lock-banner.lock-expired { background: #e6f0e3; border-color: #c7ddc0; color: #2c5b32; }
.lock-banner.lock-expired .lock-icon { animation: none; }
@keyframes lock-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@keyframes lock-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.75; }
}

/* ============================================================
   Animated confirm modal (replaces window.confirm)
   ============================================================ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27,38,32,0.42);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.confirm-overlay.is-open { opacity: 1; }
.confirm-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 28px 30px;
  max-width: 340px;
  width: 90%;
  text-align: center;
  box-shadow: 0 30px 70px -30px rgba(31,61,43,0.45);
  transform: scale(0.9) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.confirm-overlay.is-open .confirm-card { transform: scale(1) translateY(0); }
.confirm-icon { width: 40px; height: 40px; color: var(--c-mild-moderate); margin-bottom: 10px; }
.confirm-card p { color: var(--ink); font-size: 0.92rem; margin: 0 0 20px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* ============================================================
   Error pages (403 / 404 / 401 / 429 / 413 / 400 / 500)
   ============================================================ */
.error-stage {
  min-height: calc(100vh - 74px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.error-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 44px 40px 40px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 30px 80px -40px rgba(31,61,43,0.35);
}
.error-illustration { display: flex; justify-content: center; margin-bottom: 8px; }
.err-svg { width: 220px; height: 176px; }
.error-code {
  display: inline-block;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  background: #eef1e8;
  border-radius: 100px;
  padding: 4px 12px;
  margin-bottom: 10px;
}
.error-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  color: var(--canopy);
  margin: 4px 0 10px;
}
.error-message { color: var(--ink-soft); font-size: 0.96rem; line-height: 1.6; margin: 0 auto; max-width: 360px; }
.error-hint { margin-top: 16px; font-size: 0.72rem; color: #9aa693; }
.error-actions { display: flex; gap: 10px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }

/* 403 — lock drops onto a wilting leaf */
.err-pulse { animation: err-pulse 2.4s ease-in-out infinite; transform-origin: center; }
@keyframes err-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.06); }
}
.err-leaf-wilt { animation: err-wilt 1.8s ease-in-out 0.5s both; transform-origin: top center; }
@keyframes err-wilt {
  0%   { transform: translate(100px, 96px) rotate(0deg); }
  100% { transform: translate(100px, 96px) rotate(8deg) translateY(4px); }
}
.err-lock-drop { animation: err-lock-drop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes err-lock-drop {
  0%   { transform: translate(100px, -20px); opacity: 0; }
  70%  { transform: translate(100px, 68px); opacity: 1; }
  85%  { transform: translate(100px, 60px); }
  100% { transform: translate(100px, 62px); }
}
.err-lock-shackle { animation: err-shackle-snap 0.4s ease 0.55s both; }
@keyframes err-shackle-snap {
  from { transform: translateY(-6px); }
  to   { transform: translateY(0); }
}
.err-particle { animation: err-particle-float 3s ease-in-out infinite; }
.p1 { animation-delay: 0s; } .p2 { animation-delay: 0.6s; }
.p3 { animation-delay: 1.1s; } .p4 { animation-delay: 1.6s; }
@keyframes err-particle-float {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-10px); opacity: 0.9; }
}

/* 404 — leaf drifting off a dashed trail */
.err-trail { stroke-dashoffset: 0; animation: err-trail-move 3s linear infinite; }
@keyframes err-trail-move { to { stroke-dashoffset: -22; } }
.err-leaf-drift-away { animation: err-leaf-drift 3.4s ease-in-out infinite; }
@keyframes err-leaf-drift {
  0%, 100% { transform: translate(100px, 70px) rotate(-4deg); }
  50% { transform: translate(112px, 58px) rotate(6deg); }
}
.err-404-mark {
  font-family: var(--font-display);
  font-size: 34px;
  fill: var(--gold);
  opacity: 0.5;
  animation: err-pulse 2.2s ease-in-out infinite;
}

/* 401 — key floats in front of a locked gate */
.err-gate { animation: err-gate-rattle 2.6s ease-in-out infinite; transform-origin: 100px 80px; }
@keyframes err-gate-rattle {
  0%, 90%, 100% { transform: rotate(0deg); }
  92% { transform: rotate(-1.2deg); }
  95% { transform: rotate(1.2deg); }
  98% { transform: rotate(-0.6deg); }
}
.err-key-float { animation: err-key-float 2.8s ease-in-out infinite; }
@keyframes err-key-float {
  0%, 100% { transform: translate(100px, 80px) rotate(0deg); }
  50% { transform: translate(100px, 70px) rotate(12deg); }
}

/* 429 — clock ticks fast, leaves fall too quickly */
.err-clock-hand-min { animation: err-clock-spin 1.4s linear infinite; transform-origin: 0 0; }
@keyframes err-clock-spin { to { transform: rotate(360deg); } }
.fall-leaf { animation: err-leaf-fall 1.6s ease-in infinite; }
.f1 { transform: translate(72px, 30px); animation-delay: 0s; }
.f2 { transform: translate(100px, 20px); animation-delay: 0.4s; }
.f3 { transform: translate(128px, 34px); animation-delay: 0.8s; }
@keyframes err-leaf-fall {
  0%   { transform: translate(var(--fx, 100px), -10px) rotate(0deg); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translate(var(--fx, 100px), 130px) rotate(200deg); opacity: 0; }
}
.f1 { --fx: 72px; } .f2 { --fx: 100px; } .f3 { --fx: 128px; }

/* 413 — oversized leaf straining against a frame */
.err-leaf-oversize { animation: err-oversize-pulse 1.6s ease-in-out infinite; transform-origin: 100px 80px; }
@keyframes err-oversize-pulse {
  0%, 100% { transform: translate(100px, 80px) scale(1); }
  50% { transform: translate(100px, 80px) scale(1.07); }
}

/* 400 — crumpled leaf shakes */
.err-leaf-crumple { animation: lock-shake 0.6s ease 0.2s both; transform-origin: 100px 80px; }

/* 500 — storm cloud with flickering lightning */
.err-storm-cloud { animation: err-cloud-drift 4s ease-in-out infinite; }
@keyframes err-cloud-drift {
  0%, 100% { transform: translate(100px, 66px) translateX(0); }
  50% { transform: translate(100px, 66px) translateX(6px); }
}
.err-bolt { animation: err-bolt-flicker 1.6s steps(1) infinite; transform-origin: 96px 90px; }
@keyframes err-bolt-flicker {
  0%, 40%, 100% { opacity: 0; }
  45%, 55% { opacity: 1; }
  60% { opacity: 0; }
  65%, 75% { opacity: 1; }
  80% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .err-pulse, .err-leaf-wilt, .err-lock-drop, .err-lock-shackle, .err-particle,
  .err-trail, .err-leaf-drift-away, .err-404-mark, .err-gate, .err-key-float,
  .err-clock-hand-min, .fall-leaf, .err-leaf-oversize, .err-leaf-crumple,
  .err-storm-cloud, .err-bolt {
    animation: none !important;
  }
}

/* ============================================================
   DNA classification workspace
   ============================================================ */
.dna-input-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.dna-textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--ink);
  background: #fbfcf8;
  border: 1.5px dashed #b9c5ac;
  border-radius: 10px;
  padding: 16px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dna-textarea:hover { border-color: #a3b494; }
.dna-textarea:focus {
  outline: none;
  border-color: var(--moss);
  background: #f2f6ec;
  border-style: solid;
}
.dna-textarea::placeholder { color: #b3bda8; }

.dna-input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #8a9583;
}
.dna-file-btn {
  color: var(--moss);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.dna-file-btn:hover { color: var(--canopy); }

/* Idle helix in the empty results state — gentle continuous rotation */
.dna-helix-idle { color: #9aa693; animation: dna-helix-rotate 6s linear infinite; transform-origin: center; }
@keyframes dna-helix-rotate {
  to { transform: rotateY(360deg); }
}

/* Analyzing state — spinning helix + pulsing label */
.dna-analyzing {
  margin: auto;
  text-align: center;
  color: var(--moss);
}
.dna-helix-spin {
  width: 44px;
  height: 44px;
  margin-bottom: 12px;
  animation: dna-helix-spin-fast 1.1s linear infinite;
  transform-origin: center;
}
@keyframes dna-helix-spin-fast {
  to { transform: rotate(360deg); }
}
.dna-analyzing p {
  font-size: 0.88rem;
  margin: 0;
  animation: dna-text-pulse 1.4s ease-in-out infinite;
}
@keyframes dna-text-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* "Possible novel virus" banner */
.uncertain-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fdf3e3;
  border: 1px solid #ecd6a3;
  color: #8a6a1f;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  animation: lock-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
/* Without this, [hidden] has no effect: this author-stylesheet class rule
   (display: flex above) always wins over the browser's built-in
   [hidden] { display: none } rule, even at equal specificity — so the
   banner would render regardless of the hidden attribute/property. */
.uncertain-banner[hidden] { display: none; }
.uncertain-banner svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.dna-window-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-soft);
  background: var(--sage-bg);
  border-radius: 8px;
  padding: 10px 14px;
}

@media (prefers-reduced-motion: reduce) {
  .dna-helix-idle, .dna-helix-spin, .dna-analyzing p { animation: none !important; }
}

/* ============================================================
   Dashboard section headers (Image / DNA split)
   ============================================================ */
.dash-section-header {
  margin: 40px 0 4px;
}
.dash-section-header:first-of-type { margin-top: 0; }
.dash-section-header h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--canopy);
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.recent-thumb--dna {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--moss);
  background: var(--sage-bg);
}
.recent-thumb--dna svg { width: 22px; height: 22px; }

/* ============================================================
   Public welcome / portfolio page
   ============================================================ */
.welcome-page { background: var(--sage-bg); }

.welcome-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(238,241,232,0.85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.welcome-nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.welcome-nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 0.9rem;
}
.welcome-nav-links a:not(.btn) {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
}
.welcome-nav-links a:not(.btn):hover { color: var(--canopy); }
@media (max-width: 700px) {
  .welcome-nav-links a:not(.btn) { display: none; }
}

.btn-lg { padding: 14px 26px; font-size: 1rem; border-radius: 10px; }

/* Hero */
.hero {
  max-width: 1080px;
  margin: 0 auto;
  padding: 90px 28px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.hero-inner { max-width: 720px; }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.1rem, 4.6vw, 3.4rem);
  line-height: 1.12;
  color: var(--canopy);
  margin: 16px 0 18px;
}
.hero-lede { font-size: 1.08rem; max-width: 620px; margin: 0 auto; }
.hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 30px;
  flex-wrap: wrap;
}
.scroll-cue {
  margin-top: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  animation: scrollCueBounce 2.2s ease-in-out infinite;
}
.scroll-cue svg { width: 18px; height: 18px; color: var(--moss); }
@keyframes scrollCueBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}
@media (prefers-reduced-motion: reduce) { .scroll-cue { animation: none; } }

.welcome-section { padding-top: 20px; padding-bottom: 20px; }

/* About grid */
.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 8px;
}
.about-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
}
.about-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--canopy);
  margin: 14px 0 8px;
}
.about-card p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.6; }

/* Why section */
.why-section { padding-top: 40px; padding-bottom: 40px; }
.why-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}
@media (max-width: 800px) { .why-grid { grid-template-columns: 1fr; } }
.why-intro { max-width: none; margin-bottom: 0; }
.why-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 20px; }
.why-list li { display: flex; gap: 16px; align-items: flex-start; }
.why-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--moss);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 4px 8px;
  flex-shrink: 0;
}
.why-list strong { color: var(--canopy); }
.why-list div { color: var(--ink-soft); font-size: 0.92rem; line-height: 1.6; }

/* Role cards */
.role-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 8px;
}
.role-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
}
.role-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef1e8;
  color: var(--moss);
}
.role-tag.role-scientist { background: #f3ecdd; color: var(--gold); }
.role-tag.role-admin { background: #f5e6e1; color: var(--c-severe); }
.role-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--canopy);
  margin: 14px 0 8px;
}
.role-card p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.6; }

/* Steps */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 8px;
}
.step-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
}
.step-num {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--gold);
}
.step-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--canopy);
  margin: 10px 0 6px;
}
.step-card p { margin: 0; color: var(--ink-soft); font-size: 0.88rem; line-height: 1.55; }

/* Final CTA */
.final-cta {
  margin: 60px 0 0;
  padding: 70px 28px;
  text-align: center;
  background: var(--canopy);
  position: relative;
  overflow: hidden;
}
.final-cta::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 700px 400px at 50% 0%, rgba(201,154,46,0.18), transparent 60%);
  pointer-events: none;
}
.final-cta-inner { max-width: 560px; margin: 0 auto; position: relative; }
.final-cta .eyebrow { color: var(--gold); }
.final-cta h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
  color: #f4f7ee;
  margin: 14px 0 10px;
}
.final-cta .lede { color: #d6ddcd; }
.final-cta .btn-ghost { color: #f4f7ee; border-color: rgba(244,247,238,0.35); }
.final-cta .btn-ghost:hover { border-color: #f4f7ee; }
.final-cta .btn-primary { background: #f4f7ee; color: var(--canopy); }
.final-cta .btn-primary:hover { background: #ffffff; }