/* ===== Snake Oil — Balloon Race · dual-theme, responsive ===== */
:root {
  /* Verdict colours (shared, strong, both themes) */
  --take: #14a86b;
  --consider: #e0951a;
  --skip: #8893ad;
  --avoid: #e23b4e;
  --radius: 12px;
  font-synthesis: none;
}

/* ---------- Dark theme ---------- */
body.theme-dark {
  --sky-top: #070d24;
  --sky-mid: #101c41;
  --sky-bot: #1d2f5e;
  --ink: #f3f6ff;
  --muted: #c2cdec;          /* high-contrast secondary text */
  --faint: #8f9dc8;
  --line: rgba(255,255,255,.16);
  --line-soft: rgba(255,255,255,.08);
  --accent: #5fd0ff;
  --panel: #0c1430;
  --panel-2: #15224d;
  --chip: rgba(255,255,255,.10);
  --chip-hi: rgba(255,255,255,.18);
  --bubble-stroke: rgba(255,255,255,.7);
  --label-fill: #ffffff;
  --label-halo: rgba(0,0,0,.55);
  --shadow: 0 18px 50px rgba(0,0,0,.55);
  --field-bg: #1f3068;          /* solid, clearly lifted off the toolbar */
  --field-border: rgba(255,255,255,.34);
}
/* ---------- Light / minimalist theme ---------- */
body.theme-light {
  --sky-top: #ffffff;
  --sky-mid: #f6f8fc;
  --sky-bot: #eef1f8;
  --ink: #16203a;
  --muted: #45516e;
  --faint: #6b7793;
  --line: rgba(20,30,60,.16);
  --line-soft: rgba(20,30,60,.08);
  --accent: #0e7bbd;
  --panel: #ffffff;
  --panel-2: #f4f7fc;
  --chip: rgba(20,30,60,.05);
  --chip-hi: rgba(20,30,60,.10);
  --bubble-stroke: rgba(20,30,60,.45);
  --label-fill: #10182c;
  --label-halo: rgba(255,255,255,.85);
  --shadow: 0 18px 50px rgba(40,60,110,.18);
  --field-bg: #ffffff;          /* solid white cards stand off the tinted toolbar */
  --field-border: rgba(20,30,60,.30);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--sky-top); color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ===== Header ===== */
header {
  padding: 14px 22px 11px; border-bottom: 1px solid var(--line);
  background: var(--panel); z-index: 6;
}
.title-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
h1 { font-size: 21px; margin: 0; font-weight: 900; letter-spacing: -.02em; }
h1 .accent { color: var(--accent); }
.subtitle { color: var(--muted); font-size: 13px; font-weight: 500; }
.theme-toggle {
  margin-left: auto; background: var(--chip); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px;
  font-size: 12.5px; font-weight: 700; cursor: pointer; letter-spacing: .02em;
}
.theme-toggle:hover { background: var(--chip-hi); }
body.theme-dark .ic-light, body.theme-light .ic-dark { display: none; }
.disclaimer {
  margin-top: 9px; font-size: 12px; color: var(--ink); line-height: 1.5;
  background: color-mix(in srgb, var(--consider) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--consider) 42%, transparent);
  border-radius: 9px; padding: 7px 12px; display: inline-block;
}
.disclaimer b { color: color-mix(in srgb, var(--consider) 70%, var(--ink)); }

/* ===== Controls ===== */
.controls {
  display: flex; gap: 12px 14px; align-items: center; flex-wrap: wrap;
  padding: 11px 22px; border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.ctrl { display: flex; flex-direction: column; gap: 3px; }
.ctrl label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
select, input[type="search"] {
  background: var(--field-bg); color: var(--ink); border: 1px solid var(--field-border);
  border-radius: 9px; padding: 8px 11px; font-size: 13.5px; font-weight: 600; outline: none;
  font-family: inherit; box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
select { cursor: pointer; }
select:hover, input[type="search"]:hover, .toggle:hover { border-color: var(--accent); }
input[type="search"] { min-width: 210px; font-weight: 500; align-self: flex-end; }
input[type="search"]::placeholder { color: var(--faint); }
select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 26%, transparent); }
.toggle {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600;
  background: var(--field-bg); border: 1px solid var(--field-border); border-radius: 9px;
  padding: 9px 12px; cursor: pointer; align-self: flex-end; box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }
