:root {
  --bg: #090c12;
  --bg2: #0f141e;
  --card: #121824;
  --card2: #171f2e;
  --line: #212b3e;
  --track: #253044;
  --text: #eef2f8;
  --muted: #8b96ab;
  --accent: #6366f1;
  --accent2: #22d3ee;
  --good: #22c55e;
  --warn: #eab308;
  --orange: #f97316;
  --bad: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fc; --bg2: #ffffff; --card: #ffffff; --card2: #f1f4fa;
    --line: #e3e8f2; --track: #e6ebf4; --text: #0f172a; --muted: #64748b;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .05);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.55; min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -.03em; line-height: 1.15; margin: 0 0 10px; }
h2 { font-size: 20px; letter-spacing: -.02em; margin: 0 0 4px; }
h3 { font-size: 14px; font-weight: 700; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { justify-content: center; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--card2); padding: 1px 5px; border-radius: 5px; }

/* ========================== Top bar ========================== */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -.03em; }

.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tab {
  background: none; border: 0; padding: 7px 12px; border-radius: 8px;
  color: var(--muted); font-weight: 600; font-size: 13px; transition: color .15s, background .15s;
}
.tab:hover { color: var(--text); background: var(--card2); }
.tab.active { color: var(--text); background: var(--card2); box-shadow: inset 0 -2px 0 var(--accent); }

.top-right { display: flex; gap: 8px; align-items: center; }
.top-right select, .compact-input {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12.5px;
}
select option { background: var(--bg2); color: var(--text); }

.live-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 11px; font-weight: 600; font-size: 12px; color: var(--muted);
}
.live-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.live-btn.on { border-color: color-mix(in srgb, var(--good) 50%, var(--line)); color: var(--good); }
.live-btn.on .dot { background: var(--good); animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.65); } 70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }

.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }

.mode-badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); color: var(--muted); }
.mode-badge.proxy { color: var(--good); }
.mode-badge.direct { color: var(--accent2); }

.banner { margin: 12px auto 0; max-width: 1360px; padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--bad) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); font-size: 13px; }

main { flex: 1; padding: 20px 24px 48px; max-width: 1360px; width: 100%; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }
.subpanel { display: none; }
.subpanel.active { display: block; }

/* ========================== Search & Hero ========================== */
.search-bar { display: flex; gap: 8px; }
.search-bar input {
  flex: 1; padding: 13px 16px; font-size: 15px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card); outline: none; transition: border-color .15s, box-shadow .15s;
}
.search-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search-bar select { border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); padding: 0 12px; font-size: 13px; }

.primary {
  background: linear-gradient(135deg, var(--accent), #4f46e5); color: #fff; border: 0;
  border-radius: var(--radius); padding: 10px 20px; font-weight: 600; font-size: 13.5px;
}
.primary:hover { filter: brightness(1.06); }
.primary:disabled { opacity: .6; cursor: wait; }
.ghost, .btn {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; font-size: 12.5px; font-weight: 500; color: var(--text); display: inline-flex; align-items: center; gap: 4px;
}
.ghost:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
.ghost.danger { color: var(--bad); }
.icon { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); }

.hero { text-align: center; padding: 48px 16px 24px; max-width: 820px; margin: 0 auto; }
.hero-kicker { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent2); margin-bottom: 12px; }
.hero-sub { color: var(--muted); font-size: 15px; max-width: 640px; margin: 0 auto 22px; }
.hero-trends { margin-top: 32px; text-align: left; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.quiet-chips { margin: 8px 0 4px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; font-size: 12px; cursor: pointer; color: var(--text); transition: border-color .15s; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: color-mix(in srgb, var(--accent) 20%, var(--card)); border-color: var(--accent); color: var(--text); }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); font-size: 11px; text-align: center; color: var(--muted); }

.progress { margin: 12px 0; }
.progress-bar { height: 4px; background: var(--track); border-radius: 99px; overflow: hidden; }
#progressFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .25s; }
#progressText { margin-top: 5px; }

