/* ============ Spark Control — instrument readout ============
   Discipline (do not break when editing):
   • Semantic colour (green/amber/red) means STATE only — device, WDA, tool,
     ad-suspicion, cert. Nothing decorative may use it.
   • The accent (teal) has ONE job: the primary action on a screen + the active
     nav item. Toggles/selection ON count as an active state. Everything else
     is neutral grey.
   • Monospace (Plex Mono) carries real data — UDIDs, versions, codes, IPs,
     logs, counts — set deliberately, not decoratively.
   • Group with a heading + spacing, not a bordered card. Reserve a surface
     (border + fill) for things that genuinely contain: log console, tables,
     the preview frame, setup checklist, dialogs. */

@font-face {
  font-family: "Plex Mono"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("fonts/PlexMono-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("fonts/PlexMono-Medium.woff2") format("woff2");
}

:root {
  --bg: #0d0e10;            /* app background — neutral charcoal, not blue-black */
  --sidebar: #0b0c0e;       /* sidebar, a touch darker */
  --panel: #17191c;         /* surface fill for genuine containers only */
  --panel-2: #202327;       /* inputs, insets, tracks, raised chips */
  --border: #292c31;        /* hairline borders */
  --border-soft: #202225;   /* faint inner dividers */
  --line-strong: #363a40;   /* button outlines, focus */
  --text: #f3f4f6;          /* fg — headings + primary data */
  --text-dim: #a4a9b2;      /* labels, secondary */
  --text-faint: #6d727b;    /* captions, meta, disabled */
  --accent: #34b6cb;        /* the one accent — primary action + active state */
  --accent-2: #45c6da;      /* hover */
  --accent-dim: #2b93a5;    /* focus ring */
  --accent-tint: rgba(52,182,203,.14);
  --on-accent: #06181c;     /* text on an accent fill */
  --green: #46b872;  --green-2: #54c67f;   /* STATE: ok */
  --amber: #d99a3a;                        /* STATE: attention / busy */
  --red: #e5646f;    --red-muted: #5e2a30; /* STATE: fail */
  --mono: "Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* The `hidden` attribute must always win. Several components set `display`
   via a class (.modal, .wda-progress), which ties `[hidden]` on specificity
   and — author beating UA on a tie — leaves them rendered while "hidden".
   Without this, #imgModal stays up full-screen and eats every click. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text-dim);
  font: 13px/1.45 -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overflow: hidden;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.app { display: flex; height: 100vh; }

/* ============ sidebar ============ */
.sidebar {
  width: 220px; min-width: 220px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 12px 12px;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 0 8px 18px; }
.brand-mark { width: 22px; height: 22px; flex: none; color: var(--text); }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.brand-badge {
  margin-left: auto; font-size: 9px; font-weight: 600; line-height: 1.15;
  text-transform: uppercase; letter-spacing: .04em; text-align: center;
  color: var(--text-faint); background: var(--panel-2);
  border-radius: 5px; padding: 3px 6px;
}
#nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; position: relative;
  padding: 7px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--text-dim);
  font: inherit; font-size: 13px; font-weight: 500; text-align: left; cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; opacity: .85; }
.nav-item svg .fill { fill: currentColor; stroke: none; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav-item.active { color: var(--accent); background: var(--accent-tint); font-weight: 600; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px;
  width: 2px; border-radius: 0 2px 2px 0; background: var(--accent);
}
.nav-divider { height: 1px; background: var(--border); margin: 12px 8px 4px; }
.nav-label { font-size: 9.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); padding: 4px 10px 3px; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 2px; color: var(--text-faint); font-size: 11px; border-top: 1px solid var(--border); }
.sidebar-foot #versionLabel { font-family: var(--mono); color: var(--text-dim); }
.sidebar-foot .foot-links { margin-top: 3px; color: var(--text-faint); }