.count { margin-left: auto; align-self: flex-end; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.count b { color: var(--ink); font-weight: 800; }
.count .me-count { color: var(--accent); font-weight: 800; }

/* ===== "For me" personalisation ===== */
.forme-wrap { position: relative; align-self: flex-end; }
.forme-btn {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700;
  background: var(--field-bg); border: 1px solid var(--field-border); border-radius: 9px;
  padding: 9px 13px; cursor: pointer; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.forme-btn:hover { border-color: var(--accent); }
.forme-btn.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--field-bg)); }
.forme-btn .me-pip { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: none; }
.forme-btn.active .me-pip { display: inline-block; }
.forme-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40; width: 248px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; box-shadow: var(--shadow); display: none;
}
.forme-pop.open { display: block; }
.forme-pop h5 { margin: 0 0 6px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.forme-pop .seg + h5 { margin-top: 14px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  flex: 1 1 auto; background: var(--chip); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px; font-weight: 700; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.seg button:hover { border-color: var(--accent); }
.seg button.on { background: var(--accent); border-color: var(--accent); color: #06121f; }
.forme-pop { max-height: min(78vh, 560px); overflow-y: auto; }
.forme-pop h5 .h5-note { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--faint); }
.seg.goals { gap: 5px; }
.seg.goals button { flex: 1 1 46%; padding: 6px 8px; font-size: 11.5px; font-weight: 600; text-align: left; }
.sum-open {
  width: 100%; margin-top: 14px; background: var(--accent); border: none; color: #06121f;
  border-radius: 9px; padding: 10px 12px; font-size: 13px; font-weight: 800; cursor: pointer; font-family: inherit;
}
.sum-open:hover { filter: brightness(1.08); }
.forme-pop .pop-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 8px; }
.forme-pop .clear { background: none; border: none; color: var(--faint); font-weight: 700; font-size: 12px; cursor: pointer; padding: 4px; white-space: nowrap; }
.forme-pop .clear:hover { color: var(--accent); }
.forme-pop .hint { font-size: 10.5px; color: var(--faint); line-height: 1.4; }

/* ===== Personalised summary (rendered inside the drawer) ===== */
.summary-view { display: none; }
.drawer.mode-summary .cols { display: none; }
.drawer.mode-summary .summary-view { display: block; height: 100%; overflow-y: auto; padding: 30px 28px; }
.sum-title { font-size: 26px; font-weight: 900; letter-spacing: -.02em; margin: 0 0 2px; }
.sum-sub { color: var(--muted); font-size: 13.5px; font-weight: 600; margin-bottom: 16px; }
.sum-banner {
  font-size: 12px; line-height: 1.5; color: var(--ink); margin-bottom: 18px;
  background: color-mix(in srgb, var(--consider) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--consider) 42%, transparent);
  border-radius: 9px; padding: 9px 12px;
}
.sum-banner b { color: color-mix(in srgb, var(--consider) 70%, var(--ink)); }
.sum-sec { margin-top: 20px; }
.sum-sec > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 9px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.sum-sec > h3 .pip { width: 10px; height: 10px; border-radius: 50%; }
.sum-sec > h3 .n { color: var(--muted); font-weight: 700; }
.sum-list { list-style: none; padding: 0; margin: 0; }
.sum-row {
  display: flex; align-items: baseline; gap: 10px; padding: 10px 12px; margin: 6px 0;
  background: var(--chip); border: 1px solid var(--line-soft); border-radius: 10px; cursor: pointer;
}
.sum-row:hover { border-color: var(--accent); background: var(--chip-hi); }
.sum-row .sr-main { flex: 1; min-width: 0; }
.sum-row .sr-name { font-weight: 800; font-size: 14px; }
.sum-row .sr-name .foryou { font-size: 10px; font-weight: 800; color: var(--accent); margin-left: 7px; text-transform: uppercase; letter-spacing: .05em; }
.sum-row .sr-cond { color: var(--muted); font-size: 12px; margin-top: 1px; }
.sum-row .sr-take { color: var(--ink); font-size: 12.5px; margin-top: 4px; line-height: 1.4; }
.sum-row .sr-score { font-weight: 900; font-size: 13px; flex: none; white-space: nowrap; }
.sum-row .sr-flag { color: var(--avoid); font-weight: 700; }
.sum-empty { color: var(--muted); font-size: 13px; font-style: italic; padding: 4px 0; }
.sum-grouphead { font-size: 13px; font-weight: 800; color: var(--ink); margin: 22px 0 2px; letter-spacing: -.01em; }
.sum-grouphead + .sum-sec { margin-top: 10px; }
.sum-toggle {
  background: var(--chip); border: 1px solid var(--line); color: var(--ink); width: 100%; text-align: left;
  font-weight: 700; font-size: 12.5px; cursor: pointer; padding: 10px 12px; font-family: inherit; border-radius: 9px;
}
.sum-toggle:hover { border-color: var(--accent); }
.sum-toggle .arr { float: right; color: var(--muted); }
.sum-collapse { margin-top: 4px; }
.sum-foot { color: var(--faint); font-size: 11.5px; line-height: 1.5; margin-top: 22px; border-top: 1px solid var(--line-soft); padding-top: 12px; }

