:root {
  --bg: #050607;
  --bg-2: #0a0b0c;
  --panel: #0d0e0f;
  --panel-2: #131415;
  --panel-3: #1a1b1c;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f5f2ee;
  --soft: #d9d4ce;
  --muted: #a9a39c;
  --dim: #6f6962;
  --red: #ff0000;
  --red-2: #ff3b30;
  --red-line: rgba(255, 0, 0, 0.45);
  --hope: #ffc05f;
  --pain: #ff3b30;
  --fear: #ff7a18;
  --barrier: #d9d4ce;
  --ok: #7ed492;
  --radius: 16px;
  --font: "Satoshi", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --side-w: 272px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--bg); }
body {
  margin: 0;
  background:
    radial-gradient(ellipse at 85% -10%, rgba(255, 0, 0, 0.09), transparent 36rem),
    linear-gradient(180deg, #070809 0%, var(--bg) 50%);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
code { font-family: var(--mono); font-size: 0.9em; color: var(--soft); }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-2);
  background: transparent; font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s; white-space: nowrap;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.04); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-2); border-color: var(--red-2); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.danger:hover { border-color: var(--red-line); color: var(--red-2); }
input, textarea, select {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; outline: none; transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--red-line); }
input::placeholder, textarea::placeholder { color: var(--dim); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.link { background: none; border: 0; padding: 0; font-weight: 700; font-size: 13px; color: var(--c, var(--red-2)); cursor: pointer; }
.link:hover { text-decoration: underline; }
.icon-btn { background: none; border: 1px solid var(--line-2); border-radius: 10px; width: 38px; height: 38px; font-size: 18px; cursor: pointer; }

/* ---------- shell ---------- */
body.chat { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100dvh; overflow: hidden; }
.side {
  display: flex; flex-direction: column; min-height: 0; height: 100dvh;
  background: rgba(8, 9, 10, 0.92); border-right: 1px solid var(--line);
}
.side-top { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.side-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.side-brand img { height: 26px; width: auto; display: block; }
.side-brand span { font-weight: 900; font-size: 17px; letter-spacing: -0.02em; padding-left: 10px; border-left: 1px solid var(--line-2); }
.new-chat { width: 100%; }
.side-label { padding: 6px 18px; font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.side-list { flex: 1; min-height: 0; overflow: auto; padding: 0 8px 12px; }
.chat-item { position: relative; display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 10px; padding: 9px 34px 9px 10px; cursor: pointer; }
.chat-item:hover, .chat-item.on { background: rgba(255, 255, 255, 0.05); }
.chat-item.on { box-shadow: inset 2px 0 0 var(--red); }
.chat-item b { display: block; font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item small { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); }
.chat-item .del { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); opacity: 0; background: none; border: 0; color: var(--dim); font-size: 16px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.chat-item:hover .del, .chat-item:focus-within .del { opacity: 1; }
.chat-item .del:hover { color: var(--red-2); background: rgba(255, 255, 255, 0.06); }
.side-empty { padding: 10px 12px; font-size: 13px; color: var(--dim); }
.side-foot { padding: 12px 8px 16px; border-top: 1px solid var(--line); }
.side-link { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; border-radius: 10px; padding: 10px; font-size: 13.5px; font-weight: 700; color: var(--soft); cursor: pointer; text-align: left; }
.side-link:hover { background: rgba(255, 255, 255, 0.05); }
.key-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.key-dot.on { background: var(--ok); }
.spin { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--red); border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.side-scrim { display: none; }
.mobile-bar { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
.thread { flex: 1; min-height: 0; overflow-y: auto; }
.thread-inner { max-width: 1000px; margin: 0 auto; padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 22px; }
.main.empty { justify-content: center; }
.main.empty .thread { flex: none; overflow: visible; }

/* ---------- empty state ---------- */
.hero { max-width: 820px; margin: 0 auto; padding: 0 28px 22px; text-align: center; }
.hero .mark { height: 46px; width: auto; display: inline-block; margin-bottom: 18px; }
.hero h1 { font-size: clamp(30px, 4.2vw, 50px); line-height: 1.03; letter-spacing: -0.04em; font-weight: 900; }
.hero p { color: var(--muted); margin: 12px auto 0; max-width: 60ch; }
.suggest { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 26px; text-align: left; }
.suggest button { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; cursor: pointer; font-size: 14px; color: var(--soft); line-height: 1.4; transition: border-color .15s, background .15s; }
.suggest button:hover { border-color: var(--red-line); background: var(--panel-2); color: var(--text); }
.suggest button b { display: block; color: var(--text); font-size: 13px; margin-bottom: 3px; }

/* ---------- composer ---------- */
.composer-wrap { padding: 8px 28px 16px; max-width: 1000px; width: 100%; margin: 0 auto; }
.main.empty .composer-wrap { max-width: 820px; }
.composer {
  display: flex; align-items: flex-end; gap: 10px; padding: 10px 10px 10px 18px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  transition: border-color .15s;
}
.composer:focus-within { border-color: var(--red-line); }
.composer textarea { border: 0; background: transparent; padding: 9px 0; resize: none; max-height: 220px; font-size: 16px; line-height: 1.45; }
.composer textarea:focus { border: 0; }
.send { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--red); color: #fff; display: grid; place-items: center; cursor: pointer; transition: background .15s, opacity .15s; }
.send:hover { background: var(--red-2); }
.send:disabled { opacity: .35; cursor: not-allowed; }
.composer-opts { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--bg-2); }
.seg button { border: 0; background: none; border-radius: 999px; padding: 5px 13px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--text); color: var(--bg); }
.src-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.chip-toggle { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: none; border-radius: 999px; padding: 4px 10px; font-size: 12.5px; font-weight: 700; color: var(--dim); cursor: pointer; }
.chip-toggle::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.chip-toggle.on { color: var(--soft); border-color: rgba(255, 255, 255, 0.24); }
.chip-toggle.on::before { background: var(--red); }
.chip-toggle.nokey { border-style: dashed; opacity: .5; }
.chip-toggle.nokey::after { content: "key"; font-size: 10px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.hint { margin: 8px 4px 0; font-size: 12px; color: var(--dim); text-align: center; }

/* ---------- messages ---------- */
.msg-user { align-self: flex-end; max-width: min(78%, 720px); background: var(--panel-3); border: 1px solid var(--line); border-radius: 20px 20px 6px 20px; padding: 12px 18px; font-size: 15.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-ai { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--panel-3); border: 1px solid var(--line-2); display: grid; place-items: center; }
.avatar img { width: 24px; height: auto; }
.ai-body { min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.card { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 20px; font-weight: 900; }
.sub { color: var(--muted); font-size: 13px; }

.plan { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.plan-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.plan-row > span:first-child { color: var(--dim); font-weight: 700; min-width: 112px; }
.kw { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); font-weight: 700; font-size: 12.5px; }
.kw.new { border-color: var(--red-line); }
.kw.new::before { content: "+"; color: var(--red-2); }

.steps-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.step { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start; font-size: 14px; color: var(--dim); }
.step .ico { width: 18px; height: 18px; display: grid; place-items: center; margin-top: 2px; }
.step.done { color: var(--soft); }
.step.done .ico::before { content: "✓"; color: var(--ok); font-weight: 900; font-size: 13px; }
.step.wait .ico::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--panel-3); border: 1px solid var(--line-2); }
.step.now { color: var(--text); font-weight: 700; }
.step.now .ico .spin { width: 14px; height: 14px; }
.step .detail { display: block; font-weight: 500; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.counts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.count { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); color: var(--soft); font-variant-numeric: tabular-nums; }
.count i { font-style: normal; color: var(--dim); font-weight: 500; }
.bar { height: 6px; border-radius: 99px; background: var(--panel-3); overflow: hidden; margin-top: 8px; max-width: 420px; }
.bar i { display: block; height: 100%; width: var(--w, 0%); background: var(--c, var(--red)); transition: width .4s; }
details.log { margin-top: 14px; }
details.log summary { cursor: pointer; font-size: 12.5px; color: var(--dim); }
.log-lines { margin-top: 8px; max-height: 220px; overflow: auto; font: 12px/1.6 var(--mono); color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.log-lines .warn { color: var(--fear); }
.log-lines .error { color: var(--red-2); }
.err { color: var(--red-2); font-weight: 700; }

.answer-head { font-size: 16px; line-height: 1.55; color: var(--soft); }
.answer-head b { color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 8px 2px -4px; flex-wrap: wrap; }
.section-title h2 { font-size: clamp(22px, 2.4vw, 30px); font-weight: 900; letter-spacing: -0.03em; }

/* ---------- market language ---------- */
.b-hopes_dreams { --c: var(--hope); }
.b-pains, .b-pains_fears { --c: var(--pain); }
.b-fears { --c: var(--fear); }
.b-barriers_uncertainties { --c: var(--barrier); }
.b-none { --c: var(--dim); }
.vblock { border-top: 3px solid var(--c); }
.vblock .card-head h2 { display: flex; align-items: center; gap: 10px; font-size: 24px; }
.vblock .dot { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.vlist { list-style: none; margin: 0; padding: 0; }
.vitem { display: grid; grid-template-columns: 50px minmax(0, 1fr); gap: 4px 14px; padding: 20px 0; border-top: 1px solid var(--line); }
.vitem:first-child { border-top: 0; padding-top: 4px; }
.vnum { font-size: 28px; font-weight: 900; color: var(--c); letter-spacing: -0.03em; line-height: 1; padding-top: 4px; font-variant-numeric: tabular-nums; }
.vhead { margin: 0; font-size: clamp(17px, 1.6vw, 21px); line-height: 1.35; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.vmeta { margin-top: 8px; font-size: 13px; color: var(--muted); }
.vmeta b { color: var(--text); }
.vrest { list-style: none; margin: 12px 0 0; padding: 0 0 0 14px; border-left: 2px solid color-mix(in srgb, var(--c) 45%, transparent); display: flex; flex-direction: column; gap: 9px; }
.vrest li { font-size: 14px; color: var(--soft); line-height: 1.5; overflow-wrap: anywhere; }
.src-line { font-size: 12px; color: var(--dim); }
.src-line a { color: var(--muted); text-decoration: none; }
.src-line a:hover { color: var(--text); text-decoration: underline; }
.stars { color: var(--hope); letter-spacing: 1px; }
.vrest .src-line { margin-left: 4px; }
.vfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.grouped { font-size: 12px; color: var(--dim); }
.empty-note { padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 12px; }

.vgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.vgroup { border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); padding: 16px; min-width: 0; }
.vgroup-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.vgroup-head h3 { font-size: 15px; font-weight: 900; }
.terms { list-style: none; margin: 0; padding: 0; }
.term { padding: 10px 0; border-top: 1px solid var(--line); }
.term:first-child { border-top: 0; }
.vgroup:not(.all) .term.extra { display: none; }
.term-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.term-name { background: none; border: 0; padding: 0; font-weight: 900; font-size: 15px; color: var(--text); cursor: pointer; text-align: left; }
.term-name:hover { color: var(--red-2); text-decoration: underline; }
.exp { font-size: 13px; color: var(--soft); }
.used { margin-left: auto; font-size: 12px; color: var(--dim); white-space: nowrap; }
.term-ex { margin-top: 4px; font-size: 13px; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.vgroup .link { margin-top: 10px; }
mark { background: rgba(255, 0, 0, 0.22); color: var(--text); border-radius: 3px; padding: 0 2px; }
mark.snip { background: color-mix(in srgb, var(--c, var(--red)) 22%, transparent); }

/* ---------- angles & extras ---------- */
.jump { display: flex; flex-wrap: wrap; gap: 6px; position: sticky; top: 0; z-index: 5; padding: 8px 0; background: linear-gradient(180deg, var(--bg) 70%, transparent); }
.jump a { font-size: 12.5px; font-weight: 700; text-decoration: none; padding: 5px 11px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--soft); background: var(--bg-2); }
.jump a:hover { border-color: var(--red-line); color: var(--text); }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.plain-list li { font-size: 14px; color: var(--soft); line-height: 1.5; padding-left: 14px; border-left: 2px solid color-mix(in srgb, var(--c, var(--line-2)) 55%, transparent); overflow-wrap: anywhere; }
.plain-list.bad li { border-left-color: var(--pain); }
.plain-list.good li { border-left-color: var(--ok); }
.plain-list.bad + .plain-list.good { margin-top: 12px; }
.plan-note { font-size: 14px; color: var(--soft); line-height: 1.55; }
.plan-note b { color: var(--text); }
.angles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.angle { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.angle-top { display: flex; align-items: flex-start; gap: 12px; }
.angle-n { font-size: 22px; font-weight: 900; color: var(--c); line-height: 1; }
.angle-name { flex: 1; min-width: 0; }
.angle-name b { display: block; font-size: 15px; line-height: 1.3; }
.angle-name small { font-size: 12px; color: var(--muted); }
.temp { font-size: 11px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line-2); white-space: nowrap; }
.temp.t-cold { color: #8ec5ff; border-color: rgba(142, 197, 255, .4); }
.temp.t-warm { color: var(--hope); border-color: rgba(255, 192, 95, .4); }
.temp.t-hot { color: var(--red-2); border-color: var(--red-line); }
.ad { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.ad-label { font-size: 10.5px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.ad-head { font-size: 16.5px; font-weight: 700; line-height: 1.35; margin-bottom: 12px; overflow-wrap: anywhere; }
.ad-body p { margin: 0 0 8px; font-size: 14px; color: var(--soft); line-height: 1.5; overflow-wrap: anywhere; }
.cta-pair { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.cta-yes { background: var(--red); color: #fff; font-weight: 800; font-size: 13.5px; padding: 8px 14px; border-radius: 999px; }
.cta-no { font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.angle-want { margin: 0; font-size: 13.5px; color: var(--soft); line-height: 1.5; }
.angle-want .lbl, .angle-words > .lbl { display: block; font-size: 10.5px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-bottom: 3px; }
.angle-words { display: flex; flex-wrap: wrap; gap: 6px; }
.angle-words > .lbl { width: 100%; }
.angle-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; }
.comp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.comp .card-head { margin-bottom: 10px; }
.stories { display: flex; flex-direction: column; gap: 10px; }
.story { padding: 14px 18px; border-left: 3px solid var(--c); }
.story summary { cursor: pointer; font-size: 14px; line-height: 1.5; }
.story summary b { color: var(--text); margin-right: 6px; }
.story p { white-space: pre-line; font-size: 14px; color: var(--soft); line-height: 1.6; margin: 12px 0 0; }

.h3 { font-size: 16px; font-weight: 900; margin: 0; }
.search-q li { border-left-color: var(--c, var(--line-2)); }
.search-q li b { color: var(--text); font-weight: 700; }
.search-q .pill { margin-left: 6px; }
.b-neutral { --c: var(--dim); }
.sgroups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sgroup h3 { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 900; margin: 0 0 8px; }
.sgroup h3 small { color: var(--dim); font-weight: 700; }
.sgroup .dot { width: 9px; height: 9px; border-radius: 3px; background: var(--c); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; padding: 5px 11px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); font-size: 13px; color: var(--soft); }

.lp-form { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.lp-label { font-size: 13px; font-weight: 700; color: var(--soft); margin-top: 8px; }
.lp-form .seg { align-self: flex-start; }
.lp-page { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; flex-wrap: wrap; padding: 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--bg-2); margin: 12px 0; }
.lp-page > div:first-child { flex: 1; min-width: 240px; }
.lp-checks { font-size: 13px; color: var(--soft); margin: 6px 0; }
.lp-fills summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.lp-fills ul { font-size: 13px; color: var(--soft); margin: 8px 0 0; padding-left: 18px; max-height: 220px; overflow: auto; }
.lp-progress { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-weight: 700; }
.fill-demo { background: #fff3b0; color: #3b3200; border-radius: 4px; padding: 0 5px; font-weight: 700; }

/* ---------- HALO table ---------- */
.halo-wrap { overflow-x: auto; }
table.halo { width: 100%; min-width: 860px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.halo thead th { background: var(--red); color: #fff; font-weight: 900; font-size: 13px; text-align: center; padding: 12px 10px; border-right: 1px solid rgba(0, 0, 0, 0.25); }
.halo thead th:first-child { background: var(--panel-3); color: var(--text); text-align: left; padding-left: 16px; border-radius: 12px 0 0 0; width: 16%; }
.halo thead th:last-child { border-radius: 0 12px 0 0; border-right: 0; width: 14%; }
.halo tbody th, .halo tbody td { border-top: 1px solid var(--line); border-right: 1px solid var(--line); vertical-align: top; }
.halo tbody th { text-align: left; padding: 16px; background: var(--panel-2); border-left: 1px solid var(--line); }
.halo tbody th .lbl { display: block; font-size: 17px; font-weight: 900; line-height: 1.15; }
.halo tbody th .cnt { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.halo tbody th::before { content: ""; display: block; width: 26px; height: 4px; border-radius: 4px; background: var(--c); margin-bottom: 12px; }
.halo tbody tr:last-child th { border-radius: 0 0 0 12px; border-bottom: 1px solid var(--line); }
.halo tbody tr:last-child td { border-bottom: 1px solid var(--line); }
.halo tbody tr:last-child td:last-child { border-radius: 0 0 12px 0; }
.halo td { padding: 0; background: rgba(255, 255, 255, 0.012); }
.cell { display: block; width: 100%; height: 100%; text-align: left; background: none; border: 0; padding: 14px; cursor: pointer; }
.cell:hover { background: rgba(255, 255, 255, 0.035); }
.cell .t { display: block; font-weight: 900; font-size: 14px; line-height: 1.25; }
.cell .m { display: block; font-size: 12px; color: var(--muted); margin: 5px 0 8px; }
.cell .m b { color: var(--c); }
.cell q { display: block; quotes: "“" "”"; font-size: 12.5px; line-height: 1.45; color: var(--soft); padding: 6px 0 6px 10px; border-left: 2px solid var(--line-2); margin-top: 6px; }
.cell .more { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--c); }
.cell.empty { color: var(--dim); cursor: default; font-size: 13px; }
.scores { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.sc { display: grid; grid-template-columns: 32px 1fr; align-items: center; gap: 2px 8px; }
.sc b { font-size: 23px; font-weight: 900; line-height: 1; grid-row: span 2; }
.sc small { font-size: 11px; color: var(--muted); font-weight: 700; }
.sc .bar { margin-top: 0; }
.halo-note { font-size: 12px; color: var(--dim); margin: 12px 2px 0; }

/* ---------- quotes ---------- */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.q { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); border-left: 3px solid var(--c, var(--line-2)); }
.q-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.q-top .src-name { font-weight: 900; color: var(--text); }
.q-top a { color: var(--muted); text-decoration: none; margin-left: auto; }
.q-top a:hover { color: var(--text); }
.q-title { font-weight: 700; margin-bottom: 3px; }
.q-text { white-space: pre-line; font-size: 14px; color: var(--soft); overflow-wrap: anywhere; }
.q-text.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.q-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); color: var(--muted); }
.pill.bucket { color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.loadmore { margin: 14px auto 0; display: flex; }

/* ---------- dialogs ---------- */
.dlg { padding: 0; border: 1px solid var(--line-2); border-radius: 18px; background: var(--panel); color: var(--text); width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); }
.dlg.wide { width: min(900px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); }
.dlg-inner { padding: 22px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.dlg-head h2 { font-size: 20px; font-weight: 900; }
.dlg .actions { margin-top: 16px; }
.x { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.keyrow { padding: 12px 0; border-top: 1px solid var(--line); }
.keyrow label { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.keyrow small { font-weight: 500; color: var(--muted); }
.keyrow .ok { color: var(--ok); font-weight: 700; }
.key-test { margin: 6px 0 0; font-size: 12.5px; font-weight: 700; color: var(--dim); }
.key-test.pass { color: var(--ok); }
.key-test.fail { color: var(--red-2); }
.key-help { margin: 6px 0 0; font-size: 12.5px; color: var(--dim); line-height: 1.45; }
.key-help a { color: var(--soft); font-weight: 700; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); font-weight: 700; padding: 10px 18px; border-radius: 999px; transition: .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .vgrid, .angles, .comp-grid, .sgroups { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  body.chat { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-102%); transition: transform .2s; }
  body.side-open .side { transform: none; }
  body.side-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 30; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); }
  .mobile-bar img { height: 22px; }
  .main.empty { justify-content: flex-start; }
  .main.empty .thread { flex: 1; display: flex; align-items: center; overflow-y: auto; }
  .thread-inner { padding: 18px 16px; }
  .hero { padding: 0 16px 16px; }
  .suggest { grid-template-columns: minmax(0, 1fr); }
  .suggest button:nth-child(n+3) { display: none; }
  .composer-wrap { padding: 8px 16px 12px; }
  .composer-opts { flex-direction: column; align-items: stretch; }
  .src-chips { justify-content: flex-start; }
  .msg-user { max-width: 90%; }
  .msg-ai { grid-template-columns: minmax(0, 1fr); }
  .avatar { display: none; }
  .card { padding: 16px; }
  .vitem { grid-template-columns: 32px minmax(0, 1fr); gap: 4px 10px; }
  .vnum { font-size: 21px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  table.halo { min-width: 0; }
  .halo thead { display: none; }
  .halo, .halo tbody, .halo tr, .halo th, .halo td { display: block; width: 100%; }
  .halo tbody tr { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 14px; }
  .halo tbody th, .halo tbody td { border: 0; border-top: 1px solid var(--line); border-radius: 0 !important; }
  .halo tbody th { border-top: 0; }
  .halo td[data-label]::before { content: attr(data-label); display: block; padding: 12px 14px 0; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: var(--red); }
}
.lp-head { font-size: 14px; font-weight: 600; margin: 6px 0 0; }
.use-head { font-size: 12px; }
.q-tags .use-head { margin-left: auto; }
