/* Layout: a single working column. Search bar on top, then summary before detail:
   headline metrics, engine coverage, then the long lists (prompts, topics, questions, competitors). */
:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --sunk: #e9edf1;
  --ink: #13202b;
  --ink-2: #4c5a67;
  --ink-3: #7b8794;
  --line: #d9e0e6;
  --accent: #0d6b86;
  --accent-ink: #ffffff;
  --accent-soft: #dcedf2;
  --mark: #ffe9a8;
  --mark-ink: #3d2c00;
  --good: #1f7a4a;
  --good-soft: #dff1e6;
  --warn: #9a5b00;
  --warn-soft: #fbeccf;
  --bad: #a3302a;
  --bad-soft: #f8dfdc;
  --bar-other: #b5c0ca;
  --pos: #2f78c4;
  --neu: #c3cbd2;
  --neg: #d4622c;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f161c; --surface: #172129; --sunk: #1d2932; --ink: #e6edf2; --ink-2: #a9b6c1; --ink-3: #7d8b97;
    --line: #2a3843; --accent: #4fb3cf; --accent-ink: #062029; --accent-soft: #163a46; --mark: #5a4710; --mark-ink: #fff3cf;
    --good: #5fcf8f; --good-soft: #17352a; --warn: #e8b05a; --warn-soft: #3a2c12; --bad: #f08a80; --bad-soft: #3d1d1b;
    --bar-other: #4a5a67; --pos: #4a90d9; --neu: #4f5d69; --neg: #d96d36; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f161c; --surface: #172129; --sunk: #1d2932; --ink: #e6edf2; --ink-2: #a9b6c1; --ink-3: #7d8b97;
  --line: #2a3843; --accent: #4fb3cf; --accent-ink: #062029; --accent-soft: #163a46; --mark: #5a4710; --mark-ink: #fff3cf;
  --good: #5fcf8f; --good-soft: #17352a; --warn: #e8b05a; --warn-soft: #3a2c12; --bad: #f08a80; --bad-soft: #3d1d1b;
  --bar-other: #4a5a67; --pos: #4a90d9; --neu: #4f5d69; --neg: #d96d36; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font-body); padding: 0 16px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-block: 28px 64px; display: grid; gap: 22px; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 500; }
p { margin: 0; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: .86em; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.eyebrow { font: 500 .72rem/1 var(--font-body); text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header + search */
.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.top p { max-width: 62ch; }
.search { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; }
.search form { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.field { display: grid; gap: 5px; min-width: 0; }
.field label { font-size: .78rem; font-weight: 600; color: var(--ink-2); }
input, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; min-width: 0; }
input::placeholder { color: var(--ink-3); }
button { font: 600 .92rem var(--font-body); border-radius: 8px; padding: 10px 16px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .55; cursor: progress; }
button.ghost { background: transparent; }
button.small { padding: 6px 10px; font-size: .8rem; }
.recent { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .82rem; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); border-radius: 999px; padding: 3px 10px; font-size: .8rem; cursor: pointer; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.banner { border-radius: var(--r); padding: 12px 14px; font-size: .9rem; border: 1px solid var(--line); background: var(--surface); }
.banner.bad { background: var(--bad-soft); border-color: transparent; color: var(--ink); }
.banner.warn { background: var(--warn-soft); border-color: transparent; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 14px; }
.panel-head .sub { font-size: .86rem; color: var(--ink-2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.state { font-size: .88rem; color: var(--ink-2); }
.state.err { color: var(--bad); }
.skel { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--sunk), var(--line), var(--sunk)); background-size: 200% 100%; animation: sh 1.4s infinite linear; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* Prospect header */
.prospect { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 18px; align-items: end; }
.prospect h2 { font-size: 1.7rem; }
.prospect .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .86rem; color: var(--ink-2); }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.tile { background: var(--surface); padding: 14px 16px; display: grid; gap: 4px; align-content: start; }
.tile .v { font: 700 1.7rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.tile .d { font-size: .78rem; }
.up { color: var(--good); } .down { color: var(--bad); }
.tile-group { display: grid; gap: 8px; }

/* Bars */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) 4.2rem; gap: 10px; align-items: center; font-size: .86rem; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; background: var(--sunk); border-radius: 4px; position: relative; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 0 4px 4px 0; background: var(--bar-other); min-width: 2px; }
.bar-fill.me { background: var(--accent); }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bar-row.me .lbl { font-weight: 600; color: var(--ink); }

/* Tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; background: var(--bg); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
td .url { color: var(--ink-3); font-size: .78rem; word-break: break-all; }

.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.pill.yes { background: var(--good-soft); color: var(--good); }
.pill.no { background: var(--sunk); color: var(--ink-3); }
.pill.link { background: var(--accent-soft); color: var(--ink); }
.pill.brand { background: var(--mark); color: var(--mark-ink); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.link::before { background: var(--accent); }

/* Prompts */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.prompts { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.prompt { border-bottom: 1px solid var(--line); }
.prompt:last-child { border-bottom: 0; }
.prompt summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; padding: 11px 14px; align-items: center; }
.prompt summary::-webkit-details-marker { display: none; }
.prompt summary:hover { background: var(--bg); }
.prompt .q { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.prompt .q::before { content: "\201C"; color: var(--ink-3); }
.prompt .q::after { content: "\201D"; color: var(--ink-3); }
.prompt .tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: end; align-items: center; font-size: .78rem; color: var(--ink-2); }
.prompt .body { padding: 2px 14px 14px; display: grid; gap: 8px; font-size: .88rem; }
.excerpt { background: var(--bg); border-radius: 8px; padding: 10px 12px; color: var(--ink-2); max-width: 75ch; overflow-wrap: anywhere; }
mark { background: var(--mark); color: var(--mark-ink); border-radius: 3px; padding: 0 2px; }
.links { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .8rem; }
.links a { overflow-wrap: anywhere; }
.links a.own { font-weight: 600; }

/* Topics */
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.topic { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.topic h3 { overflow-wrap: anywhere; }
.topic .stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--ink-2); }
.topic ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: .84rem; }
.topic li { display: flex; justify-content: space-between; gap: 10px; }
.topic li span:first-child { min-width: 0; overflow-wrap: anywhere; }
.pos { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-2); white-space: nowrap; }

