/* ==========================================================================
   TNest Studio Hub V2 — Apple HIG × Google Material Design 3 Clean UI System
   清爽亮色为主（默认跟随系统并支持三态切换），视频审片区使用局部暗室容器
   ========================================================================== */

:root {
  /* Light Palette (Apple HIG Neutral Canvas + Material 3 Tonal Surfaces) */
  --bg-light: #f5f5f7;
  --surface-light: #ffffff;
  --surface-2-light: #f0f2f5;
  --surface-hover-light: #e8ecf2;
  --glass-light: rgba(255, 255, 255, 0.82);
  --border-light: rgba(15, 23, 42, 0.08);
  --border-strong-light: rgba(15, 23, 42, 0.16);
  --text-light: #1d1d1f;
  --muted-light: #6e6e73;
  --brand-light: #0071e3;
  --brand-hover-light: #0062c4;
  --brand-tonal-light: #e8f2ff;
  --brand-text-light: #ffffff;

  --ok-light: #047857;
  --ok-bg-light: #ecfdf5;
  --info-light: #1d4ed8;
  --info-bg-light: #eff6ff;
  --warn-light: #b45309;
  --warn-bg-light: #fffbeb;
  --err-light: #b91c1c;
  --err-bg-light: #fef2f2;

  --shadow-sm-light: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md-light: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg-light: 0 18px 48px rgba(15, 23, 42, 0.14);
  --scroll-thumb-light: #9ca3af;
  --scroll-track-light: transparent;

  /* Dark Palette (macOS Dark + Clean Neutral Slate) */
  --bg-dark: #0d1117;
  --surface-dark: #161b22;
  --surface-2-dark: #21262d;
  --surface-hover-dark: #2a313c;
  --glass-dark: rgba(22, 27, 34, 0.84);
  --border-dark: rgba(240, 246, 252, 0.10);
  --border-strong-dark: rgba(240, 246, 252, 0.20);
  --text-dark: #e6edf3;
  --muted-dark: #8b949e;
  --brand-dark: #2f81f7;
  --brand-hover-dark: #58a6ff;
  --brand-tonal-dark: rgba(56, 139, 253, 0.16);
  --brand-text-dark: #ffffff;

  --ok-dark: #3fb950;
  --ok-bg-dark: rgba(46, 160, 67, 0.16);
  --info-dark: #58a6ff;
  --info-bg-dark: rgba(56, 139, 253, 0.16);
  --warn-dark: #d29922;
  --warn-bg-dark: rgba(210, 153, 34, 0.16);
  --err-dark: #f85149;
  --err-bg-dark: rgba(248, 81, 73, 0.16);

  --shadow-sm-dark: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md-dark: 0 6px 20px rgba(0, 0, 0, 0.36);
  --shadow-lg-dark: 0 20px 56px rgba(0, 0, 0, 0.56);
  --scroll-thumb-dark: #484f58;
  --scroll-track-dark: transparent;

  /* Fallback tokens for browsers without light-dark() */
  --bg: var(--bg-light);
  --surface: var(--surface-light);
  --surface-2: var(--surface-2-light);
  --surface-hover: var(--surface-hover-light);
  --glass: var(--glass-light);
  --border: var(--border-light);
  --border-strong: var(--border-strong-light);
  --text: var(--text-light);
  --muted: var(--muted-light);
  --brand: var(--brand-light);
  --brand-hover: var(--brand-hover-light);
  --brand-tonal: var(--brand-tonal-light);
  --brand-text: var(--brand-text-light);
  --ok: var(--ok-light);
  --ok-bg: var(--ok-bg-light);
  --info: var(--info-light);
  --info-bg: var(--info-bg-light);
  --warn: var(--warn-light);
  --warn-bg: var(--warn-bg-light);
  --err: var(--err-light);
  --err-bg: var(--err-bg-light);
  --shadow-sm: var(--shadow-sm-light);
  --shadow-md: var(--shadow-md-light);
  --shadow-lg: var(--shadow-lg-light);
  --scroll-thumb: var(--scroll-thumb-light);
  --scroll-track: var(--scroll-track-light);

  @media (prefers-color-scheme: dark) {
    --bg: var(--bg-dark);
    --surface: var(--surface-dark);
    --surface-2: var(--surface-2-dark);
    --surface-hover: var(--surface-hover-dark);
    --glass: var(--glass-dark);
    --border: var(--border-dark);
    --border-strong: var(--border-strong-dark);
    --text: var(--text-dark);
    --muted: var(--muted-dark);
    --brand: var(--brand-dark);
    --brand-hover: var(--brand-hover-dark);
    --brand-tonal: var(--brand-tonal-dark);
    --brand-text: var(--brand-text-dark);
    --ok: var(--ok-dark);
    --ok-bg: var(--ok-bg-dark);
    --info: var(--info-dark);
    --info-bg: var(--info-bg-dark);
    --warn: var(--warn-dark);
    --warn-bg: var(--warn-bg-dark);
    --err: var(--err-dark);
    --err-bg: var(--err-bg-dark);
    --shadow-sm: var(--shadow-sm-dark);
    --shadow-md: var(--shadow-md-dark);
    --shadow-lg: var(--shadow-lg-dark);
    --scroll-thumb: var(--scroll-thumb-dark);
    --scroll-track: var(--scroll-track-dark);
  }

  @supports (color: light-dark(white, black)) {
    --bg: light-dark(var(--bg-light), var(--bg-dark));
    --surface: light-dark(var(--surface-light), var(--surface-dark));
    --surface-2: light-dark(var(--surface-2-light), var(--surface-2-dark));
    --surface-hover: light-dark(var(--surface-hover-light), var(--surface-hover-dark));
    --glass: light-dark(var(--glass-light), var(--glass-dark));
    --border: light-dark(var(--border-light), var(--border-dark));
    --border-strong: light-dark(var(--border-strong-light), var(--border-strong-dark));
    --text: light-dark(var(--text-light), var(--text-dark));
    --muted: light-dark(var(--muted-light), var(--muted-dark));
    --brand: light-dark(var(--brand-light), var(--brand-dark));
    --brand-hover: light-dark(var(--brand-hover-light), var(--brand-hover-dark));
    --brand-tonal: light-dark(var(--brand-tonal-light), var(--brand-tonal-dark));
    --brand-text: light-dark(var(--brand-text-light), var(--brand-text-dark));
    --ok: light-dark(var(--ok-light), var(--ok-dark));
    --ok-bg: light-dark(var(--ok-bg-light), var(--ok-bg-dark));
    --info: light-dark(var(--info-light), var(--info-dark));
    --info-bg: light-dark(var(--info-bg-light), var(--info-bg-dark));
    --warn: light-dark(var(--warn-light), var(--warn-dark));
    --warn-bg: light-dark(var(--warn-bg-light), var(--warn-bg-dark));
    --err: light-dark(var(--err-light), var(--err-dark));
    --err-bg: light-dark(var(--err-bg-light), var(--err-bg-dark));
    --scroll-thumb: light-dark(var(--scroll-thumb-light), var(--scroll-thumb-dark));
    --scroll-track: light-dark(var(--scroll-track-light), var(--scroll-track-dark));
  }

  /* MANDATORY (dark-mode-toggle): base stays light dark; meta reflects manual override */
  color-scheme: light dark;
  accent-color: var(--brand);

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
    --shadow-sm: var(--shadow-sm-dark);
    --shadow-md: var(--shadow-md-dark);
    --shadow-lg: var(--shadow-lg-dark);
  }
  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
    --shadow-sm: var(--shadow-sm-light);
    --shadow-md: var(--shadow-md-light);
    --shadow-lg: var(--shadow-lg-light);
  }

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --topbar-h: 56px;
  --sidebar-w: 224px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 0.875rem; }