/* ============ main / topbar (status strip) ============ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.topbar.alert { background: rgba(229,100,111,.06); }
.topbar.alert .topbar-msg { color: var(--red); font-weight: 600; }
.topbar-msg { font-size: 12.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.update-banner {
  display: flex; align-items: center; gap: 12px;
  margin: 12px 24px 0; padding: 9px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text);
  font-size: 12.5px; font-weight: 500;
}
.update-banner .ub-icon { font-size: 14px; color: var(--text-dim); }
.update-banner .btn { margin-left: 2px; }
.update-banner .ub-dismiss { margin-left: auto; background: none; border: 0; color: var(--text-faint); cursor: pointer; font-size: 13px; }
.update-banner .ub-dismiss:hover { color: var(--text); }
.update-banner.err { background: rgba(229,100,111,.09); border-color: rgba(229,100,111,.4); color: var(--red); }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #3a3f4d; display: inline-block; flex: none;
}
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
.dot.busy { background: var(--amber); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* ============ content / views ============ */
.content {
  flex: 1; overflow-y: auto; padding: 20px 24px 40px;
}
.view { display: none; }
.view.active { display: block; }
.view h1 {
  font-size: 19px; font-weight: 600; letter-spacing: -.01em; color: var(--text);
  margin-bottom: 3px;
}
.view > .hint { margin-bottom: 22px; display: block; }
/* title row with right-aligned controls (e.g. Ads Found) */
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.view-head h1 { margin-bottom: 3px; }
.view-head .btnrow { margin: 0; }

/* a .panel is a GROUP: heading rule + spacing, not a bordered card. */
.panel {
  background: none; border: 0; border-radius: 0;
  padding: 0; margin-bottom: 22px;
}
.panel h2 {
  font-size: 12.5px; font-weight: 600; letter-spacing: 0; color: var(--text);
  margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.panel h2 svg { width: 14px; height: 14px; stroke: var(--text-faint); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.panel h2 + .hint { margin: -6px 0 14px; display: block; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.panel-head .btn, .panel-head .toggle { margin-left: auto; }
.panel-head .toggle + .btn { margin-left: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.hint { color: var(--text-faint); font-size: 12.5px; font-weight: 400; text-transform: none; letter-spacing: 0; line-height: 1.5; }
.warn-text { color: var(--amber); }

/* ============ buttons / forms ============ */
.btn {
  font: inherit; font-weight: 500; font-size: 13px; cursor: pointer;
  padding: 7px 14px; border-radius: 6px;
  background: transparent; color: var(--text);
  border: 1px solid var(--line-strong);
  transition: background .12s, border-color .12s, filter .12s;
}
.btn:hover:not(:disabled) { border-color: var(--text-faint); }
.btn:disabled { opacity: .4; cursor: default; }
/* accent = the one primary action on a screen */
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.accent:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
/* Save is the primary action on its screen — accent, not a decorative green.
   (Save *success* is the semantic-green .savemsg readout.) */
.btn.save { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.save:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
/* danger/stop stays neutral — red is reserved for STATE, not buttons */
.btn.danger { background: transparent; border-color: var(--line-strong); color: var(--text-dim); }
.btn.danger:hover:not(:disabled) { border-color: var(--text-faint); color: var(--text); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); background: transparent; }
.btn.small { padding: 5px 11px; font-size: 12px; }
.btnrow { display: flex; align-items: center; gap: 9px; margin: 12px 0; flex-wrap: wrap; }

.formrow { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 4px; }
.formrow.col { flex-direction: column; align-items: stretch; gap: 10px; }
.formrow.toggles-row { align-items: center; gap: 20px; margin-top: 8px; }
.formrow label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-dim); font-weight: 500; }
.formrow label.wide { flex: 1; min-width: 260px; }
input[type=number], input[type=text], input[type=search], input[type=password], select {
  font: inherit; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; outline: none;
  min-width: 90px;
}
input[type=number], input[type=text], input[type=search], input[type=password] {
  font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums;
}
input:focus, select:focus { border-color: var(--accent-dim); }
input[type=search] { min-width: 160px; }

/* toggles — ON is an active state → accent; OFF neutral */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; color: var(--text-dim); flex-direction: row !important; }
.toggle input { display: none; }
.toggle span {
  width: 34px; height: 19px; border-radius: 99px; flex: none;
  background: var(--panel-2); border: 1px solid var(--border);
  position: relative; transition: background .15s, border-color .15s;
}
.toggle span::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--text-dim); transition: transform .15s, background .15s;
}
.toggle input:checked + span { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + span::after { transform: translateX(15px); background: var(--on-accent); }
.toggle.small span { width: 28px; height: 16px; }
.toggle.small input:checked + span::after { transform: translateX(11px); }
.toggle.small span::after { width: 10px; height: 10px; }

/* ============ dashboard ============ */
.statuslist { list-style: none; }
.statuslist li { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.statuslist li:last-child { border-bottom: 0; }
.statuslist li b { font-weight: 500; font-size: 13px; color: var(--text); }
.statuslist .detail { color: var(--text-dim); font-size: 12px; margin-left: auto; text-align: right; font-family: var(--mono); }
.bigstats { display: flex; gap: 34px; margin: 2px 0 14px; }
.bigstat { flex: none; }
.bigstat .num { font-family: var(--mono); font-size: 30px; font-weight: 500; color: var(--text); line-height: 1.05; font-variant-numeric: tabular-nums; }
.bigstat .lbl { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }
.wda-progress { display: flex; align-items: center; gap: 10px; color: var(--amber); font-size: 12.5px; margin-top: 6px; }
.wda-progress .btn { margin-left: auto; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid rgba(217,154,58,.25); border-top-color: var(--amber);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-box {
  margin-top: 10px; padding: 10px 12px; border-radius: 8px;
  background: rgba(229,100,111,.08); border: 1px solid rgba(229,100,111,.35);
  color: #f0a2a8; font-size: 12.5px;
}
.notice {
  padding: 9px 12px; border-radius: 6px; margin-bottom: 12px;
  background: rgba(217,154,58,.09); border: 1px solid rgba(217,154,58,.32);
  color: #e6b569; font-size: 12.5px;
}

/* ============ log boxes — a genuine container ============ */
.logbox {
  background: #0a0b0d; border: 1px solid var(--border); border-radius: 8px;
  height: 300px; overflow-y: auto; padding: 12px 14px;
  font-family: var(--mono); font-size: 12px; line-height: 1.65; white-space: pre-wrap; word-break: break-all;
  color: var(--text-dim); user-select: text;
}
.logbox.tall { height: calc(100vh - 260px); min-height: 300px; }
.logbox.console { height: 400px; }
.logline { display: block; padding: 1.5px 0; border-bottom: 1px solid rgba(255,255,255,.028); }
.logline .tag {
  display: inline-block; min-width: 34px; margin-right: 8px;
  font-size: 9.5px; font-weight: 700; text-align: center;
  border-radius: 4px; padding: 0 4px; vertical-align: 1px;
}
.logline.info .tag { background: var(--panel-2); color: var(--text-dim); }
.logline.warn .tag { background: rgba(217,154,58,.16); color: var(--amber); }
.logline.error .tag { background: rgba(229,100,111,.16); color: var(--red); }
.logline.wda { color: var(--text-faint); }
.logtools { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; margin-bottom: 10px; }
.logtools #logSearch { flex: 1 1 160px; min-width: 130px; }
.linecount { color: var(--text-faint); font-size: 11.5px; margin-left: auto; font-family: var(--mono); }
/* segmented control — active segment is a raised NEUTRAL chip (accent stays rationed) */
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 3px; }
.seg-btn { font: inherit; font-size: 12.5px; font-weight: 500; padding: 5px 13px; border: 0; border-radius: 5px; background: none; color: var(--text-dim); cursor: pointer; transition: background .12s, color .12s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--line-strong); color: var(--text); font-weight: 600; }

.runbadges { display: flex; gap: 8px; margin-left: auto; }
.runbadge {
  padding: 3px 10px; border-radius: 99px; font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim);
  font-family: var(--mono);
}
.runbadge b { color: var(--text); font-weight: 500; }

