/* Greenhouse — the dashboard's design tokens, phone first. */
:root {
  --bg: #0e1116; --bg-elev: #161b22; --bg-elev-2: #1c232c;
  --border: #2a313c; --border-soft: #222932;
  --text: #e6edf3; --text-dim: #9aa7b4; --text-faint: #6b7682;
  --accent: #3b82f6; --accent-hover: #2f6fe0;
  --leaf: #3fb950; --leaf-soft: rgba(63, 185, 80, .14); --leaf-line: #2c6b37;
  --amber: #d29922; --red: #e5534b; --purple: #8957e5;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 6px 24px rgba(0, 0, 0, .4);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --nav-h: 62px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body { overscroll-behavior-y: none; }
.hidden { display: none !important; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid #8bb8ff; outline-offset: 2px; }
button, a, summary, label { touch-action: manipulation; }
.muted { color: var(--text-faint); }
.hint { color: var(--text-dim); font-size: 13px; margin: 6px 0 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }

/* ---------- buttons, chips, inputs ---------- */
.btn { font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text); padding: 9px 14px; border-radius: var(--radius-sm); cursor: pointer; min-height: 44px; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: #232c37; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-plant { background: var(--leaf); border-color: transparent; color: #08210d; }
.btn-plant:hover { background: #4cc95e; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 13px; min-height: 36px; }
.btn-lg { padding: 12px 18px; font-size: 16px; }
.btn-block { width: 100%; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); border-radius: 999px; padding: 6px 12px; min-height: 36px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.chip.on { background: var(--leaf-soft); border-color: var(--leaf-line); color: #b7f0c0; }
.chip-quiet { color: var(--text-dim); }
.chip.warn { color: #e9cf8d; border-color: #5a4a22; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.input, .select { font: inherit; font-size: 16px; color: var(--text); background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 44px; width: 100%; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); }
.input-sm { width: 110px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 10px; min-height: 36px; }
.check input { width: 20px; height: 20px; }
.lbl { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); flex: 1; min-width: 120px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; color: var(--text-dim); background: var(--bg-elev-2); text-decoration: none; }
.tag.leaf { color: #b7f0c0; border-color: var(--leaf-line); background: var(--leaf-soft); }
.tag.amber { color: #e9cf8d; border-color: #5a4a22; background: rgba(210, 153, 34, .08); }
.tag.blue { color: #a9c6ff; border-color: #304b71; background: rgba(59, 130, 246, .1); }
.tag.purple { color: #d2bdfb; border-color: #4b3778; background: rgba(137, 87, 229, .1); }

/* ---------- login ---------- */
.overlay { position: fixed; inset: 0; background: rgba(6, 9, 13, .82); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.login-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 360px; padding: 28px 26px; text-align: center; }
.login-mark { font-size: 40px; }
.login-title { margin: 4px 0; font-size: 22px; }
.login-sub { margin: 0 0 18px; color: var(--text-dim); font-size: 14px; }
.login-card .input, .login-card input { width: 100%; margin-bottom: 14px; font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.login-error { color: var(--red); font-size: 13px; margin: 12px 0 0; }

/* ---------- frame ---------- */
.gh-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); background: rgba(14, 17, 22, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border-soft); }
.gh-brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 17px; }
.gh-mark { font-size: 22px; }
.gh-top-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.banner { margin: 10px max(14px, env(safe-area-inset-left)); padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid #304b71; background: rgba(59, 130, 246, .08); color: #a9c6ff; font-size: 13px; }
.banner.warn { border-color: #5a4a22; background: rgba(210, 153, 34, .08); color: #e9cf8d; }
.gh-main { max-width: 1100px; margin: 0 auto; padding: 14px max(14px, env(safe-area-inset-right)) calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); outline: none; }
.gh-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around; background: rgba(22, 27, 34, .97); border-top: 1px solid var(--border); padding: 4px max(6px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); }
.gh-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; min-height: 52px; color: var(--text-dim); text-decoration: none; font-size: 11.5px; font-weight: 600; border-radius: var(--radius-sm); }
.gh-nav a span { font-size: 20px; line-height: 1; }
.gh-nav a.on { color: #b7f0c0; background: var(--leaf-soft); }
.section-h { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin: 26px 0 10px; }

/* ---------- home ---------- */
.hero { padding: 18px; border: 1px solid #2c4a33; border-radius: 18px; background: linear-gradient(120deg, #132a1a, #172231 70%, var(--bg-elev)); }
.eyebrow { margin: 0; color: #9fe0aa; font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.hero h1 { margin: 6px 0; font-size: 24px; letter-spacing: -.02em; }
.hero-sub { margin: 0; color: #b6c5d7; font-size: 14px; max-width: 640px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px; min-height: 92px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); color: var(--text); text-decoration: none; }
.tile:hover { border-color: var(--leaf-line); }
.tile-ico { font-size: 24px; }
.tile-name { font-weight: 700; }
.tile-sub { color: var(--text-dim); font-size: 12.5px; }
.fact { margin-top: 14px; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px dashed var(--border); background: var(--bg-elev); font-size: 14px; }
.fact .fact-emoji { font-size: 20px; }
.strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; }
.strip .mini { flex: 0 0 210px; scroll-snap-align: start; }
.mini { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); padding: 10px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; color: var(--text); text-decoration: none; }
.mini-poster { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: calc(var(--radius) - 4px); background: var(--bg); }
.mini-title { font-weight: 600; font-size: 13.5px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mini-meta { color: var(--text-dim); font-size: 12px; }

/* ---------- wizard ---------- */
.wizard { display: flex; flex-direction: column; gap: 12px; max-width: 720px; }
.step { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); padding: 14px; }
.step-h { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 10px; cursor: default; }
.step-more > summary { list-style: none; cursor: pointer; margin: 0; min-height: 32px; }
.step-more > summary::-webkit-details-marker { display: none; }
.step-more[open] > summary { margin-bottom: 10px; }
.step-n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 999px; background: var(--leaf-soft); color: #b7f0c0; font-size: 13px; flex: none; }
.seg { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); margin-bottom: 10px; }
.seg-wrap { flex-wrap: wrap; }
.seg-sm { margin: 0; }
.seg-btn { flex: 1; font: inherit; font-size: 14px; font-weight: 600; border: 0; border-radius: 8px; background: transparent; color: var(--text-dim); padding: 8px 10px; min-height: 40px; cursor: pointer; text-align: center; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.seg-btn.on { background: var(--bg-elev-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.opt-group { margin-top: 12px; }
.opt-label { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.suggest-wrap { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 25; list-style: none; margin: 0; padding: 4px; background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 50vh; overflow: auto; }
.suggest li { display: flex; justify-content: space-between; gap: 10px; padding: 10px; border-radius: 6px; cursor: pointer; min-height: 44px; align-items: center; }
.suggest li:hover, .suggest li.active { background: var(--bg-elev); }
.suggest .s-meta { color: var(--text-faint); font-size: 12px; white-space: nowrap; }

/* ---------- feed ---------- */
.feed-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.feed-title { margin: 0; font-size: 20px; }
.filters { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 10; padding: 8px 0; background: var(--bg); }
.feed { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 900px) { .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.gcard { position: relative; display: flex; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); touch-action: pan-y; transition: transform .18s ease, opacity .18s ease; min-width: 0; }
.gcard.focus { border-color: var(--accent); }
.gcard.planted { border-color: var(--leaf-line); }
.gcard.swiping { transition: none; }
.poster { flex: 0 0 74px; width: 74px; height: 104px; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; color: rgba(255, 255, 255, .85); background: #233; }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.gbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.gmeta { color: var(--text-dim); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.gtitle { font-weight: 700; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.gcast { display: flex; flex-wrap: wrap; gap: 6px; }
.gcast .tag { font-weight: 600; }
.gbadges { display: flex; flex-wrap: wrap; gap: 6px; }
.vpills { display: flex; flex-wrap: wrap; gap: 6px; }
.vpill { font: inherit; font-size: 12.5px; font-weight: 600; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); border-radius: 8px; padding: 5px 9px; min-height: 34px; cursor: pointer; }
.vpill.on { border-color: var(--leaf-line); color: #b7f0c0; background: var(--leaf-soft); }
.gfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.gfoot .hint { margin: 0; font-size: 12px; }
.gactions { display: flex; gap: 6px; margin-left: auto; }
.swipe-hint { position: absolute; top: 50%; transform: translateY(-50%); font-weight: 700; font-size: 13px; opacity: 0; pointer-events: none; }
.swipe-hint.right { left: 14px; color: #b7f0c0; }
.swipe-hint.left { right: 14px; color: #f0a8a3; }
.skeleton { height: 128px; border-radius: var(--radius); background: linear-gradient(90deg, var(--bg-elev) 25%, var(--bg-elev-2) 50%, var(--bg-elev) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
.sentinel { height: 1px; }
.feed-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 16px 0; }

/* ---------- downloads ---------- */
.dl-list { display: flex; flex-direction: column; gap: 10px; }
.dl { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); padding: 12px; }
.dl-title { font-weight: 600; overflow-wrap: anywhere; font-size: 14px; }
.journey { display: flex; gap: 4px; margin: 10px 0 6px; }
.journey .js { flex: 1; height: 6px; border-radius: 3px; background: var(--border); }
.journey .js.done { background: var(--leaf); }
.journey .js.now { background: linear-gradient(90deg, var(--leaf), var(--border)); }
.journey .js.bad { background: var(--red); }
.dl-state { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text-dim); flex-wrap: wrap; }
.bar { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; margin-top: 6px; }
.bar > div { height: 100%; background: var(--leaf); }

/* ---------- history ---------- */
.stat-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.stat { background: var(--bg-elev); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.timeline li { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-elev); border: 1px solid var(--border-soft); font-size: 14px; }
.timeline .t-when { color: var(--text-faint); font-size: 12px; white-space: nowrap; margin-left: auto; }

/* ---------- sheet + toast ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(6, 9, 13, .72); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 760px; max-height: 88dvh; display: flex; flex-direction: column; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 18px 18px 0 0; box-shadow: var(--shadow); padding-bottom: env(safe-area-inset-bottom); }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--border); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border-soft); }
.sheet-head h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 20px; display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 900px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 18px; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.vtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.vtable td, .vtable th { padding: 8px 6px; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: top; }
.vtable th { color: var(--text-faint); font-weight: 600; font-size: 11.5px; text-transform: uppercase; }
.vtable .raw { color: var(--text-dim); font-size: 12px; overflow-wrap: anywhere; }
.scene-thumb { width: 160px; height: 90px; object-fit: cover; border-radius: 8px; background: #111; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 70; display: flex; align-items: center; gap: 10px; max-width: min(560px, calc(100vw - 28px)); padding: 10px 12px 10px 16px; border-radius: 12px; background: #1f2a22; border: 1px solid var(--leaf-line); box-shadow: var(--shadow); font-size: 14px; }
.toast.err { background: #2a1d1c; border-color: #5a2c2a; }

/* M3: catalogue + local-AI fields */
.tag.dim { opacity: .65; font-weight: 500; }
.gblurb { margin: 4px 0 0; font-size: 13.5px; color: #cfd8e2; line-height: 1.4; }
.gwhy { margin-top: 4px; color: #b7f0c0; }
.related { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--bg-elev); }
.ask-result { margin-top: 12px; padding: 12px; border: 1px solid var(--leaf-line); border-radius: var(--radius); background: var(--leaf-soft); display: flex; flex-direction: column; gap: 8px; }
.ask-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ask-row .opt-label { min-width: 84px; }
.enrich-note { color: #b7f0c0; }
.btn.nudge { border-color: var(--leaf-line); color: #b7f0c0; }
.explain { margin: 10px 0; padding: 10px 12px; border-left: 3px solid var(--leaf-line); background: var(--bg-elev-2); border-radius: 0 8px 8px 0; font-size: 13.5px; color: #cfd8e2; }
.sheet-poster { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; background: #111; }
.recap { color: #b7f0c0; margin: 0 0 8px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 420px) { .gh-name { display: none; } .poster { flex-basis: 60px; width: 60px; height: 86px; } }

/* M4: the download's "after" panel */
.dl-hint { color: #e9cf8d; }
.after { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--leaf-line); background: var(--bg-elev-2); border-radius: 0 8px 8px 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: #cfd8e2; }
.after-line.ok { color: #b7f0c0; }
.after-line.dim { color: var(--text-faint); }
.after-line.caption { font-style: italic; color: var(--text-dim); }

/* M5: PWA bits */
.tile-wide { grid-column: 1 / -1; }
.install-hint { margin: 10px 0 0; color: #b7f0c0; }
.ptr { position: fixed; top: calc(env(safe-area-inset-top) + 64px); left: 50%; transform: translateX(-50%); z-index: 40; padding: 6px 14px; border-radius: 999px; background: var(--bg-elev-2); border: 1px solid var(--leaf-line); color: #b7f0c0; font-size: 13px; }