/* Standard Scrollbar with @supports legacy fallback */
.scroller {
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
  scrollbar-width: thin;
}
@supports not (scrollbar-color: auto) {
  .scroller { scrollbar-width: auto; }
  .scroller::-webkit-scrollbar { width: 8px; height: 8px; }
  .scroller::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 99px; }
  .scroller::-webkit-scrollbar-track { background: var(--scroll-track); }
}

/* ==================== Buttons & Controls ==================== */
button, input, select, textarea { font: inherit; color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px; border-radius: 999px; border: 1px solid transparent;
  font-size: 0.875rem; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn.sm { padding: 5px 12px; font-size: 0.8125rem; }
.btn.lg { padding: 12px 22px; font-size: 0.95rem; font-weight: 600; }
.btn.full { width: 100%; }

.btn.primary { background: var(--brand); color: var(--brand-text); }
.btn.primary:hover { background: var(--brand-hover); }

.btn.tonal { background: var(--brand-tonal); color: var(--brand); }
.btn.tonal:hover { filter: brightness(0.96); }

.btn.surface { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.btn.surface:hover { background: var(--surface-2); }

.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

.btn.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 24%, transparent); }
.btn.err { background: var(--err-bg); color: var(--err); border-color: color-mix(in srgb, var(--err) 24%, transparent); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 999px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.subtle { background: var(--surface-2); border-color: var(--border); }

/* Pills / Badges (Material 3 Tonal) */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.info, .pill.brand { background: var(--info-bg); color: var(--info); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); }

.dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block;
}
.dot.ok { background: var(--ok); }
.dot.info { background: var(--info); animation: pulse-dot 1.8s infinite; }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--err); }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

/* ==================== Login Gate ==================== */
.login-gate {
  position: fixed; inset: 0; z-index: 99;
  display: grid; place-items: center; padding: 24px;
  background: var(--bg);
}
.login-gate[hidden] { display: none; }
.login-card {
  width: min(400px, 100%); background: var(--surface);
  border: 1px solid var(--border); border-radius: 22px; padding: 36px 32px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.login-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 14px; color: var(--brand); margin-bottom: 14px;
}
.login-card h1 { margin: 0; font-size: 1.45rem; letter-spacing: -0.02em; }
.login-sub { margin: 8px 0 24px; color: var(--muted); font-size: 0.875rem; }
.login-foot { margin: 18px 0 0; font-size: 0.78rem; color: var(--muted); }

/* ==================== App Shell & Translucent Topbar ==================== */
.app-shell {
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}

.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 18px;
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }

.project-switcher { display: flex; align-items: center; gap: 6px; }
.project-select {
  appearance: none; -webkit-appearance: none;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 6px 28px 6px 14px;
  font-size: 0.875rem; font-weight: 600; cursor: pointer; max-width: 240px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

.segmented-pills {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--surface-2); padding: 3px; border-radius: 999px;
}
.segmented-pills button {
  border: 0; background: transparent; color: var(--muted);
  padding: 4px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 500;
  cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease;
}
.segmented-pills button.active {
  background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm);
}

.status-capsule {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 0.8rem; font-weight: 500; cursor: pointer;
}
.status-capsule:hover { background: var(--surface-2); }

.presence-bar { display: flex; align-items: center; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-tonal); color: var(--brand); font-size: 0.75rem; font-weight: 700;
  border: 2px solid var(--surface); margin-left: -6px; position: relative;
}
.avatar:first-child { margin-left: 0; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 500; }

/* ==================== Shell Body & Left Rail ==================== */
.shell-body { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column; gap: 20px;
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.brand-row { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--brand); color: var(--brand-text);
  display: grid; place-items: center;
}
.brand-name { font-size: 0.92rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-domain { font-size: 0.72rem; color: var(--muted); }

.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-label {
  font-size: 0.72rem; font-weight: 600; color: var(--muted);
  padding: 4px 10px 6px; letter-spacing: 0.03em;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 0;
  background: transparent; color: var(--muted); font-size: 0.875rem; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: background-color 0.14s ease, color 0.14s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-tonal); color: var(--brand); font-weight: 600; }
