/* LeafMedic — design system (MyPlantin-inspired) */

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/nunito-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("../fonts/outfit-latin.woff2") format("woff2");
}

:root {
  --teal-1: #27995d;
  --teal-2: #71c14e;
  --green-nav: #2e9d68;
  --green-deep: #1c6b47;
  --blue-link: #1f8a5c;
  --blue-muted: #7d9187;

  --amber-500: #d97706;
  --amber-100: #fef0dc;
  --red-500: #dc2626;
  --red-100: #fde5e5;
  --green-100: #ddf3e4;
  --green-600: #1c8050;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f5ef;
  --border: #dde8dc;
  --text: #26302a;
  --text-2: #333d36;
  --text-soft: #6e7b72;
  --shadow: 0 20px 25px -5px rgb(20 45 30 / 0.06), 0 8px 10px -6px rgb(20 45 30 / 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --hero-grad: linear-gradient(200deg, #eef9d8 10%, #cdeed8 90%);
  --promo-grad: linear-gradient(90deg, #1c6b47, #27995d);
  --cta-grad: linear-gradient(to right, #27995d, #71c14e);
  --hero-bg: linear-gradient(90deg, #bce8db, #dcf5ea);
  --hero-ink: #1c352b;
  --hero-ink-soft: rgb(28 53 43 / 0.78);
  --hero-accent: #157a54;
  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text-2);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

svg { fill: none; stroke: currentColor; stroke-width: 1.7; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: var(--green-nav); }
img { max-width: 100%; }

.wrap, .nav-inner, .hero-inner, .app-main, .model-banner-inner, .footer-inner {
  max-width: 1280px; margin: 0 auto; padding-left: 1.25rem; padding-right: 1.25rem;
}

/* ---------- Promo bar ---------- */
.promo-bar {
  background: linear-gradient(90deg, #fbecc3, #f8e3ae);
  color: #5c4715;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  padding: 0.5rem 1rem;
}

/* ---------- Navigation ---------- */
.site-nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
}
.nav-inner {
  display: flex; align-items: center; gap: 2rem;
  padding-top: 0.85rem; padding-bottom: 0.85rem;
}
.brand {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em;
  color: var(--hero-ink); text-decoration: none;
}
.brand em { color: var(--hero-accent); font-style: normal; }
.brand-leaf { width: 24px; height: 24px; color: var(--hero-accent); }

.tabs { display: flex; gap: 1.6rem; }
.tab {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.35rem 0; position: relative;
  font-size: 1rem; font-weight: 500; color: var(--hero-ink);
  transition: color 0.15s;
}
.tab:hover { color: var(--hero-accent); }
.tab.active { color: var(--hero-accent); }
.tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px;
  height: 2px; border-radius: 1px; background: var(--hero-accent);
}
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 0.8rem; }
.search-pill {
  width: 148px; height: 42px; border-radius: 21px;
  background: #edf4ea;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 0.9rem; color: var(--blue-muted);
}
.search-pill svg { width: 18px; height: 18px; }

/* ---------- Language switcher ---------- */
.lang-switch {
  display: flex; align-items: center; gap: 0.4rem;
  height: 42px; padding: 0 0.7rem; border-radius: 21px;
  background: #edf4ea; color: var(--blue-muted); cursor: pointer;
}
.lang-switch svg {
  width: 18px; height: 18px; fill: none;
  stroke: currentColor; stroke-width: 1.6;
}
.lang-switch select {
  border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; padding-right: 0.2rem;
}
.lang-switch select:focus-visible { outline: 2px solid var(--hero-accent); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Model banner ---------- */
.model-banner {
  background: var(--cta-grad); color: #fff;
  transition: opacity 0.5s, transform 0.5s;
}
.model-banner.done { opacity: 0; transform: translateY(-100%); }
.model-banner.error { background: var(--red-500); }
.model-banner-inner {
  padding-top: 0.55rem; padding-bottom: 0.55rem;
  display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
}
.model-banner-text { display: flex; flex-direction: column; font-size: 0.85rem; line-height: 1.3; }
.model-banner-text span { opacity: 0.85; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgb(255 255 255 / 0.35); border-top-color: #fff;
  animation: spin 0.9s linear infinite;
}
.model-banner.error .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-track {
  flex: 1; min-width: 120px; height: 6px; border-radius: 3px;
  background: rgb(255 255 255 / 0.25); overflow: hidden;
}
.progress-fill { height: 100%; width: 0; background: #fff; border-radius: 3px; transition: width 0.2s; }

/* ---------- Hero ---------- */
.hero { background: var(--hero-bg); }
.hero-inner {
  display: flex; align-items: center; gap: 2rem;
  padding-top: 1.6rem; padding-bottom: 0;
  min-height: 300px;
}
.hero-text { flex: 1 1 55%; padding-bottom: 2.2rem; }
.breadcrumb {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.9rem; margin-bottom: 1.4rem;
}
.breadcrumb a { color: var(--hero-ink-soft); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb svg { width: 14px; height: 14px; stroke-width: 2.2; color: var(--hero-ink-soft); }
.breadcrumb span { color: var(--hero-accent); font-weight: 600; }

.hero h1 {
  font-family: "Outfit", "Nunito", sans-serif;
  font-size: 2.6rem; font-weight: 700; color: var(--hero-ink);
  letter-spacing: -0.02em; line-height: 1.18; margin-bottom: 0.7rem;
}
.hero-text p { max-width: 56ch; font-size: 1rem; color: var(--hero-ink-soft); margin-bottom: 1.6rem; }

.btn-cta {
  display: inline-flex; align-items: center; gap: 0.6rem;
  background: #ffffff;
  color: #1c6b47;
  font-family: "Outfit", "Nunito", sans-serif;
  font-size: 1.05rem; font-weight: 600;
  padding: 0.85rem 1.8rem; border-radius: 30px;
  border: 1px solid rgb(20 90 60 / 0.12);
  box-shadow: 0 2px 8px rgb(15 45 30 / 0.1);
  transition: transform 0.15s, background 0.15s;
}
.btn-cta:hover { background: #f2f8f4; transform: translateY(-1px); }
.btn-cta svg { width: 22px; height: 22px; stroke-width: 2; }

.hero-art { flex: 1 1 45%; align-self: flex-end; display: flex; justify-content: flex-end; }
.hero-art svg { width: 100%; max-width: 520px; height: auto; display: block; }

/* ---------- Layout ---------- */
.app-main { flex: 1; width: 100%; padding-top: 2rem; padding-bottom: 2rem; }
.view { display: none; }
.view.active { display: block; animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---------- Home sections ---------- */
.home-section { margin-bottom: 2.75rem; }
.home-section:last-child { margin-bottom: 0; }

/* Section divider: a hairline above every home section that follows
 * another block, fading out toward the edges. */
.stats-band + .home-section,
.home-section + .home-section {
  position: relative;
  padding-top: 1.8rem;
}
/* The stats band sits close under the hero, so the first section needs less
 * breathing room than the section-to-section gaps further down. */
.stats-band + .home-section { padding-top: 1.6rem; }
.stats-band + .home-section::before,
.home-section + .home-section::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border) 18%, var(--border) 82%, transparent);
}
.home-section h2 {
  font-family: "Outfit", "Nunito", sans-serif;
  font-size: 1.7rem; font-weight: 700; color: var(--text);
  letter-spacing: -0.01em;
}
.causes-sub { color: var(--text-soft); font-size: 0.95rem; margin: 0.25rem 0 1.25rem; max-width: 78ch; }

.stats-band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.1rem;
  margin-bottom: 2rem;
}
.stat {
  display: flex; align-items: center; gap: 0.95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-icon {
  flex: none;
  width: 3rem; height: 3rem; border-radius: 50%;
  display: grid; place-items: center;
  /* Matches the promo bar's warm yellow and ink. */
  background: linear-gradient(90deg, #fbecc3, #f8e3ae);
  color: #5c4715;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-text { display: flex; flex-direction: column; }
.stat-text strong {
  font-family: "Outfit", "Nunito", sans-serif;
  font-size: 1.55rem; font-weight: 700; color: #5c4715; line-height: 1.2;
}
.stat-text span { font-size: 0.85rem; color: #5c4715; line-height: 1.45; }

/* ---------- Causes section ---------- */
.causes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(224px, 1fr));
  gap: 1.1rem;
}
.cause-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
}
.cause-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.cause-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.cause-body { padding: 0.85rem 1rem 1rem; }
.cause-body h3 { font-size: 1rem; font-weight: 600; color: var(--text); line-height: 1.4; margin-bottom: 0.25rem; }
.cause-body p { font-size: 0.875rem; color: var(--text-2); }

/* ---------- How it works ---------- */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.4rem;
}
.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.4rem 1.5rem;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  background: var(--green-100); color: var(--green-deep);
  font-family: "Outfit", "Nunito", sans-serif;
  font-size: 1.1rem; font-weight: 700;
  margin-bottom: 0.8rem;
}
.step-card h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 0.35rem; }
.step-card p { font-size: 0.925rem; color: var(--text-2); }
.home-cta-row { margin-top: 1.5rem; text-align: center; }

/* ---------- Detect ---------- */
.detect-grid { display: grid; grid-template-columns: minmax(300px, 5fr) 7fr; gap: 1.5rem; align-items: start; }
@media (max-width: 800px) { .detect-grid { grid-template-columns: 1fr; } }

.input-panel { padding: 1.1rem; }
.input-tabs {
  display: flex; gap: 0.35rem; padding: 0.3rem;
  background: var(--surface-2); border-radius: 999px;
  margin-bottom: 1rem;
}
.input-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 0.4rem; border-radius: 999px;
  font-size: 0.9rem; font-weight: 500; color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.input-tab svg { width: 17px; height: 17px; }
.input-tab.active { background: var(--surface); color: var(--green-deep); box-shadow: 0 1px 3px rgb(0 0 0 / 0.1); }

.input-mode { display: none; }
.input-mode.active { display: block; }
.mode-hint { font-size: 0.9rem; color: var(--text-soft); margin-bottom: 0.75rem; }

.sample-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.sample-item {
  border-radius: var(--radius-sm); overflow: hidden; position: relative;
  border: 2px solid transparent; transition: border-color 0.15s, transform 0.15s;
  padding: 0; display: block;
}
.sample-item:hover { border-color: var(--teal-1); transform: translateY(-2px); }
.sample-item img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.sample-item span {
  position: absolute; inset: auto 0 0 0; padding: 0.9rem 0.4rem 0.25rem;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.65));
  color: #fff; font-size: 0.7rem; text-align: center;
}
body:not(.model-ready) .sample-item { pointer-events: none; opacity: 0.6; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 2.5rem 1.25rem; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--text-soft); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--teal-1); background: var(--green-100); color: var(--green-deep); }
.dropzone svg { width: 34px; height: 34px; margin-bottom: 0.3rem; }
.dropzone strong { color: var(--text); font-size: 1rem; }
.dropzone.dragging strong, .dropzone:hover strong { color: var(--green-deep); }
.dropzone span { font-size: 0.8rem; }
.dropzone .dropzone-multi { font-size: 0.75rem; opacity: 0.8; margin-top: 0.2rem; }
body:not(.model-ready) .dropzone { pointer-events: none; opacity: 0.6; }