/* ============ ad finder ============ */
.af-notready { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.af-notready .btn { margin-left: auto; }
.af-options { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 4px; }
.opt-toggle { display: flex; align-items: flex-start; gap: 11px; cursor: pointer; padding: 5px 0; }
.opt-toggle input { display: none; }
.opt-sw { width: 34px; height: 19px; border-radius: 99px; flex: none; margin-top: 1px;
  background: var(--panel-2); border: 1px solid var(--border); position: relative; transition: background .15s, border-color .15s; }
.opt-sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--text-dim); transition: transform .15s, background .15s; }
.opt-toggle input:checked + .opt-sw { background: var(--accent); border-color: var(--accent); }
.opt-toggle input:checked + .opt-sw::after { transform: translateX(15px); background: var(--on-accent); }
.opt-text { display: flex; flex-direction: column; gap: 2px; }
.opt-name { font-size: 13px; font-weight: 500; color: var(--text); }
.opt-desc { font-size: 11.5px; color: var(--text-faint); line-height: 1.45; }

/* live stats — borderless instrument strip, mono numbers */
.af-stats { display: flex; gap: 34px; margin: 20px 0 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.af-stat { flex: none; }
.af-stat-num { font-family: var(--mono); font-size: 23px; font-weight: 500; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; }
.af-stat-num.accent { color: var(--text); font-size: 15px; display: inline-flex; align-items: center; gap: 7px; }
.af-stat-lbl { font-size: 11px; color: var(--text-faint); margin-top: 6px; }

.af-empty { color: var(--text-faint); font-size: 12.5px; padding: 12px 2px; }

/* console + phone preview side by side */
.output-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.console-panel { flex: 1; min-width: 340px; margin-bottom: 0; }
.preview-panel { width: 250px; flex: none; margin-bottom: 0; }
.preview-panel .panel-head { margin-bottom: 12px; }
.preview-panel .panel-head .toggle { margin-left: auto; }
.phone-frame {
  width: 210px; aspect-ratio: 1179 / 2556; margin: 0 auto;
  border-radius: 20px; border: 1px solid var(--line-strong);
  background: #050607; overflow: hidden; position: relative;
}
.phone-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-placeholder { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--text-faint); font-size: 12px; padding: 18px; line-height: 1.5; }
.seg.small { padding: 2px; }
.seg.small .seg-btn { padding: 4px 11px; font-size: 11.5px; }
.preview-status { text-align: center; font-family: var(--mono); font-size: 11px; color: var(--text-dim); margin-top: 12px; min-height: 14px; }
.preview-note { text-align: center; font-size: 10.5px; color: var(--text-faint); margin-top: 6px; line-height: 1.4; }
.lastrun-grid { display: flex; gap: 34px; flex-wrap: wrap; }
.lr-num { font-family: var(--mono); font-size: 21px; font-weight: 500; color: var(--text); line-height: 1.05; font-variant-numeric: tabular-nums; }
.lr-num.small { font-size: 14px; color: var(--text); font-weight: 500; }
.lr-lbl { font-size: 11px; color: var(--text-faint); margin-top: 5px; }

