/* QA TestHub — design tokens and components. Ported from the HTML prototype on the ticket. */
:root {
  --bg: #0c0330;
  --bg2: #16093c;
  --accent: #6bffa8;
  --accent2: #7f56d9;
  --ink: #f4f2fc;
  --muted: rgba(214, 210, 236, .62);
  --faint: rgba(214, 210, 236, .4);
  --panel: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .12);
  --line-2: rgba(255, 255, 255, .07);
  --pass: #6bffa8;
  --fail: #ff6a4d;
  --flaky: #f6c945;
  --none: rgba(255, 255, 255, .13);
  --font: "Poppins", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }
body {
  font-family: var(--font);
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(1200px 800px at 15% -10%, #1c0e4e 0%, transparent 55%),
    radial-gradient(1000px 700px at 100% 0%, #2a1163 0%, transparent 50%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed;
}
button { font-family: inherit; }
input, select { font-family: inherit; }

/* ---- animated moiré background (G-2) ---- */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.pat { position: absolute; inset: -60%; transform-origin: center; }
.pat-a {
  background-image:
    radial-gradient(ellipse 276px 27px at 22% 28%, rgba(107, 255, 168, .16) 0, transparent 72%),
    radial-gradient(ellipse 186px 36px at 72% 62%, rgba(107, 255, 168, .13) 0, transparent 72%),
    radial-gradient(ellipse 360px 24px at 48% 90%, rgba(107, 255, 168, .11) 0, transparent 72%);
  background-size: 900px 780px;
  mix-blend-mode: screen;
  animation: rockA 14s ease-in-out infinite;
}
.pat-b {
  background-image:
    radial-gradient(ellipse 312px 30px at 38% 20%, rgba(127, 86, 217, .18) 0, transparent 72%),
    radial-gradient(ellipse 216px 39px at 82% 54%, rgba(127, 86, 217, .15) 0, transparent 72%),
    radial-gradient(ellipse 402px 27px at 18% 82%, rgba(127, 86, 217, .12) 0, transparent 72%);
  background-size: 1020px 900px;
  mix-blend-mode: screen;
  animation: rockB 17s ease-in-out infinite;
}
@keyframes rockA { 0%, 100% { transform: rotate(-26deg); } 50% { transform: rotate(-6deg); } }
@keyframes rockB { 0%, 100% { transform: rotate(22deg); } 50% { transform: rotate(2deg); } }
@keyframes gspin { to { transform: rotate(360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ---- central content strip + silver ribbons (G-3) ---- */
.blinder {
  position: fixed; top: 0; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(1440px, 100%); z-index: 0; pointer-events: none;
  background: rgba(12, 3, 48, .86);
}
.win-frame {
  position: fixed; top: 0; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(1440px, 100%); z-index: 5; pointer-events: none;
}
.ribbon {
  position: absolute; top: 0; bottom: 0; width: 16px;
  background: linear-gradient(90deg, #43474e 0%, #9aa0a8 20%, #edf0f3 44%, #ffffff 52%, #ccd1d7 62%, #888e96 82%, #40444b 100%);
  box-shadow: 0 0 12px rgba(0, 0, 0, .5);
}
.ribbon-l { left: 0; }
.ribbon-r { right: 0; }
.studs { position: absolute; top: 26px; left: 0; width: 16px; display: flex; flex-direction: column; align-items: center; gap: 11px; }
.stud { width: 10px; height: 10px; background: var(--accent); box-shadow: 0 0 6px rgba(107, 255, 168, .6), inset 0 0 0 1px rgba(0, 0, 0, .3); }

header, nav, main, .runbar { position: relative; z-index: 1; }

/* ---- header (G-4) ---- */
header { display: flex; align-items: center; gap: 22px; padding: 30px 40px 12px; max-width: 1360px; margin: 0 auto; }
.logo { filter: drop-shadow(0 0 14px rgba(107, 255, 168, .5)); flex: none; }
.logo .gear { transform-box: fill-box; transform-origin: center; animation: gspin 16s linear infinite; }
header h1 { margin: 0; font-size: 62px; font-weight: 700; letter-spacing: .5px; line-height: 1; color: var(--accent); }
header h1 span { color: var(--ink); }
header .sub { color: var(--faint); font-size: 15px; margin-top: 8px; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.env-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, .05); }
.env-toggle button {
  background: none; border: none; color: var(--muted); padding: 7px 16px; font-size: 12.5px; font-weight: 600;
  letter-spacing: .6px; text-transform: uppercase; cursor: pointer; transition: all .15s;
}
.env-toggle button + button { border-left: 1px solid var(--line); }
.env-toggle button:hover { color: var(--ink); }
.env-toggle button.active { background: rgba(107, 255, 168, .16); color: var(--accent); }

.connection { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.connection::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.connection.connected::before { background: var(--accent); box-shadow: 0 0 8px rgba(107, 255, 168, .7); }
.connection.disconnected::before { background: var(--fail); }

/* ---- login ---- */
.user-box { display: inline-flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 14px; }
.user-name { color: var(--ink); font-weight: 600; }
.user-box.auth-off .user-name { color: var(--flaky); font-weight: 600; }
.logout-btn { background: none; border: 1px solid var(--line); color: var(--muted); font-size: 11.5px; padding: 4px 10px; border-radius: 7px; cursor: pointer; }
.logout-btn:hover { color: var(--accent); border-color: rgba(107, 255, 168, .4); }
body.locked nav, body.locked main, body.locked .runbar, body.locked #env-toggle, body.locked #connection { display: none; }
.login-view { position: relative; z-index: 1; display: flex; justify-content: center; padding: 40px 20px 80px; }
.login-card {
  width: min(400px, 100%); padding: 28px 30px 30px; border-radius: 16px; border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .11), rgba(255, 255, 255, .055)); box-shadow: 0 10px 30px rgba(4, 1, 20, .35);
  display: flex; flex-direction: column; gap: 6px;
}
.login-card h2 { margin: 0 0 2px; font-size: 22px; }
.login-sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.login-card label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); margin-top: 8px; }
.login-card input { background: rgba(255, 255, 255, .06); border: 1px solid var(--line); color: var(--ink); font-size: 14px; padding: 10px 12px; border-radius: 8px; outline: none; }
.login-card input:focus { border-color: rgba(107, 255, 168, .5); }
.login-error { min-height: 18px; color: var(--fail); font-size: 12.5px; margin-top: 6px; }
.login-card .run-btn { margin-top: 8px; padding: 10px 14px; font-size: 14px; }

/* ---- run summary bar (G-5) ---- */
.runbar { max-width: 1360px; margin: 0 auto; padding: 2px 40px 10px; color: var(--muted); font-size: 12.5px; }

/* ---- tabs (G-6) ---- */
nav { display: flex; gap: 8px; padding: 8px 40px 0; max-width: 1360px; margin: 0 auto; border-bottom: 1px solid var(--line-2); }
nav button {
  background: none; border: none; color: var(--muted); padding: 12px 4px; margin-right: 18px;
  font-size: 15px; cursor: pointer; border-bottom: 2px solid transparent; transition: color .2s;
}
nav button:hover { color: var(--ink); }
nav button.active { color: var(--accent); border-bottom-color: var(--accent); }

main { padding: 26px 40px 60px; max-width: 1360px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.loading, .empty, .hub-empty { color: var(--muted); font-size: 13px; padding: 20px 4px; }
.error-box { color: #ffd7cd; background: rgba(255, 106, 77, .1); border: 1px solid rgba(255, 106, 77, .35); border-radius: 10px; padding: 12px 14px; font-size: 13px; }

/* ---- cards & sections (HUB-1) ---- */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .11), rgba(255, 255, 255, .055));
  border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px; margin-bottom: 22px;
  backdrop-filter: blur(6px); box-shadow: 0 10px 30px rgba(4, 1, 20, .35);
}
summary.sec-head { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; padding: 4px 2px; }
summary.sec-head::-webkit-details-marker { display: none; }
details[open] summary.sec-head { margin-bottom: 14px; }
.sec-left { display: flex; align-items: center; gap: 12px; }
.sec-left::before {
  content: ""; width: 0; height: 0; flex: none;
  border-left: 8px solid var(--accent); border-top: 6px solid transparent; border-bottom: 6px solid transparent;
  transition: transform .2s;
}
details[open] .sec-left::before { transform: rotate(90deg); }
.sec-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.sec-tags { color: var(--faint); font-size: 11px; font-weight: 500; }
.sec-right { display: flex; align-items: center; gap: 16px; }
.sec-summary { display: flex; gap: 16px; }
.tot { font-weight: 700; font-size: 13px; }
.tot-pass { color: var(--pass); }
.tot-fail { color: var(--fail); }
.tot-flaky { color: var(--flaky); }
.tot-none { color: var(--muted); }

/* ---- case table (HUB-3) ---- */
table.cases { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.cases th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint);
  padding: 6px 12px 10px; border-bottom: 1px solid var(--line);
}
table.cases td { padding: 15px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; font-size: 13.5px; overflow-wrap: anywhere; }
table.cases tr:last-child td { border-bottom: none; }
table.cases tbody tr { transition: background .15s; }
table.cases tbody tr:hover { background: rgba(107, 255, 168, .06); }
.case-row { cursor: pointer; }
.case-row.is-running { animation: pulse 1.4s ease-in-out infinite; }
td.c-id { display: flex; align-items: center; gap: 8px; }
.c-id .cid-text { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; color: var(--accent); font-size: 12.5px; opacity: .9; white-space: nowrap; }
.tsel { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex: none; }
.c-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.c-desc { color: var(--muted); font-size: 13px; margin-top: 4px; line-height: 1.5; }
.c-meta { color: var(--faint); font-size: 11.5px; margin-top: 4px; }
.c-expected { color: #d9d5ee; line-height: 1.5; }
.c-expected.none { color: var(--faint); font-style: italic; }
.reason {
  margin-top: 9px; font-size: 12.5px; color: #ffd7cd; background: rgba(255, 106, 77, .1);
  border: 1px solid rgba(255, 106, 77, .35); border-radius: 8px; padding: 8px 10px; line-height: 1.45;
}
.reason-tag { font-weight: 700; text-transform: uppercase; font-size: 10px; letter-spacing: .5px; margin-right: 6px; color: var(--fail); }

.history { display: inline-flex; gap: 4px; }
.seg { width: 13px; height: 26px; border-radius: 4px; display: inline-block; }
.seg-pass { background: var(--pass); box-shadow: 0 0 8px rgba(107, 255, 168, .55); }
.seg-fail { background: var(--fail); box-shadow: 0 0 8px rgba(255, 106, 77, .5); }
.seg-flaky { background: var(--flaky); box-shadow: 0 0 8px rgba(246, 201, 69, .5); }
.seg-none, .seg-skip { background: var(--none); }

td.c-last, td.c-history { white-space: nowrap; }
table.cases th.th-history, table.cases th.th-last { white-space: nowrap; }
.last { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13.5px; letter-spacing: .4px; }
.lr-ico { flex: none; display: block; }
.lr-ico.spin { animation: spin 1.2s linear infinite; }
.last-pass { color: var(--pass); }
.last-fail { color: var(--fail); }
.last-none, .last-skip { color: var(--muted); }
.last-running { color: var(--accent2); }
.flaky-mark {
  display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 700; letter-spacing: .4px;
  color: #2a1a00; background: var(--flaky); border-radius: 999px; padding: 2px 6px; vertical-align: middle;
}

/* ---- selection toolbar + buttons (HUB-2) ---- */
.sel-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .05);
}
.sel-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.sel-actions { display: flex; gap: 8px; }
.filter-input {
  flex: 1; min-width: 160px; max-width: 420px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
  color: var(--ink); font-size: 13px; padding: 8px 12px; border-radius: 8px; outline: none;
}
.filter-input:focus { border-color: rgba(107, 255, 168, .5); }
.filter-input::placeholder { color: var(--faint); }
.run-btn {
  font-size: 12.5px; font-weight: 700; cursor: pointer; border-radius: 8px; padding: 7px 14px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: var(--ink); transition: all .15s;
}
.run-btn:hover { border-color: rgba(107, 255, 168, .5); color: var(--accent); }
.run-btn:disabled { opacity: .5; cursor: not-allowed; }
.run-btn.ghost { background: none; color: var(--muted); }
.run-btn.primary { background: rgba(107, 255, 168, .16); border-color: rgba(107, 255, 168, .5); color: var(--accent); }
.run-btn.run-all { padding: 5px 12px; font-size: 12px; }