/* ========================== Layout blocks ========================== */
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 18px 0 14px; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions select { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.seg-btn { background: none; border: 0; padding: 5px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.seg-btn.active { background: var(--card2); color: var(--text); }
.dropdown { display: inline-flex; gap: 4px; }

.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 3px 0 2px; }
.stat .sub { font-size: 12px; color: var(--muted); }

.block { margin-bottom: 18px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.block-head h3 { margin: 0; font-size: 15px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
.split-editor { display: grid; grid-template-columns: minmax(0, 1.25fr) 390px; gap: 16px; align-items: start; }
@media (max-width: 1060px) { .grid-3, .split, .split-editor { grid-template-columns: 1fr; } }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

/* ========================== Picks & Badges ========================== */
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(265px, 1fr)); gap: 10px; }
.pick { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; cursor: pointer; transition: border-color .15s, transform .15s; }
.pick:hover { border-color: var(--accent); transform: translateY(-1px); }
.pick .kw { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.pick .why { font-size: 12px; color: var(--muted); margin-top: 8px; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; }
.b { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--track); white-space: nowrap; }
.b.info { color: #93c5fd; } .b.com { color: #fcd34d; } .b.tra { color: #86efac; } .b.nav { color: #c4b5fd; }
@media (prefers-color-scheme: light) { .b.info { color: #1d4ed8; } .b.com { color: #a16207; } .b.tra { color: #15803d; } .b.nav { color: #6d28d9; } }

/* ========================== Filters & Table ========================== */
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.filters > input[type=search] { width: 100%; max-width: 340px; background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; }
.filters .chips { margin: 0; }
.filter-controls { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.filter-controls select { background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-size: 12.5px; }
.slider { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.slider input { width: 90px; accent-color: var(--accent); }

.table-wrap { overflow-x: auto; }
.kw-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kw-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 8px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; user-select: none; background: var(--card);
}
.kw-table th.sorted.desc::after { content: ' \25BE'; }
.kw-table th.sorted.asc::after { content: ' \25B4'; }
.kw-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.kw-table tbody tr { cursor: pointer; }
.kw-table tbody tr:hover { background: var(--card2); }
.kw-table td.kwc { font-weight: 600; max-width: 360px; }
.kw-table .seed-row td.kwc::before { content: '\2605 '; color: var(--warn); }

.meter { display: flex; align-items: center; gap: 6px; min-width: 82px; }
.meter .track { flex: 1; height: 5px; background: var(--track); border-radius: 99px; overflow: hidden; min-width: 36px; }
.meter .fill { height: 100%; border-radius: 99px; }
.meter b { font-size: 12px; min-width: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.rank-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid currentColor; }
.trend-tag { font-size: 12px; font-weight: 600; white-space: nowrap; }
.trend-Breakout { color: #a855f7; } .trend-Rising { color: var(--good); } .trend-Stable { color: var(--muted); } .trend-Declining { color: var(--orange); } .trend-Unknown { color: var(--muted); opacity: .55; }
.engines { display: flex; gap: 2px; }
.eng { font-size: 10px; font-weight: 700; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; background: var(--track); color: var(--muted); }
.eng.on { background: color-mix(in srgb, var(--accent) 32%, var(--card)); color: var(--text); }
.opp { font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }

/* ========================== Charts ========================== */
.chart { min-height: 210px; }
.chart-wrap { position: relative; }
.chart svg .grid { stroke: var(--line); stroke-width: 1; }
.chart svg .axis { fill: var(--muted); font-size: 10px; }
.chart svg .marker { stroke: var(--warn); stroke-dasharray: 3 3; }
.chart svg .hover-line { stroke: var(--muted); stroke-dasharray: 2 2; }
.chart-tip { position: absolute; top: 6px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12px; pointer-events: none; min-width: 150px; box-shadow: var(--shadow); z-index: 5; }
.chart-tip i, .chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.chart-empty { display: flex; align-items: center; justify-content: center; min-height: 150px; color: var(--muted); font-size: 13px; text-align: center; padding: 14px; border: 1px dashed var(--line); border-radius: 10px; }
.trends-embed iframe { width: 100%; height: 320px; border: 0; border-radius: 8px; background: #fff; }
.gauge { width: 100%; max-width: 118px; }
.gauge-v { font-size: 20px; font-weight: 800; fill: var(--text); }
.gauge-l { font-size: 7px; fill: var(--muted); }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 56px; gap: 8px; align-items: center; font-size: 12px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 7px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; }
.bar-val { text-align: right; color: var(--muted); }

/* ========================== Live & Buzz ========================== */
.live-list { display: flex; flex-direction: column; max-height: 440px; overflow-y: auto; }
.live-item { display: flex; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.live-item:last-child { border-bottom: 0; }
.live-item .rk { font-weight: 700; color: var(--muted); min-width: 20px; font-size: 12px; padding-top: 1px; }
.live-item .body { flex: 1; min-width: 0; }
.live-item .t { font-weight: 600; font-size: 13px; }
.live-item .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.live-item .go { font-size: 11.5px; white-space: nowrap; }
.live-item.new { animation: flash 2s; }
@keyframes flash { from { background: color-mix(in srgb, var(--good) 22%, transparent); } to { background: transparent; } }

.buzz { display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; }
.buzz-item { font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.buzz-item:last-child { border-bottom: 0; }
.buzz-item .s { font-size: 11.5px; color: var(--muted); }

/* ========================== Clusters ========================== */
.cluster { margin-bottom: 12px; }
.cluster-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.cluster ol { margin: 8px 0 0; padding-left: 20px; }
.cluster li { padding: 3px 0; cursor: pointer; }
.cluster li:hover { color: var(--accent2); }
.pillar-tag { font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--warn); margin-right: 6px; }

/* ========================== AEO / GEO / Optimize ========================== */
.q-group { margin-bottom: 10px; }
.q-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; display: flex; justify-content: space-between; }
.q-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 7px; padding: 6px 8px; font-size: 13px; color: var(--text); }
.q-item:hover { background: var(--card2); }
.q-item.active { background: color-mix(in srgb, var(--accent) 20%, var(--card)); font-weight: 600; }

.editor-area {
  width: 100%; min-height: 460px; resize: vertical;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; font-family: inherit; font-size: 14px; line-height: 1.65; outline: none;
}
.editor-area:focus { border-color: var(--accent); }
.small-area { width: 100%; min-height: 120px; resize: vertical; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.55; outline: none; }
.small-area:focus { border-color: var(--accent); }

.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; align-items: flex-start; }
.check-list li:last-child { border-bottom: 0; }
.chk { width: 17px; height: 17px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; flex-shrink: 0; margin-top: 1px; }
.chk.ok { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.chk.no { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }

.fix-item { padding: 8px 10px; border-radius: 8px; background: var(--card2); border-left: 3px solid var(--orange); margin-bottom: 6px; font-size: 12.5px; }
.fix-item.high { border-left-color: var(--bad); }
.fix-item .area { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* ========================== Drawer ========================== */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(860px, 100vw); background: var(--bg); border-left: 1px solid var(--line); z-index: 40; transform: translateX(100%); transition: transform .22s ease; overflow-y: auto; box-shadow: var(--shadow); }
.drawer.open { transform: none; }
.drawer-inner { padding: 20px 24px 60px; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer-head h2 { font-size: 22px; }
.drawer-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 16px; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .48); z-index: 30; }

.gauges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.gauges .g { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-align: center; }
.gauges .g .t { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.gauges .g .x { font-size: 12px; font-weight: 700; margin-top: 2px; }
@media (max-width: 640px) { .gauges { grid-template-columns: repeat(2, 1fr); } }

.verdict { border-radius: var(--radius); padding: 13px 16px; margin-bottom: 14px; border: 1px solid; }
.verdict h3 { margin: 0 0 4px; font-size: 15px; }
.verdict ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }

.evidence { list-style: none; padding: 0; margin: 0; }
.evidence li { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; align-items: flex-start; }
.evidence .str { font-size: 10px; font-weight: 800; text-transform: uppercase; min-width: 54px; padding-top: 2px; }
.str.strong { color: var(--good); } .str.medium { color: var(--warn); } .str.info { color: var(--muted); }
.evidence a { white-space: nowrap; font-size: 12px; margin-left: auto; padding-left: 8px; }
.parts { font-size: 12.5px; width: 100%; border-collapse: collapse; }
.parts td { padding: 4px 6px; border-bottom: 1px dashed var(--line); }
.parts td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.serp-table td.weak { color: var(--good); font-weight: 700; }
.tips { padding-left: 18px; margin: 0; }
.tips li { margin-bottom: 6px; }
pre.brief { white-space: pre-wrap; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 12px; max-height: 380px; overflow: auto; }

/* ========================== Settings & Misc ========================== */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin: 10px 0; }
.field input, .field select { background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; color: var(--text); }
.src-row { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.src-row .st { font-size: 11.5px; font-weight: 700; }
.st.ok { color: var(--good); } .st.bad { color: var(--bad); } .st.off, .st.idle { color: var(--muted); }

.prose { max-width: 800px; }
.prose p, .prose li { opacity: .92; }
.prose h3 { margin-top: 20px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 16px; z-index: 60; box-shadow: var(--shadow); font-size: 13px; }
.foot { text-align: center; padding: 18px; border-top: 1px solid var(--line); }
.spin { display: inline-block; width: 11px; height: 11px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: sp .75s linear infinite; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }
