/* RinkTape styles, in the order of docs/design.md: tokens, base, components, shell, pages, player.
   Rules use the tokens only; colors are written once, in the token block (play-type colors come from the server). */

/* ---- tokens --------------------------------------------------------------- */

:root {
  color-scheme: dark;
  /* Surfaces */
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --line: #2a2f3a;
  --line-strong: #3a4150;
  --stage-bg: #000;
  --overlay: rgb(0 0 0 / .7);
  --backdrop: rgb(0 0 0 / .55);
  /* Text */
  --text: #e6e8ee;
  --text-muted: #8b93a5;
  /* Accent (the only tokens an Org's color changes, T216) */
  --accent: #3b82f6;
  --accent-hover: #5b95f7;
  --accent-text: #fff;
  --accent-soft: #1e3a8a;
  --accent-strong: #93c5fd;
  /* Semantic (never themed) */
  --danger: #ef4444;
  --danger-soft: #2a1215;
  --danger-text: #fca5a5;
  --warning: #fbbf24;
  --warning-soft: #78350f;
  --warning-text: #fde68a;
  --success: #22c55e;
  --success-soft: #14532d;
  --success-text: #bbf7d0;
  --info: #38bdf8;
  --info-soft: #0c4a6e;
  --info-text: #bae6fd;
  /* Data (never themed) */
  --grade-good: #22c55e;
  --grade-bad: #ef4444;
  /* Space */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --text-sm: 12px;
  --text-md: 13px;
  --text-lg: 15px;
  --text-xl: 18px;
  /* Shape */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-pop: 0 8px 24px rgb(0 0 0 / .4);
  /* Size */
  --bar-h: 40px;
  --toolbar-h: 36px;
  --content-w: 1100px;
  --sidenav-w: 200px;

  font: var(--text-md)/1.4 var(--font);
}

/* ---- base ----------------------------------------------------------------- */

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); display: flex; flex-direction: column; overflow: hidden; }
[hidden] { display: none !important; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
h1 { font-size: var(--text-xl); font-weight: 600; margin: 0; }
.muted { color: var(--text-muted); font-size: var(--text-sm); }
.error { color: var(--danger-text); }
.spacer { flex: 1; }

/* ---- components ----------------------------------------------------------- */

/* Buttons and fields */
button, select, input, textarea { font: inherit; color: inherit; }
button, select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
}
button:hover, select:hover { border-color: var(--line-strong); }
button.ghost { background: transparent; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--danger-text); }
button.danger-fill { background: var(--danger); border-color: var(--danger); }
button.mini, select.mini { padding: 2px 8px; font-size: var(--text-sm); }
input[type=text], input[type=search], input[type=number], input[type=email], input[type=date], textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 8px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input[type=color] {
  width: 36px; height: 28px; padding: 2px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 2px; }
input[type=date] { color-scheme: dark; font-variant-numeric: tabular-nums; }
input[type=date]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .7; }
input:disabled, button:disabled, select:disabled { opacity: .6; cursor: default; }
kbd {
  font: 11px var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 0 4px;
}

