:root {
    color-scheme: dark;
    /* Exact tokens from the Space mockup. Keep tailwind.config.js aligned. */
    --bg-primary: hsl(212 8% 11%);
    --bg-surface: hsl(212 8% 14%);
    --bg-card: hsl(212 8% 17%);
    --bg-raised: hsl(212 8% 20%);
    --border-color: hsl(212 8% 23%);
    --text-primary: #EDEDEE;
    --text-secondary: #B5B5BA;
    --text-faint: #929298;
    --accent-blue: #6F95FF;
    --accent-green: #3CC497;
    --accent-amber: #D4B076;
    --accent-red: #E59797;
    /* One height for every column's top band, so their bottom borders line up. */
    --app-bar-height: 44px;
}

html, body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-optical-sizing: auto;
}

/* Align digits in dense data (tables, run IDs, DAG labels) and disambiguate glyphs. */
table, .font-mono, [class*="font-mono"] {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1, 'calt' 0;
}
.font-mono, [class*="font-mono"] { font-variant-ligatures: none; }

::selection { background: rgba(111, 149, 255, 0.30); }

/* Lab run activity: quiet when read, pulsing only while work is underway. */
.run-activity { display: none; }
.run-activity[data-state] {
    display: block;
    width: 0.5rem;
    height: 0.5rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--accent-green);
}
.run-activity[data-state="working"] { animation: run-working 1.5s ease-in-out infinite; }
@keyframes run-working {
    50% { opacity: 0.35; }
}

/* Consistent focus ring for interactive elements */
a:focus-visible, button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid rgba(111, 149, 255, 0.65);
    outline-offset: 1px;
    border-radius: 0.375rem;
}