/* ============ code result — a genuine container (holds the captured code) ============ */
.code-result-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; margin-bottom: 22px; }
.cr-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 650; margin-bottom: 10px; }
.cr-line { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cr-code { font-family: var(--mono); font-size: 24px; font-weight: 500; letter-spacing: .01em; color: var(--text); user-select: text; }
.cr-meta { font-size: 12.5px; color: var(--text-dim); margin-top: 10px; font-family: var(--mono); }
.cg-debug-desc { margin-top: 10px; }
.cg-adperm { display: flex; align-items: flex-start; gap: 12px; }
.cg-adperm .ub-dismiss { margin-left: auto; background: none; border: 0; color: var(--text-faint); cursor: pointer; font-size: 13px; }
.cg-adperm .ub-dismiss:hover { color: var(--text); }

/* ============ tables — a genuine container ============ */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; color: var(--text-faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; padding: 6px 10px; border-bottom: 1px solid var(--border); }
td { padding: 7px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; user-select: text; }
/* themed checkbox — checked is an active selection state → accent */
.chk { display: inline-flex; align-items: center; cursor: pointer; }
.chk input { display: none; }
.chk > span {
  width: 17px; height: 17px; border-radius: 5px; flex: none;
  border: 1.5px solid var(--line-strong); background: var(--panel-2);
  display: grid; place-items: center; transition: background .12s, border-color .12s;
}
.chk:hover > span { border-color: var(--accent-dim); }
.chk input:checked + span { background: var(--accent); border-color: var(--accent); }
.chk > span::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px;
  border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent);
  transform: rotate(-45deg) scale(0); transition: transform .1s;
}
.chk input:checked + span::after { transform: rotate(-45deg) scale(1); }
.chkcol { width: 34px; }
th.chkcol, td.chkcol { padding-right: 4px; }
.sel-count { font-size: 12.5px; color: var(--text-dim); }

