:root {
  /* Creative AdBundance palette (from the CAB brand mark in AdBundance OS) */
  --bg: #f6f5fb;
  --panel: #ffffff;
  --ink: #0a2540;          /* CAB navy */
  --muted: #5b6478;
  --line: #e3e1ef;
  --accent: #6b47ff;       /* CAB violet */
  --accent-2: #a78bfa;     /* gradient end */
  --accent-deep: #4a2fcc;
  --accent-ink: #ffffff;
  --accent-soft: #ede7ff;
  --accent-line: #c9b8ff;
  --ok: #188038;
  --ok-soft: #e6f4ea;
  --warn: #b06000;
  --warn-soft: #fef7e0;
  --err: #c5221f;
  --err-soft: #fce8e6;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1424; --panel: #111d31; --ink: #e8ebf3; --muted: #9aa3b8; --line: #24324b;
    --accent: #8b6dff; --accent-2: #b9a2ff; --accent-deep: #c9b8ff; --accent-ink: #ffffff; --accent-soft: #241b4d; --accent-line: #4a3a99;
    --ok: #5bd88a; --ok-soft: #12301f; --warn: #f5b84a; --warn-soft: #33270f; --err: #f28b82; --err-soft: #3a1716;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 24px 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
p { margin: 0 0 10px; }
code, pre, textarea.code { font-family: var(--mono); font-size: 12.5px; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; background: var(--panel); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; padding: 0 8px 16px; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, #6b47ff, #a78bfa); color: #fff; font-weight: 800; font-size: 11px; display: grid; place-items: center; letter-spacing: -.02em; }
.side a.nav { color: var(--ink); padding: 7px 10px; border-radius: 7px; display: block; }
.side a.nav:hover { background: var(--bg); text-decoration: none; }
.side a.nav.on { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.side .sect { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 14px 10px 4px; }
.side .me { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.main { padding: 28px 32px; min-width: 0; }
.main.full { padding: 0; display: flex; flex-direction: column; height: 100vh; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.sub { color: var(--muted); }

.btn { border-radius: 999px !important; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 12px; border-radius: 8px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.danger { color: var(--err); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 90px; resize: vertical; }
textarea.code { min-height: 260px; white-space: pre; tab-size: 2; }
label { display: block; font-weight: 550; margin: 12px 0 4px; }
label .hint { font-weight: 400; color: var(--muted); }
.field-inline { display: flex; gap: 8px; align-items: center; }
.field-inline input, .field-inline select { width: auto; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tool-card { display: flex; flex-direction: column; gap: 8px; color: var(--ink); }
.tool-card:hover { border-color: var(--accent-line); box-shadow: 0 4px 18px rgba(107,71,255,.12); text-decoration: none; }
.tool-card .name { font-weight: 620; font-size: 15px; }
.tool-card .desc { color: var(--muted); flex: 1; }

.badge { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); font-weight: 550; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent-deep); border-color: var(--accent-line); }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

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

.notice { padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); margin-bottom: 14px; }
.notice.err { background: var(--err-soft); color: var(--err); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--accent-soft); color: var(--ink); }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.toolbar .title { font-weight: 620; }
iframe.tool-frame { flex: 1; width: 100%; border: 0; background: #fff; }

.split { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 18px; align-items: start; }
.output { min-height: 240px; }
.md { line-height: 1.6; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3 { margin: 14px 0 6px; }
.md pre { background: var(--bg); padding: 10px; border-radius: 8px; overflow-x: auto; }
.md code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.md pre code { padding: 0; background: none; }
.md table { margin: 8px 0; }
.md ul, .md ol { padding-left: 22px; }
.status-line { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; background: var(--bg); padding: 10px; border-radius: 8px; max-height: 420px; overflow: auto; margin: 0; }

.trace-k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin: 12px 0 4px; }
.pre.trace-prompt { max-height: none; background: var(--accent-soft); color: var(--ink); }
details > summary { cursor: pointer; }
.ab { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stat { display: flex; flex-direction: column; }
.stat .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: 12px; }
.stats { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 16px; }

.center-box { max-width: 380px; margin: 12vh auto; }
.empty { color: var(--muted); padding: 28px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.toast.err { background: var(--err); color: #fff; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* small-screen top bar and menu button (hidden on wide screens) */
.topbar { display: none; position: sticky; top: 0; z-index: 30; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .brand { padding: 0; color: var(--ink); }
.topbar .brand:hover { text-decoration: none; }
.menu-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); display: grid; place-content: center; gap: 4px; cursor: pointer; padding: 0; }
.menu-btn span { display: block; width: 16px; height: 2px; border-radius: 1px; background: var(--ink); }
.menu-btn:hover { border-color: var(--muted); }
.scrim { display: none; }
.side-brand { align-items: center; }
.side-close { display: none; margin-left: auto; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 18px; line-height: 1; place-items: center; cursor: pointer; padding: 0; }
@media (prefers-reduced-motion: reduce) { .side, .scrim { transition: none !important; } }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .topbar { display: flex; }
  .side { position: fixed; inset: 0 auto 0 0; z-index: 41; width: min(280px, 84vw); overflow-y: auto;
    transform: translateX(-100%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s;
    box-shadow: 0 0 40px rgba(10,37,64,.25); }
  body.nav-open .side { transform: none; visibility: visible; transition: transform .22s ease; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(10,37,64,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .side-close { display: grid; }
  .main { padding: 18px 16px; }
  .main.full { height: calc(100vh - 53px); min-height: 0; }
  iframe.tool-frame { min-height: 75vh; }
  .split, .ab { grid-template-columns: 1fr; }
}

.steps { display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; gap: 10px; align-items: flex-start; }
.step-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.step.done .step-ic { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.step.warn .step-ic { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.step.error .step-ic { background: var(--err-soft); color: var(--err); border-color: transparent; }
.step.running .step-ic { background: var(--accent-soft); border-color: var(--accent-line); }
.step.pending .step-l, .step.skipped .step-l { color: var(--muted); }
.step-l { font-weight: 600; }
.step-d { font-size: 13px; overflow-wrap: anywhere; }
img.shot { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); display: block; }
.card-acts { display: inline-flex; gap: 6px; opacity: .55; transition: opacity .15s; }
.tool-card:hover .card-acts, .card-acts:focus-within { opacity: 1; }
@media (hover: none) { .card-acts { opacity: 1; } }
