/* OpenTron MAM. Family tokens first (opentron-design-system SPEC.md §1), then this app's parts.
 * The Studio Bar supplies the light values for the family tokens; this file sets the dark ones and this app's
 * own extensions (prefixed --mam-) for both appearances. No colour is written outside these two blocks
 * (UI-TOK-03). Sizes come from the family scales: type 11 12 13 15 16 20, space 4 8 12 16 20 24 32. */

:root {
  --ot-navy-900: #10131e; --ot-navy-800: #1d2133; --ot-navy-700: #2a2540; --ot-surface: #191e2c; --ot-surface-2: #202639;
  --ot-line: #30384d; --ot-text: #f0f3fa; --ot-muted: #9caac1; --ot-accent: #2e9bf0; --ot-accent-strong: #3d8bff; --ot-accent-deep: #0d2f8f;
  --ot-onair: #ff3b30; --ot-ok: #35e08a; --ot-warn: #efc37a; --ot-error: #ff453a; --ot-text-on-accent: #081726; --ot-dot-off: #5a6070;
  --ot-field-bg: #0f1424; --ot-focus-ring: #7fc6f8;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 14px; --radius-pill: 999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  /* extensions */
  --mam-slate: #0b0e17;            /* the dark frame behind every picture, in both appearances */
  --mam-slate-text: #c9d3e6;
  --mam-slate-veil: rgba(11, 14, 23, 0.72);
  --mam-tint: rgba(46, 155, 240, 0.14);
  --mam-tint-ok: rgba(53, 224, 138, 0.14);
  --mam-tint-warn: rgba(239, 195, 122, 0.14);
  --mam-tint-error: rgba(255, 69, 58, 0.14);
  --mam-line-ok: rgba(53, 224, 138, 0.35);
  --mam-line-warn: rgba(239, 195, 122, 0.35);
  --mam-line-error: rgba(255, 69, 58, 0.35);
  --mam-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
  --mam-shadow-menu: 0 9px 30px rgba(0, 0, 0, 0.28);
  --mam-shadow-modal: 0 18px 60px rgba(0, 0, 0, 0.55);
  --mam-veil: rgba(6, 8, 14, 0.66);
  --mam-star: #efc37a;
  /* Colour labels carry Lightroom's names. Squares, never dots: they are labels, not status. */
  --mam-label-red: #e2606f; --mam-label-yellow: #e6c94f; --mam-label-green: #4fbf7c; --mam-label-blue: #4f9be6; --mam-label-purple: #a57be0;
  /* Marker colours on a clip's timeline, by name. */
  --mam-mark-blue: #4f9be6; --mam-mark-green: #4fbf7c; --mam-mark-yellow: #e6c94f; --mam-mark-purple: #a57be0; --mam-mark-pink: #e27fb4; --mam-mark-cyan: #55c3cf;
  --mam-ai: #a194ff;               /* the AI mark's stroke, the same violet the Studio Bar uses for it */
}
html[data-ot-theme="light"] {
  --mam-tint: rgba(10, 124, 255, 0.09);
  --mam-tint-ok: rgba(36, 138, 61, 0.1);
  --mam-tint-warn: rgba(195, 84, 0, 0.1);
  --mam-tint-error: rgba(215, 0, 21, 0.08);
  --mam-line-ok: rgba(36, 138, 61, 0.35);
  --mam-line-warn: rgba(195, 84, 0, 0.35);
  --mam-line-error: rgba(215, 0, 21, 0.3);
  --mam-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 6px 20px rgba(20, 30, 60, 0.07);
  --mam-shadow-menu: 0 9px 30px rgba(20, 30, 60, 0.16);
  --mam-shadow-modal: 0 18px 60px rgba(20, 30, 60, 0.25);
  --mam-veil: rgba(60, 64, 80, 0.4);
  --mam-star: #c98a00;
  --mam-label-red: #d0455a; --mam-label-yellow: #c9a400; --mam-label-green: #2f9d5f; --mam-label-blue: #2f7fd6; --mam-label-purple: #8556cf;
  --mam-mark-blue: #2f7fd6; --mam-mark-green: #2f9d5f; --mam-mark-yellow: #c9a400; --mam-mark-purple: #8556cf; --mam-mark-pink: #cf5797; --mam-mark-cyan: #2a9aa8;
  --mam-ai: #6a5cff;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ot-navy-900); color: var(--ot-text); font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; color-scheme: inherit; }
/* Room for the bars that sit at the bottom of the window (the chat bar, a bottom-placed Studio Bar). */
body { padding-bottom: calc(var(--ot-bar-inset-bottom, 0px) + var(--ot-comms-inset-bottom, 0px)); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ot-focus-ring); outline-offset: 2px; }
a { color: var(--ot-accent); }
.grow { flex: 1; }
.mono { font-family: var(--mono); }
.muted { color: var(--ot-muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ico { flex: none; display: block; }
kbd { font: 11px var(--mono); background: var(--ot-surface-2); border: 1px solid var(--ot-line); border-radius: 4px; padding: 0 4px; }
.ai-mark { flex: none; fill: none; stroke: var(--mam-ai); stroke-width: 1.2; stroke-linejoin: round; }

/* ---- the app's own header, under the Studio Bar (UI-BAR-25) ---- */
.app-header { display: flex; align-items: center; gap: 8px; padding: 12px 24px; }
.app-icon { border-radius: 7px; display: block; }
.app-name { font-size: 15px; font-weight: 700; }
.app-view { color: var(--ot-muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.app-view::before { content: "·"; margin-right: 8px; }

/* ---- controls (UI-CMP-01, 03, 05) ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--ot-line); background: var(--ot-surface-2); border-radius: var(--radius-pill); padding: 6px 16px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--ot-text); line-height: 1.3; }
.btn:hover { border-color: var(--ot-accent); }
.btn.primary { background: var(--ot-accent); border-color: var(--ot-accent); color: var(--ot-text-on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--ot-accent-strong); border-color: var(--ot-accent-strong); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ot-muted); }
.btn.quiet:hover { border-color: var(--ot-line); color: var(--ot-text); }
.btn.danger { color: var(--ot-error); border-color: var(--mam-line-error); background: transparent; }
.btn.danger:hover { background: var(--mam-tint-error); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: default; pointer-events: none; }
.btn .ico { width: 14px; height: 14px; }
.more { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border: 1px solid transparent; background: transparent; border-radius: var(--radius-sm); color: var(--ot-muted); cursor: pointer; padding: 0; }
.more:hover, .more[aria-expanded="true"] { border-color: var(--ot-line); background: var(--ot-surface-2); color: var(--ot-text); }
.help { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 0; background: var(--ot-dot-off); color: var(--ot-surface); font: 700 11px var(--font); cursor: pointer; padding: 0; margin-left: 6px; vertical-align: middle; text-transform: none; letter-spacing: 0; }
.field { border: 1px solid var(--ot-line); background: var(--ot-field-bg); border-radius: var(--radius-sm); padding: 6px 12px; min-width: 0; color: var(--ot-text); }
.field:focus { outline: 0; border-color: var(--ot-focus-ring); }
.field.search { width: 300px; }
textarea.field { width: 100%; min-height: 84px; resize: vertical; }
select.field { padding-right: 8px; }
label.row, div.row { display: block; margin-bottom: 12px; }
label.row > span, .label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: var(--ot-muted); margin-bottom: 4px; }
label.row > .field, div.row > .field, label.row > .chip-input, div.row > .chip-input { width: 100%; }
.row-help { margin: 4px 0 0; font-size: 12px; }
.req { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 400; }
.switch { appearance: none; -webkit-appearance: none; width: 36px; height: 20px; border-radius: var(--radius-pill); background: var(--ot-dot-off); position: relative; cursor: pointer; flex: none; margin: 0; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--ot-surface); transition: transform 0.15s; }
.switch:checked { background: var(--ot-accent); }
.switch:checked::after { transform: translateX(16px); }
.switch:disabled { opacity: 0.45; cursor: default; }
.switch-row { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: 6px; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }

/* ---- shell ---- */
.shell { display: flex; align-items: flex-start; gap: 24px; padding: 0 24px 48px; transition: padding-right 0.12s; }
.rail { width: 196px; flex: none; position: sticky; top: 12px; display: flex; flex-direction: column; gap: 2px; }
.rail button { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; color: var(--ot-text); }
.rail button:hover { background: var(--ot-surface-2); }
.rail button[aria-current="page"] { background: var(--mam-tint); color: var(--ot-accent); font-weight: 600; }
.rail-label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.rail-label .ico { width: 14px; height: 14px; color: var(--ot-muted); }
.rail button[aria-current="page"] .ico { color: var(--ot-accent); }
.rail .count { font: 11px var(--mono); color: var(--ot-muted); overflow: hidden; text-overflow: ellipsis; max-width: 80px; }
.rail .sep { height: 1px; background: var(--ot-line); margin: 8px 12px; }
main { flex: 1; min-width: 0; outline: 0; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: var(--ot-muted); margin: 24px 0 8px; }
.lede { color: var(--ot-muted); margin: 0 0 16px; max-width: 70ch; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h2 { margin-bottom: 8px; }
.page-head > .btn, .page-head > .toolbar { margin-bottom: 16px; }
.page-head h2 + .btn, .page-head > h2 ~ .btn { margin-bottom: 8px; }
.card { background: var(--ot-surface); border: 1px solid var(--ot-line); border-radius: var(--radius-md); box-shadow: var(--mam-shadow); }
.table-wrap { overflow-x: auto; }
.empty { padding: 32px; text-align: center; color: var(--ot-muted); }
.empty b { display: block; color: var(--ot-text); font-size: 15px; margin-bottom: 4px; }
.empty-acts { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; border: 1px solid var(--ot-line); border-radius: var(--radius-pill); padding: 2px; background: var(--ot-surface-2); max-width: 100%; }
.seg button { display: inline-flex; align-items: center; border: 0; background: transparent; padding: 4px 12px; border-radius: var(--radius-pill); cursor: pointer; color: var(--ot-muted); flex: none; }
.seg button[aria-pressed="true"] { background: var(--ot-surface); color: var(--ot-text); font-weight: 600; box-shadow: var(--mam-shadow); }
.status { display: inline-flex; align-items: center; gap: 6px; }
.error-text { color: var(--ot-error); }

/* A group of rows under one small heading: the settings layout every page here uses. */
.group { margin-bottom: 8px; }
.group-body { overflow: hidden; }
.grow-row { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-top: 1px solid var(--ot-line); min-height: 44px; }
.grow-row:first-child { border-top: 0; }
.grow-row-text { flex: 1; min-width: 0; }
.grow-row-label { font-weight: 600; }
.grow-row-hint { font-size: 12px; margin-top: 2px; }
.grow-row-control { flex: none; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 60%; }
/* A note that offers something: its own tinted box, outside the group it is about. */
.notice { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border: 1px solid var(--ot-line); border-left: 3px solid var(--ot-accent); background: var(--mam-tint); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; }
.notice.warn { border-left-color: var(--ot-warn); background: var(--mam-tint-warn); }
.notice.ok { border-left-color: var(--ot-ok); }
.notice.ai { border-left-color: var(--mam-ai); }
.notice > .grow { min-width: 200px; }
/* AI-made content wears its mark on the left edge (UI-AI-02), and keeps it. */
.ai-made { border-left: 2px solid var(--mam-ai); padding-left: 12px; }
.ai-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ot-muted); }

/* ---- the episode slate: the folder, as a card ---- */
.slates { display: flex; flex-direction: column; gap: 12px; }
.slate { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto auto; align-items: stretch; cursor: pointer; overflow: hidden; text-align: left; padding: 0; width: 100%; }
.slate:hover, .slate:focus-visible { border-color: var(--ot-accent); }
.slate-date { background: var(--mam-slate); color: var(--mam-slate-text); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px 8px; }
.slate-date .d { font-size: 32px; font-weight: 900; line-height: 1; color: var(--mam-slate-text); font-variant-numeric: tabular-nums; }
.slate-date .m { font: 600 11px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 4px; }
.slate-date .y { font: 11px var(--mono); opacity: 0.7; }
.slate-body { padding: 12px 16px; min-width: 0; }
.slate-name { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; letter-spacing: 0.01em; min-width: 0; }
/* A long episode name wraps to a second line rather than being cut mid-word (a narrow card beside the inspector). */
.slate-name-text { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; line-height: 1.25; }
.slate-key { font: 11px var(--mono); color: var(--ot-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slate-guests { font-size: 12px; color: var(--ot-muted); margin: 2px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slate-strip { display: flex; gap: 6px; padding: 12px 0 12px 12px; align-items: center; }
.slate-strip .thumb { width: 96px; }
.slate-more { display: flex; align-items: flex-start; padding: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--ot-surface-2); color: var(--ot-muted); white-space: nowrap; max-width: 100%; }
.chip.accent { background: var(--mam-tint); color: var(--ot-accent); font-weight: 600; }
.chip.warn { color: var(--ot-warn); background: var(--mam-tint-warn); }
.chip.ok { color: var(--ot-ok); background: var(--mam-tint-ok); }
.chip.status-approved { color: var(--ot-ok); background: var(--mam-tint-ok); }
.chip.status-review, .chip.status-progress { color: var(--ot-accent); background: var(--mam-tint); }
.chip.status-rejected { color: var(--ot-warn); background: var(--mam-tint-warn); }
.chip .ico { width: 12px; height: 12px; }
.stars-chip .ico { fill: var(--mam-star); stroke: var(--mam-star); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ot-dot-off); flex: none; display: inline-block; }
.dot.ok { background: var(--ot-ok); box-shadow: 0 0 6px var(--ot-ok); } .dot.warn { background: var(--ot-warn); } .dot.error { background: var(--ot-error); }
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; background: var(--ot-dot-off); color: var(--ot-surface); font-weight: 700; font-size: 11px; overflow: hidden; line-height: 1; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.swatch-wrap { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; display: inline-block; }
.swatch-red { background: var(--mam-label-red); } .swatch-yellow { background: var(--mam-label-yellow); } .swatch-green { background: var(--mam-label-green); } .swatch-blue { background: var(--mam-label-blue); } .swatch-purple { background: var(--mam-label-purple); }
.stars { display: inline-flex; gap: 2px; align-items: center; border-radius: var(--radius-sm); }
.star { color: var(--ot-dot-off); cursor: pointer; display: grid; }
.stars[tabindex] .star:hover { color: var(--mam-star); }
.star.on { color: var(--mam-star); }
.star.on .ico { fill: var(--mam-star); }

/* ---- smart chips and pickers (UI-CMP-17) ---- */
.chip.smart { font-size: 12px; padding: 2px 8px; border: 1px solid var(--ot-line); background: var(--ot-surface-2); color: var(--ot-text); cursor: default; }
.chip.smart:hover, .chip.smart:focus-visible { border-color: var(--ot-accent); }
.chip.smart .avatar { margin-left: -4px; }
.chip-text { overflow: hidden; text-overflow: ellipsis; }
.chip-x { display: inline-grid; place-items: center; width: 16px; height: 16px; border: 0; background: transparent; color: var(--ot-muted); cursor: pointer; padding: 0; border-radius: 50%; margin-right: -4px; }
.chip-x:hover { background: var(--ot-line); color: var(--ot-text); }
.chip-x .ico { width: 10px; height: 10px; }
.chip-input { position: relative; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--ot-line); background: var(--ot-field-bg); border-radius: var(--radius-sm); padding: 4px 8px; min-height: 32px; cursor: text; }
.chip-input:focus-within { border-color: var(--ot-focus-ring); }
.chip-typing { flex: 1; min-width: 80px; border: 0; background: transparent; outline: 0; padding: 2px 4px; color: var(--ot-text); }
.suggest { position: absolute; z-index: 60; left: -1px; right: -1px; top: calc(100% + 4px); background: var(--ot-surface-2); border: 1px solid var(--ot-line); border-radius: var(--radius-sm); box-shadow: var(--mam-shadow-menu); padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow-y: auto; }
.suggest-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 12px; border-radius: var(--radius-pill); border: 1px solid var(--ot-line); background: var(--ot-surface); color: var(--ot-text); cursor: pointer; max-width: 100%; }
.suggest-chip:hover, .suggest-chip.active { border-color: var(--ot-accent); background: var(--mam-tint); }
.suggest-chip.new { border-style: dashed; }
.suggest-chip .ico { width: 12px; height: 12px; color: var(--ot-muted); }
.chip-sub { color: var(--ot-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.chip-count { color: var(--ot-muted); font: 11px var(--mono); }
.suggest-none { font-size: 12px; padding: 4px; }

/* ---- menus: context menus, submenus and drop-downs read as one family (UI-CMP-15) ---- */
.menu { position: fixed; z-index: 200; min-width: 200px; max-width: min(340px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow-y: auto; background: var(--ot-surface-2); color: var(--ot-text); border: 1px solid var(--ot-line); border-radius: var(--radius-sm); box-shadow: var(--mam-shadow-menu); padding: 4px; outline: 0; }
.menu-item { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 8px; border-radius: 6px; font: 13px var(--font); cursor: default; white-space: nowrap; outline: 0; user-select: none; -webkit-user-select: none; }
.menu-item:focus, .menu-item:hover { background: var(--ot-accent); color: var(--ot-text-on-accent); }
.menu-item:focus .menu-hint, .menu-item:hover .menu-hint, .menu-item:focus .ico, .menu-item:hover .ico { color: inherit; }
.menu-item .ico { width: 14px; height: 14px; color: var(--ot-muted); }
.menu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; display: inline-flex; align-items: center; gap: 6px; }
.menu-hint { font-size: 12px; color: var(--ot-muted); margin-left: 16px; }
.menu-arrow { font-size: 11px; margin-left: 8px; }
.menu-check { width: 14px; flex: none; display: grid; place-items: center; }
.menu-check .ico { width: 12px; height: 12px; color: inherit; }
.menu-item.danger { color: var(--ot-error); }
.menu-item.danger .ico { color: var(--ot-error); }
.menu-item.danger:focus, .menu-item.danger:hover { background: var(--ot-error); color: var(--ot-text-on-accent); }
.menu-item.danger:focus .ico, .menu-item.danger:hover .ico { color: inherit; }
.menu-item[aria-disabled="true"] { opacity: 0.45; }
.menu-item[aria-disabled="true"]:focus, .menu-item[aria-disabled="true"]:hover { background: transparent; color: var(--ot-text); outline: 1px dashed var(--ot-line); }
.menu-sep { height: 1px; background: var(--ot-line); margin: 4px 0; }
.menu-group { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: var(--ot-muted); padding: 8px 8px 4px; }
@media (pointer: coarse) { .menu-item { height: 44px; padding: 0 12px; } .menu { min-width: 240px; } .more { width: 36px; height: 36px; } }

/* ---- dialogs (UI-CMP-07) ---- */
.veil { position: fixed; inset: 0; z-index: 150; background: var(--mam-veil); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; }
.dialog { width: min(420px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--ot-surface); color: var(--ot-text); border: 1px solid var(--ot-line); border-radius: var(--radius-lg); box-shadow: var(--mam-shadow-modal); outline: 0; }
.dialog.wide { width: min(560px, 100%); }
.veil.under-bar { padding-top: calc(var(--mam-veil-top) + 12px); }
.veil.under-bar .dialog { max-height: calc(100vh - var(--mam-veil-top) - 28px); }
.veil.under-bar .dialog.props-window { height: min(800px, calc(100vh - var(--mam-veil-top) - 28px)); }
.dialog-head { display: flex; align-items: center; gap: 8px; padding: 16px 16px 0 20px; }
.dialog-head h1 { flex: 1; font-size: 16px; margin: 0; }
.dialog-body { padding: 12px 20px; overflow-y: auto; }
.dialog-body > p:first-child { margin-top: 0; }
.dialog-body .field { width: 100%; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 20px; flex-wrap: wrap; }
.dialog-form .chip-input { width: 100%; }
.keys th { width: 1%; }

/* ---- assets ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 16px; }
.asset { position: relative; padding: 0; overflow: hidden; cursor: pointer; text-align: left; display: flex; flex-direction: column; }
.asset:hover, .asset[aria-current="true"], .asset:focus-visible { border-color: var(--ot-accent); }
.asset.selected, .asset-row.selected { border-color: var(--ot-accent); box-shadow: 0 0 0 2px var(--ot-accent); }
.thumb { aspect-ratio: 16 / 9; background: var(--mam-slate); color: var(--mam-slate-text); position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 6px; }
.asset .thumb { border-radius: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .kind { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; font: 600 11px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.75; }
.thumb .kind .ico { width: 20px; height: 20px; }
.thumb .dur { position: absolute; right: 6px; bottom: 6px; font: 11px var(--mono); background: var(--mam-slate-veil); padding: 1px 5px; border-radius: 4px; }
.thumb .away { position: absolute; left: 6px; bottom: 6px; font-size: 11px; background: var(--mam-slate-veil); padding: 1px 6px; border-radius: 4px; display: flex; gap: 5px; align-items: center; }
.tick { position: absolute; top: 8px; left: 8px; z-index: 2; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--mam-slate-text); background: var(--mam-slate-veil); color: transparent; display: grid; place-items: center; cursor: pointer; opacity: 0; }
.asset:hover .tick, .asset:focus-within .tick, body.selecting .tick, .tick[aria-checked="true"] { opacity: 1; }
.tick[aria-checked="true"] { background: var(--ot-accent); border-color: var(--ot-accent); color: var(--ot-text-on-accent); }
.tick .ico { width: 12px; height: 12px; }
@media (pointer: coarse) { .tick { opacity: 1; width: 24px; height: 24px; } }
.asset-body { padding: 8px 8px 12px 12px; min-width: 0; }
.asset-top { display: flex; align-items: center; gap: 4px; }
.asset-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-sub { font-size: 12px; color: var(--ot-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assets-list .col-thumb { width: 96px; padding-right: 0; } .assets-list .col-thumb .thumb { width: 80px; }
.assets-list .col-tick { width: 36px; padding-right: 0; position: relative; } .assets-list .tick { position: static; opacity: 1; border-color: var(--ot-line); background: var(--ot-field-bg); }
.assets-list .tick[aria-checked="true"] { background: var(--ot-accent); border-color: var(--ot-accent); }
.assets-list .col-name { min-width: 180px; max-width: 320px; }
.assets-list .chips { margin-top: 0; }
.asset-row { cursor: pointer; }
.asset-row:hover td, .asset-row[aria-current="true"] td { background: var(--mam-tint); }
.asset-row.selected { box-shadow: none; } .asset-row.selected td { background: var(--mam-tint); }
.col-more { width: 1%; text-align: right; }

/* the bar that appears when several things are selected */
.bulkbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + var(--ot-bar-inset-bottom, 0px) + var(--ot-comms-inset-bottom, 0px)); z-index: 35; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; max-width: calc(100vw - 32px); background: var(--ot-surface); border: 1px solid var(--ot-line); border-radius: var(--radius-lg); box-shadow: var(--mam-shadow-modal); padding: 8px 12px; }
.bulk-count { font-weight: 600; padding: 0 8px; }
.bulkbar .grow { min-width: 8px; }

/* ---- the inspector: docked on the right; the page gives it room ---- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--ot-surface); border-left: 1px solid var(--ot-line); box-shadow: var(--mam-shadow-modal); z-index: 20; overflow-y: auto; padding: 16px 20px calc(32px + var(--ot-bar-inset-bottom, 0px) + var(--ot-comms-inset-bottom, 0px)); }
@media (min-width: 1180px) { body.inspecting .shell, body.inspecting .app-header { padding-right: calc(480px + 24px); } body.inspecting .bulkbar { left: calc((100vw - 480px) / 2); } }
.drawer-head { display: flex; align-items: flex-start; gap: 4px; margin-bottom: 12px; }
.drawer-head h1 { font-size: 16px; word-break: break-word; padding-top: 4px; }
.player { background: var(--mam-slate); border-radius: var(--radius-md); overflow: hidden; margin-bottom: 16px; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; color: var(--mam-slate-text); text-align: center; padding: 0; position: relative; }
.player video, .player img { width: 100%; height: 100%; object-fit: contain; display: block; }
.player audio { width: 90%; }
.player p { padding: 16px; margin: 0; }
.publish { border: 1px solid var(--ot-line); border-radius: var(--radius-md); padding: 12px; margin-bottom: 16px; background: var(--ot-surface-2); }
.publish .state { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; flex-wrap: wrap; }
.publish-why { font-weight: 400; font-size: 12px; }
.publish .acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--ot-line); margin: 0 -20px 16px; padding: 0 20px; scrollbar-width: thin; }
.tabs button { border: 0; background: transparent; padding: 8px 8px; cursor: pointer; white-space: nowrap; color: var(--ot-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--ot-text); }
.tabs button[aria-selected="true"] { color: var(--ot-accent); border-bottom-color: var(--ot-accent); font-weight: 600; }
.nav-count { margin-left: 6px; opacity: 0.7; font: 11px var(--mono); }
.quick-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
table.facts { width: 100%; border-collapse: collapse; font-size: 12px; }
table.facts th { text-align: left; font-weight: 400; color: var(--ot-muted); padding: 4px 12px 4px 0; vertical-align: top; white-space: nowrap; width: 1%; }
table.facts td { padding: 4px 0; word-break: break-all; }
.copies { list-style: none; margin: 0; padding: 0; }
.copies li { display: flex; gap: 8px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--ot-line); font-size: 12px; }
.copies li:first-child { border-top: 0; }
.copies .where { font-weight: 600; white-space: nowrap; }
.copies .uri { flex: 1; font-family: var(--mono); font-size: 11px; color: var(--ot-muted); word-break: break-all; }
.copies .verified { white-space: nowrap; }

/* ---- the credit: whose pictures these are, and how that reads on screen ---- */
.drawer form { margin: 0; }
.credit-help { margin: 0 0 12px; }
.credit-preview { border: 1px solid var(--ot-line); border-left: 3px solid var(--ot-accent); background: var(--ot-surface-2); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 12px; font-weight: 600; overflow-wrap: anywhere; }
.credit-preview.none { font-weight: 400; color: var(--ot-muted); border-left-color: var(--ot-line); }
.credit-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.credit-pair .field { height: 32px; }
.chip.credit { max-width: 100%; min-width: 0; }
.chip.credit .credit-mark { flex: none; font-weight: 700; }
.chip.credit .credit-words { overflow: hidden; text-overflow: ellipsis; }

/* ---- tables ---- */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: var(--ot-muted); padding: 8px 16px; border-bottom: 1px solid var(--ot-line); white-space: nowrap; }
table.list td { padding: 8px 16px; border-bottom: 1px solid var(--ot-line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list th.num, table.list td.num { text-align: right; }
.keybox { font: 12px var(--mono); background: var(--ot-field-bg); border: 1px solid var(--ot-line); border-radius: var(--radius-sm); padding: 8px 12px; word-break: break-all; user-select: all; margin: 8px 0; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
.checks { display: flex; gap: 12px; flex-wrap: wrap; }
.checks label { display: inline-flex; gap: 4px; align-items: center; }

/* ---- sign-in ---- */
.signin { max-width: 420px; margin: 48px auto; padding: 24px; }
.signin img { border-radius: 14px; display: block; margin-bottom: 16px; }
.signin .or { text-align: center; color: var(--ot-muted); margin: 16px 0; font-size: 12px; }
.signin .field.mono, .signin label.row .field { width: 100%; margin-bottom: 8px; }
.code { font: 900 20px var(--mono); letter-spacing: 0.12em; text-align: center; padding: 12px; background: var(--ot-surface-2); border-radius: var(--radius-md); margin: 12px 0; }

/* ---- drop, tray, toasts ---- */
.drop { position: fixed; inset: 0; background: var(--mam-veil); z-index: 140; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.drop-card { border: 2px dashed var(--ot-accent); border-radius: var(--radius-lg); padding: 32px 48px; background: var(--ot-surface); text-align: center; display: flex; flex-direction: column; gap: 4px; font-size: 16px; }
.drop-card span { font-size: 13px; color: var(--ot-muted); }
.tray { position: fixed; right: 16px; bottom: calc(16px + var(--ot-bar-inset-bottom, 0px) + var(--ot-comms-inset-bottom, 0px)); width: 340px; max-width: calc(100vw - 32px); z-index: 30; background: var(--ot-surface); border: 1px solid var(--ot-line); border-radius: var(--radius-lg); box-shadow: var(--mam-shadow-modal); padding: 12px 16px; max-height: 50vh; overflow-y: auto; }
.tray .head { display: flex; align-items: center; margin-bottom: 4px; font-weight: 600; }
.tray .item { padding: 8px 0; border-top: 1px solid var(--ot-line); font-size: 12px; }
.tray .item .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray progress { width: 100%; height: 6px; accent-color: var(--ot-accent); }
progress { accent-color: var(--ot-accent); }
.toasts { position: fixed; right: 16px; bottom: calc(16px + var(--ot-bar-inset-bottom, 0px) + var(--ot-comms-inset-bottom, 0px)); z-index: 210; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.tray:not([hidden]) ~ .toasts { bottom: calc(50vh + 32px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: var(--ot-surface); color: var(--ot-text); border: 1px solid var(--mam-line-ok); border-left: 3px solid var(--ot-ok); padding: 8px 12px; border-radius: var(--radius-sm); box-shadow: var(--mam-shadow-modal); font-size: 12px; }
.toast.error { border-color: var(--mam-line-error); border-left-color: var(--ot-error); }
.toast-text { flex: 1; overflow-wrap: anywhere; }
.toast-act { border: 0; background: transparent; color: var(--ot-accent); font-weight: 600; cursor: pointer; padding: 4px; white-space: nowrap; }
.toast-x { display: grid; place-items: center; border: 0; background: transparent; color: var(--ot-muted); cursor: pointer; padding: 4px; }
.toast-x .ico { width: 12px; height: 12px; }

/* ---- episode dossier: the MAM's complete view of an episode ---- */
.episode-hero { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.8fr); gap: 16px; margin: 8px 0 16px; }
.episode-hero-copy { padding: 20px; }
.episode-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.episode-kicker { display: block; color: var(--ot-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.episode-title { font-size: 20px; line-height: 1.15; font-weight: 700; margin: 4px 0 8px; }
.episode-description { max-width: 70ch; color: var(--ot-muted); margin: 0 0 12px; }
.people-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.episode-stats { display: grid; grid-template-columns: repeat(4, minmax(70px, 1fr)); gap: 8px; }
.episode-stat { background: var(--ot-surface-2); border-radius: var(--radius-md); padding: 8px 12px; }
.episode-stat b { display: block; font-size: 16px; line-height: 1.15; font-weight: 900; font-variant-numeric: tabular-nums; }
.episode-stat span { color: var(--ot-muted); font-size: 11px; }
.episode-acts { margin: 16px 0 0; }
.episode-cover { min-height: 220px; overflow: hidden; background: var(--mam-slate); }
.episode-cover img { width: 100%; height: 100%; min-height: 220px; object-fit: cover; display: block; }
.episode-cover-empty { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; color: var(--mam-slate-text); text-align: center; }
.episode-nav { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 16px; scrollbar-width: thin; }
.episode-nav button { border: 1px solid var(--ot-line); background: var(--ot-surface); border-radius: var(--radius-pill); padding: 6px 12px; cursor: pointer; white-space: nowrap; color: var(--ot-text); }
.episode-nav button[aria-selected="true"] { background: var(--ot-accent); border-color: var(--ot-accent); color: var(--ot-text-on-accent); font-weight: 600; }
.episode-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 20px 0 8px; flex-wrap: wrap; }
.episode-section-head h2 { margin: 0; color: var(--ot-text); font-size: 15px; text-transform: none; letter-spacing: 0; }
.package-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.package-card { padding: 16px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-height: 112px; color: var(--ot-text); }
.package-card:hover { border-color: var(--ot-accent); }
.package-card > b { font-size: 16px; margin-top: 4px; }
.chips.from-episode { margin: 0; }

@media (max-width: 900px) { .episode-hero { grid-template-columns: 1fr; } .episode-cover { min-height: 180px; } .package-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 820px) {
  .shell { flex-direction: column; padding: 0 12px 48px; gap: 12px; }
  .rail { position: static; width: 100%; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .rail button { width: auto; white-space: nowrap; } .rail .sep { width: 1px; height: auto; margin: 4px; flex: none; }
  .app-header { padding: 12px; flex-wrap: wrap; }
  .field.search { width: 100%; order: 5; }
  .slate { grid-template-columns: 72px minmax(0, 1fr) auto; } .slate-strip { display: none; }
  /* The page never grows wider than the phone: a wide thing scrolls sideways inside itself instead. */
  main { align-self: stretch; }
  .seg { overflow-x: auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .drawer { width: 100vw; border-left: 0; }
  .grow-row { flex-wrap: wrap; } .grow-row-control { max-width: 100%; justify-content: flex-start; }
  .bulkbar { left: 12px; right: 12px; transform: none; bottom: calc(12px + var(--ot-bar-inset-bottom, 0px) + var(--ot-comms-inset-bottom, 0px)); }
  .btn { padding: 8px 16px; }
  .dialog-foot .btn { flex: 1; }
}
@media (max-width: 560px) { .episode-stats { grid-template-columns: repeat(2, 1fr); } .package-grid { grid-template-columns: 1fr; } }

/* Clicking with Shift or Cmd chooses things; it must not also select the words on the cards. */
.asset, .asset-row, .slate, .rail, .tabs, .episode-nav, .bulkbar, .seg { user-select: none; -webkit-user-select: none; }

/* ------------------------------------------------------------- the Properties window (views/properties.js) */
.dialog.props-window { width: min(1080px, 100%); height: min(800px, 100%); }
.props-window .dialog-body { padding: 0; overflow: hidden; flex: 1; display: flex; min-height: 0; border-top: 1px solid var(--ot-line); margin-top: 12px; }
.props { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); flex: 1; min-height: 0; width: 100%; }
.props-side { border-right: 1px solid var(--ot-line); padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.props-side .player { margin-bottom: 0; }
.props-side-info { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.props-name { display: flex; align-items: flex-start; gap: 8px; }
.props-name b { flex: 1; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.props-line { font-size: 12px; }
.props-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.props-attrs { display: flex; flex-direction: column; gap: 4px; }
.props-attr { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.props-attr .label { width: 56px; flex: none; }
.props-mixed { font-size: 12px; }
.props-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.props-tabs { margin: 0; padding: 0 20px; flex: none; }
@media (min-width: 761px) { .props-tabs { flex-wrap: wrap; overflow: visible; row-gap: 0; } }
.props-panel { flex: 1; overflow-y: auto; padding: 16px 20px 24px; outline: 0; min-height: 0; }
.props-panel:focus-visible { box-shadow: inset 0 0 0 2px var(--ot-accent); }
.props-tools { margin-bottom: 8px; }
.props-tools { flex-wrap: nowrap; }
.dialog-body .props-tools .props-find { width: auto; flex: 0 1 320px; min-width: 0; }
.props-group { margin-bottom: 20px; }
.props-group h2 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ot-muted); margin: 0 0 4px; }
.props-table th { width: 32%; white-space: normal; }
.props-table td { word-break: normal; overflow-wrap: anywhere; }
.props-table td.mono { font-family: var(--mono); font-size: 11px; word-break: break-all; }
.props-table td.props-edit { padding: 4px 0 8px; }
.props-table td.props-edit .field, .props-table td.props-edit .chip-input { width: 100%; }
.props-table tr[hidden], .props-group[hidden] { display: none; }
.props-note { font-size: 12px; margin: 8px 0 0; }
.props-copies li { align-items: center; }
.props-tags { display: flex; flex-direction: column; gap: 8px; }
.props-some { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.props-mosaic { position: relative; display: grid; gap: 2px; aspect-ratio: 16 / 9; background: var(--mam-slate); border-radius: var(--radius-md); overflow: hidden; color: var(--mam-slate-text); }
.props-mosaic.n1 { grid-template-columns: 1fr; }
.props-mosaic.n2 { grid-template-columns: 1fr 1fr; }
.props-mosaic.n3, .props-mosaic.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.props-mosaic.n3 img:first-child { grid-row: span 2; }
.props-mosaic img { width: 100%; height: 100%; object-fit: cover; display: block; min-height: 0; }
.props-mosaic .kind { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
.props-more-count { position: absolute; right: 8px; bottom: 8px; background: var(--mam-slate-veil); color: var(--mam-slate-text); border-radius: var(--radius-sm); padding: 2px 8px; font-size: 12px; font-weight: 600; }
.props-items { list-style: none; margin: 0; padding: 0; }
.props-item { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--ot-line); cursor: pointer; }
.props-item:first-child { border-top: 0; }
.props-item:focus-visible { outline: 2px solid var(--ot-accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.props-item .thumb { width: 96px; border-radius: var(--radius-sm); }
.props-item-text { min-width: 0; }
@media (max-width: 760px) {
  .dialog.props-window, .veil.under-bar .dialog.props-window { width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .veil:has(.props-window) { padding: 0; }
  .veil.under-bar:has(.props-window) { padding: var(--mam-veil-top) 0 0; }
  .props { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); overflow-y: auto; }
  .props-side { border-right: 0; border-bottom: 1px solid var(--ot-line); padding: 12px 16px; overflow: visible; }
  .props-main { min-height: 60vh; }
  .props-tabs { padding: 0 16px; }
  .props-panel { padding: 12px 16px 24px; overflow: visible; }
  .props-table th { width: 40%; }
  .props-table tr:has(> td.props-edit) > th, .props-table tr:has(> td.props-edit) > td { display: block; width: auto; padding-right: 0; }
  .props-table tr:has(> td.props-edit) > th { padding-bottom: 0; }
  .props-side .player video, .props-side .player img { max-height: 200px; }
  .props-side .player audio { max-height: none; }
  .props-mosaic { max-height: 200px; }
  .props-side .mp-stage { max-height: 200px; }
  .props-item { grid-template-columns: 72px minmax(0, 1fr) auto; }
  .props-item .thumb { width: 72px; }
}