.camera-stage {
  position: relative; border-radius: var(--radius-sm); overflow: hidden;
  background: #0c110e; aspect-ratio: 4 / 3;
}
#camera-video { width: 100%; height: 100%; object-fit: cover; display: block; }
#camera-video.mirrored { transform: scaleX(-1); }
.camera-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.6rem;
  color: #9fb3a7; text-align: center; padding: 1rem;
}
.camera-placeholder svg { width: 40px; height: 40px; }
.camera-placeholder p { font-size: 0.9rem; max-width: 34ch; }
.camera-controls { display: flex; gap: 0.6rem; margin-top: 0.8rem; }
.btn-capture { flex: 1; }
body:not(.model-ready) .camera-controls { pointer-events: none; opacity: 0.6; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.6rem 1.3rem; border-radius: 999px;
  font-weight: 500; font-size: 0.95rem;
  transition: background 0.15s, transform 0.1s, filter 0.15s;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--green-nav); color: #fff; }
.btn-primary:hover { filter: brightness(0.94); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: var(--border); }
.btn-link { color: var(--text-soft); font-size: 0.85rem; text-decoration: underline; }
.btn-link:hover { color: var(--text); }

/* ---------- Results ---------- */
.results-panel { padding: 1.5rem; min-height: 320px; position: relative; }
.results-panel.analyzing::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  backdrop-filter: blur(1.5px);
}
.results-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.5rem; text-align: center; color: var(--text-soft);
  min-height: 280px; padding: 1rem;
}
.results-empty svg { width: 44px; height: 44px; stroke: var(--teal-1); }
.results-empty h2 { color: var(--text); font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; }
.results-empty p { max-width: 44ch; font-size: 0.92rem; }