/* status badges — SEMANTIC (suspicious/ok), the point of the whole discipline */
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 10.5px; font-weight: 700; }
.badge.sus { background: rgba(229,100,111,.15); color: var(--red); }
.badge.ok { background: rgba(70,184,114,.13); color: var(--green); }
.thumb { width: 44px; height: 78px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; display: block; background: #0b0c10; }
.adthumb { position: relative; display: inline-block; cursor: zoom-in; }
/* slide count is DATA, not decoration — neutral chip, mono, no glow */
.slide-badge {
  position: absolute; bottom: 5px; right: 5px; pointer-events: none;
  padding: 1px 7px; border-radius: 99px; white-space: nowrap;
  font-size: 10px; font-weight: 600; font-family: var(--mono);
  color: var(--text); background: rgba(10,11,13,.82);
}
.empty { color: var(--text-dim); padding: 18px 4px; font-size: 12.5px; }

/* ============ settings layout + range sliders ============ */
.settings-grid { display: grid; grid-template-columns: 1fr 300px; gap: 28px; align-items: start; }
.settings-main { display: flex; flex-direction: column; gap: 22px; }
.settings-side { display: flex; flex-direction: column; gap: 22px; }
.settings-card { margin-bottom: 0; }
.settings-card.mini h2 { margin-bottom: 14px; }
.settings-card.mini .mini-lbl { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.card-rows { display: flex; flex-direction: column; gap: 20px; margin-top: 6px; }

.slider-block { display: flex; flex-direction: column; gap: 11px; }
.slider-block.toggle-block { gap: 0; padding: 2px 0; }
.slider-block.dimmed { opacity: .4; transition: opacity .15s; }
.slider-hint { margin-top: -2px; }
.slider-label { font-size: 13px; color: var(--text); }
.slider-label .slk { color: var(--text-dim); }
.slider-label .slv { color: var(--text); font-weight: 500; font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* reusable range slider — neutral (a value readout, not the accent) */
.rng { position: relative; height: 22px; }
.rng-track { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); height: 4px; border-radius: 3px; background: var(--panel-2); }
.rng-fill { position: absolute; top: 50%; transform: translateY(-50%); height: 4px; border-radius: 3px; background: var(--text-faint); }
.rng input[type=range] {
  position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 22px; margin: 0;
  background: none; pointer-events: none; -webkit-appearance: none; appearance: none;
}
.rng input[type=range]::-webkit-slider-runnable-track { background: none; border: none; }
.rng input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--text); border: 2px solid var(--bg); cursor: pointer;
  box-shadow: 0 0 0 1px var(--line-strong);
}

.actionbar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px; justify-content: flex-end;
  margin: 10px -24px -40px; padding: 14px 24px;
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}
.savemsg { font-size: 12.5px; color: var(--green); margin-right: auto; }
.savemsg.err { color: var(--red); }

/* ============ references ============ */
.thumbgrid { display: grid; grid-template-columns: repeat(auto-fill, 92px); gap: 12px; justify-content: start; }
.refitem { position: relative; }
.refitem img { width: 100%; aspect-ratio: 9/16; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; background: #0b0c10; }
.refitem .del {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0,0,0,.72); color: #fff; font-size: 12px; line-height: 1;
  opacity: 0; transition: opacity .12s;
}
.refitem:hover .del { opacity: 1; }
.refitem .del:hover { color: var(--red); }

