/* Theme: light by default, dark when the computer prefers it, or forced by the switch (html[data-theme]). */
:root {
  color-scheme: light;
  --bg: #f2f4f7;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --ink: #0f1419;
  --ink-2: #333c46;
  --muted: #5b6570;
  --line: #d5dae1;
  --line-2: #e6e9ee;
  --accent: #0f7a5f;
  --accent-ink: #ffffff;
  --accent-soft: #e2f4ee;
  --fire: #e2561f;
  --fire-2: #c64514;
  --up: #12814f;
  --down: #c8312a;
  --warn: #9a6400;
  --warn-bg: #fff2d6;
  --p1: #0e7a48; --p1-bg: #d9f2e4;
  --p2: #0c6280; --p2-bg: #dbeef6;
  --p3: #8f5d00; --p3-bg: #fbecc9;
  --p4: #4d555d; --p4-bg: #e7e9ec;
  --chip: #edf0f3;
  --side-bg: #0d2b24; --side-ink: #e9f5f1; --side-muted: #9ec2b7; --side-hover: rgba(255,255,255,.08);
  --side-on: rgba(255,255,255,.14); --side-line: rgba(255,255,255,.12); --side-accent: #5fe0b4;
  --tip-bg: #111820; --tip-ink: #f3f6f8;
  --shadow: 0 1px 2px rgba(15, 20, 25, .06), 0 4px 14px rgba(15, 20, 25, .05);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Arabic", "Noto Sans", Tahoma, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1014; --panel: #161a20; --panel-2: #1b2027; --ink: #f2f4f6; --ink-2: #cdd3da; --muted: #9ba5b0;
    --line: #2d343d; --line-2: #232931; --accent: #3fd0a0; --accent-ink: #06140f; --accent-soft: #123328;
    --fire: #f36b33; --fire-2: #ff8250; --up: #4fd18f; --down: #ff6f62; --warn: #f4bb52; --warn-bg: #33270f;
    --p1: #5fdc9f; --p1-bg: #143528; --p2: #63c8e3; --p2-bg: #12303b; --p3: #f4bb52; --p3-bg: #382b12;
    --p4: #aab2ba; --p4-bg: #262c33; --chip: #222830;
    --side-bg: #080a0d; --side-ink: #e8edf1; --side-muted: #8d98a3; --side-hover: rgba(255,255,255,.06);
    --side-on: rgba(63,208,160,.16); --side-line: rgba(255,255,255,.08); --side-accent: #3fd0a0;
    --tip-bg: #f2f4f6; --tip-ink: #0f1419; --shadow: 0 1px 0 rgba(255,255,255,.03);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1014; --panel: #161a20; --panel-2: #1b2027; --ink: #f2f4f6; --ink-2: #cdd3da; --muted: #9ba5b0;
  --line: #2d343d; --line-2: #232931; --accent: #3fd0a0; --accent-ink: #06140f; --accent-soft: #123328;
  --fire: #f36b33; --fire-2: #ff8250; --up: #4fd18f; --down: #ff6f62; --warn: #f4bb52; --warn-bg: #33270f;
  --p1: #5fdc9f; --p1-bg: #143528; --p2: #63c8e3; --p2-bg: #12303b; --p3: #f4bb52; --p3-bg: #382b12;
  --p4: #aab2ba; --p4-bg: #262c33; --chip: #222830;
  --side-bg: #080a0d; --side-ink: #e8edf1; --side-muted: #8d98a3; --side-hover: rgba(255,255,255,.06);
  --side-on: rgba(63,208,160,.16); --side-line: rgba(255,255,255,.08); --side-accent: #3fd0a0;
  --tip-bg: #f2f4f6; --tip-ink: #0f1419; --shadow: 0 1px 0 rgba(255,255,255,.03);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---- top bar ---- */
.top { position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1280px; margin: 0 auto; padding: 0 20px; height: 54px; display: flex; align-items: center; gap: 22px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; }
.logo svg { width: 14px; height: 14px; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--ink-2); padding: 6px 10px; border-radius: 7px; }
.nav a:hover, .nav a.on { background: var(--chip); color: var(--ink); text-decoration: none; }
.top .spacer { flex: 1; }