/* Badges */
.badge {
  font-size: var(--text-sm); padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap;
}
.badge.on { background: var(--success-soft); border-color: var(--success); color: var(--success-text); }
.badge.accent { background: var(--accent-soft); border-color: var(--accent); }
.badge.subtle { color: var(--text-muted); }
.badge.missing, .badge.deactivated, .badge.deleted { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, var(--bg)); color: var(--danger-text); }
.badge.pending, .badge.orphaned { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 45%, var(--bg)); color: var(--warning-text); }
.badge.archived { color: var(--text-muted); background: transparent; }
.badges { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); vertical-align: middle; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--text-sm); padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  cursor: pointer; user-select: none;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip.on { border-color: var(--c, var(--accent)); background: var(--surface-2); background: color-mix(in srgb, var(--c, var(--accent)) 22%, var(--surface-2)); }
.chip .key { color: var(--text-muted); font-size: 10px; }
.chip.grade-good { --c: var(--grade-good); }
.chip.grade-bad { --c: var(--grade-bad); }
.chip.tag { cursor: default; }
.chip.tag button { border: 0; background: none; padding: 0 0 0 2px; color: var(--text-muted); line-height: 1; }
/* Assigning (ui.js `chipAssign`): chips with × and + Add; read-only chips in tables. */
.chip-assign { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.chip.assigned, .chip.readonly { cursor: default; }
.chip-remove {
  border: 0; background: none; padding: 0 2px; margin-right: -4px;
  color: var(--text-muted); line-height: 1; font-size: var(--text-md); border-radius: var(--radius-sm);
}
.chip-remove:hover { color: var(--text); background: var(--line); }
.chip-add { border-radius: 999px; }
.chip-empty { margin-right: var(--space-1); }
.menu-filter { width: 100%; margin-bottom: var(--space-1); }
.chip-menu { max-height: 320px; overflow-y: auto; }
/* A muted word on a chip ("archived", "no access now"), and a heading in the + Add menu (T103). */
.chip-note { color: var(--text-muted); font-size: var(--text-sm); }
.menu-group { padding: 6px var(--space-2) 2px; color: var(--text-muted); font-size: var(--text-sm); font-weight: 600; }
.menu-group:not(:first-child) { border-top: 1px solid var(--line); margin-top: var(--space-1); }
.menu-filter + .menu-group { border-top: 0; margin-top: 0; }
.share-dialog { width: min(520px, calc(100vw - 32px)); }

/* Toast */
.toast {
  position: fixed; right: var(--space-4); bottom: var(--space-4); max-width: 360px;
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--space-2) var(--space-3); box-shadow: var(--shadow-pop);
}
.toast.error { border-color: var(--danger); background: var(--danger-soft); }
.toast-action { color: var(--accent-strong); }
.toast-close { margin-left: auto; }