.ref-caption { margin: 8px 0 14px; }
.ref-uploader {
  border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 22px 20px;
  text-align: center; margin-bottom: 16px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ref-uploader:hover:not(.full) { border-color: var(--text-faint); }
.ref-uploader.dragover { border-color: var(--accent); background: var(--accent-tint); }
.ref-uploader.full { opacity: .5; cursor: default; border-style: solid; }
.ref-uploader svg { width: 26px; height: 26px; fill: none; stroke: var(--text-faint); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ref-uploader.dragover svg { stroke: var(--accent); }
.ref-drop-title { font-size: 13px; color: var(--text); margin-top: 8px; }
.ref-browse { background: none; border: 0; color: var(--text); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.ref-browse:hover { color: var(--accent); }
.ref-slots { font-size: 12px; color: var(--text-faint); margin-top: 6px; font-family: var(--mono); }

/* both sets in one view: upload-target choice + grouped grid + set chips */
.ref-upload-target { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--text-dim); }
.seg.small .seg-btn { padding: 3px 11px; font-size: 12px; }

.ref-group { margin-top: 20px; }
.ref-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 11px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.ref-group-title { font-size: 13px; font-weight: 600; color: var(--text); }
.ref-group-title .hint { font-weight: 400; }
.ref-group-slots { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); }
.ref-group-slots.full { color: var(--amber); }
.ref-group-empty { padding: 2px 0 4px; }

/* the set tag — always visible, and clicking it flips the set (⇄ hint on hover) */
.ref-chip { position: absolute; top: 6px; left: 6px; border: 0; cursor: pointer; font: inherit;
  font-size: 10px; font-weight: 600; line-height: 1.4; padding: 2px 7px; border-radius: 999px; }
.ref-chip.ideal { background: var(--accent); color: var(--on-accent); }
.ref-chip.flag  { background: var(--amber); color: #1a1204; }
.ref-chip::after { content: " ⇄"; opacity: 0; transition: opacity .12s; }
.refitem:hover .ref-chip::after { opacity: .9; }
.ref-chip:hover { filter: brightness(1.12); }
/* a quiet coloured edge so the two sets read apart at a glance */
.refitem.ideal img { border-left: 2px solid var(--accent); }
.refitem.flag  img { border-left: 2px solid var(--amber); }

/* ============ signing — the semantic-colour showcase ============ */
.sign-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 99px;
  font-weight: 650; font-size: 13px;
  border: 1px solid transparent; margin-bottom: 14px;
}
.sign-badge::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.sign-badge.state-ok { background: rgba(70,184,114,.12); color: var(--green); border-color: rgba(70,184,114,.4); }
.sign-badge.state-warn { background: rgba(217,154,58,.12); color: var(--amber); border-color: rgba(217,154,58,.4); }
.sign-badge.state-expired,
.sign-badge.state-none { background: rgba(229,100,111,.14); color: var(--red); border-color: rgba(229,100,111,.45); }
.sign-note { margin: -4px 0 14px; max-width: 640px; }
.sign-facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 12.5px; }
.sign-facts .k { color: var(--text-dim); }
.sign-facts .v { color: var(--text); user-select: text; }
.sign-facts .v.mono { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
#signUsing { margin-top: 12px; }

/* collapsible card */
.collapse-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--text-dim); font: inherit; font-size: 11px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .06em; text-align: left;
}
.collapse-head .chev { display: inline-block; transition: transform .15s; }
.collapse-head[aria-expanded="true"] .chev { transform: rotate(90deg); }
.collapse-body { margin-top: 12px; }
.collapse-body p { color: var(--text-dim); font-size: 13px; margin-bottom: 8px; }
.trust-steps { margin: 4px 0 8px 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.trust-steps li { padding-left: 4px; }
.err-link { color: var(--text); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; margin-left: 6px; white-space: nowrap; }
.err-link:hover { color: var(--accent); }

/* ============ setup wizard ============ */
.setup-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.setup-head h1 { margin-bottom: 3px; }
.setup-head .btnrow { margin: 0; }
.setup-ready {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 13px 15px; margin-bottom: 20px; border-radius: 8px;
  background: rgba(70,184,114,.1); border: 1px solid rgba(70,184,114,.4);
  color: var(--green); font-weight: 600;
}
.setup-ready .btn { margin-left: auto; }
/* one bordered container; rows are a dense checklist, not stacked cards */
.setup-list { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); overflow: hidden; }
.setup-group {
  font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint); padding: 11px 16px 6px; background: rgba(255,255,255,.015);
  border-top: 1px solid var(--border);
}
.setup-list > .setup-group:first-child { border-top: 0; }
.setup-item + .setup-item { border-top: 1px solid var(--border-soft); }
.setup-row { display: flex; align-items: center; gap: 11px; padding: 9px 16px; }
.setup-ic { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; flex: none; }
.status-ok   .setup-ic { background: rgba(70,184,114,.15); color: var(--green); }
.status-warn .setup-ic { background: rgba(217,154,58,.15); color: var(--amber); }
.status-fail .setup-ic { background: rgba(229,100,111,.15); color: var(--red); }
.setup-name { font-weight: 500; font-size: 13px; color: var(--text); display: inline-flex; align-items: center; gap: 8px; flex: none; }
.setup-opt { font-size: 9.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); border: 1px solid var(--border); border-radius: 99px; padding: 1px 6px; }
.setup-detail { color: var(--text-dim); font-size: 12px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.setup-actions { flex: none; display: flex; align-items: center; gap: 8px; margin-left: auto; }
.setup-extra { padding: 0 16px 12px 45px; display: flex; flex-direction: column; gap: 8px; }
.setup-instructions { font-size: 12px; color: var(--text); white-space: pre-wrap; background: #0a0b0d; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; user-select: text; font-family: var(--mono); line-height: 1.55; }
.setup-instructions a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.setup-instructions a:hover { color: var(--accent); }
.setup-spin { display: inline-flex; align-items: center; gap: 8px; color: var(--amber); font-size: 12px; }

/* device-first setup layout */
.setup-summary { font-size: 13px; color: var(--text-dim); margin-bottom: 20px; }
.setup-summary b { color: var(--text); font-weight: 600; }
.sum-needs.needs, .sum-needs.needs b { color: var(--amber); }

.status-pill { padding: 3px 11px; border-radius: 99px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.status-pill.ok { color: var(--green); background: rgba(70,184,114,.13); border: 1px solid rgba(70,184,114,.35); }
.status-pill.warn { color: var(--amber); background: rgba(217,154,58,.12); border: 1px solid rgba(217,154,58,.35); }
.status-pill.fail { color: var(--red); background: rgba(229,100,111,.13); border: 1px solid rgba(229,100,111,.4); }

/* device card — the hero device readout, a genuine surface container */
.device-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; margin-bottom: 22px; }
.device-card .panel-head { margin-bottom: 14px; }
.device-card .panel-head .status-pill { margin-left: auto; }
.device-main { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; }
.dev-dot { width: 10px; height: 10px; flex: none; }
.dev-id { min-width: 0; }
.dev-name { font-weight: 600; font-size: 15px; color: var(--text); }
.dev-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; font-family: var(--mono); }
.device-svcs { margin-left: auto; min-width: 230px; }
.device-svcs li { padding: 6px 0; }
.device-card .setup-instructions { margin-top: 14px; }
.device-card .btnrow { margin-bottom: 0; }

.setup-section { margin-bottom: 22px; }
.setup-section-label { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; color: var(--text-faint); }
.setup-section-label.attn { color: var(--amber); }

.collapse-card .collapse-head { font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text); }
.collapse-card .collapse-head .chev { color: var(--text-dim); }
.collapse-card .collapse-head .status-pill { margin-left: auto; }
.collapse-card .collapse-body { margin-top: 14px; }
.env-form { display: grid; grid-template-columns: 200px 1fr; gap: 10px 12px; align-items: center; margin-top: 10px; max-width: 620px; }
.env-form label { color: var(--text-dim); font-size: 12.5px; font-family: var(--mono); }
.env-form .env-save { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; }
.udid-suggest { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12.5px; }
.udid-suggest .mono { user-select: text; }