.nav-badge {
  margin-left: auto; font-size: 0.72rem; font-weight: 600;
  padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.nav-item.active .nav-badge { background: var(--surface); color: var(--brand); }
.nav-badge.accent { background: var(--info-bg); color: var(--info); }

.sidebar-footer { margin-top: auto; }
.meta-card {
  padding: 12px; border-radius: var(--radius-md); background: var(--surface-2);
  font-size: 0.78rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px;
}
.meta-card strong { color: var(--text); font-size: 0.82rem; }

/* ==================== Main Canvas ==================== */
.main-canvas {
  flex: 1; min-width: 0; overflow-y: auto; padding: 24px 28px 80px;
}
.view-section { max-width: 1440px; margin: 0 auto; }
.view-section[hidden] { display: none; }

.page-header {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 14px; margin-bottom: 22px;
}
.page-header h1 { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.page-header p { margin: 4px 0 0; color: var(--muted); font-size: 0.875rem; }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ==================== Cards & Grids ==================== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
}
.card-title { margin: 0 0 14px; font-size: 0.98rem; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.03em; margin: 6px 0 4px; }
.kpi-sub { font-size: 0.78rem; color: var(--muted); }

.two-col { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; }

.progress-track {
  height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px; background: var(--brand);
  transition: width 0.35s ease;
}
.progress-fill.ok { background: var(--ok); }
.progress-fill.warn { background: var(--warn); }

.alert-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 18px;
  font-size: 0.86rem; background: var(--info-bg); color: var(--info);
}
.alert-banner.err { background: var(--err-bg); color: var(--err); }
.alert-banner.warn { background: var(--warn-bg); color: var(--warn); }

/* ==================== Asset Vault (Apple Photos style) ==================== */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface); padding: 24px; text-align: center; cursor: pointer;
  margin-bottom: 20px; transition: border-color 0.16s ease, background-color 0.16s ease;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand); background: var(--brand-tonal);
}
.asset-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px;
}
.asset-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.asset-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.asset-thumb {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-2); display: block;
}
.asset-info { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.asset-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.asset-name { font-size: 0.875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==================== Storyboard Grid (16:9 / 9:16 Adaptive) ==================== */
.shot-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.shot-grid.vertical {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.shot-card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm);
  cursor: pointer; transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.shot-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.shot-card.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-tonal); }
.shot-card.locked { border-color: var(--info); box-shadow: 0 0 0 2px var(--info-bg); }

.shot-thumb-wrap {
  position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden;
}
.shot-grid.vertical .shot-thumb-wrap { aspect-ratio: 9 / 16; }
.shot-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-placeholder {
  width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 0.8rem;
}
.shot-check {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  width: 20px; height: 20px; cursor: pointer;
}
.shot-top-badge { position: absolute; top: 10px; right: 10px; z-index: 2; }
.shot-lock-pill {
  position: absolute; bottom: 8px; left: 8px; right: 8px;
  background: rgba(15, 23, 42, 0.76); color: #fff; font-size: 0.74rem;
  padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(8px);
}
.shot-body { padding: 13px 15px; display: flex; flex-direction: column; gap: 6px; }
.shot-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.shot-title { font-size: 0.92rem; font-weight: 600; }
.shot-sub {
  font-size: 0.8rem; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Breakdown Table */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow-x: auto; box-shadow: var(--shadow-sm);
}
table.clean-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.clean-table th {
  text-align: left; padding: 12px 14px; font-size: 0.76rem; font-weight: 600;
  color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface-2);
}
table.clean-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.clean-table tr:last-child td { border-bottom: 0; }
table.clean-table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* ==================== Review & Theater Stage (Localized Dark Scheme) ==================== */
.review-layout {
  display: grid; grid-template-columns: 270px 1fr; gap: 18px; align-items: start;
}
.shot-rail {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  max-height: calc(100vh - 170px); overflow-y: auto; padding: 8px;
}
.rail-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 9px 11px; border: 0; border-radius: 10px; background: transparent;
  cursor: pointer; text-align: left; color: var(--text);
}
.rail-item:hover { background: var(--surface-2); }
.rail-item.active { background: var(--brand-tonal); color: var(--brand); font-weight: 600; }

/* MANDATORY (component-specific-light-dark-theme): localized dark theater with explicit background & re-specified inherited colors */
.theater-stage {
  color-scheme: only dark;
  background: #111318;
  color: var(--text);
  accent-color: var(--brand);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-md);
}
.theater-players {
  display: grid; grid-template-columns: 1fr; gap: 14px;
}
.theater-players.ab-mode { grid-template-columns: 1fr 1fr; }
.video-box {
  background: #000; border-radius: 12px; overflow: hidden; position: relative;
}
.video-box video {
  width: 100%; height: auto; max-height: 440px; display: block; background: #000;
}
.video-label {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  background: rgba(0, 0, 0, 0.65); color: #fff; backdrop-filter: blur(8px);
}
.theater-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==================== Compute Pool (Hardware Cards) ==================== */
.worker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px; margin-bottom: 22px;
}
.worker-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px;
}
.worker-card.online { border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.worker-card.busy { border-color: color-mix(in srgb, var(--info) 45%, var(--border)); }
.worker-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.worker-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 0.8rem; }
.metric-box { background: var(--surface-2); padding: 9px 11px; border-radius: 10px; }
.metric-box .k { color: var(--muted); font-size: 0.72rem; }
.metric-box .v { font-weight: 600; margin-top: 2px; }