/* Dialogs */
dialog {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px;
  min-width: 320px; max-width: min(720px, calc(100vw - 32px));
}
dialog::backdrop { background: var(--backdrop); }
dialog h2 { margin: 0 0 var(--space-3); font-size: 16px; }
dialog h3 { margin: 0 0 6px; font-size: var(--text-md); color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
dialog label { display: flex; flex-direction: column; gap: var(--space-1); }
dialog label.check { flex-direction: row; align-items: center; gap: var(--space-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: 14px; }
/* ui.js `formDialog` / `confirmDialog` */
.ui-dialog { width: 440px; }
.dialog-form { display: flex; flex-direction: column; gap: var(--space-3); }
.dialog-form h2 { margin: 0; }
.dialog-form p { margin: 0; }
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field-label { font-weight: 600; }
.field > input, .field > select { width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
/* A command to copy (the upload's ffmpeg fix) and a progress bar (docs/design.md → Feedback) */
.code-line { display: flex; gap: var(--space-2); align-items: center; }
.code-line code {
  flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; user-select: all;
  font: var(--text-sm) var(--mono); color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-1) var(--space-2);
}
.field-error { display: flex; flex-direction: column; gap: var(--space-2); }
.field-error p { margin: 0; }
.progress { display: flex; flex-direction: column; gap: var(--space-1); }
.progress progress {
  appearance: none; width: 100%; height: 8px; border: none; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2);
}
.progress progress::-webkit-progress-bar { background: var(--surface-2); }
.progress progress::-webkit-progress-value { background: var(--accent); }
.progress progress::-moz-progress-bar { background: var(--accent); }
.progress-text { font-variant-numeric: tabular-nums; }

/* Tables (docs/design.md → Tables) */
.data-table { border-collapse: collapse; width: 100%; }
.data-table th, .data-table td { text-align: left; padding: var(--space-2) 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table th { color: var(--text-muted); font-size: var(--text-sm); font-weight: 600; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr.empty-row:hover { background: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; width: 90px; }
.data-table .actions { text-align: right; white-space: nowrap; width: 1%; }
.data-table .actions button + button { margin-left: var(--space-1); }
.data-table tr.archived td:first-child { color: var(--text-muted); }
.data-table .badge { margin-left: 6px; }
.empty-row td { color: var(--text-muted); text-align: center; padding: var(--space-5) 10px; }

/* Inline edit (ui.js `inlineEdit`) */
.inline-edit { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.inline-edit-field { display: inline-flex; flex-direction: column; gap: 2px; }
.inline-edit-error { font-size: var(--text-sm); }

/* Empty and not-found states */
.empty-state { text-align: center; color: var(--text-muted); padding: 60px var(--space-5); }
.empty-state h1, .empty-state h2 { color: var(--text); }

/* Cards (docs/design.md → Card list) */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: var(--space-3); }
.card-head { display: flex; align-items: center; gap: var(--space-2); padding: 10px var(--space-3); border-bottom: 1px solid var(--line); }
.page .card-head h3 { margin: 0; font-size: var(--text-lg); }
.card-body { padding: 10px var(--space-3); }

/* Menus (shell.js `bindMenu`): a button with aria-haspopup="menu" opening a popover. */
.menu {
  margin: 0; inset: auto; position: fixed;
  min-width: 200px; padding: var(--space-1);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
}
.menu-note { padding: 6px var(--space-2); border-bottom: 1px solid var(--line); margin-bottom: var(--space-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu [role=menuitem] {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 0; border-radius: var(--radius-sm); padding: 6px var(--space-2);
}
.menu [role=menuitem]:hover, .menu [role=menuitem]:focus { background: var(--surface-2); outline: none; }

/* Feature flag rows (the Feature flags page and the player's Settings) */
.feature-list { display: flex; flex-direction: column; gap: 10px; margin-top: var(--space-2); }
.feature-row { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--space-4); align-items: center; }
.feature-row p { margin: 0; grid-column: 1; }
.feature-row select { grid-row: 1 / span 2; grid-column: 2; }

/* ---- shell (shell.js) ----------------------------------------------------- */

.app-bar {
  flex: 0 0 var(--bar-h); height: var(--bar-h);
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-4);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
/*
 * The identity band (T216): the brand and the Org context on the Org's color (--accent), from the bar's left
 * edge to a slanted end, then slanted stripes that thin out into the bar. The slant is 20px over the bar's
 * height; the stripes are skewed to match (atan(20 / 40) ≈ 26.57°), and the margin makes room for them.
 */
.bar-identity {
  position: relative; isolation: isolate; align-self: stretch;
  display: flex; align-items: center; gap: var(--space-3);
  margin: 0 64px 0 calc(-1 * var(--space-4)); padding: 0 var(--space-2) 0 var(--space-4);
  color: var(--accent-text);
}
.bar-identity::before, .bar-identity::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: -1; pointer-events: none; }
.bar-identity::before {
  left: 0; right: -20px; background: var(--accent);
  clip-path: polygon(0 0, 100% 0, calc(100% - 20px) 100%, 0 100%);
}
.bar-identity::after {
  left: calc(100% + 16px); width: 46px; transform: skewX(-26.57deg);
  background: linear-gradient(90deg,
    var(--accent) 0 8px, transparent 8px 14px, var(--accent) 14px 19px, transparent 19px 25px,
    var(--accent) 25px 28px, transparent 28px 34px, var(--accent) 34px 36px, transparent 36px 42px,
    var(--accent) 42px 43px, transparent 43px);
}
.bar-identity :focus-visible { outline-color: var(--accent-text); }
.brand { font-weight: 700; letter-spacing: .02em; color: inherit; white-space: nowrap; }
a.brand:hover { text-decoration: none; }
.org-context { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
span.org-context { color: inherit; opacity: .8; }
select.org-context {
  background: color-mix(in srgb, var(--accent-text) 12%, transparent); color: inherit;
  border-color: color-mix(in srgb, var(--accent-text) 35%, transparent);
}
select.org-context:hover { border-color: color-mix(in srgb, var(--accent-text) 60%, transparent); }
select.org-context option { background: var(--surface); color: var(--text); }
.app-nav { display: flex; align-self: stretch; gap: var(--space-1); }
.app-nav a {
  display: flex; align-items: center; padding: 0 var(--space-2);
  color: var(--text-muted); border-bottom: 2px solid transparent;
}
.app-nav a:hover { color: var(--text); text-decoration: none; }
.app-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.account-btn { background: transparent; border-color: transparent; white-space: nowrap; }
.update-banner {
  background: var(--warning-soft); color: var(--warning-text);
  padding: 6px 14px; border-bottom: 1px solid color-mix(in srgb, var(--warning) 55%, var(--warning-soft));
  font-size: var(--text-md);
}

/* Admin section: the side nav beside the page */
.admin-layout { flex: 1; display: flex; min-height: 0; }
.side-nav {
  flex: 0 0 var(--sidenav-w); padding: var(--space-4) var(--space-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.side-nav a { color: var(--text-muted); padding: 6px var(--space-3); border-radius: var(--radius); }
.side-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.side-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }

/* ---- pages ---------------------------------------------------------------- */

/* Standard page (library, Teams, every Admin page): it scrolls, the content is centered. */
body.std-page { overflow: auto; }
.page { flex: 1; padding: var(--space-4) var(--space-5) 40px; max-width: var(--content-w); width: 100%; margin: 0 auto; }
.page-header {
  display: flex; align-items: flex-start; flex-wrap: wrap; gap: var(--space-2) var(--space-3);
  padding-bottom: var(--space-3); margin-bottom: var(--space-3); border-bottom: 1px solid var(--line);
}
.page-header > div:first-child { flex: 1; min-width: 0; }
.page-header p { margin: var(--space-1) 0 0; }
.page-toolbar { display: flex; align-items: center; gap: var(--space-2); min-height: var(--toolbar-h); margin-bottom: var(--space-3); }
.page-toolbar input[type=search] { flex: 0 1 320px; min-width: 0; }
.page-toolbar .count { margin-left: auto; }
/* Show hidden (T224): at the end of a toolbar or in a section bar, before the count. */
.show-hidden { display: inline-flex; align-items: center; gap: var(--space-1); white-space: nowrap; color: var(--text-muted); }
.section-bar .show-hidden { margin-left: auto; }
.section-bar .show-hidden ~ :last-child { margin-left: 0; }
.page-actions { display: flex; gap: var(--space-2); align-items: center; }
/* Detail page: breadcrumb, the title with its rename and "⋯", sections with + Add on the right. */
.breadcrumb { font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--space-2); }
.breadcrumb a + span::before { content: "›"; margin: 0 6px; color: var(--text-muted); }
.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.title-row .inline-edit-value { font-size: var(--text-xl); font-weight: 600; }
.title-row .inline-edit input { font-size: var(--text-lg); min-width: 260px; }
.section-bar { display: flex; align-items: center; gap: var(--space-2); margin: 28px 0 var(--space-2); }
.page .section-bar h2 { margin: 0; }
.section-bar > :last-child:not(h2) { margin-left: auto; }
.fields { display: grid; grid-template-columns: max-content 1fr; gap: 10px var(--space-5); align-items: center; margin: var(--space-3) 0 0; }
.fields dt { color: var(--text-muted); }
.fields dd { margin: 0; }
.color-field { display: flex; align-items: center; gap: var(--space-2); }
.color-field .hex { width: 11ch; font-family: var(--mono); }
.field-note { margin: var(--space-1) 0 var(--space-2); font-size: var(--text-sm); }
/* The Org color preview (T216): the Org's tokens set on this box only, on the page background. */
.theme-preview {
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
}
.theme-preview .focus-sample { outline: 2px solid var(--accent-strong); outline-offset: 2px; border-radius: var(--radius-sm); padding: 2px 6px; }
.page h2 { font-size: 16px; margin-top: 28px; }
.page h3 { font-size: 14px; margin: var(--space-4) 0 6px; }

/* Tapes (library.html) */
#lib-filter { flex: 0 1 320px; min-width: 0; }
.lib-list { display: flex; flex-direction: column; gap: var(--space-3); }
.lib-continue {
  display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--space-3);
  padding: 10px var(--space-3); color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius);
}
.lib-continue:hover { text-decoration: none; border-color: var(--line-strong); border-left-color: var(--accent); }
.lib-continue-what { color: var(--accent-strong); font-size: var(--text-lg); }
.lib-tape { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.lib-tape-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; padding: 10px var(--space-3); }
.lib-tape-title { color: var(--text); font-size: var(--text-lg); font-weight: 600; }
.lib-breakdowns { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.lib-breakdowns li { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-1) 10px; padding: 6px var(--space-3) 6px 28px; }
.lib-breakdowns li + li { border-top: 1px solid var(--line); }
.lib-breakdowns li:hover { background: var(--surface-2); }
.lib-breakdowns li button { visibility: hidden; }
.lib-breakdowns li:hover button, .lib-breakdowns li:focus-within button { visibility: visible; }
.lib-none { margin: 0; padding: 0 var(--space-3) 10px; }
/* A Tape's Breakdowns, grouped (ADR-0034 §6): Mine, Shared with me, Shared with <Team>, Shared with <Org>. */
.lib-group { margin: 0; padding: 6px var(--space-3) 4px; border-top: 1px solid var(--line); color: var(--text-muted); font-size: var(--text-sm); font-weight: 600; }
.lib-group + .lib-breakdowns { border-top: 0; }
.lib-owner { color: var(--text-muted); }
.lib-empty { text-align: center; color: var(--text-muted); padding: 60px var(--space-5); }
.lib-empty h2 { color: var(--text); font-size: 16px; }
.lib-empty code { color: var(--text); }
#import-dialog { width: 480px; }
#import-form { display: flex; flex-direction: column; gap: 10px; }
#import-form p { margin: 0; }
.import-owner { display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-start; }
.owner-button { min-width: 160px; text-align: left; }
.import-report { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
#import-result .dialog-actions { align-items: baseline; }

/* Sign-in page (login.html) */
.login { max-width: 560px; }
.login h2 { font-size: 16px; }
.login-users { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: flex; flex-direction: column; gap: 6px; }
.login-user { width: 100%; display: flex; align-items: baseline; gap: 10px; text-align: left; padding: var(--space-2) var(--space-3); }
.login-user:focus { border-color: var(--accent); outline: none; }
.login-user:disabled { opacity: .5; cursor: not-allowed; }
.login details { margin: 10px 0; }
.login summary { cursor: pointer; color: var(--accent-strong); }
.login-buttons { display: flex; gap: 10px; margin: var(--space-3) 0 var(--space-5); }
.login-buttons button { padding: var(--space-2) 18px; }
.login-form { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }
.login-form label { display: flex; flex-direction: column; gap: var(--space-1); }
.login-form label.check { flex-direction: row; align-items: center; gap: var(--space-2); }

/* Admin Overview (admin.html) */
.hub-links { list-style: none; padding: 0; margin: var(--space-2) 0; display: flex; flex-direction: column; gap: 10px; }
.hub-links li { display: flex; flex-direction: column; gap: 2px; }

/* Role permissions (admin-permissions.html) */
.perms-grid { max-width: 860px; }
.perms-grid td { vertical-align: top; }
.perms-grid .perms-role { text-align: center; width: 90px; }
.perms-grid input[type="checkbox"] { width: 16px; height: 16px; }

/* Teams page (teams.html) and a person's memberships (admin-person.html) */
.team-org h2:first-child { margin-top: 0; }
.card-head select { margin-left: var(--space-2); }

/* ---- player (index.html) -------------------------------------------------- */

/* Focus mode (V) hides the global bar too. */
body.focus-mode .app-bar { display: none; }
.player-toolbar {
  display: flex; align-items: center; gap: 10px;
  flex: 0 0 var(--toolbar-h); height: var(--toolbar-h); padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.player-toolbar button { white-space: nowrap; }
/* One row: the selects give up width before anything wraps. */
#tape-select { flex: 0 1 420px; min-width: 80px; }
#breakdown-select { flex: 0 1 220px; min-width: 80px; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) var(--side-w, 340px); }
.layout.side-hidden { grid-template-columns: minmax(0, 1fr); }
.layout.side-hidden .side { display: none; }
body.resizing, body.resizing * { user-select: none !important; }
body.resizing-v, body.resizing-v * { cursor: col-resize !important; }
body.resizing-h, body.resizing-h * { cursor: row-resize !important; }

.resizer { position: absolute; z-index: 5; }
.resizer::after { content: ""; position: absolute; background: var(--accent); opacity: 0; transition: opacity .12s; }
.resizer:hover::after, body.resizing .resizer::after { opacity: .8; }
.resizer-v { top: 0; bottom: 0; left: -4px; width: 8px; cursor: col-resize; }
.resizer-v::after { top: 0; bottom: 0; left: 3px; width: 2px; }
.resizer-h { left: 0; right: 0; top: -4px; height: 8px; cursor: row-resize; }
.resizer-h::after { left: 0; right: 0; top: 3px; height: 2px; }

.stage-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage { position: relative; flex: 1; min-height: 120px; background: var(--stage-bg); }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; cursor: pointer; }
.stage:fullscreen { display: flex; }
.stage:-webkit-full-screen { display: flex; }
.osd {
  position: absolute; top: 14px; left: 14px; z-index: 3;
  background: var(--overlay); color: var(--text);
  padding: 6px var(--space-3); border-radius: var(--radius);
  font-size: var(--text-lg); font-weight: 600; pointer-events: none;
}
/* Video loading (T221, design.md → Feedback): over the video only, never taking clicks or keys. */
.video-loading {
  position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; align-content: center; gap: var(--space-2);
  pointer-events: none;
}
.video-loading:not(.on) .spinner { display: none; }
.video-loading .spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
.video-loading-text {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .video-loading .spinner { animation: none; border-color: var(--accent); }
  /* Only while loading: idle, the empty text stays visually hidden, so no box sits over the video (T220). */
  .video-loading.on .video-loading-text {
    position: static; width: auto; height: auto; overflow: visible; clip-path: none;
    background: var(--overlay); color: var(--text); padding: 2px var(--space-2); border-radius: var(--radius-sm);
  }
}
.empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: var(--text-muted); padding: var(--space-5);
}
.empty code { color: var(--text); }

.transport {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 6px var(--space-3);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.transport .icon { width: 34px; padding: var(--space-1) 0; }
.time { font: var(--text-md) var(--mono); min-width: 170px; }

.timeline-wrap { position: relative; background: var(--surface); border-top: 1px solid var(--line); }
#timeline { display: block; width: 100%; }
.timeline-tools {
  position: absolute; left: var(--space-1); top: 23px;
  display: flex; align-items: center; gap: 2px;
}
.timeline-tools .mini { padding: 0 6px; line-height: 16px; }
.lanes-btn.on, .toggle-badge.on { background: var(--accent-soft); border-color: var(--accent); }
.magnifier { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.stage.magnifying video { cursor: crosshair; }
.timeline-wrap.mini .timeline-tools { display: none; }
.zoom-label { font-size: 11px; color: var(--text-muted); min-width: 34px; text-align: center; }

.side {
  position: relative;
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--line); background: var(--surface);
}

/* Side panel sections (Filters / Bookmarks / Edit), each collapsible like VS Code's sidebar. */
.panel-section { display: flex; flex-direction: column; min-height: 0; flex: 0 0 auto; border-bottom: 1px solid var(--line); }
.section-head {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  height: 30px; padding: 0 var(--space-2) 0 6px;
  background: var(--surface); color: var(--text-muted);
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  cursor: pointer; user-select: none;
}
.section-head:hover { color: var(--text); }
.section-head .chev { width: 12px; text-align: center; transition: transform .12s; }
.panel-section.collapsed .chev { transform: rotate(-90deg); }
.section-title { white-space: nowrap; }
.section-summary { font-weight: 400; letter-spacing: 0; text-transform: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-head .mini { text-transform: none; letter-spacing: 0; font-weight: 400; }
.panel-section.collapsed > .section-body { display: none; }

.filters { padding: 2px var(--space-3) 10px; display: flex; flex-direction: column; gap: var(--space-2); overflow-y: auto; max-height: 45vh; }
.filters input[type=search] { width: 100%; }
#filters-summary.active { color: var(--warning); }

/* The list takes the leftover height; if it's collapsed, the editor does. */
#sec-list:not(.collapsed) { flex: 1 1 0; }
#sec-editor:not(.collapsed) { flex: 0 1 auto; max-height: 60%; }
.side.list-collapsed #sec-editor:not(.collapsed) { flex: 1 1 0; max-height: none; }
.side.list-collapsed.editor-collapsed .filters { max-height: none; }

.bm-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 60px; border-top: 1px solid var(--line); }
.bm-list li {
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); cursor: pointer;
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px;
}
.bm-list li:hover { background: var(--surface-2); }
.bm-list li.selected { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); box-shadow: inset 3px 0 0 var(--accent); }
.bm-list li.playing { box-shadow: inset 3px 0 0 var(--success); }
.bm-time { font: var(--text-sm) var(--mono); }
.bm-num { display: inline-block; min-width: 2.2em; color: var(--text-muted); }
.bm-dur { color: var(--text-muted); font-size: 11px; grid-column: 1; padding-left: 2.2em; }
.bm-body { grid-row: 1 / span 2; grid-column: 2; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bm-note { color: var(--text-muted); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mode-switch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mode-switch button { border: 0; border-radius: 0; background: transparent; padding: var(--space-1) var(--space-3); }
.mode-switch button + button { border-left: 1px solid var(--line); }
.mode-switch button.on { background: var(--accent); color: var(--accent-text); }
/* In View mode the editor section is a read-only "Details" view. */
body.view-mode #ed-fields { pointer-events: none; }
body.view-mode #editor .edit-only { display: none; }
body.view-mode #ed-note { resize: none; }
body.view-mode .bm-note { white-space: pre-wrap; overflow: visible; color: color-mix(in srgb, var(--text) 85%, var(--text-muted)); font-size: var(--text-md); }
.bm-list .chip { cursor: inherit; padding: 0 6px; font-size: 11px; }
.bm-del {
  grid-column: 3; grid-row: 1 / span 2; align-self: start;
  width: 22px; height: 22px; padding: 0; line-height: 1; font-size: var(--text-lg);
  background: transparent; border-color: transparent; color: var(--text-muted);
  visibility: hidden;
}
.bm-list li:hover .bm-del, .bm-list li.selected .bm-del { visibility: visible; }
.bm-del:hover { color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 45%, var(--bg)); background: var(--danger-soft); }
body.view-mode .bm-del { display: none; }
.bm-empty { padding: var(--space-4) var(--space-3); color: var(--text-muted); cursor: default !important; display: block !important; }

.editor { background: var(--surface-2); overflow-y: auto; min-height: 0; flex: 1 1 auto; border-top: 1px solid var(--line); }
.editor-body { display: flex; flex-direction: column; gap: 7px; padding: var(--space-2) var(--space-3) 10px; }
.ed-empty { margin: 0; padding: var(--space-3); }
.editor .chips { gap: 3px; }
.editor .chip { padding: 1px 7px; font-size: 11px; }
.range-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.range-row label { display: flex; align-items: center; gap: var(--space-1); color: var(--text-muted); font-size: var(--text-sm); }
.range-row input { width: 84px; font-family: var(--mono); font-size: var(--text-sm); color: var(--text); }
.tag-box { display: flex; flex-direction: column; gap: var(--space-1); }
.editor textarea { resize: vertical; min-height: 40px; }

/* The player's dialogs: Settings and Shortcuts */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px var(--space-4); }
.settings-subhead { margin: 18px 0 var(--space-2); }
.settings-note { margin: 0; align-self: center; }
.range-row-inline { display: flex; align-items: center; gap: var(--space-2); }
.range-row-inline input { flex: 1; }
.range-row-inline output { min-width: 2.5em; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.help-grid dl { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--space-3); margin: 0 0 14px; align-items: baseline; }
.help-grid dt { white-space: nowrap; }
.help-grid dd { margin: 0; }
.type-keys { display: grid; grid-template-columns: repeat(3, auto 1fr); gap: 6px 10px; margin: 0 0 10px; align-items: baseline; }
.type-keys dt { text-align: right; }
.type-keys dd { margin: 0; display: flex; align-items: center; gap: 6px; }
.type-keys .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .layout, .layout.side-hidden { grid-template-columns: 1fr; }
  .resizer { display: none; }
  .stage { min-height: 240px; flex: none; aspect-ratio: 16 / 9; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .settings-grid, .help-grid { grid-template-columns: 1fr; }
  .admin-layout { flex-direction: column; }
  .side-nav { flex: none; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
}