.analyzed-row { display: flex; gap: 1.1rem; align-items: flex-start; margin-bottom: 1rem; }
.analyzed-img {
  width: 130px; height: 130px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border); flex-shrink: 0;
}
.diagnosis h2 { font-size: 1.45rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; margin: 0.3rem 0 0.1rem; }
.diagnosis-sub { color: var(--text-soft); font-size: 0.92rem; }

.diagnosis-badge {
  display: inline-block; padding: 0.15rem 0.7rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.diagnosis-badge.healthy { background: var(--green-100); color: var(--green-600); }
.diagnosis-badge.uncertain { background: var(--surface-2); color: var(--text-soft); }
.diagnosis-badge.severity-low { background: var(--green-100); color: var(--green-600); }
.diagnosis-badge.severity-medium { background: var(--amber-100); color: var(--amber-500); }
.diagnosis-badge.severity-high { background: var(--red-100); color: var(--red-500); }
.diagnosis-badge.severity-critical { background: var(--red-500); color: #fff; }
.diagnosis-badge.severity-none { background: var(--surface-2); color: var(--text-soft); }

.low-confidence-note {
  background: var(--amber-100); color: var(--text-2);
  border-radius: var(--radius-sm); padding: 0.7rem 0.9rem;
  font-size: 0.88rem; margin-bottom: 1rem;
}

/* ---------- Combined (multi-photo) diagnosis note ---------- */
.multi-note {
  background: var(--surface-2); color: var(--text-2);
  border-left: 3px solid var(--teal-1);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem; font-size: 0.85rem; margin-bottom: 1rem;
}

/* ---------- Capture-quality warnings ---------- */
.capture-note {
  display: flex; flex-direction: column; gap: 0.35rem;
  margin-bottom: 1rem;
}
.capture-note span {
  background: var(--surface-2); color: var(--text-2);
  border-left: 3px solid var(--amber-500, #e0a531);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem; font-size: 0.85rem;
}

/* ---------- Explainability heatmap ---------- */
.explain-block { margin-top: 1.2rem; }
.btn-explain { font-size: 0.85rem; }
.btn-explain svg {
  width: 16px; height: 16px; fill: none;
  stroke: currentColor; stroke-width: 1.8;
}
.btn-explain[disabled] { opacity: 0.6; cursor: progress; }
.explain-hint {
  font-size: 0.8rem; color: var(--text-soft); margin: 0.4rem 0 0;
}
.explain-result { margin-top: 0.8rem; }
.explain-canvas-wrap {
  max-width: 300px; border-radius: var(--radius-sm); overflow: hidden;
}
.explain-canvas-wrap canvas { display: block; width: 100%; height: auto; }
.explain-legend {
  display: flex; align-items: center; gap: 0.5rem;
  margin-top: 0.5rem; font-size: 0.75rem; color: var(--text-soft);
}
.legend-gradient {
  flex: 1; max-width: 140px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(255,200,60,0.15), rgba(255,60,20,0.9));
}
.explain-caption {
  font-size: 0.8rem; color: var(--text-soft); margin: 0.5rem 0 0;
}

/* ---------- Printable report ---------- */
.report-block { margin-top: 1.2rem; }
.btn-report { font-size: 0.85rem; }
.btn-report svg {
  width: 16px; height: 16px; fill: none;
  stroke: currentColor; stroke-width: 1.8;
}
.report-hint {
  font-size: 0.8rem; color: var(--text-soft); margin: 0.4rem 0 0;
}

/* ---------- Benchmark readout (?bench) ---------- */
.bench-readout {
  position: fixed; bottom: 12px; right: 12px; z-index: 60;
  background: rgba(17, 24, 20, 0.9); color: #d8f3e2;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem; padding: 0.45rem 0.7rem; border-radius: 6px;
  pointer-events: none;
}

.section-title {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--blue-muted); margin: 1.1rem 0 0.55rem;
}

.pred-row {
  display: grid; grid-template-columns: minmax(110px, 1fr) 2fr 3.2rem;
  gap: 0.7rem; align-items: center; margin-bottom: 0.45rem;
}
.pred-name { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pred-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.pred-fill {
  height: 100%; border-radius: 4px; background: var(--amber-500);
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.pred-fill.healthy { background: var(--teal-1); }
.pred-row:first-child .pred-fill:not(.healthy) { background: var(--red-500); }
.pred-pct { font-size: 0.85rem; font-variant-numeric: tabular-nums; text-align: right; color: var(--text-soft); }

.treatment-desc { font-size: 0.95rem; margin-bottom: 0.8rem; }
.treatment-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.9rem; }
.treatment-col {
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.85rem 1rem;
}
.treatment-col h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.4rem; display: flex; gap: 0.4rem; align-items: center; }
.treatment-col ul { padding-left: 1.1rem; font-size: 0.86rem; color: var(--text-soft); display: grid; gap: 0.25rem; }

.healthy-note {
  background: var(--green-100); border-radius: var(--radius-sm);
  padding: 0.9rem 1rem; margin-top: 1rem; font-size: 0.92rem;
}
.healthy-note p { color: var(--text-soft); margin-top: 0.25rem; }

.disclaimer { font-size: 0.78rem; color: var(--text-soft); margin-top: 1.2rem; }

/* ---------- History ---------- */
.history-block { margin-top: 1.75rem; }
.history-head { display: flex; align-items: baseline; justify-content: space-between; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.7rem; }
.history-item {
  display: flex; gap: 0.7rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.55rem;
  text-align: left; cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.history-item:hover { border-color: var(--teal-1); transform: translateY(-1px); }
.history-item img { width: 46px; height: 46px; object-fit: cover; border-radius: 7px; }
.history-meta { display: flex; flex-direction: column; min-width: 0; }
.history-meta strong { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-meta span { font-size: 0.74rem; color: var(--text-soft); }
.history-item-wrap { display: flex; flex-direction: column; }
.history-tag-input {
  margin-top: 0.35rem; padding: 0.3rem 0.6rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 0.76rem;
}
.history-tag-input:focus-visible { outline: 2px solid var(--teal-1); outline-offset: 1px; }

.timelines-block { margin-top: 1.75rem; }
.timelines-block > .section-title { margin-bottom: 0.7rem; }
.timeline-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.85rem 1rem; margin-bottom: 0.8rem;
}
.timeline-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.6rem; }
.timeline-head strong { font-size: 0.92rem; }
.timeline-head span { font-size: 0.76rem; color: var(--text-soft); }
.timeline-strip { display: flex; gap: 0.7rem; overflow-x: auto; padding-bottom: 0.2rem; }
.timeline-item {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  flex: 0 0 auto; width: 84px; text-align: center; cursor: pointer;
}
.timeline-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.timeline-item span { font-size: 0.68rem; color: var(--text-soft); }
.timeline-item strong { font-size: 0.72rem; font-weight: 600; line-height: 1.2; }
.timeline-item:hover img { border-color: var(--teal-1); }

/* ---------- Library ---------- */
.library-intro { margin-bottom: 0.9rem; }
.library-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.filter-chip {
  font-family: "Outfit", "Nunito", sans-serif;
  padding: 0.5rem 1.3rem; border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  background: #ffffff; color: #5c4715;
  border: 1px solid rgb(92 71 21 / 0.4);
  box-shadow: 0 2px 8px rgb(15 45 30 / 0.1);
  transition: transform 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
}
.filter-chip:hover { background: #faf3e0; border-color: rgb(92 71 21 / 0.6); transform: translateY(-1px); }
.filter-chip.active { background: #5c4715; border-color: transparent; color: #fff; box-shadow: 0 2px 8px rgb(15 45 30 / 0.1); }

.matches-label { color: var(--blue-muted); font-size: 0.875rem; }

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(224px, 1fr));
  gap: 1.1rem;
}
.library-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
  padding: 0;
  display: flex; flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
}
.library-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.library-card .card-img {
  width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block;
  background: var(--surface-2);
}
.library-card .card-body { padding: 0.85rem 1rem 1rem; }
.library-card h3 { font-size: 1rem; font-weight: 600; color: var(--text); line-height: 1.4; margin-bottom: 0.25rem; }
.library-card p {
  font-size: 0.875rem; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgb(15 25 20 / 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 680px; width: 100%; max-height: 94dvh; overflow: hidden;
  position: relative;
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.25);
}
.modal-close {
  position: sticky; top: 0.75rem; margin-left: calc(100% - 3rem);
  transform: translateX(-0.25rem);
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-soft); z-index: 2;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 0 1.5rem 1rem; margin-top: -1.5rem; }
.modal-body .modal-img {
  width: 100%; aspect-ratio: 3 / 1; object-fit: cover;
  border-radius: var(--radius-sm); margin: 0.3rem 0 0.6rem;
}
.modal-body h2 { font-size: 1.25rem; font-weight: 700; color: var(--text); margin: 0.3rem 0 0.15rem; }
.modal-body .diagnosis-badge { font-size: 0.68rem; }
.modal-body .section-title { margin: 0.6rem 0 0.4rem; }
.modal-body .treatment-desc { font-size: 0.88rem; margin-bottom: 0.5rem; }
.modal-body .treatment-cols {
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem;
}
.modal-body .treatment-col { padding: 0.6rem 0.65rem; min-width: 0; }
.modal-body .treatment-col h4 { font-size: 0.78rem; margin-bottom: 0.3rem; flex-wrap: wrap; }
.modal-body .treatment-col ul { font-size: 0.74rem; padding-left: 0.9rem; gap: 0.15rem; overflow-wrap: break-word; }

