/* ============================================================
   SKYNETHVAC — main stylesheet (U10 technical-HUD redesign)
   Near-black surfaces, single cyan accent, monospace readouts,
   mobile-first. Do not add a second accent color (brief rule).
   ============================================================ */

:root {
  --bg: #06090d;
  --bg-2: #0a0f16;
  --surface: #0b1119;
  --surface-2: #101a26;
  --line: #17232f;
  --line-2: #23394c;
  --text: #dbe4ee;
  --text-dim: #8ba0b5;
  --text-faint: #54697d;
  --accent: #2dd9c4;
  --accent-2: #17b5a3;
  --danger: #ff4d52;
  --danger-2: #d21f2b;
  --ok: #2dd97a;
  --warn: #ffb020;
  --font: "Inter", "SF Pro Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", "Cascadia Code", ui-monospace, "SF Mono Regular", Menlo, Consolas, monospace;
  --radius: 10px;
  --tap: 44px; /* minimum tap-target size */
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(45, 217, 196, 0.05), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: rgba(45, 217, 196, 0.25); }

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 8px 16px;
  background: rgba(6, 9, 13, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  min-height: var(--tap);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(45, 217, 196, 0.07);
}
.brand-name {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.brand-accent { color: var(--accent); }

.topnav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  min-height: var(--tap);
  align-items: center;
}
.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-radius: 8px;
}
.topnav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); text-decoration: none; }
.topnav a.active { color: var(--accent); background: rgba(45, 217, 196, 0.08); }

.topbar-user { display: flex; align-items: center; gap: 8px; }
.user-chip {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.signout {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 10px;
  font-size: 13px;
  color: var(--text-dim);
  border-radius: 8px;
}
.signout:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); text-decoration: none; }

/* ---------------- layout ---------------- */
.content {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

/* HUD eyebrow + headlines */
.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}
.eyebrow::before {
  content: "";
  width: 18px; height: 1px;
  background: var(--accent);
  opacity: 0.7;
}
h1 {
  margin: 8px 0 10px;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h2 { margin: 12px 0 8px; font-size: 20px; font-weight: 700; }
h3 { margin: 8px 0 6px; font-size: 15px; font-weight: 650; }
p { margin: 0 0 10px; }
.muted { color: var(--text-dim); }
.hint { color: var(--text-faint); font-size: 12.5px; margin: 8px 0 0; }
code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text);
}

/* health status strip (pings /health client-side) */
.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 4px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  overflow: hidden;
  white-space: nowrap;
}
.status-strip .pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 auto;
}
.status-strip.ping-ok .pulse { background: var(--ok); animation: pulse 2.4s ease-in-out infinite; }
.status-strip.ping-bad .pulse { background: var(--danger); }
.status-strip .ss-model { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; }
.status-strip .ss-date { margin-left: auto; flex: 0 0 auto; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 217, 122, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(45, 217, 122, 0); }
}

/* beta-test account banner (non-admin 'beta' user) */
.beta-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 6px 16px;
  border-bottom: 1px solid var(--warn);
  background: #2b2110;
  background: color-mix(in srgb, var(--warn) 14%, var(--bg-2));
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}
.beta-banner .beta-badge {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: #1a1205;
  background: var(--warn);
  padding: 2px 8px;
  border-radius: 4px;
}
.beta-banner .beta-text { text-align: left; }
@media (max-width: 560px) {
  .beta-banner { flex-direction: column; gap: 4px; }
  .beta-banner .beta-text { text-align: center; }
}

/* ---------------- flash / alerts ---------------- */
.flash-stack { display: flex; flex-direction: column; gap: 10px; margin: 0 0 18px; }
.flash-stack:first-child { margin-top: 0; }
.alert {
  border: 1px solid var(--line-2);
  border-left-width: 3px;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  background: var(--surface);
  overflow-wrap: anywhere;
  animation: slide-in 0.22s ease-out;
}
.alert-info { border-left-color: var(--accent); }
.alert-success { border-left-color: var(--ok); }
.alert-error, .alert-danger { border-left-color: var(--danger); color: #ffd7d9; background: rgba(255, 77, 82, 0.07); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------------- cards ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin: 0 0 18px;
  position: relative;
  animation: rise 0.3s ease-out both;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 34px; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: var(--radius) 0 0 0;
  opacity: 0.75;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 6px;
}
.card-title svg { color: var(--accent); flex: 0 0 auto; }
.card-sub { color: var(--text-dim); font-size: 13.5px; margin: 0 0 14px; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  text-align: center;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: linear-gradient(180deg, rgba(45, 217, 196, 0.16), rgba(45, 217, 196, 0.08));
  border-color: rgba(45, 217, 196, 0.5);
  color: var(--accent);
  box-shadow: 0 0 18px rgba(45, 217, 196, 0.10), inset 0 0 12px rgba(45, 217, 196, 0.05);
}
.btn-primary:hover { background: rgba(45, 217, 196, 0.2); box-shadow: 0 0 24px rgba(45, 217, 196, 0.18); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: transparent; background: rgba(255, 255, 255, 0.04); box-shadow: none; }