/* ==================== Floating Batch Bar ==================== */
.batch-bar {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.batch-bar[hidden] { display: none; }
.batch-actions { display: flex; gap: 8px; }

/* ==================== Native Dialogs & Right Slide-Over Drawer ==================== */
/* MANDATORY (animate-to-from-top-layer): @starting-style + transition overlay/display + allow-discrete */
dialog {
  padding: 0; border: 0; background: transparent; color: var(--text);
  max-width: none; max-height: none;
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.24s;
  transition-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  transition-behavior: allow-discrete;
}
dialog::backdrop {
  background-color: rgba(15, 23, 42, 0);
  backdrop-filter: blur(0px);
  transition-property: background-color, backdrop-filter, display, overlay;
  transition-duration: 0.24s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

:is(dialog[open]):where(:not([data-closing])) {
  opacity: 1;
  @starting-style { opacity: 0; }
}
:is(dialog[open]):where(:not([data-closing]))::backdrop {
  background-color: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(3px);
  @starting-style { background-color: rgba(15, 23, 42, 0); backdrop-filter: blur(0px); }
}

.modal-dialog {
  margin: auto; width: min(520px, calc(100vw - 32px));
  @media (prefers-reduced-motion: no-preference) { transform: scale(0.95); }
}
.modal-dialog.wide { width: min(680px, calc(100vw - 32px)); }
:is(.modal-dialog[open]):where(:not([data-closing])) {
  @media (prefers-reduced-motion: no-preference) {
    transform: scale(1);
    @starting-style { transform: scale(0.95); }
  }
}

.drawer-dialog {
  margin: 0 0 0 auto; height: 100dvh; width: min(460px, 92vw);
  @media (prefers-reduced-motion: no-preference) { transform: translateX(36px); }
}
:is(.drawer-dialog[open]):where(:not([data-closing])) {
  @media (prefers-reduced-motion: no-preference) {
    transform: translateX(0);
    @starting-style { transform: translateX(36px); }
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog, dialog::backdrop { transition-duration: 0.1s; }
}

.modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 22px 24px; box-shadow: var(--shadow-lg);
}
.modal-header, .drawer-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.modal-header h2, .drawer-header h2 { margin: 4px 0 0; font-size: 1.12rem; font-weight: 700; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.drawer-sheet {
  height: 100%; background: var(--surface); border-left: 1px solid var(--border);
  padding: 22px; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.drawer-body { display: flex; flex-direction: column; gap: 16px; }

/* Forms */
.form-grid { display: flex; flex-direction: column; gap: 13px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.84rem; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
  outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tonal);
}
.field textarea { resize: vertical; font-family: inherit; }

.code-block {
  color-scheme: only dark;
  background: #11161f; color: #e6edf3; accent-color: var(--brand);
  padding: 13px 15px; border-radius: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
  margin: 6px 0 12px;
}

.script-blocks { display: flex; flex-direction: column; gap: 12px; }
.script-head { display: flex; align-items: center; justify-content: space-between; font-size: 0.84rem; font-weight: 600; }

/* Activity Feed */
.feed-list { display: flex; flex-direction: column; gap: 10px; }
.feed-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border); font-size: 0.83rem;
}
.feed-item:last-child { border-bottom: 0; padding-bottom: 0; }

/* Toast */
.toast-stack {
  position: fixed; top: 70px; right: 20px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 0.85rem; font-weight: 500; max-width: 340px;
}

/* Responsive */
.mobile-only { display: none; }
@media (max-width: 960px) {
  .mobile-only { display: inline-flex; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .two-col, .review-layout, .theater-players.ab-mode { grid-template-columns: 1fr; }
  .main-canvas { padding: 18px 14px 80px; }
}