@media (max-width: 460px), (max-height: 700px) {
  .modal { max-height: 97dvh; }
  .modal-body .modal-img { aspect-ratio: 5 / 1; margin: 0.25rem 0 0.4rem; }
  .modal-body h2 { font-size: 1.05rem; }
  .modal-body .diagnosis-badge { font-size: 0.62rem; padding: 0.1rem 0.55rem; }
  .modal-body .section-title { margin: 0.4rem 0 0.25rem; font-size: 0.72rem; }
  .modal-body .treatment-desc { font-size: 0.78rem; margin-bottom: 0.35rem; line-height: 1.3; }
  .modal-body .treatment-cols { gap: 0.3rem; }
  .modal-body .treatment-col { padding: 0.4rem 0.4rem; }
  .modal-body .treatment-col h4 { font-size: 0.66rem; margin-bottom: 0.2rem; gap: 0.2rem; }
  .modal-body .treatment-col ul { font-size: 0.62rem; line-height: 1.25; padding-left: 0.65rem; gap: 0.1rem; }
}

/* ---------- About ---------- */
.about-card { max-width: 760px; margin: 0 auto; padding: 2rem; }
.about-card h2 { font-size: 1.6rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; margin-bottom: 0.6rem; }
.about-card h3 { margin: 1.1rem 0 0.3rem; font-size: 1.05rem; font-weight: 600; color: var(--text); }
.about-card p, .about-card ul { color: var(--text-2); font-size: 0.95rem; }
.about-card ul { padding-left: 1.2rem; display: grid; gap: 0.25rem; }
.about-card a { color: var(--blue-link); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 0 1.5rem;
  font-size: 0.875rem;
}
.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1.4fr;
  gap: 2rem;
}
.footer-brand .brand { font-size: 1.2rem; margin-bottom: 0.6rem; }
.footer-brand p { color: var(--text-soft); font-size: 0.82rem; max-width: 32ch; }
.footer-col { display: flex; flex-direction: column; gap: 0.55rem; }
.footer-col h4 { font-size: 0.95rem; font-weight: 700; color: var(--text); margin-bottom: 0.2rem; }
.footer-col a { color: var(--text-2); text-decoration: none; }
.footer-col a:hover { color: var(--green-nav); text-decoration: underline; }