.btn-secondary { background: var(--surface); color: var(--text); }
.btn-secondary:hover { border-color: var(--accent); color: var(--text); box-shadow: none; }

.btn-xl { min-height: 52px; font-size: 15px; padding: 12px 26px; }
.btn-block { width: 100%; }

.result-actions, .upload-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  justify-content: space-between;
}
.result-actions .btn, .upload-actions .btn { flex: 0 1 auto; }

/* ---------------- forms ---------------- */
.field { margin: 0 0 14px; display: block; }
.field label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}
input[type=text], input[type=password], input[type=file], select, textarea {
  width: 100%;
  min-height: var(--tap);
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
}
textarea { resize: vertical; min-height: 110px; font-family: inherit; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 217, 196, 0.12);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%),
                    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
input[type=file] { padding: 10px; font-size: 13.5px; font-family: var(--mono); }
input[type=file]::file-selector-button {
  min-height: var(--tap);
  margin-right: 10px;
  padding: 8px 14px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }
.form-row { display: grid; gap: 12px; }
.form-row.two { grid-template-columns: 1fr 1fr; }
.form-row.three { grid-template-columns: repeat(3, 1fr); }

/* ---------------- dropzone / upload ---------------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  min-height: 220px;
  padding: 22px;
  margin: 0;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--bg-2);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(45, 217, 196, 0.04); }
.dropzone h3 { margin: 4px 0 2px; font-size: 15px; }
.dropzone p { color: var(--text-dim); font-size: 13px; margin: 0 0 10px; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.dz-icon { color: var(--accent); margin-bottom: 4px; }
.dz-icon svg { filter: drop-shadow(0 0 10px rgba(45, 217, 196, 0.35)); }
.dz-btn { pointer-events: none; }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.preview-item {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-2);
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-item .remove {
  position: absolute;
  top: 6px; right: 6px;
  width: 30px; height: 30px;
  min-height: 0; min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: rgba(6, 9, 13, 0.8);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.preview-item .remove:hover { border-color: var(--danger); color: var(--danger); }

/* ---------------- photo gallery ----------------
   Desktop: grid. Mobile (<740px): horizontal snap carousel.  */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 2px;
}
.g-item {
  position: relative;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-2);
  aspect-ratio: 4 / 3;
}
.g-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-plate {
  position: absolute;
  top: 6px; left: 6px;
  pointer-events: none;
}

/* ---------------- badges ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(45, 217, 196, 0.08);
  border: 1px solid rgba(45, 217, 196, 0.35);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.badge.good { color: var(--ok); border-color: rgba(45, 217, 122, 0.4); background: rgba(45, 217, 122, 0.08); }
.badge.danger { color: var(--danger); border-color: rgba(255, 77, 82, 0.5); background: rgba(255, 77, 82, 0.1); }

/* ---------------- home hero + features ---------------- */
.hero { padding: 34px 0 22px; text-align: left; }
.hero h1 { font-size: 30px; max-width: 640px; }
.hero p { max-width: 620px; color: var(--text-dim); font-size: 15px; }
.hero .btn { margin-top: 12px; }

.feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 8px 0 20px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.feature-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.feature-icon {
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: rgba(45, 217, 196, 0.06);
  color: var(--accent);
  margin-bottom: 10px;
}
.feature-card p { color: var(--text-dim); font-size: 13.5px; margin: 0; }

.steps-box .steps { margin: 10px 0 0; padding-left: 0; list-style: none; counter-reset: step; }
.steps-box .steps li {
  counter-increment: step;
  position: relative;
  padding: 10px 0 10px 44px;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
  color: var(--text-dim);
}
.steps-box .steps li:last-child { border-bottom: none; }
.steps-box .steps li b { color: var(--text); }
.steps-box .steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0; top: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  border: 1px solid rgba(45, 217, 196, 0.4);
  border-radius: 7px;
  min-width: 32px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(45, 217, 196, 0.06);
}

/* ---------------- login ---------------- */
.login-page { display: flex; justify-content: center; padding: 30px 0 10px; }
.login-card { width: 100%; max-width: 400px; margin: 0 auto; }
.logomark {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 54px; height: 54px;
  margin: 4px auto 10px;
  border: 1px solid rgba(45, 217, 196, 0.4);
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: rgba(45, 217, 196, 0.06);
  box-shadow: 0 0 28px rgba(45, 217, 196, 0.12);
}
.logomark-emblem {
  width: auto; height: auto;
  border: none; background: none; box-shadow: none;
  margin: 10px auto 6px;
  filter: drop-shadow(0 0 14px rgba(45, 217, 196, 0.35));
}
.brand-mark { display: inline-flex; align-items: center; }
.brand-mark img { display: block; }