/* Sources */
.sources { display: grid; gap: 6px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }


/* Sentiment */
#sentiment { display: grid; gap: 28px; }
.sent { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 28px; align-items: center; }
.ring-box { display: grid; justify-items: center; gap: 14px; }
.ring { width: 100%; max-width: 230px; height: auto; display: block; }
.ring circle.seg { fill: none; stroke-width: 26; transition: stroke-width .15s ease; cursor: default; }
.ring circle.seg:hover { stroke-width: 31; }
.ring .track { fill: none; stroke: var(--sunk); stroke-width: 26; }
.ring text { fill: var(--ink); font-family: var(--font-display); }
.ring .score { font-size: 46px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ring .cap { font: 500 10.5px var(--font-body); fill: var(--ink-2); letter-spacing: .08em; text-transform: uppercase; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-size: .84rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.positive { background: var(--pos); } .sw.neutral { background: var(--neu); } .sw.negative { background: var(--neg); }
.verdict { font: 700 1.05rem var(--font-display); text-align: center; }
.div-bars { display: grid; gap: 12px; min-width: 0; }
.div-head { display: grid; grid-template-columns: minmax(0, 9.5rem) minmax(0, 1fr) 6.5rem; gap: 12px; font-size: .72rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; }
.div-head .ax { display: flex; justify-content: space-between; }
.div-row { display: grid; grid-template-columns: minmax(0, 9.5rem) minmax(0, 1fr) 6.5rem; gap: 12px; align-items: center; font-size: .86rem; }
.div-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.div-row.all .lbl { font-weight: 600; }
.div-track { position: relative; height: 22px; }
.div-track::after { content: ""; position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: var(--ink-3); }
.dseg { position: absolute; top: 0; bottom: 0; box-shadow: inset 0 0 0 1px var(--surface); }
.dseg.positive { background: var(--pos); border-radius: 0 4px 4px 0; }
.dseg.neutral { background: var(--neu); }
.dseg.negative { background: var(--neg); border-radius: 4px 0 0 4px; }
.div-row.all .div-track { height: 28px; }
.div-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: .8rem; line-height: 1.25; }
.div-row .val b { color: var(--ink); font-weight: 600; }
.quotes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.quotes h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.quotes ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.quotes li { border-left: 3px solid var(--line); padding: 2px 0 2px 10px; font-size: .88rem; }
.quotes li.positive { border-color: var(--pos); } .quotes li.negative { border-color: var(--neg); }
.quotes li .from { display: block; font-size: .76rem; color: var(--ink-3); margin-top: 2px; overflow-wrap: anywhere; }
.pill.s-positive, .pill.s-neutral, .pill.s-negative { background: var(--sunk); color: var(--ink); }
.pill.s-positive::before { background: var(--pos); } .pill.s-neutral::before { background: var(--neu); } .pill.s-negative::before { background: var(--neg); }
.why { font-size: .84rem; color: var(--ink-2); }
#tip { position: fixed; z-index: 10; pointer-events: none; background: var(--ink); color: var(--bg); font-size: .78rem; padding: 6px 9px; border-radius: 6px; max-width: 260px; line-height: 1.35; }
@media (max-width: 860px) { .sent, .quotes { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 480px) { .div-head, .div-row { grid-template-columns: minmax(0, 5.5rem) minmax(0, 1fr) 4.6rem; gap: 8px; } }

/* Intro (at rest) */
.intro { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.intro .card { border: 1px dashed var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 6px; align-content: start; background: var(--surface); }
.intro .card .src { font-size: .74rem; color: var(--ink-3); font-family: var(--font-mono); }
.foot { font-size: .78rem; color: var(--ink-3); }

@media (max-width: 860px) {
  .search form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .search form .field:first-child { grid-column: 1 / -1; }
  .grid-2, .intro { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .search form { grid-template-columns: minmax(0, 1fr); }
  .prompt summary { grid-template-columns: minmax(0, 1fr); }
  .prompt .tags { justify-content: start; }
  .bar-row { grid-template-columns: minmax(0, 6.5rem) minmax(0, 1fr) 3.6rem; }
  h1 { font-size: 1.55rem; }
}

/* Additions for the hosted version */
.who { display: flex; align-items: center; gap: 12px; font-size: .84rem; color: var(--ink-2); }
.who a { font-weight: 600; text-decoration: none; }
.who a:hover { text-decoration: underline; }
.login { min-height: 100svh; display: grid; place-items: center; padding-block: 32px; }
.login .card { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; display: grid; gap: 14px; }
.gbtn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; font: 600 .95rem var(--font-body); border-radius: 8px; padding: 11px 16px; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
.gbtn:hover { filter: brightness(1.06); }
.gbtn svg { width: 18px; height: 18px; background: #fff; border-radius: 50%; padding: 2px; }