/* ---- detail side panel (P-1..P-7) ----
   P-1: the page content shifts left so the panel occupies the freed space. The content blocks keep
   their 1360px cap and are centred in the area left of the panel; nothing ends up underneath it. */
body { --panel-w: 0px; }
body.panel-open { --panel-w: min(460px, 92vw); }
header, nav, .runbar, main { transition: width .3s ease, margin .3s ease; }
.blinder, .win-frame { transition: width .3s ease, transform .3s ease; }
.detail-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(460px, 92vw);
  background: linear-gradient(180deg, #17093f, #120733); border-left: 1px solid rgba(255, 255, 255, .14);
  box-shadow: -14px 0 40px rgba(0, 0, 0, .5); z-index: 30; transform: translateX(100%);
  transition: transform .3s ease; overflow-y: auto;
}
.detail-panel.open { transform: translateX(0); }
body.panel-open header, body.panel-open nav, body.panel-open .runbar, body.panel-open main {
  max-width: none;
  width: min(1360px, calc(100% - var(--panel-w)));
  margin-left: max(0px, calc((100% - var(--panel-w) - 1360px) / 2));
  margin-right: 0;
}
body.panel-open .blinder, body.panel-open .win-frame { left: 0; transform: none; width: calc(100% - var(--panel-w)); }
.dp-inner { padding: 22px 22px 44px; }
.dp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dp-title { font-size: 20px; font-weight: 700; margin: 0; }
.dp-id { color: var(--accent); font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; margin-bottom: 4px; }
.dp-desc { color: var(--muted); font-size: 13px; margin-top: 4px; line-height: 1.5; }
.dp-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.dp-close { background: none; border: none; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; flex: none; }
.dp-close:hover { color: var(--ink); }
.dp-badge { font-size: 11px; font-weight: 700; padding: 4px 11px; border-radius: 999px; white-space: nowrap; flex: none; }
.dp-badge.pass { background: rgba(107, 255, 168, .16); color: var(--accent); border: 1px solid rgba(107, 255, 168, .4); }
.dp-badge.fail { background: rgba(255, 106, 77, .16); color: var(--fail); border: 1px solid rgba(255, 106, 77, .4); }
.dp-badge.none { background: rgba(255, 255, 255, .08); color: var(--muted); border: 1px solid var(--line); }
.dp-badge.running { background: rgba(127, 86, 217, .2); color: #c9b5ff; border: 1px solid rgba(127, 86, 217, .5); }
.dp-section-label { text-transform: uppercase; letter-spacing: .6px; font-size: 10.5px; color: var(--faint); margin: 20px 0 8px; }
.dp-expected { background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5; color: #d9d5ee; }
.dp-step { border: 1px solid var(--line-2); border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
.dp-step-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.dp-step-num { width: 22px; height: 22px; border-radius: 6px; background: rgba(255, 255, 255, .08); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.dp-step-text { flex: 1; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.dp-step-stat { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; flex: none; letter-spacing: .4px; }
.st-pass { background: rgba(107, 255, 168, .16); color: var(--accent); }
.st-fail { background: rgba(255, 106, 77, .16); color: var(--fail); }
.st-skip, .st-unknown, .st-none { background: rgba(255, 255, 255, .08); color: var(--muted); }
.dp-caret { color: var(--muted); font-size: 11px; flex: none; transition: transform .2s; }
.dp-step.open .dp-caret { transform: rotate(90deg); }
.dp-shot { display: none; border-top: 1px solid var(--line-2); padding: 10px 12px; }
.dp-step.open .dp-shot { display: block; }
.dp-shot img { width: 100%; border-radius: 8px; display: block; }
.noshot { color: var(--faint); font-size: 12px; font-style: italic; }
.dp-steps-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 8px; }
.steps-toggle { background: none; border: 1px solid var(--line); color: var(--muted); font-size: 11px; padding: 4px 10px; border-radius: 7px; cursor: pointer; }
.steps-toggle:hover { color: var(--accent); border-color: rgba(107, 255, 168, .4); }
.dp-note { border-left: 3px solid var(--accent2); background: rgba(255, 255, 255, .04); padding: 8px 12px; border-radius: 0 8px 8px 0; margin-bottom: 8px; }
.dp-note-meta { font-size: 11px; color: var(--faint); margin-bottom: 3px; }
.dp-note-body { font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; margin: 0; overflow-wrap: anywhere; }
.dp-empty { color: var(--faint); font-size: 12.5px; font-style: italic; }

.evidence-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.evidence { background: rgba(255, 255, 255, .04); border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.evidence-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); padding: 8px 10px 4px; }
.evidence img { width: 100%; display: block; cursor: zoom-in; }
.evidence video { width: 100%; display: block; background: #000; }
.evidence a { display: inline-block; margin: 4px 10px 10px; color: var(--accent); font-size: 12.5px; }
.attachment-missing { display: block; color: var(--faint); font-size: 12px; font-style: italic; padding: 10px; }

/* run selector (P-4) */
.run-row { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; }
.run-label-static { text-transform: uppercase; letter-spacing: .6px; font-size: 11px; color: var(--faint); font-weight: 700; flex: none; }
.run-select-wrap { position: relative; flex: 1; min-width: 0; }
.run-select {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line); color: var(--ink);
  font-size: 12.5px; padding: 9px 12px; border-radius: 8px; cursor: pointer; text-align: left;
}
.run-select:hover { border-color: rgba(107, 255, 168, .4); }
.run-select .run-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-caret { color: var(--muted); font-size: 10px; flex: none; }
.run-dd {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5; background: #1a0c44;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: 0 12px 34px rgba(0, 0, 0, .55);
}
.run-search { width: 100%; background: rgba(255, 255, 255, .06); border: none; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 12.5px; padding: 9px 12px; outline: none; }
.run-list { max-height: 230px; overflow-y: auto; }
.run-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 12px; cursor: pointer; color: var(--ink); border-bottom: 1px solid var(--line-2); }
.run-item:hover { background: rgba(107, 255, 168, .08); }
.run-item.sel { background: rgba(107, 255, 168, .12); }
.ri-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ri-dot.pass { background: var(--pass); }
.ri-dot.fail { background: var(--fail); }
.ri-dot.flaky { background: var(--flaky); }
.ri-dot.none { background: var(--muted); }

/* ---- Perf tab ---- */
.perf-runbar { flex: 1; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.c-level { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.dp-step-head.static { cursor: default; }
table.thr { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.thr th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); padding: 4px 8px 6px; border-bottom: 1px solid var(--line); }
table.thr td { padding: 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; line-height: 1.4; overflow-wrap: anywhere; }
table.thr tr:last-child td { border-bottom: none; }
table.thr tr.thr-broken td { background: rgba(255, 106, 77, .08); }
.thr-metric { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--accent); font-size: 12px; }
.thr-num { font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; }
ul.chk { list-style: none; margin: 0; padding: 0; }
ul.chk li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
ul.chk li:last-child { border-bottom: none; }
.chk-name { flex: 1; overflow-wrap: anywhere; }
.chk-num { color: var(--muted); font-variant-numeric: tabular-nums; }
.dp-log { display: inline-block; margin-top: 8px; color: var(--accent); font-size: 12.5px; }

/* ---- full-page case view (?case=<ID>) ---- */
.back-link { display: none; color: var(--accent); font-size: 13px; text-decoration: none; margin-right: 8px; }
.back-link:hover { text-decoration: underline; }
body.case-page .back-link { display: inline; }
body.case-page nav, body.case-page main, body.case-page .runbar, body.case-page .dp-close, body.case-page .dp-newtab { display: none; }
body.case-page .detail-panel {
  position: relative; height: auto; width: min(980px, calc(100% - 40px)); margin: 8px auto 60px; transform: none;
  border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 30px rgba(4, 1, 20, .35); z-index: 1;
}
body.case-page.panel-open { --panel-w: 0px; }
body.case-page .dp-inner { padding: 26px 30px 44px; }

/* ---- theatre mode (T-1..T-4) ---- */
.theatre { position: fixed; inset: 0; z-index: 100; background: rgba(4, 1, 20, .93); display: flex; align-items: center; justify-content: center; overflow: auto; }
.th-img { max-width: 92vw; max-height: 88vh; cursor: zoom-in; transform-origin: center; transition: transform .08s; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.th-close { position: fixed; top: 16px; right: 20px; z-index: 102; background: rgba(255, 255, 255, .1); border: 1px solid var(--line); color: #fff; font-size: 22px; width: 40px; height: 40px; border-radius: 8px; cursor: pointer; line-height: 1; }
.th-close:hover { background: rgba(255, 255, 255, .2); }
.th-zoom { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 102; display: flex; align-items: center; gap: 12px; background: rgba(20, 10, 50, .96); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; }
.th-zoom button { background: rgba(255, 255, 255, .1); border: 1px solid var(--line); color: #fff; width: 30px; height: 30px; border-radius: 6px; font-size: 18px; cursor: pointer; line-height: 1; }
.th-zoom span { color: var(--ink); font-size: 13px; min-width: 46px; text-align: center; }

/* ---- gallery (GAL-1..3) ---- */
.gal-day { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .4px; margin: 6px 0 12px; padding-left: 12px; border-left: 3px solid var(--accent2); }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; margin-bottom: 26px; }
.album { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s; }
.album:hover { transform: translateY(-3px); border-color: rgba(107, 255, 168, .5); }
.album-cover { height: 150px; background-color: #1a0c44; overflow: hidden; }
.album-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
details.gal-run { margin-bottom: 14px; }
details.gal-run > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .05); font-size: 13px; }
details.gal-run > summary::-webkit-details-marker { display: none; }
details.gal-run > summary::before { content: ""; width: 0; height: 0; border-left: 7px solid var(--accent); border-top: 5px solid transparent; border-bottom: 5px solid transparent; transition: transform .2s; flex: none; }
details.gal-run[open] > summary::before { transform: rotate(90deg); }
details.gal-run[open] > summary { margin-bottom: 14px; }
.gal-run-id { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--accent); font-size: 12.5px; }
.gal-run-meta { color: var(--muted); margin-left: auto; white-space: nowrap; }
.album-meta { padding: 12px 14px; }
.album-title { font-weight: 700; font-size: 14px; }
.album-sub { color: var(--muted); font-size: 12px; margin-top: 3px; overflow-wrap: anywhere; }
.pass-tx { color: var(--pass); }
.fail-tx { color: var(--fail); }
.flaky-tx { color: var(--flaky); }
.none-tx { color: var(--muted); }
.gal-back { background: rgba(255, 255, 255, .06); border: 1px solid var(--line); color: var(--ink); font-size: 13px; padding: 8px 14px; border-radius: 8px; cursor: pointer; margin-bottom: 16px; }
.gal-head { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.shot-cell { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; transition: border-color .15s; }
.shot-cell:hover { border-color: rgba(107, 255, 168, .5); }
.shot-cell img { width: 100%; display: block; aspect-ratio: 16 / 9; object-fit: cover; object-position: top; }
.shot-cell figcaption { padding: 8px 10px; font-size: 11px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .3px; word-break: break-all; }

/* ---- metrics (M-1..M-3) ---- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat {
  background: linear-gradient(180deg, rgba(255, 255, 255, .11), rgba(255, 255, 255, .055));
  border: 1px solid var(--line); border-radius: 16px; padding: 22px 18px; text-align: center;
  backdrop-filter: blur(6px); position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--accent), var(--accent2)); opacity: .8; }
.stat-num { font-size: 34px; font-weight: 700; color: var(--accent); text-shadow: 0 0 18px rgba(107, 255, 168, .35); }
.stat-lbl { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.metrics-head h2, .chart-head h2 { margin: 0 0 12px; font-size: 16px; font-weight: 700; padding-left: 12px; border-left: 3px solid var(--accent); }
ul.rank { list-style: none; margin: 0; padding: 0; }
ul.rank li { display: grid; grid-template-columns: 1fr 120px 30px; align-items: center; gap: 12px; padding: 10px 0; font-size: 13px; border-bottom: 1px solid var(--line-2); }
ul.rank li:last-child { border-bottom: none; }
.rank-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-label .rank-id { color: var(--accent); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; margin-right: 6px; }
.rank-bar { background: rgba(255, 255, 255, .09); border-radius: 6px; height: 11px; overflow: hidden; }
.rank-fill { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--fail), #ff9a5a); }
.rank-fill.flaky { background: linear-gradient(90deg, var(--flaky), #ffe08a); }
.rank-num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 12px; }
.chart-head h2 { margin: 0; }
.chart-toggle { display: flex; gap: 6px; }
.cbtn { background: rgba(255, 255, 255, .06); border: 1px solid var(--line); color: var(--muted); font-size: 12px; padding: 5px 12px; border-radius: 8px; cursor: pointer; }
.cbtn:hover { color: var(--ink); }
.cbtn.active { background: rgba(107, 255, 168, .16); border-color: rgba(107, 255, 168, .5); color: var(--accent); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.lg { display: inline-flex; align-items: center; }
.lg::before { content: ""; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; display: inline-block; }
.lg-pass::before { background: var(--pass); }
.lg-fail::before { background: var(--fail); }
.lg-rate::before { background: var(--accent2); }
.chart { width: 100%; height: auto; display: block; margin-top: 6px; }
.chart .grid { stroke: rgba(255, 255, 255, .1); stroke-width: 1; }
.chart .ylab { fill: var(--muted); font-size: 11px; text-anchor: end; font-family: var(--font); }
.chart .xlab { fill: var(--muted); font-size: 11px; text-anchor: middle; font-family: var(--font); }
.chart .bar-pass { fill: var(--pass); }
.chart .bar-fail { fill: var(--fail); }
.chart .bar-empty { fill: rgba(255, 255, 255, .18); }
.chart .area { fill: rgba(127, 86, 217, .28); }
.chart .line { fill: none; stroke: var(--accent2); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); }
.chart .dot.low { fill: var(--fail); }

/* ---- live run output panel ---- */
.output-panel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: #0a0226; border-top: 1px solid var(--line);
  max-height: 300px; display: flex; flex-direction: column; transform: translateY(100%); transition: transform .3s ease;
}
.output-panel.visible { transform: translateY(0); }
.output-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; background: #120733; border-bottom: 1px solid var(--line); }
.output-header h3 { font-size: 13px; font-weight: 600; margin: 0; color: var(--muted); }
.output-close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.output-close:hover { color: var(--ink); }
.output-content { margin: 0; padding: 14px 20px; overflow: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; white-space: pre-wrap; color: #d9d5ee; }

/* ---- toast ---- */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: rgba(20, 10, 50, .97); border: 1px solid rgba(107, 255, 168, .4); color: var(--ink);
  padding: 11px 18px; border-radius: 10px; font-size: 13px; z-index: 120; opacity: 0; pointer-events: none;
  transition: all .25s; max-width: 80vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  header { flex-wrap: wrap; gap: 14px; padding: 22px 20px 8px; }
  header h1 { font-size: 44px; }
  .logo { width: 72px; height: 72px; }
  .header-right { margin-left: 0; width: 100%; }
  .runbar, nav, main { padding-left: 20px; padding-right: 20px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .metrics-grid { grid-template-columns: 1fr; }
  .sel-toolbar { flex-wrap: wrap; }
  body.panel-open { --panel-w: 0px; } /* the panel overlays on small screens instead of squeezing the page */
}

/* ---- reduced motion (G-2) ---- */
@media (prefers-reduced-motion: reduce) {
  .pat, .view.active, .logo .gear, .case-row.is-running, .lr-ico.spin { animation: none; }
  .detail-panel, header, nav, .runbar, main, .blinder, .win-frame, .output-panel, .album, #toast { transition: none; }
}