/* ---------------- nameplate panel ---------------- */
.plate-panel {
  border: 1px solid rgba(45, 217, 196, 0.25);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(45, 217, 196, 0.045), transparent 60%), var(--bg-2);
  padding: 16px;
  margin: 0 0 18px;
}
.plate-head { display: flex; gap: 12px; align-items: flex-start; }
.plate-ic {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(45, 217, 196, 0.35);
  border-radius: 10px;
  color: var(--accent);
  background: rgba(45, 217, 196, 0.07);
}
.plate-head p { color: var(--text-dim); font-size: 13px; margin: 2px 0 0; }
.plate-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.plate-result {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--surface-2);
  overflow-wrap: anywhere;
}
.plate-result.show { display: block; animation: rise 0.25s ease-out; }
.plate-result.ok { border-color: rgba(45, 217, 122, 0.4); color: var(--ok); }
.plate-result.err { border-color: rgba(255, 77, 82, 0.4); color: #ffb3b6; }

/* ---------------- thinking page ---------------- */
.thinking-page {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px 0;
}
.thinking-spinner {
  position: relative;
  width: 84px; height: 84px;
  margin-bottom: 22px;
}
.thinking-spinner::before, .thinking-spinner::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  animation: spin 1.1s linear infinite;
}
.thinking-spinner::after {
  inset: 12px;
  border-top-color: rgba(45, 217, 196, 0.45);
  animation-duration: 1.7s;
  animation-direction: reverse;
}
.thinking-spinner .thinking-core {
  position: absolute;
  inset: 34px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thinking-page h2 { margin: 6px 0 4px; max-width: 560px; }
.thinking-elapsed {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 26px;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(45, 217, 196, 0.35);
}
.thinking-detail { margin-top: 10px; min-height: 1em; margin-bottom: 14px; }
.thinking-error { color: var(--danger); }
.thinking-error .btn { margin-top: 4px; }
.thinking-hint { color: var(--text-dim); font-size: 13.5px; max-width: 520px; }

/* Instant-read triage banner */
.triage-banner {
  width: 100%;
  max-width: 680px;
  border: 1px solid rgba(45, 217, 196, 0.3);
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(45, 217, 196, 0.08), transparent 70%), var(--surface);
  padding: 14px 16px;
  margin: 0 0 20px;
  text-align: left;
  animation: rise 0.3s ease-out;
}
.triage-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.triage-header small {
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  text-transform: none;
}
.triage-line { font-size: 14px; margin-top: 4px; color: var(--text-dim); overflow-wrap: anywhere; }
.triage-line strong { color: var(--text); font-weight: 600; }

/* markdown-rendered agent output (window.skvMd) */
.md { font-size: inherit; line-height: 1.62; }
.md > * { margin: 0 0 10px; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md .md-h { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin: 16px 0 8px; }
.md .md-ul, .md .md-ol { margin: 0 0 10px; padding-left: 22px; }
.md .md-ul li, .md .md-ol li { margin: 3px 0; }
.md .md-hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.md .md-pre { background: #05080c; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; margin: 0 0 10px; }
.md .md-code-i { font-family: var(--mono); font-size: 0.92em; background: #05080c; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.md strong { color: var(--text); font-weight: 650; }
/* the prominent answer card: markdown flows as normal blocks, not pre-wrap */
.response-box.md { white-space: normal; font-size: 14.5px; line-height: 1.65; }
/* on desktop cap the answer card so the page isn't endless; scroll inside it */
@media (min-width: 740px) {
  .response-box.md.md-scroll { max-height: 62vh; overflow-y: auto; }
}

/* ---------------- diagnosis ---------------- */
.response-box {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14.5px;
  line-height: 1.65;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-top: 10px;
}

.kv { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13.5px; }
.kv td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}
.kv tr td:first-child {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  width: 110px;
  white-space: nowrap;
}
.kv tr:last-child td { border-bottom: none; }

/* follow-up chat — window grows with the full conversation (no forced
   inner scroll; the page scrolls). Tall on long cases but content always
   fully readable without a second scroll area. */
.chat-window {
  max-height: none;
  overflow-y: visible;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 14px;
  margin: 10px 0;
}
.chat-window:empty { padding: 12px; }
.chat-message { max-width: 88%; font-size: 13.5px; }
.chat-message .agent-label, .chat-message .user-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 3px;
}
.chat-message .message-content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.chat-message .message-content.md { white-space: normal; }
.chat-message.agent {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
}
.chat-message.user {
  align-self: flex-end;
  background: rgba(45, 217, 196, 0.08);
  border: 1px solid rgba(45, 217, 196, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
}
.input-row { display: flex; gap: 8px; }
.input-row .question-input { flex: 1; }
.input-row .btn { flex: 0 0 auto; }
#waitingIndicator { display: none; margin-top: 8px; font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
#waitingIndicator.show { display: flex; align-items: center; gap: 8px; }

/* ---------------- emergency (instant red path) ---------------- */
/* App.py wraps the diagnosis content in <div class="content-emergency"> when
   an emergency is detected. The .emergency-hero panel does the rest:
   full-width red hazard treatment.  */
.content-emergency { background: none; }
.emergency-hero {
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(45deg, rgba(255, 77, 82, 0.10) 0 14px, transparent 14px 28px),
    rgba(255, 27, 34, 0.10);
  padding: 20px 16px;
  margin: 0 0 18px;
  animation: emg-blink 1.6s ease-in-out infinite;
}
@keyframes emg-blink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 82, 0.0); border-color: var(--danger); }
  50% { box-shadow: 0 0 34px rgba(255, 77, 82, 0.25); border-color: #ff7a7e; }
}
.emergency-hero .emg-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--danger);
}
.emergency-hero .emg-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  flex: 0 0 auto;
}
.emergency-hero .emg-sub {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: #ffb3b6;
  text-transform: uppercase;
  margin: 6px 0 12px;
}
.emergency-hero .response-box {
  border-color: rgba(255, 77, 82, 0.4);
  background: rgba(6, 9, 13, 0.65);
  color: #ffd7d9;
}