/* Back-to-summary link inside a detail opened from the summary */
.d-back {
  background: var(--chip); border: 1px solid var(--line); color: var(--ink); border-radius: 8px;
  padding: 6px 11px; font-size: 12.5px; font-weight: 700; cursor: pointer; font-family: inherit;
  align-self: flex-start; margin-bottom: 16px;
}
.d-back:hover { border-color: var(--accent); color: var(--accent); }

/* Highlight / de-emphasis driven by the "For me" selection.
   Highlight is just an accent outline on the balloon itself — no extra
   overlay circle, so balloons always keep their fill colour. */
.bubble.me-hi circle.body { stroke: var(--accent); stroke-width: 3.5; filter: drop-shadow(0 0 5px var(--accent)); }
.bubble.me-dim { opacity: .22; }
.bubble.dim { opacity: .1; }   /* filter dimming always wins over me-dim */

/* ===== Stage ===== */
.stage-wrap { position: relative; flex: 1; display: flex; overflow: hidden; min-height: 0; }
.stage-area { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; }
svg.stage {
  width: 100%; height: 100%; display: block;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-bot) 100%);
}
.band-line { stroke: var(--line-soft); stroke-dasharray: 2 7; }
.band-label { fill: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .02em; }
.band-score { fill: color-mix(in srgb, var(--ink) 22%, transparent); font-size: 42px; font-weight: 900; }

.bubble { cursor: pointer; }
.bubble circle.body { stroke: var(--bubble-stroke); stroke-width: 1.2; transition: stroke-width .12s; }
.bubble .string { stroke: var(--line); stroke-width: 1; }
.bubble:hover circle.body { stroke-width: 3; }
.bubble.dim { opacity: .10; pointer-events: none; }
.bubble.selected circle.body { stroke: var(--ink); stroke-width: 3.5; }
.bubble text.lbl {
  fill: var(--label-fill); font-size: 10.5px; font-weight: 700; text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: var(--label-halo); stroke-width: 3px;
}
.otw-ring { fill: none; stroke: var(--consider); stroke-width: 1.8; stroke-dasharray: 2 3; opacity: .95; }