/* ============ modal & toast ============ */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.8);
  display: flex; align-items: center; justify-content: center; z-index: 50; cursor: zoom-out;
}
.modal img { max-width: 88vw; max-height: 88vh; border-radius: 10px; }

/* ============ proxy tab + dialog ============ */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.px-star { background: none; border: 0; color: var(--text-faint); font-size: 15px; cursor: pointer; line-height: 1; padding: 0 2px; }
.px-star:hover { color: var(--text); }
.px-star.on { color: var(--text); }
.px-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mini-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 99px; font-size: 9.5px; font-weight: 600; font-family: var(--mono); color: var(--text); background: var(--panel-2); vertical-align: middle; }
.config-preview {
  background: #0a0b0d; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; height: 320px; overflow: auto; margin-top: 12px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55; white-space: pre; color: var(--text-dim); user-select: text;
}
.srv-status { display: flex; align-items: center; gap: 9px; height: 34px; }
.srv-dot { width: 8px; height: 8px; border-radius: 50%; background: #3a3f4d; flex: none; }
.srv-dot.ok { background: var(--green); }
.srv-dot.bad { background: var(--red); }
.srv-status #proxySrvText { font-size: 12.5px; color: var(--text-dim); }
.srv-status .btn { margin-left: 4px; }
.sub-grid { display: flex; gap: 20px; align-items: flex-start; margin-top: 14px; flex-wrap: wrap; }
.qr-wrap { background: #fff; padding: 9px; border-radius: 10px; flex: none; line-height: 0; }
.qr-wrap img { display: block; width: 150px; height: 150px; image-rendering: pixelated; }
.sub-side { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 14px; }
.sub-side label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-dim); font-weight: 500; }
.url-row { display: flex; gap: 8px; }
.url-row input { flex: 1; min-width: 0; }

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 65; padding: 24px;
  background: rgba(0,0,0,.62);
  display: flex; align-items: center; justify-content: center;
}
.dialog {
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.dialog-x { background: none; border: 0; color: var(--text-dim); font-size: 15px; cursor: pointer; }
.dialog-x:hover { color: var(--text); }
.dialog-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-body label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-dim); font-weight: 500; }
.dialog-body label .hint { font-weight: 400; }
.dialog-body input, .dialog-body select { width: 100%; }
.dialog-row { display: flex; gap: 12px; }
.dialog-row label { flex: 1; }
.dialog-row .px-portcol { flex: 0 0 110px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* carousel lightbox */
.lightbox { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.9); }
.lb-img { max-width: 84vw; max-height: 86vh; border-radius: 10px; box-shadow: 0 12px 50px rgba(0,0,0,.6); }
.lb-nav, .lb-close {
  position: absolute; border: 1px solid var(--border); background: rgba(23,25,28,.82);
  color: var(--text); cursor: pointer; display: grid; place-items: center;
  transition: color .12s, border-color .12s;
}
.lb-nav { top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; font-size: 26px; line-height: 1; }
.lb-prev { left: 26px; } .lb-next { right: 26px; }
.lb-close { top: 22px; right: 26px; width: 40px; height: 40px; border-radius: 50%; font-size: 17px; }
.lb-nav:hover, .lb-close:hover { color: var(--text); border-color: var(--text-faint); }
.lb-counter {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  font-size: 13px; font-weight: 500; font-family: var(--mono); color: var(--text);
  background: rgba(23,25,28,.85); border: 1px solid var(--border);
  padding: 5px 15px; border-radius: 99px;
}
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 8px; font-size: 13px; z-index: 60;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.err { border-color: var(--red-muted); color: #f0a2a8; }

@media (max-width: 1100px) {
  .grid-2, .settings-grid { grid-template-columns: 1fr; }
}

/* ===== Poster tab ===== */
.poster-folder { display: flex; align-items: center; gap: 12px; }
.poster-folder-path {
  flex: 1; min-width: 0; padding: 8px 11px; border-radius: 7px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.poster-folder-path.muted { color: var(--text-faint); font-style: italic; }
.poster-count-line { display: flex; align-items: center; gap: 12px; margin-top: 11px; }
.poster-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-tint); color: var(--accent);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.poster-badge.tiny { padding: 1px 6px; font-size: 10.5px; }
.poster-progress { margin-left: 6px; color: var(--accent); font-size: 12.5px; align-self: center; }
.po-caption-box textarea { width: 100%; resize: vertical; min-height: 40px; }
.po-sidecar-note code {
  padding: 1px 5px; border-radius: 4px; background: var(--panel-2);
  border: 1px solid var(--border); font-size: 11.5px;
}
.notice.po-invalid { border-color: var(--red-muted); color: #f0a2a8; }
.notice.po-publish-warn { border-color: rgba(217,154,58,.45); color: var(--amber); background: rgba(217,154,58,.08); }
/* the publish switch is the one destructive control — tint it so it reads as such */
.danger-toggle input:checked + .opt-sw { background: var(--red); border-color: var(--red); }
.danger-toggle input:checked + .opt-sw::after { border-color: var(--red); }

.btn.tiny {
  padding: 2px 8px; font-size: 11px; min-height: 0; line-height: 1.5;
  border-radius: 6px;
}
#poPostsTable .po-cap {
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-dim);
}
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 11.5px; font-weight: 600;
}
.chip.good { background: rgba(70,184,114,.12); border-color: rgba(70,184,114,.4); color: var(--green-2); }
.chip.warn { background: rgba(217,154,58,.12); border-color: rgba(217,154,58,.4); color: var(--amber); }

