/* ─── Design tokens ────────────────────────────────── */
:root {
  --bg:          #f3f1ea;
  --surface:     #ffffff;
  --surface-soft:#faf8f2;
  --text:        #141414;
  --muted:       #5f5b51;
  --line:        #e8e3d7;
  --accent:      #0f766e;
  --accent-light:#14b8a6;
  --accent-2:    #1d4ed8;
  --danger:      #b42318;
  --ok:          #117a37;
  --warn:        #92400e;
  --radius-xl:   24px;
  --radius-lg:   16px;
  --radius-md:   12px;
  --shadow:      0 24px 70px rgba(20,20,20,0.10);
  --shadow-sm:   0 4px 16px rgba(20,20,20,0.07);
}

/* ─── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* Ensure [hidden] always hides — overrides display:flex/grid on specific elements */
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 5% -5%,  rgba(15,118,110,0.14), transparent 22%),
    radial-gradient(circle at 95% 0%,  rgba(29,78,216,0.10),  transparent 25%),
    linear-gradient(180deg, #f8f6f1 0%, var(--bg) 60%, #ece6db 100%);
  font-family: "Inter", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ─── Shell ──────────────────────────────────────────── */
.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 18px 64px;
}

/* ─── Nav ────────────────────────────────────────────── */
.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--text);
}

.brand-icon { flex-shrink: 0; color: var(--accent); }

.nav-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-links a {
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.nav-links a.active,
.nav-links a:hover {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255,255,255,0.8);
}

/* ─── Panel ──────────────────────────────────────────── */
.panel {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

/* ─── Hero panel ─────────────────────────────────────── */
.hero-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: center;
  padding: 32px 36px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(15,118,110,0.09);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(28px, 3.6vw, 42px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
  max-width: 56ch;
  font-size: 15px;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn-primary-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: var(--radius-md);
  padding: 11px 18px;
  transition: opacity 0.15s, transform 0.15s;
}

.btn-primary-link:hover { opacity: 0.88; transform: translateY(-1px); }

.btn-secondary-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  background: rgba(255,255,255,0.75);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 11px 18px;
  transition: background 0.15s;
}

.btn-secondary-link:hover { background: #fff; }

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  min-width: 110px;
  box-shadow: var(--shadow-sm);
}

.stat-val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
}

.stat-lbl {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ─── Domain notice ──────────────────────────────────── */
.domain-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0;
  background: rgba(15,118,110,0.07);
  border: 1px solid rgba(15,118,110,0.2);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  font-size: 13.5px;
  color: #134e4a;
  line-height: 1.6;
}

.domain-notice a { font-weight: 600; text-decoration: underline; }
.notice-icon { flex-shrink: 0; margin-top: 1px; color: var(--accent); }

/* ─── Demo grid ──────────────────────────────────────── */
.demo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 0;
}

.upload-panel,
.result-panel {
  padding: 22px 24px;
}

h2 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* ─── Sample tiles ───────────────────────────────────── */
.samples-block { margin-bottom: 4px; }

.samples-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 8px;
}

.sample-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.sample-tile {
  position: relative;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 4px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  aspect-ratio: 1;
}

.sample-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.sample-tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(15,118,110,0.2);
}

.sample-tile.active-sample {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,118,110,0.18);
}

.tile-badge {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.tile-badge.good {
  background: #dcfce7;
  color: #15803d;
}

.tile-badge.bad {
  background: #fee2e2;
  color: #b91c1c;
}

/* ─── Or divider ─────────────────────────────────────── */
.or-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
}

.or-row::before,
.or-row::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.or-text {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

/* ─── Drop zone ──────────────────────────────────────── */
.drop-zone {
  position: relative;
  border: 2px dashed #c9c3b5;
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(15,118,110,0.04);
  outline: none;
}

.drop-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 20px;
  pointer-events: none;
}