/* ===== Tooltip ===== */
.tip {
  position: absolute; pointer-events: none; z-index: 20; max-width: 250px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; font-size: 12.5px; color: var(--ink); box-shadow: var(--shadow);
  opacity: 0; transition: opacity .1s;
}
.tip .t-name { font-weight: 800; font-size: 13.5px; }
.tip .t-cond { color: var(--muted); margin-top: 1px; }
.tip .t-verdict { margin-top: 6px; font-weight: 800; display: inline-flex; align-items: center; gap: 6px; }
.tip .pip { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ===== Legend ===== */
.legend {
  position: absolute; right: 16px; bottom: 16px; z-index: 10;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px;
  font-size: 12.5px; max-width: 230px; backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.legend h4 { margin: 0 0 7px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.legend .row { display: flex; align-items: center; gap: 8px; margin: 4px 0; cursor: pointer; font-weight: 600; color: var(--ink); }
.legend .row.off { opacity: .4; }
.legend .dot { width: 13px; height: 13px; border-radius: 50%; flex: none; border: 1px solid var(--bubble-stroke); }
.legend .size-hint { color: var(--muted); margin-top: 9px; font-size: 11px; font-weight: 500; line-height: 1.4; }
.empty-hint { position: absolute; left: 22px; bottom: 16px; color: var(--muted); font-size: 11.5px; z-index: 4; font-weight: 600; }

/* ===== Detail drawer (docked on wide, overlay on narrow) ===== */
.drawer {
  flex: 0 0 0; width: 0; overflow: hidden; position: relative;
  background: var(--panel); border-left: 1px solid var(--line);
  transition: flex-basis .3s cubic-bezier(.4,0,.2,1), width .3s cubic-bezier(.4,0,.2,1);
}
.drawer.open { flex-basis: clamp(360px, 34vw, 760px); width: clamp(360px, 34vw, 760px); }
.drawer .close {
  position: absolute; top: 12px; right: 14px; z-index: 3;
  background: var(--chip); border: 1px solid var(--line); color: var(--ink);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 16px;
}
.drawer .close:hover { background: var(--chip-hi); }
.drawer .cols { display: flex; width: 100%; height: 100%; }

/* Left identity panel */
.d-left {
  width: 44%; min-width: 230px; padding: 30px 24px; overflow-y: auto;
  background: linear-gradient(165deg, var(--panel-2), color-mix(in srgb, var(--panel) 80%, var(--panel-2)));
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
}
.d-type { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.d-name { font-size: 31px; font-weight: 900; line-height: 1.04; margin: 9px 0 2px; letter-spacing: -.025em; }
.d-alt { color: var(--muted); font-style: italic; font-size: 14px; font-weight: 500; }
.otw-tag { display: inline-block; margin-top: 12px; font-size: 11px; font-weight: 800; color: #1a1300; background: var(--consider); padding: 3px 9px; border-radius: 6px; }
.d-for { margin-top: 24px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.d-cond { font-size: 21px; font-weight: 800; margin-top: 5px; line-height: 1.2; }
.verdict-box { margin-top: auto; padding-top: 22px; }
.verdict-pill {
  display: flex; align-items: center; gap: 11px; padding: 14px 16px; border-radius: 14px;
  font-weight: 900; font-size: 17px; color: #fff; letter-spacing: -.01em;
}
.verdict-pill .vscore { margin-left: auto; font-size: 13px; font-weight: 800; opacity: .92; }
.delta { display: inline-block; font-size: 12.5px; font-weight: 800; margin-top: 10px; }
.delta.up { color: var(--take); } .delta.down { color: var(--avoid); } .delta.same { color: var(--muted); }

/* Right detail panel */
.d-right { flex: 1; padding: 30px 28px; overflow-y: auto; min-width: 0; }
.takeaway {
  font-size: 18px; font-weight: 800; line-height: 1.35; letter-spacing: -.01em;
  padding: 14px 16px; border-radius: 12px; border-left: 5px solid var(--accent);
  background: var(--chip); margin-bottom: 6px;
}
.d-right h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 22px 0 7px; font-weight: 800; }
.d-summary { font-size: 14.5px; line-height: 1.6; color: var(--ink); }
.meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px; margin-top: 4px; align-items: center; }
.meta-grid .k { color: var(--muted); font-weight: 600; }
.badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 7px; border: 1px solid; }
.badge.verified { background: color-mix(in srgb, var(--take) 16%, transparent); color: var(--take); border-color: color-mix(in srgb, var(--take) 50%, transparent); }
.badge.partially-verified { background: color-mix(in srgb, var(--consider) 16%, transparent); color: color-mix(in srgb, var(--consider) 75%, var(--ink)); border-color: color-mix(in srgb, var(--consider) 50%, transparent); }
.badge.unverified { background: color-mix(in srgb, var(--avoid) 16%, transparent); color: var(--avoid); border-color: color-mix(in srgb, var(--avoid) 50%, transparent); }
.badge.dead-original-link { background: var(--chip); color: var(--muted); border-color: var(--line); }
.badge.ai { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.badge.new { background: color-mix(in srgb, var(--take) 16%, transparent); color: var(--take); border-color: color-mix(in srgb, var(--take) 50%, transparent); }
.conf { font-weight: 800; }
.conf.high { color: var(--take); } .conf.medium { color: color-mix(in srgb, var(--consider) 75%, var(--ink)); } .conf.low { color: var(--avoid); }
.flag { color: var(--avoid); font-weight: 700; font-size: 13.5px; line-height: 1.5; }
ul.sources { list-style: none; padding: 0; margin: 8px 0 0; }
ul.sources li {
  margin: 9px 0; font-size: 13px; line-height: 1.45; padding: 10px 12px;
  background: var(--chip); border: 1px solid var(--line-soft); border-radius: 10px;
}
ul.sources a { color: var(--accent); text-decoration: none; font-weight: 700; word-break: break-word; }
ul.sources a:hover { text-decoration: underline; }
ul.sources .src-meta { color: var(--muted); font-size: 11.5px; margin-top: 3px; font-weight: 600; }
ul.sources .ok { color: var(--take); } ul.sources .no { color: var(--avoid); }
.notes-2019 { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin-top: 12px; }

/* ===== Responsive ===== */
/* Ultrawide: cap header/controls text width nicely; drawer already uses vw. */
@media (min-width: 1700px) {
  .subtitle { font-size: 14px; }
  .legend { font-size: 13px; }
}
/* Tablet / small laptop: drawer overlays instead of docking so it never
   squeezes the stage or pushes detail content off the right edge */
@media (max-width: 1200px) {
  .drawer {
    position: absolute; inset: 0 0 0 auto; z-index: 30; width: min(94vw, 600px); flex-basis: auto;
    transform: translateX(102%); transition: transform .3s cubic-bezier(.4,0,.2,1); box-shadow: var(--shadow);
  }
  .drawer.open { transform: translateX(0); width: min(94vw, 600px); }
}
/* Phone */
@media (max-width: 640px) {
  header { padding: 12px 15px 9px; }
  h1 { font-size: 18px; }
  .subtitle { flex-basis: 100%; font-size: 12px; }
  .theme-toggle { margin-left: 0; order: 3; }
  .controls { padding: 10px 14px; gap: 9px 10px; }
  .controls .ctrl { flex: 1 1 140px; }
  select, input[type="search"] { width: 100%; min-width: 0; }
  .count { flex-basis: 100%; margin-left: 0; }
  .drawer { width: 100%; }
  .drawer.open { width: 100%; }
  .drawer .cols { flex-direction: column; }
  .d-left { width: 100%; min-width: 0; padding: 22px 18px; }
  .verdict-box { padding-top: 16px; }
  .d-right { padding: 22px 18px; }
  .takeaway { font-size: 16px; }
  .legend { right: 10px; bottom: 10px; padding: 9px 10px; max-width: 180px; font-size: 11.5px; }
  .empty-hint { display: none; }
  .band-score { font-size: 30px; }
}

.fatal { padding: 40px; font-size: 15px; color: var(--avoid); font-weight: 700; }