/* Flat surfaces keep the conversation and operational state in focus. */
.surface {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
}
.surface-sunken {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}
.surface-raised {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 16px 48px -12px rgba(0, 0, 0, 0.5);
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-primary);
}
.btn-primary:hover { background: #FFFFFF; }
.btn-primary:active { background: #D3D4D6; }

/* A compact application frame: the rail carries the brand, so no top bar. */
.app-brand { display: flex; align-items: center; justify-content: center; width: 100%; height: var(--app-bar-height); color: var(--text-secondary); border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.app-brand:hover { color: var(--text-primary); }
.app-brand img { flex-shrink: 0; }
.app-navigation-rail [aria-current="page"] { background: var(--bg-raised); color: var(--text-primary); }
.app-navigation-rail {
    --rail-width: 76px;
    position: fixed;
    z-index: 30;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--rail-width);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 0 0 12px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
}
.app-main-with-rail { margin-left: 76px; }
.app-navigation-links {
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    scrollbar-width: none;
}
.app-navigation-links::-webkit-scrollbar { display: none; }
.workspace-switch, .app-primary-navigation {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.workspace-switch { margin-bottom: 12px; }
.app-rail-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 64px;
    min-height: 50px;
    padding: 6px 2px 5px;
    margin-inline: auto;
    border-radius: 8px;
    flex-shrink: 0;
}
.app-rail-link svg { width: 19px; height: 19px; flex-shrink: 0; }
.app-rail-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -.01em;
}
.app-navigation-rail #user-menu { flex-shrink: 0; }
.app-navigation-rail #user-menu-dropdown {
    left: calc(100% + 16px);
    bottom: 0;
}
@media (max-width: 639px) {
    .app-navigation-rail { --rail-width: 64px; }
    .app-main-with-rail { margin-left: 64px; }
    .app-rail-link { width: 58px; min-height: 46px; padding: 5px 1px 4px; }
    .app-rail-label { font-size: 9.5px; letter-spacing: -.02em; }
    .app-navigation-rail #user-menu-dropdown { left: calc(100% + 12px); }
}
/* The runs search band shares the column top-band height. */
.runs-sidebar-bar { display: flex; align-items: center; gap: 8px; height: var(--app-bar-height); padding: 0 8px 0 12px; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.runs-sidebar-bar .ui-field { min-height: 0; height: 30px; padding-top: 0; padding-bottom: 0; }
.user-avatar { background: var(--bg-card); border: 1px solid var(--border-color); }
.user-avatar:hover { background: var(--border-color); }

/* The composer stays in the reading column, rather than a separate toolbar. */
.chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.625rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.chat-composer:focus-within { border-color: var(--text-secondary); }
.chat-composer textarea {
    background: transparent;
    border: 0;
    padding: 0.5rem;
    line-height: 1.5;
    max-height: 12rem;
}
.chat-composer textarea:focus-visible { outline-offset: -1px; }
.chat-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--text-primary);
    color: var(--bg-primary);
}
.chat-send:hover { background: #FFFFFF; }
.chat-send:disabled { background: var(--border-color); color: var(--text-secondary); }
.chat-self { background: var(--bg-card); border-radius: 8px; }
.chat-reply { padding-top: 0.375rem; }
.chat-reply .chat-markdown { font-size: 0.9375rem; line-height: 1.7; }
.chat-message .chat-timestamp { opacity: 0; }
.chat-message:hover .chat-timestamp,
.chat-message:focus-within .chat-timestamp { opacity: 1; }
.chat-message:focus-visible {
    outline: 1px solid var(--border-color);
    outline-offset: 4px;
    border-radius: 8px;
}

/* Click-to-copy public-id chip (see the .pid-chip click handler in base.html). */
.pid-chip {
    cursor: copy;
    color: #B5B5BA;
    border-radius: 0.375rem;
    padding: 0.125rem 0.375rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.pid-chip:hover { background: rgba(255, 255, 255, 0.07); color: #D3D4D6; }
.pid-chip.copied { color: var(--accent-green); border-color: rgba(60, 196, 151, 0.4); }

/* Metrics: restrained data density, with the existing blue as the only
   decorative accent. Outcome colors remain semantic (ok/warn/danger). */
.metric-kpi {
    position: relative;
    overflow: hidden;
}
.metric-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.75rem;
    color: var(--accent-blue);
    background: rgba(111, 149, 255, 0.09);
    border: 1px solid rgba(111, 149, 255, 0.15);
}
.metric-chart {
    position: relative;
    width: 100%;
    height: 18rem;
    min-width: 0;
}
.metric-chart-tall { height: 20rem; }
.metric-chart-loading,
.metric-chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: center;
}
.metric-data-details {
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
}
.metric-data-details > summary {
    width: fit-content;
    cursor: pointer;
    transition: color 0.15s ease;
}
.metric-data-details > summary:hover { color: #D3D4D6; }
.metric-stat {
    min-width: 0;
    padding: 1rem;
    background: var(--bg-surface);
}
.metric-stat p {
    color: var(--text-secondary);
    font-size: 0.6875rem;
    line-height: 1rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.metric-stat strong {
    display: block;
    margin-top: 0.5rem;
    color: #EDEDEE;
    font-size: 1.25rem;
    line-height: 1.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.metric-stat span {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    line-height: 1rem;
}

@media (max-width: 639px) {
    .metric-chart { height: 16rem; }
    .metric-chart-tall { height: 18rem; }
}

/* Disable scroll anchoring so user can scroll up freely */
#chat-messages { overflow-anchor: none; }

/* Custom scrollbar for chat/sidebar/panel */
.custom-scroll { scrollbar-width: thin; scrollbar-color: var(--border-color) transparent; }
.custom-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
.custom-scroll::-webkit-scrollbar-thumb:hover { background: #4B5056; background-clip: content-box; }

/* Chat and session tools share one workspace at every screen size. */
.conversation-workspace { min-height: 0; }
.chat-column { min-height: 0; }
#context-panel {
    position: relative;
    width: clamp(264px, 28vw, 352px);
    min-height: 0;
    overflow: hidden;
    border-left: 1px solid var(--border-color);
    background: var(--bg-primary);
}
.context-panel-header {
    min-height: var(--app-bar-height);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}
/* Phones: the session panel is a drawer over the chat, sliding in from the
   right like the runs sidebar does from the left. It scrolls as one column so
   every camera and the whole plan stay reachable. */
@media (max-width: 699px) {
    #context-panel {
        position: fixed;
        inset: 0 0 0 auto;
        z-index: 50;
        display: block;
        width: min(90%, 384px);
        overflow-y: auto;
        overscroll-behavior: contain;
        box-shadow: -16px 0 40px #0008;
        scrollbar-width: thin;
        animation: context-drawer-in 0.2s ease-out;
    }
    #context-panel.hidden { display: none; }
    .context-panel-header { position: sticky; top: 0; z-index: 2; }
    #context-panel .context-camera-section { max-height: none; overflow: visible; }
    #context-panel .camera-grid { overflow: visible; }
    #context-panel > section { overflow: visible; }
    #context-panel #panel-section-dag { flex: none; }
}
@keyframes context-drawer-in { from { transform: translateX(100%); } to { transform: none; } }

/* Empty state inside the execution-plan section */
.dag-empty {
    color: #929298;
}
.dag-empty svg { color: #4B5056; }

/* Fade-in for newly arriving chat bubbles */
@keyframes chat-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
#chat-messages-inner > div { animation: chat-msg-in 0.28s ease-out; }

/* Markdown rendered in chat messages */
/* Chat text is full of unbreakable tokens (public ids, asset reprs, URLs). Without
   this a single one is wider than a phone viewport and the whole chat column scrolls
   sideways. `anywhere` (not `break-word`) so it also shrinks min-content, which is
   what keeps flex/table children from pushing the column wide.
   `pre` opts back out: white-space:pre gives no wrap opportunities anyway and code
   blocks scroll inside their own overflow-x:auto box. */
.chat-markdown { overflow-wrap: anywhere; }
.chat-markdown pre { overflow-wrap: normal; }
/* Same treatment for chat text that isn't markdown (own messages, status pills). */
.chat-wrap-anywhere { overflow-wrap: anywhere; }
.chat-markdown p { margin: 0.25rem 0; }
.chat-markdown p:first-child { margin-top: 0; }
.chat-markdown p:last-child { margin-bottom: 0; }
.chat-markdown strong { font-weight: 600; }
.chat-markdown em { font-style: italic; }
.chat-markdown code { background: rgba(0,0,0,0.3); padding: 0.1em 0.35em; border-radius: 0.25rem; font-size: 0.8em; font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace; }
.chat-markdown pre { background: rgba(0,0,0,0.3); padding: 0.5rem 0.75rem; border-radius: 0.375rem; overflow-x: auto; margin: 0.5rem 0; }
.chat-markdown pre code { background: none; padding: 0; font-size: 0.8em; }
.chat-markdown ul, .chat-markdown ol { margin: 0.25rem 0; padding-left: 1.25rem; }
.chat-markdown ul { list-style: disc; }
.chat-markdown ol { list-style: decimal; }
.chat-markdown li { margin: 0.15rem 0; }
.chat-markdown h1, .chat-markdown h2, .chat-markdown h3 { font-weight: 600; margin: 0.5rem 0 0.25rem; }
.chat-markdown h1 { font-size: 1.1em; }
.chat-markdown h2 { font-size: 1.05em; }
.chat-markdown h3 { font-size: 1em; }
.chat-markdown table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; font-size: 0.85em; }
.chat-markdown th, .chat-markdown td { border: 1px solid rgba(148,163,184,0.2); padding: 0.35rem 0.5rem; text-align: left; }
.chat-markdown th { background: rgba(0,0,0,0.2); font-weight: 600; }
.chat-markdown hr { border: none; border-top: 1px solid rgba(148,163,184,0.2); margin: 0.5rem 0; }
.chat-markdown a { color: var(--accent-blue); text-decoration: underline; text-underline-offset: 2px; }
.chat-markdown blockquote { border-left: 3px solid rgba(148,163,184,0.3); padding-left: 0.75rem; margin: 0.25rem 0; color: #B5B5BA; }

/* Opt-in syntax highlighted code blocks (e.g. protocol draft proposals) */
.chat-code-block {
    margin: 0;
    tab-size: 4;
    background: rgba(26, 28, 30, 0.7) !important;
}
.chat-code-block > code.chat-syntax-highlight {
    display: block;
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: pre;
    background: transparent !important;
    text-shadow: none;
    /* Contextual ligatures are pleasant in code, off everywhere else. */
    font-variant-ligatures: contextual;
}

/* Bouncing dots animation for executing indicator */
@keyframes bounce-dot {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
.bounce-dot-1 { animation: bounce-dot 1.4s infinite ease-in-out both; animation-delay: -0.32s; }
.bounce-dot-2 { animation: bounce-dot 1.4s infinite ease-in-out both; animation-delay: -0.16s; }
.bounce-dot-3 { animation: bounce-dot 1.4s infinite ease-in-out both; }

.chat-stop-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-card);
  color: #B5B5BA;
  transition: background .15s, color .15s, border-color .15s;
}
.chat-stop-button:hover { background: var(--border-color); color: var(--text-primary); border-color: #4B5056; }
.chat-stop-button:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 3px; }
.chat-stop-button:disabled { cursor: wait; opacity: .5; }

.chat-header { display: flex; align-items: center; gap: 10px; min-height: var(--app-bar-height); padding: 4px 60px 4px 16px; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.chat-conversation-title { flex: 0 1 auto; min-width: 0; color: #B5B5BA; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header > form { flex-shrink: 0; }
.chat-archived-label { color: #929298; font-size: 11px; }
.chat-toolbar-button, .chat-attach-button { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 8px; color: var(--text-secondary); transition: background .15s, color .15s; }
.chat-toolbar-button { width: 32px; height: 32px; }
.chat-toolbar-button.hidden { display: none; }
/* Match the header content center, excluding its bottom border. */
.chat-context-toggle { top: calc((var(--app-bar-height) - 1px) / 2); transform: translateY(-50%); }
.chat-attach-button { width: 36px; height: 36px; }
.chat-toolbar-button:hover, .chat-attach-button:hover { color: var(--text-primary); background: var(--border-color); }
.chat-toolbar-button:focus-visible, .chat-attach-button:focus-visible, .chat-remove-attachment:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.chat-attach-button:disabled { cursor: not-allowed; opacity: .5; }
.chat-attachments { margin-top: 8px; }
.chat-attachment-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-attachment-chip { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; padding: 4px 6px 4px 10px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-card); color: #B5B5BA; font-size: 12px; }
.chat-attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attachment-size { flex-shrink: 0; color: #929298; font-size: 11px; }
.chat-remove-attachment { flex-shrink: 0; width: 24px; height: 24px; border-radius: 4px; color: var(--text-secondary); }
.chat-remove-attachment:hover { color: var(--text-primary); background: var(--border-color); }
.chat-attachment-hint, .chat-upload-progress { margin-top: 6px; color: var(--text-secondary); font-size: 11px; line-height: 18px; }
.chat-attachment-error { margin-top: 6px; color: #f19c96; font-size: 12px; line-height: 18px; }

.chat-activity { display: flex; gap: 10px; padding: 8px 0; max-width: 32rem; }
.chat-activity-spinner {
  width: 14px;
  height: 14px;
  margin-top: 3px;
  flex-shrink: 0;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: chat-activity-spin 1s linear infinite;
}
.chat-activity-copy { flex: 1; min-width: 0; }
.chat-activity-heading { display: flex; align-items: baseline; gap: 12px; color: #B5B5BA; font-size: 13px; line-height: 20px; }
.chat-activity-elapsed { color: #929298; font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chat-activity-detail { color: var(--text-secondary); font-size: 12px; line-height: 20px; }
.chat-activity-tools { color: #929298; font-size: 11px; line-height: 18px; }
@keyframes chat-activity-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .chat-activity-spinner, .bounce-dot-1, .bounce-dot-2, .bounce-dot-3 { animation: none; }
}

/* DAG node running pulse animation */
@keyframes dag-pulse {
    0%, 100% { opacity: 1; filter: drop-shadow(0 0 0 transparent); }
    50% { opacity: 0.85; filter: drop-shadow(0 0 7px rgba(111, 149, 255, 0.40)); }
}
.dag-node-running {
    animation: dag-pulse 2s infinite ease-in-out;
}

/* Live indicator — slow pulse ring for "something is happening" states. */
@keyframes live-ping {
    0%   { box-shadow: 0 0 0 0 rgba(60, 196, 151, 0.45); }
    70%  { box-shadow: 0 0 0 5px rgba(60, 196, 151, 0); }
    100% { box-shadow: 0 0 0 0 rgba(60, 196, 151, 0); }
}
.dot-live { animation: live-ping 2.2s infinite cubic-bezier(0.2, 0.8, 0.2, 1); }

/* Respect the OS reduced-motion setting: collapse animations and transitions
   to imperceptible durations rather than removing classes template-by-template. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Multiple camera players share the panel height with the execution plan. */
.context-camera-section { min-height: 0; max-height: 55%; flex-shrink: 1; }
#panel-section-video, #camera-panel-wrapper, .camera-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#panel-section-video.hidden { display: none; }
.camera-panel { position: relative; gap: 8px; }
.camera-panel [hidden] { display: none !important; }
.camera-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-shrink: 0; }
.camera-picker { position: relative; min-width: 0; }
.camera-picker-button, .camera-expand-button, .camera-close-button, .camera-play-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 32px;
    padding: 6px 9px;
    border: 1px solid var(--border-color);
    border-radius: 7px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
}
.camera-picker-button { list-style: none; }
.camera-picker-button::-webkit-details-marker { display: none; }
.camera-picker-button:hover, .camera-expand-button:hover, .camera-close-button:hover, .camera-play-button:hover { border-color: var(--text-secondary); }
.camera-picker-button:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.camera-picker-options {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 30;
    width: min(280px, calc(100vw - 76px));
    max-height: min(320px, 50dvh);
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    box-shadow: 0 10px 28px #0006;
}
.camera-picker-option { display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: 5px; color: var(--text-primary); font-size: 13px; cursor: pointer; }
.camera-picker-option:hover { background: var(--bg-surface); }
.camera-picker-option > span { min-width: 0; overflow-wrap: anywhere; }
.camera-choice { width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--accent-blue); }
/* Rows keep their content height: tiles clip with overflow:hidden, so auto rows
   would otherwise shrink to the grid's height and crop every feed. */
.camera-grid { display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; align-content: start; gap: 8px; min-height: 0; overflow-y: auto; }
.camera-grid.camera-grid-many { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.camera-tile { position: relative; min-width: 0; border-radius: 8px; overflow: hidden; background: var(--bg-primary); }
.camera-viewport { position: relative; aspect-ratio: var(--camera-aspect, 16 / 9); }
.camera-video { display: block; width: 100%; height: 100%; object-fit: contain; }
.camera-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 28px 8px 8px; background: var(--bg-primary); color: var(--text-secondary); text-align: center; font-size: 12px; }
.camera-overlay-spinner { width: 18px; height: 18px; border: 2px solid var(--border-color); border-top-color: var(--text-secondary); border-radius: 50%; animation: camera-spin 1s linear infinite; flex-shrink: 0; }
@keyframes camera-spin { to { transform: rotate(360deg); } }
/* The name sits on the video so it is visible at every tile size, and doubles
   as the drag handle for reordering. */
.camera-tile-label {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 5px;
    max-width: calc(100% - 12px);
    padding: 3px 8px 3px 6px;
    border: 0;
    border-radius: 6px;
    background: #000a;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    line-height: 16px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.camera-tile-label svg { flex-shrink: 0; opacity: 0.65; }
.camera-tile-label:hover svg, .camera-tile-label:focus-visible svg { opacity: 1; }
.camera-tile-label:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
.camera-tile-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camera-tile.camera-tile-dragging { outline: 2px solid var(--accent-blue); outline-offset: -2px; opacity: 0.75; }
.camera-tile.camera-tile-dragging .camera-tile-label { cursor: grabbing; }
.camera-grid.camera-grid-sorting { user-select: none; -webkit-user-select: none; }
.camera-empty { padding: 40px 16px; text-align: center; color: var(--text-secondary); font-size: 12px; }
/* The expanded view fills the screen; the player sizes its grid so every
   selected feed fits whole, scrolling only once tiles would get too small. */
.camera-expanded-dialog { width: calc(100vw - 32px); height: calc(100dvh - 32px); max-width: none; max-height: none; margin: auto; padding: 0; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-surface); color: var(--text-primary); }
.camera-expanded-dialog[open] { display: flex; flex-direction: column; }
.camera-expanded-dialog::backdrop { background: #000b; }
.camera-expanded-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.camera-expanded-content { display: flex; flex: 1; flex-direction: column; min-height: 0; padding: 12px; }
.camera-expanded-content .camera-panel { flex: 1; min-height: 0; }
.camera-expanded-content .camera-expand-button { display: none; }
.camera-expanded-content .camera-grid { flex: 1; justify-content: center; align-content: center; }
.camera-expanded-content .camera-tile-label { top: 8px; left: 8px; padding: 4px 10px 4px 8px; font-size: 13px; }
@media (max-width: 479px) {
    .camera-expanded-dialog { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
    .camera-expanded-content { padding: 8px; }
}

#runs-sidebar [data-run-id][hidden] { display: none; }