.store-badge {
  display: inline-flex; align-items: center; gap: 0.6rem;
  background: #111; color: #fff !important;
  border-radius: 9px; padding: 0.45rem 0.9rem;
  text-decoration: none !important; width: fit-content;
}
.store-badge:hover { background: #2a2a2a; }
.store-badge svg { width: 24px; height: 24px; }
.store-badge span { display: flex; flex-direction: column; line-height: 1.15; font-weight: 600; font-size: 0.95rem; }
.store-badge small { font-weight: 400; font-size: 0.65rem; opacity: 0.8; }

.footer-social { display: flex; gap: 0.6rem; margin-top: 0.4rem; }
.footer-social a { color: var(--text-2); }
.footer-social a:hover { color: var(--green-nav); }
.footer-social svg { width: 22px; height: 22px; }

.footer-copy {
  text-align: center; color: var(--text-soft); font-size: 0.8rem;
  margin-top: 2rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .search-pill { display: none; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .hero-art { display: none; }
  .hero-text { padding-bottom: 2rem; }
  .hero h1 { font-size: 1.8rem; }
}
@media (max-width: 640px) {
  .nav-inner { flex-wrap: wrap; gap: 0.6rem 1rem; }
  .tabs { order: 3; width: 100%; justify-content: flex-start; gap: 1.1rem; overflow-x: auto; }
  .analyzed-row { flex-direction: column; }
  .analyzed-img { width: 100%; height: 180px; }
  .footer-inner { grid-template-columns: 1fr; }
}

/* ---------- Printable report page ---------- */
/* Filled and revealed only when "Save report" toggles body.print-report,
 * so a plain Ctrl+P still prints the site as usual. */
#report-page { display: none; }

@media print {
  body.print-report > *:not(#report-page) { display: none !important; }
  body.print-report #report-page {
    display: block; max-width: 660px; margin: 0 auto; color: #111;
  }
  #report-page .report-head {
    display: flex; align-items: center; gap: 0.5rem;
    border-bottom: 2px solid var(--green-nav, #2e9d68);
    padding-bottom: 0.6rem; margin-bottom: 0.4rem;
  }
  #report-page .report-head .brand-leaf { width: 22px; height: 22px; color: #2e9d68; }
  #report-page .report-brand { font-family: "Outfit", "Nunito", sans-serif; font-weight: 700; font-size: 1.2rem; }
  #report-page .report-brand em { font-style: normal; color: #2e9d68; }
  #report-page .report-title {
    margin-left: auto; font-size: 0.85rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em; color: #555;
  }
  #report-page .report-meta { font-size: 0.8rem; color: #555; margin-bottom: 1.2rem; }
  #report-page .analyzed-img { width: 150px; height: 150px; }
  /* Keep the confidence bars visible on ink-saving printers. */
  #report-page .pred-track { border: 1px solid #ccc; }
  #report-page .pred-fill { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  #report-page .treatment-cols { grid-template-columns: repeat(3, 1fr); }
  #report-page .treatment-col { border: 1px solid #ddd; background: #fff; }
  #report-page .healthy-note { border: 1px solid #ddd; background: #fff; }
  #report-page .disclaimer { margin-top: 1.5rem; }
}
