.scap, .scap * { box-sizing: border-box; }
.scap {
  --bg: #16171a; --surface: #1e2024; --raised: #26292e; --border: #353940;
  --ink: #e8eaed; --ink-2: #b4b9c0; --muted: #868c94;
  --accent: #73c2fb; --accent-ink: #0d2233;
  --danger: #f26d6d; --warn: #e8b04b; --ok: #5cc98a;
  --chart: #73c2fb; --grid: #2c3036;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

/* launcher */
.scap-launch {
  position: fixed; left: 74px; bottom: 12px; z-index: 9998;
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--raised); color: var(--accent); cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 2px 10px #0008;
}
.scap-launch:hover { background: #30343a; }
.scap-launch svg { width: 20px; height: 20px; }

/* overlay */
.scap-overlay { position: fixed; inset: 0; z-index: 9999; background: #000a; display: flex; }
.scap-panel {
  margin: auto; width: min(1180px, 100vw); height: min(860px, 100vh);
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 40px #000c;
}
@media (max-width: 700px) { .scap-panel { border-radius: 0; border: 0; } }
.scap-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.scap-title { font-weight: 700; font-size: 16px; margin-right: 8px; }
.scap-tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.scap-tab {
  border: 0; background: transparent; color: var(--ink-2); padding: 6px 12px;
  border-radius: 8px; cursor: pointer; font: inherit;
}
.scap-tab:hover { background: var(--raised); color: var(--ink); }
.scap-tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.scap-badge { margin-left: 6px; padding: 0 6px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; }
.scap-close { margin-left: auto; }
.scap-body { flex: 1; overflow: auto; padding: 16px; }

/* controls */
.scap-btn {
  border: 1px solid var(--border); background: var(--raised); color: var(--ink);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font: inherit; white-space: nowrap;
}
.scap-btn:hover:not(:disabled) { background: #30343a; }
.scap-btn:disabled { opacity: .5; cursor: default; }
.scap-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.scap-btn.danger { border-color: #6b2b2b; color: #ffb3b3; }
.scap-btn.danger:hover:not(:disabled) { background: #3a1f1f; }
.scap-btn.small { padding: 3px 8px; font-size: 12.5px; }
.scap-input {
  background: var(--surface); border: 1px solid var(--border); color: var(--ink);
  padding: 7px 10px; border-radius: 8px; font: inherit; min-width: 0;
}
.scap-input:focus, .scap-btn:focus-visible, .scap-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.scap-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.scap-bar .scap-input { flex: 1; min-width: 180px; }
.scap-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* tables */
.scap-tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.scap-table { width: 100%; border-collapse: collapse; }
.scap-table th, .scap-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.scap-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; background: var(--surface); }
.scap-table tr:last-child td { border-bottom: 0; }
.scap-table tr.click { cursor: pointer; }
.scap-table tr.click:hover td { background: var(--surface); }
.scap-num { text-align: right !important; font-variant-numeric: tabular-nums; }
.scap-mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; word-break: break-all; }
.scap-muted { color: var(--muted); }
.scap-pill { display: inline-block; padding: 0 7px; border-radius: 9px; font-size: 11.5px; margin: 1px 4px 1px 0; border: 1px solid var(--border); color: var(--ink-2); }
.scap-pill.red { border-color: #6b2b2b; color: #ffb3b3; }
.scap-pill.yellow { border-color: #6b5426; color: #f3d38d; }
.scap-pill.blue { border-color: #2b4f6b; color: var(--accent); }
.scap-empty { color: var(--muted); padding: 28px; text-align: center; }

/* cards / detail */
.scap-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.scap-card h3 { margin: 0 0 10px; font-size: 14px; }
.scap-kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.scap-kv dt { color: var(--muted); }
.scap-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.scap-back { margin-bottom: 12px; }
.scap-quote { background: var(--bg); border-left: 3px solid var(--border); padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0; }
.scap-list { list-style: none; margin: 0; padding: 0; }
.scap-list li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.scap-list li:last-child { border-bottom: 0; }

/* stats */
.scap-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.scap-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.scap-tile .label { color: var(--muted); font-size: 12px; }
.scap-tile .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.scap-tile .sub { color: var(--ink-2); font-size: 12px; }
.scap-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.scap-chart { position: relative; }
.scap-chart svg { display: block; width: 100%; height: 150px; overflow: visible; }
.scap-chart .hit { fill: transparent; cursor: default; }
.scap-chart .hit:hover + .bar, .scap-chart .bar.on { opacity: .75; }
.scap-tip {
  position: absolute; pointer-events: none; background: var(--raised); border: 1px solid var(--border);
  padding: 4px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%);
}
.scap-thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--raised); display: block; }

/* dialog + toast */
.scap-dialog-back { position: fixed; inset: 0; z-index: 10000; background: #0009; display: grid; place-items: center; padding: 16px; }
.scap-dialog { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.scap-dialog h3 { margin: 0 0 8px; }
.scap-dialog p { color: var(--ink-2); margin: 0 0 12px; white-space: pre-wrap; }
.scap-dialog label { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.scap-dialog .scap-input { width: 100%; }
.scap-dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.scap-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 10001; display: flex; flex-direction: column; gap: 8px; }
.scap-toast { background: var(--raised); border: 1px solid var(--border); border-left: 4px solid var(--ok); padding: 8px 12px; border-radius: 8px; max-width: 380px; box-shadow: 0 4px 16px #0008; }
.scap-toast.err { border-left-color: var(--danger); }

/* media viewer */
.scap-viewer { width: min(1000px, 100%); max-height: 100%; display: flex; flex-direction: column; }
.scap-viewer-stage { flex: 1; min-height: 160px; display: grid; place-items: center; overflow: auto; background: var(--bg); border-radius: 8px; padding: 8px; }
.scap-viewer-stage img, .scap-viewer-stage video { max-width: 100%; max-height: 75vh; display: block; }
.scap-viewer-stage audio { width: min(480px, 100%); }