/* ---------------- misc widgets ---------------- */
.spin {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -2px;
  margin-right: 7px;
  animation: spin 0.8s linear infinite;
}

/* toasts */
.toast-root {
  position: fixed;
  z-index: 200;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  padding: 11px 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast-error { border-color: rgba(255, 77, 82, 0.5); }
.toast-success { border-color: rgba(45, 217, 122, 0.5); }
.toast-info { border-color: rgba(45, 217, 196, 0.4); }

/* footer */
.footer {
  border-top: 1px solid var(--line);
  padding: 16px;
  text-align: center;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ---------------- sessions (admin beta review) ---------------- */
.badge-emg {
  color: #ff8589;
  border-color: rgba(255, 77, 82, 0.55);
  background: rgba(255, 77, 82, 0.12);
  text-transform: uppercase;
}
.session-list { display: flex; flex-direction: column; gap: 12px; }
.session-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 16px;
  margin: 0;
  transition: border-color .15s ease, transform .15s ease;
}
.session-row:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.session-row-main { flex: 1 1 auto; min-width: 0; }
.session-row-title {
  font-weight: 650;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.session-row-title .muted { font-weight: 400; }
.session-row-symptom {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-row-meta {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.session-row-meta .muted { font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; }
.sess-open { color: var(--accent); font-weight: 600; font-size: 13px; }

/* session detail */
.session-detail-date { font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em; text-align: right; }
.review-thread {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 14px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.review-thread .r-msg { max-width: 88%; font-size: 13.5px; }
.review-thread .r-msg .user-label,
.review-thread .r-msg .agent-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.review-thread .r-msg .message-content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.review-thread .r-msg .message-content.md { white-space: normal; }
.review-thread .r-msg.user {
  align-self: flex-end;
  background: rgba(45, 217, 196, 0.08);
  border: 1px solid rgba(45, 217, 196, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
}
.review-thread .r-msg.agent {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
}

/* ---------------- responsive ---------------- */
@media (min-width: 740px) {
  .content { padding: 30px 24px 60px; }
  h1 { font-size: 30px; }
  .hero h1 { font-size: 36px; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
  .form-row.three { grid-template-columns: repeat(3, 1fr); }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .g-item { aspect-ratio: 3 / 2; }
  .card { padding: 22px; }
  .response-box { font-size: 15px; }
  .topbar { padding: 8px 24px; }
  .status-strip { padding: 4px 24px; }
}

/* <740px = phone: single column, photo gallery becomes a
   horizontal scroll-snap carousel (brief must-keep). */
@media (max-width: 739px) {
  .gallery {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding: 2px 2px 8px;
    scrollbar-width: thin;
  }
  .g-item {
    flex: 0 0 62vw;
    max-width: 230px;
    scroll-snap-align: center;
  }
  h1 { font-size: 23px; }
  .hero { padding: 22px 0 14px; }
  .result-actions, .upload-actions { justify-content: stretch; }
  .result-actions .btn, .upload-actions .btn { flex: 1 1 auto; }
  .topnav a { padding: 0 9px; font-size: 11px; }
  .user-chip { display: none; } /* keep the top bar under 375px */
  .form-row.two, .form-row.three { grid-template-columns: 1fr; gap: 0; }
  .plate-head { flex-direction: column; }
}

/* respect reduced-motion (brief must-keep) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  html { scroll-behavior: auto; }
}