/* ===== Flows tab ===== */
.flow-row { display: flex; align-items: stretch; gap: 4px; margin: 6px 0 26px; overflow-x: auto; padding-bottom: 4px; }
.flow-stage {
  flex: 1 1 0; min-width: 152px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 13px 14px; display: flex; flex-direction: column; gap: 7px;
}
.flow-stage.manual { background: none; border-style: dashed; border-color: var(--line-strong); }
.flow-stage.running { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-tint); }
.flow-stage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.flow-stage-name { font-size: 13px; font-weight: 600; color: var(--text); }
.flow-kind { font-size: 8.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.flow-count { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; min-height: 30px; }
.flow-count .num { font-size: 24px; font-weight: 500; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; }
.flow-lbl { font-size: 11px; color: var(--text-faint); }
.flow-sub { flex-basis: 100%; font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.flow-stub { font-size: 12px; color: var(--text-faint); font-style: italic; }
.flow-last { font-size: 11px; color: var(--text-faint); min-height: 14px; }
.flow-action { margin-top: auto; padding-top: 2px; }
.flow-action .btn { width: 100%; }
.flow-manual { font-size: 11px; color: var(--text-faint); }
.flow-arrow { display: flex; align-items: center; color: var(--text-faint); font-size: 17px; flex: none; }
.flow-stub-panel { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; padding: 6px 2px; max-width: 720px; }
.flow-stub-panel code { padding: 1px 5px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--border); font-size: 11.5px; }