/* ---- runs dock ---- */
.dock { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.dock:empty { display: none; }
.dock .run { display: flex; align-items: center; gap: 14px; padding: 9px 0; border-top: 1px dashed var(--line); font-size: 13px; }
.dock .run:first-child { border-top: 0; }
.dock .run .name { font-weight: 600; min-width: 140px; }
.dock .run .state { color: var(--ink-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock .run.captcha { background: var(--warn-bg); margin: 0 -20px; padding: 10px 20px; }
.dock .run.captcha .state { color: var(--warn); font-weight: 600; }
.bar { width: 140px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

/* ---- layout ---- */
main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 80px; }
.head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head .grow { flex: 1; min-width: 240px; }
.head .sub { color: var(--muted); margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-b { padding: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

/* ---- buttons & inputs ---- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: 600 13px var(--sans); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--down); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.fire { background: var(--fire); color: #fff; border-color: transparent; height: 38px; padding: 0 18px; font-size: 14px; box-shadow: 0 2px 0 var(--fire-2); }
.btn.fire:hover { background: var(--fire-2); }
.btn.fire svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=number], input[type=time], input[type=password], input[type=url], select, textarea {
  font: 13px var(--sans); color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 9px; width: 100%; }
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-weight: 600; font-size: 12px; margin-bottom: 5px; color: var(--ink-2); }
label.f small { display: block; color: var(--muted); margin-top: 4px; font-size: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.check input { margin-top: 3px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 14px 14px 2px; margin: 0 0 16px; }
legend { padding: 0 6px; font-weight: 700; font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }

/* ---- flash ---- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--panel); }
.flash.ok { border-color: color-mix(in srgb, var(--up) 40%, var(--line)); }
.flash.error { border-color: var(--down); color: var(--down); }

/* ---- project cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.card .t { display: flex; align-items: flex-start; gap: 10px; }
.card .t a.name { font-weight: 700; font-size: 16px; color: var(--ink); }
.card .dom { color: var(--muted); font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.stats div { padding: 9px 10px; border-left: 1px solid var(--line-2); }
.stats div:first-child { border-left: 0; }
.stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; color: var(--muted); }
.card .foot { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.card .foot .meta { flex: 1; font-size: 12px; color: var(--muted); }
.new-card { border-style: dashed; display: grid; place-items: center; min-height: 220px; color: var(--ink-2); cursor: pointer; background: transparent; box-shadow: none; }
.new-card:hover { border-color: var(--accent); color: var(--accent); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--fire); }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---- tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-bottom: 16px; }
@media (max-width: 1000px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { padding: 12px 14px; }
.tile b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile span { font-size: 12px; color: var(--muted); }
.tile.up b { color: var(--up); } .tile.down b { color: var(--down); } .tile.warn b { color: var(--warn); }

/* ---- tabs ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--ink); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ---- tables ---- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--chip) 55%, transparent); }
td.kw { font-weight: 600; max-width: 300px; }
td.kw .loc { font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
tr.paused td { opacity: .5; }
th.c, td.c { text-align: center; }
.url { font-family: var(--mono); font-size: 12px; color: var(--ink-2); word-break: break-all; }
.url a { color: inherit; }

.pos { display: inline-grid; place-items: center; min-width: 38px; height: 26px; padding: 0 7px; border-radius: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos.p1 { background: var(--p1-bg); color: var(--p1); } .pos.p2 { background: var(--p2-bg); color: var(--p2); }
.pos.p3 { background: var(--p3-bg); color: var(--p3); } .pos.p4 { background: var(--p4-bg); color: var(--p4); }
.pos.none { color: var(--muted); background: transparent; border: 1px dashed var(--line); font-weight: 500; font-size: 12px; }
.chg { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }
.chg.up { color: var(--up); } .chg.down { color: var(--down); } .chg.flat { color: var(--muted); font-weight: 400; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 10px; background: var(--chip); font-size: 11px; color: var(--ink-2); margin: 1px 3px 1px 0; white-space: nowrap; }
.chip.warn { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.chip.err { background: color-mix(in srgb, var(--down) 14%, transparent); color: var(--down); }
.chip.tag { background: transparent; border: 1px solid var(--line); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filters button { border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); border-radius: 16px; padding: 4px 11px; font: 12px var(--sans); cursor: pointer; }
.filters button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.search { max-width: 240px; }
.bulk { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 18px; background: var(--chip); border-bottom: 1px solid var(--line); }
.bulk input { width: 150px; height: 28px; padding: 3px 8px; }

/* ---- serp list ---- */
.serp { list-style: none; margin: 0; padding: 0; }
.serp li { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; padding: 9px 18px; border-bottom: 1px solid var(--line-2); align-items: start; }
.serp li.mine { background: color-mix(in srgb, var(--p2-bg) 70%, transparent); }
.serp li.target { background: var(--p1-bg); }
.serp .n { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.serp .ttl { font-weight: 600; }
.serp li.page-break { display: block; padding: 4px 18px; background: var(--line-2); color: var(--muted); font-size: 11px; }

.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart .line { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.tgt, .chart .dot.tgt { stroke: var(--accent); }
.chart .line.dom, .chart .dot.dom { stroke: var(--p2); }
.chart .line.dashed { stroke-dasharray: 5 4; stroke-width: 1.6; opacity: .8; }
.chart .dot { fill: var(--panel); stroke-width: 2; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2.5px solid var(--accent); vertical-align: middle; margin-right: 5px; }
.legend i.dom { border-color: var(--p2); border-top-style: dashed; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 16px; }
.note { background: var(--chip); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 14px; }
.note code, .help code { font-family: var(--mono); font-size: 12px; background: var(--panel); padding: 0 4px; border-radius: 4px; border: 1px solid var(--line); }
pre.code { background: var(--chip); padding: 12px; border-radius: 8px; overflow-x: auto; font: 12px/1.5 var(--mono); margin: 0; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { padding: 8px 12px; border-radius: 7px; color: var(--ink-2); }
.side-nav a.on { background: var(--chip); color: var(--ink); font-weight: 600; }
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: 20px; }
@media (max-width: 760px) { .settings-layout { grid-template-columns: 1fr; } }

/* ---- modal ---- */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--panel); color: var(--ink); width: min(680px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20, 20, 20, .35); }
dialog .panel-h { justify-content: space-between; }

/* ---- chat drawer ---- */
.chat-btn { display: inline-flex; align-items: center; gap: 7px; }
.chat-btn svg { width: 16px; height: 16px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--panel); border-left: 1px solid var(--line);
  z-index: 40; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s ease; box-shadow: -10px 0 40px rgba(0,0,0,.08); }
.drawer.open { transform: none; }
.drawer-h { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer-h .scope { font-size: 12px; color: var(--muted); }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--chip); border-bottom-left-radius: 4px; }
.msg.assistant p { margin: 0 0 6px; } .msg.assistant p:last-child { margin: 0; }
.msg.assistant ul { margin: 4px 0; padding-left: 18px; }
.msg.assistant table { font-size: 12px; margin: 6px 0; } .msg.assistant td, .msg.assistant th { padding: 4px 6px; position: static; }
.msg.error { align-self: stretch; background: transparent; border: 1px solid var(--down); color: var(--down); font-size: 13px; }
.msg .used { font-size: 11px; color: var(--muted); margin-top: 6px; }
.msg.thinking { color: var(--muted); }
.chat-in { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 8px; align-items: flex-end; }
.chat-in textarea { min-height: 42px; max-height: 160px; height: 42px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest button { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 5px 10px; font: 12px var(--sans); color: var(--ink-2); cursor: pointer; text-align: left; }
.suggest button:hover { border-color: var(--accent); color: var(--accent); }

[dir=auto] { unicode-bidi: plaintext; }

/* ---- accounts ---- */
.who { display: flex; flex-direction: column; line-height: 1.15; color: var(--ink); font-weight: 600; font-size: 13px; text-align: right; }
.who span { font-weight: 400; font-size: 11px; color: var(--muted); }
.who:hover { text-decoration: none; color: var(--accent); }
.auth { max-width: 400px; margin: 8vh auto 0; }
.auth h1 { margin-bottom: 6px; }
.auth .panel-b { padding: 24px; }
.role { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--chip); }
.role.admin { background: var(--p1-bg); color: var(--p1); }
.role.client { background: var(--p3-bg); color: var(--p3); }
.checks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.checks label { display: flex; gap: 6px; align-items: center; font-size: 13px; }
details.edit > summary { cursor: pointer; color: var(--accent); font-size: 12px; list-style: none; }
details.edit[open] { background: var(--chip); padding: 12px; border-radius: 8px; margin-top: 6px; }
.token { font-family: var(--mono); font-size: 12px; background: var(--chip); padding: 10px; border-radius: 8px; word-break: break-all; }

/* panels inside grids don't stack-space */
.tiles > .panel, .cards > .panel, .grid2 > .panel, .grid2 > div > .panel:first-child { margin-top: 0; }
/* keep mixed Arabic/English text aligned with the layout */
h1[dir=auto], td.kw [dir=auto], .serp .ttl, .serp .url, .msg[dir=auto] { text-align: left; }
.msg.user[dir=auto] { text-align: right; }

@media (max-width: 760px) {
  .top-in { height: auto; flex-wrap: wrap; gap: 8px 10px; padding: 10px 16px; }
  .brand { white-space: nowrap; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .who { display: none; }
  main { padding: 16px 16px 60px; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile b { font-size: 18px; }
  .search { max-width: none; }
  .dock { padding: 0 16px; }
  .dock .run .name { min-width: 0; }
  .dock .bar { display: none; }
}

.chip.ok { background: var(--p1-bg); color: var(--p1); font-weight: 600; }
.btn.fire.ai { background: var(--accent); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 70%, black); }
.btn.fire.ai:hover { background: color-mix(in srgb, var(--accent) 85%, black); }
.rate { display: inline-flex; flex-direction: column; align-items: center; min-width: 74px; padding: 4px 6px; border-radius: 8px; font-size: 11px; line-height: 1.3; color: var(--muted); }
.rate b { font-size: 14px; font-variant-numeric: tabular-nums; }
.rate.hi { background: var(--p1-bg); } .rate.hi b { color: var(--p1); }
.rate.mid { background: var(--p3-bg); } .rate.mid b { color: var(--p3); }
.rate.lo { background: var(--chip); } .rate.lo b { color: var(--ink-2); }
.rate.off { opacity: .45; }
.answer { white-space: pre-wrap; line-height: 1.65; font-size: 13.5px; }
.answer mark { background: var(--p3-bg); color: inherit; padding: 0 2px; border-radius: 3px; }
.cites { list-style: none; margin: 0; padding: 0; }
.cites li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.cites li.own { background: var(--p1-bg); margin: 0 -18px; padding: 7px 18px; }
.cites .n { color: var(--muted); font-weight: 700; text-align: right; }
.engine-tabs { display: flex; gap: 6px; flex-wrap: wrap; }

/* ================= v3 layout: sidebar + project nav ================= */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px; gap: 10px; z-index: 25; }
.side .brand { padding: 4px 8px 10px; font-size: 15px; }
.side svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side-nav-main { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav-main > a, .side-projects a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.side-nav-main > a:hover, .side-projects a:hover { background: var(--chip); color: var(--ink); text-decoration: none; }
.side-nav-main > a.on { background: var(--chip); color: var(--ink); font-weight: 650; }
.side-projects { display: flex; flex-direction: column; gap: 1px; margin: 0 0 6px 18px; padding-left: 8px; border-left: 1px solid var(--line); }
.side-projects a { padding: 5px 8px; font-size: 13px; }
.side-projects a .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-projects a.on { color: var(--accent); font-weight: 650; }
.dot-av { width: 18px; height: 18px; border-radius: 5px; background: var(--chip); color: var(--ink-2); font-size: 10px; font-weight: 700; display: grid; place-items: center; flex: none; }
.side-projects a.on .dot-av { background: var(--accent); color: var(--accent-ink); }
.side-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.side-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); font: 600 13px var(--sans); cursor: pointer; }
.side-btn:hover { border-color: var(--accent); color: var(--accent); }
.side-btn.sm { border: 0; padding: 6px 8px; color: var(--muted); font-weight: 500; width: auto; }
.side-user { display: flex; align-items: center; gap: 6px; padding: 0 2px 0 10px; }
.side-user .label { flex: 1; min-width: 0; line-height: 1.2; }
.side-user b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user small { color: var(--muted); font-size: 11px; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.main-col .dock { position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); max-width: none; padding: 0 28px; }
.main-col .dock:empty { display: none; border: 0; }
.main-col main { max-width: 1320px; width: 100%; margin: 0; padding: 22px 28px 80px; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 64px 1fr; }
  .side .label, .side-projects { display: none; }
  .side { padding: 14px 8px; align-items: center; }
  .side-nav-main > a, .side-btn { justify-content: center; padding: 9px; }
  .side-user { padding: 0; }
}
@media (max-width: 640px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: sticky; height: auto; flex-direction: row; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .side .brand { display: none; }
  .side-nav-main { flex-direction: row; flex: 1; }
  .side-foot { flex-direction: row; border: 0; padding: 0; }
  .main-col main { padding: 16px 14px 60px; }
}

.crumb { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.crumb a { color: var(--muted); }
.phead { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.phead .grow { flex: 1; min-width: 260px; }
.phead .sub { color: var(--muted); margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; }
.pactions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.role-badge { display: inline-block; vertical-align: middle; font-size: 11px; font-weight: 600; color: var(--ink-2); background: var(--chip);
  border-radius: 10px; padding: 1px 8px; letter-spacing: 0; }
h1 .role-badge { margin-left: 6px; }
.pnav { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.pnav a { padding: 10px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.pnav a.on { color: var(--ink); border-color: var(--accent); font-weight: 650; }
.pnav a:hover { text-decoration: none; color: var(--ink); }

.checkbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 16px; margin-bottom: 16px; }
.checkbar label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.checkbar select { width: auto; max-width: 280px; }
.grow { flex: 1; }
.tile b small { font-size: 14px; }
.tile em { font-style: normal; font-weight: 700; margin-left: 4px; font-size: 12px; }
.tile span small { font-size: 11px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 16px; }
@media (max-width: 1100px) { .grid3 { grid-template-columns: 1fr; } }
.grid3 > .panel { margin-top: 0; }
.dist { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut-n { font: 700 24px var(--sans); fill: var(--ink); }
.donut-l { font: 11px var(--sans); fill: var(--muted); }
.legend-t { width: auto; flex: 1; }
.legend-t td, .legend-t th { padding: 4px 6px; position: static; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }
.sw-top3 { background: var(--p1); } .sw-p1 { background: var(--p2); } .sw-p2 { background: var(--p3); } .sw-p3 { background: var(--p4); } .sw-nr { background: var(--line); }
table.compact td, table.compact th { padding: 7px 10px; }
tr.sel td { background: var(--chip); }
.chip.auto { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.sovbar { position: relative; height: 18px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.sovbar i { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--p2) 55%, transparent); }
.sovbar span { position: relative; font-size: 11.5px; font-weight: 700; padding-left: 6px; line-height: 18px; }
tr.own-row td { background: var(--p1-bg); }
tr.own-row .sovbar i { background: var(--p1); }
.inline-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-edit input[type=text] { width: auto; flex: 1; min-width: 120px; }
.access-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.access-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line-2); }
.sec-list > div { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.sec-list > div:last-child { border-bottom: 0; }
.linkbox { border-color: var(--accent); margin-bottom: 16px; }
.steps { padding-left: 18px; line-height: 1.8; margin-top: 0; }
.btn.wide { width: 100%; justify-content: center; }
.code-input { font: 600 20px var(--mono); letter-spacing: .3em; text-align: center; }
main.bare { max-width: 440px; margin: 0 auto; padding: 8vh 16px 40px; }
.bare-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; margin-bottom: 18px; justify-content: center; }
.auth { margin: 0; }
.auth-flash { margin-bottom: 12px; }
a.card { color: inherit; }
a.card:hover { text-decoration: none; border-color: var(--accent); }
a.card .name { font-weight: 700; font-size: 16px; color: var(--ink); }
.stats em { font-style: normal; font-weight: 700; font-size: 11px; margin-left: 3px; }
.tile b .chg { font-size: inherit; font-weight: 700; }

/* ================= v4: larger, higher-contrast layout ================= */
body { font-size: 15px; line-height: 1.5; }
h1 { font-size: 26px; font-weight: 750; letter-spacing: -.015em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
.small { font-size: 13px; }
.mono, .url { font-size: 13px; }
.panel { border-color: var(--line); }
.panel-h { padding: 14px 18px; background: var(--panel-2); border-radius: var(--radius) var(--radius) 0 0; }
.panel-h h2, .panel-h h3 { display: inline-flex; align-items: center; gap: 6px; }
.head .sub, .phead .sub { color: var(--ink-2); font-size: 14px; }
.crumb, .crumb a { font-size: 13px; color: var(--muted); }

/* sidebar: dark in both themes so navigation always stands out */
.side { background: var(--side-bg); border-right: 0; color: var(--side-ink); }
.side .brand { color: var(--side-ink); font-size: 16px; }
.side .logo { background: var(--side-accent); }
.side .logo svg { stroke: var(--side-bg); }
.side-nav-main > a, .side-projects a { color: var(--side-ink); opacity: .86; font-size: 14.5px; }
.side-nav-main > a:hover, .side-projects a:hover { background: var(--side-hover); color: var(--side-ink); opacity: 1; }
.side-nav-main > a.on { background: var(--side-on); color: #fff; opacity: 1; box-shadow: inset 3px 0 0 var(--side-accent); }
.side-projects { border-left-color: var(--side-line); }
.side-projects a { font-size: 13.5px; }
.side-projects a.on { color: var(--side-accent); opacity: 1; }
.dot-av { background: var(--side-hover); color: var(--side-ink); }
.side-projects a.on .dot-av { background: var(--side-accent); color: var(--side-bg); }
.side-foot { border-top-color: var(--side-line); }
.side-btn { background: transparent; border-color: var(--side-line); color: var(--side-ink); }
.side-btn:hover { border-color: var(--side-accent); color: var(--side-accent); }
.side-btn.sm { color: var(--side-muted); }
.side-user small { color: var(--side-muted); }
.theme-btn .t-sys, .theme-btn .t-light, .theme-btn .t-dark { display: none; }
:root:not([data-theme]) .theme-btn .t-sys, :root[data-theme="light"] .theme-btn .t-light,
:root[data-theme="dark"] .theme-btn .t-dark { display: inline; }
.bare-theme { position: fixed; top: 14px; right: 14px; width: auto; color: var(--ink); border-color: var(--line); background: var(--panel); }

/* project header + nav */
.pnav { gap: 4px; border-bottom: 2px solid var(--line); }
.pnav a { padding: 11px 16px; font-size: 15px; color: var(--ink-2); border-bottom-width: 3px; margin-bottom: -2px; }
.pnav a.on { color: var(--accent); border-color: var(--accent); }
.role-badge { font-size: 12px; padding: 2px 9px; }

/* buttons & inputs */
.btn { height: 38px; font-size: 14px; border-radius: 9px; }
.btn.sm { height: 31px; font-size: 13px; }
.btn.fire { height: 40px; font-size: 15px; }
input[type=text], input[type=number], input[type=time], input[type=password], input[type=url], input[type=email], select, textarea {
  font-size: 14.5px; padding: 8px 10px; border-color: var(--line); border-radius: 8px; }
label.f > span { font-size: 13.5px; color: var(--ink); }
label.f small { font-size: 13px; color: var(--muted); }
legend { font-size: 12.5px; color: var(--ink); }

/* tiles */
.tiles { gap: 12px; }
.tile { padding: 14px 16px 13px; border-top: 3px solid var(--accent); position: relative; }
.tile b { font-size: 30px; font-weight: 750; line-height: 1.15; }
.tile span { font-size: 13.5px; color: var(--ink-2); font-weight: 500; }
.tile em { font-size: 13.5px; }
.tile .info { position: absolute; top: 10px; right: 10px; }
.tile.up { border-top-color: var(--up); } .tile.down { border-top-color: var(--down); } .tile.warn { border-top-color: var(--warn); }

/* tables */
th { font-size: 12px; color: var(--ink-2); font-weight: 700; padding: 11px 14px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
td { padding: 11px 14px; border-bottom-color: var(--line-2); }
tbody tr:hover td { background: var(--accent-soft); }
td.kw { font-weight: 650; }
.pos { min-width: 42px; height: 30px; font-size: 15px; border-radius: 7px; }
.pos.none { font-size: 13px; }
.chg { font-size: 14.5px; }
.chip { font-size: 12.5px; padding: 2px 9px; border-radius: 11px; }
.chip.via { background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.filters button { font-size: 13.5px; padding: 6px 13px; color: var(--ink-2); }
.filters button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.checkbar label { font-size: 13px; color: var(--ink-2); }
.stats b { font-size: 21px; }
.stats span { font-size: 12.5px; color: var(--ink-2); }
.card .dom, .card .meta { font-size: 13px; }
.flash { font-size: 14.5px; padding: 12px 16px; }
.flash.ok { background: var(--accent-soft); border-color: var(--accent); }
.flash.error { background: color-mix(in srgb, var(--down) 10%, var(--panel)); }
.note { font-size: 14px; }
.answer { font-size: 15px; }
.legend { font-size: 13px; color: var(--ink-2); }
.chart .axis { font-size: 12px; }
.donut-l { font-size: 12px; }
.sovbar { height: 20px; } .sovbar span { font-size: 12.5px; line-height: 20px; }

/* info (i) badges and their tooltip */
.info { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--muted); color: var(--muted); font: italic 700 11px/1 Georgia, "Times New Roman", serif;
  cursor: help; vertical-align: middle; margin-left: 5px; user-select: none; text-transform: none; letter-spacing: 0; }
.info:hover, .info:focus-visible, .info.open { border-color: var(--accent); color: var(--accent); outline: none; }
th .info { width: 15px; height: 15px; font-size: 10px; margin-left: 3px; }
.tip { position: fixed; z-index: 100; max-width: 280px; padding: 9px 12px; border-radius: 9px; background: var(--tip-bg); color: var(--tip-ink);
  font: 500 13px/1.45 var(--sans); box-shadow: 0 8px 30px rgba(0,0,0,.25); pointer-events: none; opacity: 0; transition: opacity .12s;
  text-transform: none; letter-spacing: 0; white-space: normal; }
.tip.show { opacity: 1; }

/* users: password generator, copy rows */
.pw-gen { display: flex; gap: 8px; margin: -4px 0 12px 24px; }
.pw-gen input { font-family: var(--mono) !important; }
.btn-row { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.cites.plain li { grid-template-columns: 1fr auto; }
@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .tile b { font-size: 24px; }
  .side-nav-main > a.on { box-shadow: inset 0 -3px 0 var(--side-accent); }
}
/* keep the big keyword tables readable with the larger text */
td.kw { min-width: 210px; }
td.kw .loc { display: flex; flex-wrap: wrap; gap: 2px 0; }
td.url, td .url { word-break: normal; overflow-wrap: anywhere; min-width: 150px; }
#rankTable td, #rankTable th { padding-left: 10px; padding-right: 10px; }
#rankTable td.small { white-space: nowrap; }
.layout { background: linear-gradient(to right, var(--side-bg) 232px, var(--bg) 232px); }
@media (max-width: 1100px) { .layout { background: linear-gradient(to right, var(--side-bg) 64px, var(--bg) 64px); } }
@media (max-width: 640px) { .layout { background: var(--bg); } }
@media (max-width: 640px) {
  .checkbar label { flex-wrap: wrap; width: 100%; }
  .checkbar select { max-width: 100%; width: 100%; min-width: 0; }
  .pw-gen { margin-left: 0; }
}
.grid2 > .panel, .grid3 > .panel { min-width: 0; overflow-x: auto; }
@media (max-width: 640px) { table.compact td, table.compact th { padding: 7px 6px; } }
.drawer:not(.open) { box-shadow: none; visibility: hidden; }
.drawer.open { visibility: visible; }

/* live CAPTCHA solving */
.solve-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .solve-wrap { grid-template-columns: 1fr; } }
.solve-wrap > .panel { margin-top: 0; }
.solve-img { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; min-height: 320px; }
.solve-img img { display: block; width: 100%; height: auto; cursor: crosshair; user-select: none; }
.solve-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.6);
  font-weight: 600; padding: 20px; text-align: center; }
.solve-dot { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  border: 3px solid var(--fire); pointer-events: none; animation: solveping .9s ease-out forwards; }
@keyframes solveping { to { transform: scale(2); opacity: 0; } }
.dock .run .btn.fire { height: 30px; font-size: 13px; padding: 0 12px; box-shadow: none; }

/* CAPTCHA pop-up window: just the live view and controls */
body.popup .layout { grid-template-columns: 1fr; background: var(--bg); }
body.popup .side, body.popup .main-col .dock, body.popup .crumb, body.popup .drawer { display: none !important; }
body.popup .main-col main { max-width: none; padding: 14px 16px 20px; }
body.popup .head { margin-bottom: 12px; }
body.popup h1 { font-size: 20px; }
body.popup .solve-wrap { grid-template-columns: minmax(0, 1fr) 250px; }
@media (max-width: 800px) { body.popup .solve-wrap { grid-template-columns: 1fr; } }

/* desktop app page */
.desk-hero { text-align: center; }
.desk-hero .panel-b { padding: 28px 22px; }
.desk-icon img { border-radius: 18px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.btn.big { height: 46px; padding: 0 22px; font-size: 16px; }
.desk-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--side-accent); margin-left: auto; box-shadow: 0 0 0 3px rgba(95,224,180,.25); }