.drop-icon { color: #a8a097; }
.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon { color: var(--accent); }

.drop-label {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.55;
}

.drop-sub { font-size: 13px; font-weight: 400; color: var(--muted); }

.link-text {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

.drop-hint {
  margin: 0;
  font-size: 11px;
  color: #b0a898;
}

#preview {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: calc(var(--radius-lg) - 2px);
  background: var(--surface-soft);
  padding: 8px;
}

/* ─── Preview clear button ───────────────────────────── */
.preview-clear {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: rgba(20,20,20,0.7);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
  backdrop-filter: blur(4px);
}

.preview-clear:hover {
  background: rgba(20,20,20,0.92);
  transform: scale(1.1);
}

/* ─── Form actions ───────────────────────────────────── */
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  align-items: flex-end;
}

.btn-primary {
  flex: 1;
  border: 0;
  border-radius: var(--radius-md);
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  font-family: inherit;
}

.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
}

.btn-outline:hover { border-color: var(--accent); background: rgba(15,118,110,0.04); }

.camera-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.camera-note {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* ─── Status text ────────────────────────────────────── */
.status-text {
  margin: 10px 0 14px;
  font-size: 13px;
  color: var(--muted);
  min-height: 20px;
}

.status-text .ok  { color: var(--ok);     font-weight: 700; }
.status-text .bad { color: var(--danger); font-weight: 700; }

/* ─── Guide card ─────────────────────────────────────── */
.guide-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px 18px;
  margin-top: 4px;
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.guide-card h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.guide-scope-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(15,118,110,0.10);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.guide-scope-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.guide-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.guide-list li {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

.dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
}

.dot.good { background: var(--ok); }
.dot.bad  { background: var(--danger); }
.dot.warn { background: #d97706; }

/* ─── Result panel ───────────────────────────────────── */
.result-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  min-height: 220px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  padding: 28px;
}

.empty-icon { color: #ccc6bc; }

/* Verdict badge */
.verdict-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.04em;
  margin-bottom: 18px;
  text-transform: uppercase;
}

.verdict-badge.verdict-good {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  color: #15803d;
  border: 1.5px solid #86efac;
}

.verdict-badge.verdict-defective {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #b91c1c;
  border: 1.5px solid #fca5a5;
}

/* Probability bar */
.prob-section {
  margin-bottom: 16px;
}

.prob-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.prob-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.prob-value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.prob-track {
  position: relative;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e9edf8;
  overflow: hidden;
}

.prob-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent-light));
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.prob-fill.fill-danger {
  background: linear-gradient(90deg, #ef4444, #fca5a5);
}

.prob-threshold-line {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2.5px;
  background: var(--text);
  border-radius: 2px;
  opacity: 0.55;
  left: 33.6%;
}

.prob-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

.prob-threshold-label {
  font-weight: 600;
  color: var(--text);
}

/* Meta chips */
.meta-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.meta-chip {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 10px 12px;
}

.meta-lbl {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.meta-val {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Result note */
.result-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 4px;
}

/* Raw JSON */
.raw-wrap {
  margin-top: 14px;
}

.raw-wrap summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 6px;
  user-select: none;
}

pre {
  margin: 0;
  border-radius: var(--radius-lg);
  background: #08112b;
  color: #d7e2ff;
  border: 1px solid #111b38;
  padding: 14px 16px;
  font-size: 12.5px;
  line-height: 1.55;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 100px;
  max-height: 300px;
}

/* ─── Animations ────────────────────────────────────── */
@keyframes pulse-opacity {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ─── Live metrics bar ───────────────────────────────── */
.metrics-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.75);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 12px;
  margin-bottom: 14px;
  width: fit-content;
  backdrop-filter: blur(10px);
}

.metrics-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: live-blink 2s ease-in-out infinite;
}

.metrics-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.metrics-lbl { color: var(--muted); font-weight: 500; }
.metrics-val { font-weight: 700; color: var(--text); }
.metrics-sep { color: var(--line); font-size: 14px; }

/* ─── Loading skeleton ───────────────────────────────── */
.result-loading {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skel {
  background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
  background-size: 200% 100%;
  border-radius: 10px;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skel-badge  { height: 64px; border-radius: var(--radius-lg); }
.skel-bar    { height: 48px; border-radius: var(--radius-md); }
.skel-row    { display: flex; gap: 8px; }
.skel-chip   { flex: 1; height: 60px; border-radius: var(--radius-md); }
.skel-note   { height: 52px; border-radius: var(--radius-md); }
.skel-heatmap { height: 200px; border-radius: var(--radius-lg); }

/* ─── Needs review alert ─────────────────────────────── */
.review-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  margin-bottom: 14px;
}

/* ─── Heatmap viewer ─────────────────────────────────── */
.heatmap-section {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.heatmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.heatmap-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.heatmap-toggle {
  display: inline-flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
}

.htoggle-btn {
  border: 0;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.htoggle-btn.active {
  background: var(--accent);
  color: #fff;
}

.heatmap-img {
  width: 100%;
  display: block;
  max-height: 280px;
  object-fit: contain;
  background: #000;
}

.heatmap-caption {
  padding: 10px 14px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
  border-top: 1px solid var(--line);
  margin: 0;
}

/* Analyze button loading state */
.btn-primary.loading {
  opacity: 0.75;
  cursor: not-allowed;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ─── Score guide (compact, inside left panel) ──────── */
.score-guide {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.score-row strong { color: var(--text); }

/* ─── Upload strip (full-width below demo) ───────────── */
.upload-strip {
  margin-top: 14px;
  padding: 24px 28px;
}

.strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.strip-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.strip-col {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  overflow: hidden;
}

.good-strip-col { border-color: #bbf7d0; }
.bad-strip-col  { border-color: #fecaca; }

.strip-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}

.good-strip-col .strip-col-header { background: #f0fdf4; color: #15803d; border-bottom-color: #bbf7d0; }
.bad-strip-col  .strip-col-header { background: #fef2f2; color: #b91c1c; border-bottom-color: #fecaca; }

.strip-items {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.strip-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.strip-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--surface-soft);
}

.strip-item span {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.strip-list {
  margin: 0;
  padding: 0 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.strip-list li {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.strip-ood-note {
  font-size: 12px;
  color: #7f1d1d;
  background: rgba(180,35,24,0.05);
  border: 1px solid rgba(180,35,24,0.12);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.6;
}

/* ─── Footer ─────────────────────────────────────────── */
.footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.footer a { font-weight: 500; text-decoration: underline; }

/* ═══════════════════════════════════════════════════════
   HOW IT WORKS PAGE
══════════════════════════════════════════════════════ */

.hiw-hero {
  padding: 32px 36px;
  margin-bottom: 0;
}

.hiw-title {
  margin: 0 0 12px;
  font-size: clamp(32px, 4vw, 52px);
  font-weight: 900;
  letter-spacing: -0.05em;
}

/* Sections */
.hiw-section {
  padding: 30px 36px;
  margin-top: 14px;
}

.section-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.section-sub {
  margin: 4px 0 20px;
  color: var(--muted);
  line-height: 1.75;
  max-width: 72ch;
  font-size: 14px;
}

/* Pipeline */
.pipeline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0;
  margin-top: 4px;
}

.pipe-step {
  flex: 1 1 120px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  position: relative;
}

.pipe-arrow {
  display: flex;
  align-items: center;
  padding: 0 4px;
  font-size: 20px;
  color: var(--accent);
  font-weight: 700;
  align-self: center;
  flex-shrink: 0;
}

.pipe-num {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  background: rgba(15,118,110,0.12);
  color: var(--accent);
  margin-bottom: 8px;
}

.pipe-icon { color: var(--accent); margin-bottom: 6px; }

.pipe-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.pipe-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.pipe-desc code {
  font-family: ui-monospace, "Cascadia Code", Menlo, monospace;
  font-size: 11px;
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 4px;
}

/* Architecture cards */
.arch-cards {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
}

.arch-card {
  width: 100%;
  max-width: 540px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  overflow: hidden;
}

.arch-card.frozen { border-color: #cbd5e1; }
.arch-card.trained { border-color: rgba(15,118,110,0.35); }

.arch-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 14px;
  background: #f1f5f9;
  color: #64748b;
  border-bottom: 1px solid var(--line);
}

.trained-badge {
  background: rgba(15,118,110,0.08);
  color: var(--accent);
  border-bottom-color: rgba(15,118,110,0.2);
}

.arch-title {
  font-size: 15px;
  font-weight: 700;
  padding: 12px 14px 8px;
}

.arch-body { padding: 0 14px 14px; }

.arch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.arch-row:last-child { border-bottom: none; }

.arch-layer { color: var(--text); font-weight: 500; }
.arch-shape { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

.arch-note {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
  line-height: 1.6;
}

.arch-arrow-vertical {
  font-size: 24px;
  color: var(--accent);
  font-weight: 700;
  text-align: center;
  padding: 6px 0;
}

/* Why DenseNet */
.why-densenet {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  padding: 20px;
}

.why-densenet h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
}

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

.why-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.why-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(15,118,110,0.1);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  margin-top: 1px;
}

.why-item strong { display: block; font-size: 13px; margin-bottom: 3px; }
.why-item p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }

/* Dataset stats */
.dataset-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.ds-stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 14px;
}

.ds-val {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--accent);
}

.ds-lbl {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

/* Dataset context note */
.dataset-context-note {
  background: rgba(29,78,216,0.05);
  border: 1px solid rgba(29,78,216,0.15);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  font-size: 13.5px;
  color: #1e3a6e;
  line-height: 1.7;
  margin-bottom: 22px;
}

/* Defect types */
.defect-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0 20px;
}

.defect-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.defect-img-wrap img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #f9f9f9;
}

.defect-info { padding: 12px 14px; }

.defect-name {
  font-size: 12px;
  font-weight: 700;
  font-family: ui-monospace, Menlo, monospace;
  color: var(--danger);
  margin-bottom: 4px;
}

.defect-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}

/* Good samples */
.good-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.good-img-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.good-img-wrap img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.good-label {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  background: #dcfce7;
  color: #15803d;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.img-caption {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
  margin: 4px 0 0;
}

/* Confidence explainer */
.conf-explainer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.conf-exp-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 18px;
}

.conf-exp-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
}

.conf-exp-card p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 12px;
}

/* Mini bar demo */
.mini-bar-demo { margin-top: 8px; }

.mini-bar-track {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e9edf8;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent-light));
  border-radius: 999px;
}

.mini-bar-fill.bad-fill {
  background: linear-gradient(90deg, #ef4444, #fca5a5);
}

.mini-bar-thresh {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--text);
  opacity: 0.5;
}

.mini-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.ok-text  { color: var(--ok); }
.bad-text { color: var(--danger); }

/* Threshold insight */
.thresh-insight {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 8px 0;
  font-size: 13px;
}

.ti-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.ti-row:last-child { border-bottom: none; }
.ti-row.highlight { background: rgba(15,118,110,0.06); }

.ti-val { font-weight: 600; }
.ti-val.muted { color: var(--muted); }

.thresh-note {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.6;
  margin: 0 !important;
}

/* ROC bar */
.roc-scale { margin-top: 8px; }

.roc-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e9edf8;
  overflow: hidden;
  margin-bottom: 6px;
}

.roc-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent-light));
  border-radius: 999px;
}

.roc-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.roc-val { font-weight: 800; font-size: 13px; color: var(--accent); }

/* Upload guide */
.upload-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.ug-col {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}

.ug-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}

.good-header { background: #f0fdf4; color: #15803d; border-bottom-color: #bbf7d0; }
.bad-header  { background: #fef2f2; color: #b91c1c; border-bottom-color: #fecaca; }

.ug-list {
  margin: 0;
  padding: 14px 16px 14px 32px;
  list-style: disc;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ug-list li { font-size: 13px; color: var(--muted); line-height: 1.5; }

.ood-callout {
  background: rgba(180,35,24,0.05);
  border: 1px solid rgba(180,35,24,0.15);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  font-size: 13.5px;
  color: #5a1a1a;
  line-height: 1.7;
}

/* Limitations */
.limit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.limit-card {
  border: 1px solid rgba(180,35,24,0.15);
  border-radius: var(--radius-lg);
  background: rgba(180,35,24,0.03);
  padding: 18px;
}

.limit-icon {
  font-size: 18px;
  margin-bottom: 8px;
}

.limit-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: #7f1d1d;
}

.limit-card p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
}

/* CTA section */
.hiw-cta {
  padding: 32px 36px;
  text-align: center;
  margin-top: 14px;
}

.hiw-cta h2 { margin: 0 0 10px; }
.hiw-cta p  { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 980px) {
  .hero-panel {
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .demo-grid {
    grid-template-columns: 1fr;
  }

  .sample-tiles {
    grid-template-columns: repeat(4, 1fr);
  }

  .pipeline {
    flex-direction: column;
  }

  .pipe-arrow {
    transform: rotate(90deg);
    align-self: flex-start;
    padding: 2px 6px;
    font-size: 18px;
  }

  .why-grid      { grid-template-columns: 1fr; }
  .dataset-stats { grid-template-columns: repeat(2, 1fr); }
  .defect-grid   { grid-template-columns: 1fr 1fr; }
  .good-grid     { grid-template-columns: repeat(2, 1fr); }
  .conf-explainer { grid-template-columns: 1fr; }
  .upload-guide  { grid-template-columns: 1fr; }
  .limit-grid    { grid-template-columns: 1fr; }

  .hiw-section,
  .hiw-hero,
  .hiw-cta { padding: 22px 20px; }
}

@media (max-width: 640px) {
  .shell { padding: 16px 12px 48px; }

  h1 { font-size: clamp(24px, 7vw, 36px); }

  .stat-grid { grid-template-columns: 1fr 1fr; }
  .sample-tiles { grid-template-columns: repeat(2, 1fr); }
  .meta-row { flex-wrap: wrap; }

  .upload-panel,
  .result-panel { padding: 18px 16px; }

  .strip-cols { grid-template-columns: 1fr; }
  .upload-strip { padding: 18px 16px; }

  .dataset-stats { grid-template-columns: repeat(2, 1fr); }
  .defect-grid { grid-template-columns: 1fr; }
  .good-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Architecture: inline notes for activation layers ── */
.arch-note-inline {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  font-style: italic;
}

.arch-arrow-vertical {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  padding: 6px 0;
}

/* ─── Why DenseNet icon boxes ────────────────────────── */
.why-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}

/* ─── Grad-CAM section ───────────────────────────────── */
.gradcam-explainer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

.gradcam-how h3,
.gradcam-visual h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
}

.gradcam-steps {
  margin: 12px 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gradcam-steps li {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.gradcam-steps li strong {
  color: var(--text);
}

.gradcam-note {
  margin-top: 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  color: #166534;
  line-height: 1.6;
}

/* Heatmap legend */
.heatmap-legend {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.legend-bar {
  margin-bottom: 16px;
}

.legend-gradient {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(to right, #313695, #4575b4, #74add1, #abd9e9, #e0f3f8, #fee090, #fdae61, #f46d43, #d73027, #a50026);
  margin-bottom: 6px;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.legend-guide {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}

.red-dot    { background: #d73027; }
.yellow-dot { background: #fee090; }
.blue-dot   { background: #4575b4; }

.legend-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

@media (max-width: 760px) {
  .gradcam-explainer { grid-template-columns: 1fr; }
}

/* ─── Autoencoder section ────────────────────────────── */
.ae-explainer {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 24px;
}

.ae-concept h3,
.ae-disagreement h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 10px;
}

.ae-concept p,
.ae-disagreement p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  margin: 0 0 10px;
}

/* AE architecture flow */
.ae-arch-visual {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.ae-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ae-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  text-align: center;
  min-width: 110px;
}

.ae-encoder { border-color: var(--accent-light); background: rgba(20,184,166,0.06); }
.ae-decoder { border-color: var(--accent-2); background: rgba(29,78,216,0.06); }

.ae-block-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.ae-block-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.ae-flow-arrow {
  font-size: 18px;
  color: var(--muted);
  flex-shrink: 0;
}

/* Disagreement cases */
.ae-cases {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.ae-case {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.6;
}

.ae-case-icon {
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
  min-width: 32px;
}

.agree-icon    { color: var(--ok); }
.disagree-icon { color: var(--warn); }

/* ─── Limitations: SVG icon boxes ───────────────────── */
.limit-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #c2410c;
  margin-bottom: 10px;
}

.limit-card .limit-icon-box + h3 {
  margin-top: 0;
}
