:root {
  color-scheme: light dark;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --sidebar: #0f1115;
  --sidebar-fg: #a9afbc;
  --sidebar-active: #1c2029;
  --fg: #11141a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.04);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d11;
    --surface: #13161c;
    --surface-2: #1a1e26;
    --sidebar: #08090c;
    --sidebar-active: #171a21;
    --fg: #e8eaef;
    --muted: #8b92a1;
    --line: #232834;
    --accent: #818cf8;
    --accent-soft: rgba(129, 140, 248, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html { height: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  min-height: 100%;
  display: flex;
  font: 14px/1.5 var(--font);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-fg);
  padding: 20px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 24px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff; font-weight: 700; font-size: 16px;
}
.brand-name { color: #fff; font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--sidebar-fg); text-decoration: none; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
nav a:hover { background: var(--sidebar-active); color: #fff; }
nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 2px 0 0 #818cf8; }
nav .nav-group { margin: 16px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #5b6170; }
.sidebar-foot { margin-top: auto; padding: 12px; border-radius: 10px; background: var(--sidebar-active); font-size: 12px; line-height: 1.6; }
.sidebar-foot b { color: #fff; font-weight: 500; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  padding: 28px 36px 20px;
}
.topbar h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.topbar p { margin: 4px 0 0; }
.page { padding: 0 36px 48px; width: 100%; }
.actions { display: flex; gap: 8px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* Layout helpers */
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-title { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.card-sub { font-size: 12px; color: var(--muted); }

/* Metrics */
.metric { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 14px 0 10px; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.4s ease; }
.progress.warn > span { background: var(--warn); }
.progress.bad > span { background: var(--bad); }
.week-bar { display: flex; height: 10px; margin: 12px 0 8px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.seg-owner { background: var(--warn); }
.seg-agents { background: var(--ok); }
.seg-unknown { background: var(--muted); opacity: 0.5; }
.seg-total { background: var(--accent); }
.bar-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 12px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.bar-legend > span > b { flex-shrink: 0; width: 10px; height: 10px; border-radius: 3px; }
.limit-bar { position: relative; height: 14px; margin: 12px 0 8px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.limit-bar > span { position: absolute; top: 0; bottom: 0; }
.zone-soft { background: rgba(245, 158, 11, 0.35); }
.zone-wait { background: rgba(249, 115, 22, 0.5); }
.zone-hard { background: rgba(239, 68, 68, 0.6); }
.limit-bar .zone-soft, .limit-bar .zone-wait, .limit-bar .zone-hard { border-left: 2px solid var(--fg); }
.limit-fill { left: 0; height: 6px; top: 4px !important; bottom: auto !important; border-radius: 0 3px 3px 0; }
.limit-fill.ok { background: var(--ok); }
.limit-fill.warn { background: var(--warn); }
.limit-fill.bad { background: var(--bad); }
.bar-legend b.num { width: auto; height: auto; color: var(--fg); font-weight: 600; }
.share-bar { display: flex; gap: 3px; height: 26px; margin: 12px 0 10px; }
.share-bar > span { position: relative; display: flex; align-items: center; min-width: 0; border-radius: 6px; overflow: hidden; }
.share-bar > .seg-owner { background: rgba(245, 158, 11, 0.22); }
.share-bar > .seg-agents { background: rgba(16, 185, 129, 0.22); }
.share-bar i { position: absolute; inset: 0 auto 0 0; }
.share-bar .seg-owner i { background: var(--warn); }
.share-bar .seg-agents i { background: var(--ok); }
.share-bar em { position: relative; padding: 0 8px; font-size: 12px; font-style: normal; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.provider-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: rgba(16, 185, 129, 0.12); color: var(--ok); }
.badge.warn { background: rgba(245, 158, 11, 0.14); color: var(--warn); }
.badge.bad { background: rgba(239, 68, 68, 0.12); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.plain::before { display: none; }
.badge.pending::before { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.2; } }
.steps { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; font-size: 11px; }
.steps span { padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.steps .done { color: var(--ok); }
.steps .now { background: var(--accent-soft); color: var(--accent); font-weight: 600; animation: pulse 1.6s ease-in-out infinite; }
.live-frame { display: block; width: 100%; max-width: 400px; margin-top: 6px; border-radius: 8px; border: 1px solid var(--line); }

/* Controls */
button, .btn {
  font: inherit; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  cursor: pointer; transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
button:hover { border-color: var(--accent); }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 8px; }
button.ghost:hover { color: var(--bad); }
button svg, .btn svg { width: 16px; height: 16px; flex-shrink: 0; }

input, select {
  font: inherit; color: var(--fg);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=number] { width: 96px; font-variant-numeric: tabular-nums; }
input.time { width: 76px; text-align: center; font-variant-numeric: tabular-nums; }

/* Rules: one setting per row, the day as a strip. */
.rule-sub { margin: -8px 0 6px; }
.rule-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.rule-sub + .rule-row { border-top: 0; }
.rule-row > span:first-child { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.rule-row small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.rule-row .switch { white-space: nowrap; flex-shrink: 0; }
.unit-input { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.unit-input input { width: 76px; text-align: right; font-variant-numeric: tabular-nums; }
.day-strip { position: relative; display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.day-strip i { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--fg); opacity: 0.8; }
.day-ticks { position: relative; height: 20px; margin-top: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.day-ticks span { position: absolute; transform: translateX(-50%); }
.day-ticks span:first-child { transform: none; }
.day-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.day-legend span { display: inline-flex; align-items: center; gap: 6px; }
.day-legend b { width: 10px; height: 10px; border-radius: 3px; }
.day-owner { background: var(--accent); }
.day-agents { background: var(--ok); }
.day-soft { background: var(--warn); }
.day-wait { background: var(--bad); }
.day-5h { background: var(--fg); width: 2px !important; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.field input, .field select { font-size: 14px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.2s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform 0.2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }

.segmented { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 14px; border-radius: 9px; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: middle; }
th { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Toggle tiles on overview */
.toggle-tile { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.toggle-tile:last-child { border-bottom: 0; padding-bottom: 0; }
.toggle-tile:first-child { padding-top: 0; }
.toggle-tile .desc { font-size: 12px; color: var(--muted); }

/* Timeline */

/* Week grid */
.week-row { display: grid; grid-template-columns: 48px auto 1fr; align-items: center; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.week-row:last-child { border-bottom: 0; }
.week-row .day { font-weight: 600; }
.week-row.off .times { opacity: 0.35; pointer-events: none; }

.scope-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.scope-row:last-child { border-bottom: 0; }
.scope-row.off > .row { opacity: 0.4; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 10;
  padding: 12px 16px; border-radius: 12px;
  background: var(--fg); color: var(--bg); font-weight: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
  animation: toast-in 0.2s ease;
}
.toast.error { background: var(--bad); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.mobilebar, .backdrop { display: none; }
.icon-btn { padding: 8px; border-radius: 10px; background: transparent; border-color: transparent; color: inherit; }
.icon-btn svg { width: 22px; height: 22px; }

@media (max-width: 860px) {
  body { flex-direction: column; }

  .mobilebar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 20;
    padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
    background: var(--sidebar); color: #fff;
  }
  .mobilebar .brand-mark { width: 26px; height: 26px; font-size: 14px; border-radius: 8px; }

  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; height: 100dvh;
    width: min(280px, 82vw);
    transform: translateX(-100%); transition: transform 0.25s ease;
    padding-top: max(20px, env(safe-area-inset-top));
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.35);
  }
  body.nav-open .sidebar { transform: none; }
  .backdrop {
    display: block; position: fixed; inset: 0; z-index: 30;
    background: rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.25s;
  }
  body.nav-open .backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  nav a { padding: 12px; }

  .topbar { padding: 20px 16px 14px; align-items: flex-start; flex-wrap: wrap; }
  .topbar h1 { font-size: 22px; }
  .page { padding: 0 16px 32px; }
  .card { padding: 16px; }
  .card-head { flex-wrap: wrap; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .segmented { max-width: 100%; overflow-x: auto; }
  .segmented button { white-space: nowrap; }
  .field { flex: 1 1 100%; }
  .field input, .field select { width: 100%; }
  #journal-search { width: 100% !important; }
  .hide-sm { display: none; }
  .toast { left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }

  /* Data tables become one card per row, labelled from data-label. */
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: auto !important; }
  table.responsive tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.responsive tr:last-child { border-bottom: 0; }
  table.responsive td { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; border: 0; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex-shrink: 0; }
  table.responsive td:empty { display: none; }
  table.responsive td.mono { word-break: break-word; }
}

.budget-line {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 13px; font-variant-numeric: tabular-nums;
}

.mode-grid { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; }
.mode-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
}
.mode-tile b { font-size: 14px; }
.mode-tile span { font-size: 12px; color: var(--muted); font-weight: 400; line-height: 1.45; }
.mode-tile.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.mode-tile.mode-stop.active { border-color: var(--bad); background: rgba(239, 68, 68, 0.1); box-shadow: 0 0 0 1px var(--bad) inset; }
.mode-until { min-width: 220px; }
.mode-label.mode-stop { color: var(--bad); }
.mode-label.mode-owner, .mode-label.mode-away, .mode-label.mode-parallel { color: #a5b4fc; }
.mode-select { display: none; }
.mode-select span { font-weight: 400; line-height: 1.45; }
@media (max-width: 860px) {
  .mode-grid { display: none; }
  .mode-select { display: flex; }
}
/* Name takes the free space on the left; every other column hugs its content on the right. */
.projects-table th:not(:first-child), .projects-table td:not(:first-child) { width: 1%; white-space: nowrap; text-align: right; }
.project-row { cursor: pointer; }
.project-row:hover td { background: var(--surface-2); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-size: 12px; }
button.link:hover { text-decoration: underline; }

.project-dialog { background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(680px, 96vw); max-height: 92vh; }
body:has(dialog[open]) { overflow: hidden; }
dialog:focus, dialog:focus-visible { outline: none; }
.squads-dialog { width: min(760px, 94vw); }
.branches-dialog { width: min(820px, 94vw); }
.branches-dialog .dialog-actions { justify-content: flex-end; margin-top: 16px; }
.branch-list { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.branch-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.branch-list > div:last-child { border-bottom: 0; }
.project-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.pd-head { margin-bottom: 8px; align-items: flex-start; }
.pd-head .card-title { white-space: normal; overflow-wrap: anywhere; min-width: 0; }
.pd-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pd-section { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.pd-section .card-head { margin: 0; }
.pd-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.pd-stats > div { display: flex; flex-direction: column; gap: 4px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); font-size: 12px; }
.pd-stats b { font-size: 18px; font-variant-numeric: tabular-nums; }
.pd-stats b .mono { font-size: 14px; }
.pd-none { padding: 6px 0; font-size: 13px; }
.pd-route { flex-wrap: nowrap; gap: 4px; color: var(--muted); }
.pd-route select { width: 92px; }
.pd-section .rule-row { padding: 10px 0; }
.cut-row { gap: 12px; align-items: flex-end; }
.cut-row .field { flex: 1 1 120px; }
.cut-row .field input, .cut-row .field select { width: 100%; }
.cut-form [hidden] { display: none; }
iframe.video-cover { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; }
.branch-edit { gap: 8px; flex-wrap: nowrap; margin: 8px 0; }
.branch-edit input { flex: 1; min-width: 0; }

.sim-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.sim-presets button { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 12px 14px; }
.sim-presets span { font-size: 12px; color: var(--muted); }
.sim-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sim-fields:last-child { border-bottom: 0; }
.sim-fields > b { width: 100%; font-size: 13px; }
.sim-fields input[type=datetime-local] { width: 190px; }
.sim-fields select { max-width: 260px; }
.sim-clock-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.sim-clock { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sim-steps { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.sim-for input { width: 80px; }
.sim-chart { width: 100%; height: 120px; display: block; margin-top: 6px; }
.sim-chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.sim-list { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.sim-events { display: flex; flex-direction: column; max-height: 420px; overflow-y: auto; font-size: 13px; }
.sim-events > div { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.sim-events .badge { flex: none; }

.drill-status { padding: 12px 0 0; border-top: 1px solid var(--line); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.drill-banner { display: block; padding: 12px 20px; border-color: var(--warn); color: var(--warn); text-decoration: none; font-size: 13px; }
.queue-page a:visited { color: LinkText; }

/* Shard */
.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.clip-card { padding: 12px; display: flex; flex-direction: column; gap: 8px; position: relative; }
.clip-del { position: absolute; top: 18px; right: 18px; padding: 6px; border: none; border-radius: 8px; background: rgba(0, 0, 0, 0.55); color: var(--bad); }
.clip-del:hover { background: rgba(0, 0, 0, 0.8); }
.clip-card.off { opacity: 0.5; }
.clip-card video { width: 100%; aspect-ratio: 9 / 16; border-radius: 8px; background: #000; }
.clip-title { font-size: 13px; font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.clip-meta { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clip-info { display: flex; flex-direction: column; gap: 6px; flex: 1; cursor: pointer; border-radius: 8px; margin: -4px; padding: 4px; }
.clip-info:hover { background: var(--surface-2); }
.clip-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.clip-actions > :not(.ghost) { flex: 1 1 auto; justify-content: center; padding: 7px 10px; }
.clip-actions > .btn:first-child { flex: 0 0 auto; }
.clip-dialog { width: min(860px, 96vw); }
.clip-dialog-body { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.clip-dialog-body video { width: 100%; aspect-ratio: 9 / 16; border-radius: 8px; background: #000; }
.clip-dialog .pd-stats { margin-bottom: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.clip-dialog .tags { flex-wrap: wrap; gap: 6px; }
@media (max-width: 640px) { .clip-dialog-body { grid-template-columns: 1fr; } .clip-dialog-body video { max-height: 60vh; } }
.cam-editor { position: relative; cursor: crosshair; user-select: none; touch-action: none; aspect-ratio: 16 / 9; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.cam-editor img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cam-rect { position: absolute; border: 2px solid var(--warn); background: rgba(245, 158, 11, 0.18); pointer-events: none; }
.cam-note { position: absolute; inset: 0; display: grid; place-items: center; }
.cam-note[hidden] { display: none; }
.video-row { cursor: pointer; }
.video-cell { display: flex; align-items: center; gap: 12px; }
.video-thumb { width: 120px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; flex: none; background: var(--surface-2); }
.video-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; display: block; }
.video-cover.blank, .video-thumb.blank { background: var(--surface-2); }
.video-error { color: var(--bad); white-space: pre-wrap; word-break: break-word; font-size: 12px; margin-top: 4px; }
.video-error.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }

.auth-screen { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; padding: 16px; }
.auth-screen form { width: min(360px, 100%); }
.sidebar-user { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.sidebar-user button { padding: 2px 8px; font-size: 12px; }
.token-box { word-break: break-all; user-select: all; padding: 10px; border-radius: 8px; background: var(--surface-2); }
.profile-shot { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }

/* Add-a-machine dialog */
.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--surface-2); width: max-content; }
.tabs .tab { border: 0; background: transparent; color: var(--muted); padding: 4px 10px; border-radius: 6px; }
.tabs .tab.active { background: var(--bg); color: inherit; box-shadow: 0 0 0 1px var(--line); }
.cmd-box { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.cmd-box .mono { flex: 1; word-break: break-all; white-space: pre-wrap; font-size: 12.5px; }
.connect-status { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.pulse { background: var(--accent); animation: dot-pulse 1.4s ease-in-out infinite; }
@keyframes dot-pulse { 50% { opacity: 0.3; } }
label.check { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
