/*
CatchOntheWeb's look: design tokens, Bootstrap 5.3 variables, the app shell (sidebar, top bar), and the shared page parts.
Loaded after Bootstrap and fish_counter.css, before a page's own styles.
Design: docs/superpowers/specs/2026-09-26-web-ui-shell-design.md
*/

:root {
    --cotw-deep-water: #0E2A3B;
    --cotw-deep-water-2: #163A4F;
    --cotw-ink: #1B2B34;
    --cotw-muted: #5B6B75;
    --cotw-teal: #0F766E;
    --cotw-teal-dark: #0B5E58;
    --cotw-teal-soft: #E3F2F0;
    --cotw-signal: #E8772E;
    --cotw-mist: #F3F6F8;
    --cotw-rope: #DCE3E8;
    --cotw-panel: #FFFFFF;
    --cotw-sidebar-text: #C9D6DE;
    --cotw-sidebar-width: 15.5rem;
    --cotw-topbar-height: 3.25rem;
    --cotw-radius: 6px;
    --cotw-font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;

    /* Bootstrap 5.3 */
    --bs-body-font-family: var(--cotw-font);
    --bs-body-font-size: 1rem;
    --bs-body-color: var(--cotw-ink);
    --bs-body-bg: var(--cotw-mist);
    --bs-emphasis-color: var(--cotw-ink);
    --bs-secondary-color: var(--cotw-muted);
    --bs-primary: var(--cotw-teal);
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: var(--cotw-teal);
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: var(--cotw-teal-dark);
    --bs-link-hover-color-rgb: 11, 94, 88;
    --bs-border-color: var(--cotw-rope);
    --bs-border-radius: var(--cotw-radius);
    --bs-border-radius-sm: 4px;
    --bs-border-radius-lg: 8px;
    --bs-focus-ring-color: rgba(15, 118, 110, 0.35);
    --bs-heading-color: var(--cotw-ink);

        /* Colours that used to be written out, as tokens so the dark theme can change them */
    --cotw-warn-text: #B4531A;
    --cotw-bad-text: #B42318;
    --cotw-good-text: #198754;
    --cotw-field-border: #C5D0D7;
    --cotw-dash-border: #B7C4CD;
    --cotw-hover-border: #C3CED6;
    --cotw-subtle: #F8FAFB;
    --cotw-waiting-bg: #FCEBDD;
    --cotw-waiting-text: #8A3F10;
    --cotw-failed-bg: #FDE8E7;
    --cotw-danger-bg: #FDF6F5;
    --cotw-danger-border: #F1C4BE;
    --cotw-info-text: #1F5F8B;
    --cotw-info-bg: #E6F0F8;
    --cotw-info-border: #BFD6EA;
    --cotw-drop-bg: rgba(227, 242, 240, 0.92);
    --cotw-drop-bg-active: rgba(227, 242, 240, 0.97);
    --cotw-shadow: rgba(14, 42, 59, 0.14);
    --cotw-link-strong: #073F3B;
    --cotw-teal-text: var(--cotw-teal);            /* teal as a text colour, lighter in the dark theme */
    --cotw-teal-dark-text: var(--cotw-teal-dark);

/* Older styles in fish_counter.css use these */
    --primary-color: var(--cotw-teal);
    --secondary-color: var(--cotw-teal-dark);
    --text-secondary: var(--cotw-muted);
}

/* The dark theme (static/theme.js, the top bar's switch; components/theme_init.html applies it before the page is
   drawn). Bootstrap's own components follow data-bs-theme; these are the site's colours. The sidebar is dark in both. */
:root { color-scheme: light; }
[data-bs-theme="dark"] {
    color-scheme: dark;
    --cotw-deep-water: #0A1A24;
    --cotw-deep-water-2: #10293A;
    --cotw-ink: #E1E8EC;
    --cotw-muted: #9AACB7;
    --cotw-teal-text: #5CCDC1;
    --cotw-teal-dark-text: #7FDCD1;
    --cotw-teal-soft: #123430;
    --cotw-mist: #0F181E;
    --cotw-rope: #2B3A43;
    --cotw-panel: #172229;
    --cotw-link-strong: #A6EBE2;
    --cotw-warn-text: #F2A36F;
    --cotw-bad-text: #F4908A;
    --cotw-good-text: #6FD39B;
    --cotw-field-border: #3A4B55;
    --cotw-dash-border: #465964;
    --cotw-hover-border: #465964;
    --cotw-subtle: #1B2830;
    --cotw-waiting-bg: #4A2A14;
    --cotw-waiting-text: #F6C49E;
    --cotw-failed-bg: #4A1E1C;
    --cotw-danger-bg: #2A1A19;
    --cotw-danger-border: #6B3530;
    --cotw-info-text: #9CC8EC;
    --cotw-info-bg: #16293A;
    --cotw-info-border: #2F4C66;
    --cotw-drop-bg: rgba(18, 52, 48, 0.92);
    --cotw-drop-bg-active: rgba(18, 52, 48, 0.97);
    --cotw-shadow: rgba(0, 0, 0, 0.5);

    --bs-link-color: var(--cotw-teal-text);
    --bs-link-color-rgb: 92, 205, 193;
    --bs-link-hover-color: var(--cotw-teal-dark-text);
    --bs-link-hover-color-rgb: 127, 220, 209;
    --bs-focus-ring-color: rgba(92, 205, 193, 0.4);
    --bs-secondary-bg: #1E2B33;
    --bs-tertiary-bg: #1B2830;
}

body.cotw {
    font-family: var(--cotw-font);
    font-size-adjust: from-font;
    background-color: var(--cotw-mist);
    color: var(--cotw-ink);
    min-height: 100vh;
}

.cotw :is(h1, h2, h3, h4, h5, h6) {
    font-weight: 600;
    color: var(--cotw-ink);
    text-align: left;
    letter-spacing: 0;
}
.cotw h1 { font-size: 1.75rem; }
.cotw h2 { font-size: 1.625rem; margin-bottom: 0.75rem; }
.cotw h3 { font-size: 1.25rem; }
.cotw h4 { font-size: 1.125rem; }
.cotw h5, .cotw h6 { font-size: 1rem; }

.cotw a { text-decoration: none; }
/* Clickable text stands out from the text around it: dark teal, semi-bold and underlined, with a thicker line on
   hover. Buttons, menus, the sidebar, the top bar, the step circles and linked pictures keep their own look. Written
   with :where() so that it counts like `.cotw a`: a part of a page that sets its own link colour (light teal on the
   dark log-in panel, say) keeps it. */
.cotw a:where(:not(.btn, .nav-link, .dropdown-item, .page-link, .about-brand, .sidebar-brand, .skip-link, .visually-hidden-focusable)):where(:not(:is(.app-sidebar, .app-topbar, .dash-step, .manual-figure, .manual-contents, .about-top) a)) {
    color: var(--cotw-teal-dark-text);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}
.cotw a:where(:not(.btn, .nav-link, .dropdown-item, .page-link, .about-brand, .sidebar-brand, .skip-link, .visually-hidden-focusable)):where(:not(:is(.app-sidebar, .app-topbar, .dash-step, .manual-figure, .manual-contents, .about-top) a)):hover {
    color: var(--cotw-link-strong);
    text-decoration-thickness: 2px;
}
/* The manual's contents: underlined too, lighter, so the list stays easy to scan */
.cotw .manual-contents a { color: var(--cotw-teal-dark-text); text-decoration: underline; text-decoration-color: rgba(11, 94, 88, 0.4);
    text-underline-offset: 0.18em; }
.cotw .manual-contents a:hover { text-decoration-color: currentColor; text-decoration-thickness: 2px; }

/* One visible focus ring everywhere, for keyboard users */
.cotw :focus-visible {
    outline: 3px solid var(--cotw-teal);
    outline-offset: 2px;
    box-shadow: none;
}
.cotw .app-sidebar :focus-visible { outline-color: #7FD4CB; }

.skip-link {
    position: absolute;
    left: 0.5rem;
    top: -3rem;
    z-index: 2000;
    padding: 0.5rem 0.75rem;
    background: var(--cotw-panel);
    color: var(--cotw-ink);
    border-radius: var(--cotw-radius);
}
.skip-link:focus { top: 0.5rem; }

/* ---------- Buttons ---------- */
.cotw .btn { font-weight: 600; }
.cotw .btn-primary {
    --bs-btn-bg: var(--cotw-teal);
    --bs-btn-border-color: var(--cotw-teal);
    --bs-btn-hover-bg: var(--cotw-teal-dark);
    --bs-btn-hover-border-color: var(--cotw-teal-dark);
    --bs-btn-active-bg: var(--cotw-teal-dark);
    --bs-btn-active-border-color: var(--cotw-teal-dark);
    --bs-btn-disabled-bg: var(--cotw-teal);
    --bs-btn-disabled-border-color: var(--cotw-teal);
    --bs-btn-focus-shadow-rgb: 15, 118, 110;
}
/* Secondary buttons: dark text and icons on a clear border, filled dark on hover */
.cotw .btn-outline-secondary {
    --bs-btn-color: var(--cotw-ink);
    --bs-btn-border-color: #7D8D97;
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: var(--cotw-ink);
    --bs-btn-hover-border-color: var(--cotw-ink);
    --bs-btn-active-color: #FFFFFF;
    --bs-btn-active-bg: var(--cotw-ink);
    --bs-btn-active-border-color: var(--cotw-ink);
    --bs-btn-disabled-color: var(--cotw-muted);
    --bs-btn-disabled-border-color: var(--cotw-rope);
}
.cotw .btn-close { opacity: 0.8; }
.cotw .btn-close:hover { opacity: 1; }
.cotw .btn-outline-primary {
    --bs-btn-color: var(--cotw-teal);
    --bs-btn-border-color: var(--cotw-teal);
    --bs-btn-hover-bg: var(--cotw-teal);
    --bs-btn-hover-border-color: var(--cotw-teal);
    --bs-btn-active-bg: var(--cotw-teal-dark);
    --bs-btn-active-border-color: var(--cotw-teal-dark);
}

/* ---------- The shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* A fixed width: nothing inside may widen it (min-width: 0, and words that don't fit are cut with an ellipsis) */
.app-sidebar-col {
    flex: 0 0 var(--cotw-sidebar-width);
    width: var(--cotw-sidebar-width);
    min-width: 0;
    background-color: var(--cotw-deep-water);
    transition: flex-basis 0.15s ease, width 0.15s ease;
}
@media (max-width: 991.98px) {
    .app-sidebar-col { flex-basis: 0; }
}

.app-sidebar {
    --bs-offcanvas-width: min(18rem, 85vw);
    --bs-offcanvas-bg: var(--cotw-deep-water);
    --bs-offcanvas-color: var(--cotw-sidebar-text);
    color: var(--cotw-sidebar-text);
    display: flex;
    flex-direction: column;
}
@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
        scrollbar-width: thin;
    }
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 0.75rem;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #FFFFFF;
    font-weight: 700;
    font-size: 1.0625rem;
}
.sidebar-brand:hover { color: #FFFFFF; text-decoration: none; }
.sidebar-brand-mark { width: 1.75rem; height: 1.1rem; color: #7FD4CB; }

.sidebar-body { flex: 1 1 auto; padding: 0.25rem 0.625rem; }

.sidebar-nav { list-style: none; margin: 0 0 1rem; padding: 0; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.4rem 0.625rem;
    border-radius: var(--cotw-radius);
    color: var(--cotw-sidebar-text);
}
.sidebar-nav a:hover { background-color: rgba(255, 255, 255, 0.06); color: #FFFFFF; text-decoration: none; }
.sidebar-nav a.current { background-color: rgba(127, 212, 203, 0.14); color: #FFFFFF; }

/* On a project's pages the main links fold into one Menu line (components/sidebar.html) */
.sidebar-main-fold { margin: 0 0 0.75rem; }
.sidebar-main-fold > summary {
    display: flex; align-items: center; gap: 0.625rem; padding: 0.4rem 0.625rem; border-radius: var(--cotw-radius);
    color: var(--cotw-sidebar-text); cursor: pointer; list-style: none;
}
.sidebar-main-fold > summary::-webkit-details-marker { display: none; }
.sidebar-main-fold-chevron { display: inline-block; margin-left: auto; font-size: 0.8rem; transform: rotate(-90deg); transition: transform 0.15s; }
.sidebar-main-fold[open] .sidebar-main-fold-chevron { transform: none; }
.sidebar-main-fold > summary:hover { background-color: rgba(255, 255, 255, 0.06); color: #FFFFFF; }
.sidebar-main-fold > summary:focus-visible { outline: 2px solid #7FD4CB; outline-offset: -2px; }
.sidebar-main-fold-hint { min-width: 0; font-size: 0.8125rem; color: rgba(201, 214, 222, 0.6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-main-fold[open] .sidebar-main-fold-hint { display: none; }
.sidebar-main-fold .sidebar-nav { margin: 0.25rem 0 0; }
@media (prefers-reduced-motion: reduce) { .sidebar-main-fold-chevron { transition: none; } }

/* The project's steps: the one bold element of the shell */
.sidebar-project {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.875rem;
}
.sidebar-project-name {
    display: block;
    padding: 0 0.625rem 0.5rem;
    color: #FFFFFF;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-project-name:hover { color: #FFFFFF; }
.sidebar-project-name.current { color: #7FD4CB; }

.sidebar-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}
/* The line joining the steps */
.sidebar-steps::before {
    content: "";
    position: absolute;
    left: calc(0.625rem + 0.6875rem - 1px);
    top: 0.875rem;
    bottom: 0.875rem;
    width: 2px;
    background: rgba(255, 255, 255, 0.12);
}
.sidebar-step a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.3rem 0.625rem;
    border-radius: var(--cotw-radius);
    color: var(--cotw-sidebar-text);
}
.sidebar-step a:hover { background-color: rgba(255, 255, 255, 0.06); color: #FFFFFF; text-decoration: none; }
.sidebar-step-marker {
    flex: 0 0 1.375rem;
    height: 1.375rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.28);
    background: var(--cotw-deep-water);
    font-size: 0.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.sidebar-step-marker { position: relative; }
.sidebar-step-marker svg { width: 0.8rem; height: 0.8rem; }
.sidebar-step-num { display: inline-flex; }
/* The step's glyph and done notch show on the folded rail only */
.sidebar-step-icon, .sidebar-step-tick { display: none; }
.sidebar-step.done .sidebar-step-marker {
    background: var(--cotw-teal);
    border-color: var(--cotw-teal);
    color: #FFFFFF;
}
.sidebar-step.next .sidebar-step-marker {
    border-color: var(--cotw-signal);
    color: var(--cotw-signal);
}
.sidebar-step.next .sidebar-step-label::after {
    content: "next";
    margin-left: 0.375rem;
    padding: 0 0.375rem;
    border-radius: 999px;
    background: rgba(232, 119, 46, 0.18);
    color: #F6B386;
    font-size: 0.75rem;
}
.sidebar-step.current a { background-color: rgba(127, 212, 203, 0.14); color: #FFFFFF; font-weight: 600; }
.sidebar-step.current .sidebar-step-marker { box-shadow: 0 0 0 3px rgba(127, 212, 203, 0.35); }

.sidebar-foot {
    padding: 0.75rem 0.625rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.875rem;
}
.sidebar-gpus .gpu-status { color: var(--cotw-sidebar-text); padding: 0 0.625rem 0.5rem; }
.sidebar-gpus .gpu-status-label { color: var(--cotw-sidebar-text); }
.sidebar-account {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.4rem 0.625rem;
    border: 0;
    border-radius: var(--cotw-radius);
    background: transparent;
    color: #FFFFFF;
    text-align: left;
}
.sidebar-account:hover { background-color: rgba(255, 255, 255, 0.06); }
.sidebar-account-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-credit { margin: 0.5rem 0.625rem 0; color: rgba(201, 214, 222, 0.6); font-size: 0.75rem; line-height: 1.35; }
.sidebar-credit a { color: inherit; text-decoration: underline; }
.sidebar-credit a:hover { color: #fff; }

/* ---------- The sidebar folded to a rail of icons (components/sidebar.html, static/sidebar_fold.js) ---------- */
.sidebar-fold-button {
    display: none;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    border-radius: var(--cotw-radius);
    background: transparent;
    color: rgba(201, 214, 222, 0.75);
    font-size: 0.875rem;
}
.sidebar-fold-button:hover { background-color: rgba(255, 255, 255, 0.08); color: #FFFFFF; }
.sidebar-head { gap: 0.5rem; }
.sidebar-brand, .sidebar-nav a, .sidebar-main-fold > summary, .sidebar-step a { min-width: 0; }
.sidebar-label, .sidebar-step-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-main-fold-word { flex: none; }
@media (min-width: 992px) {
    .sidebar-fold-button { display: inline-flex; }
    html[data-sidebar="folded"] { --cotw-sidebar-width: 4.25rem; }
    html[data-sidebar="folded"] .sidebar-label,
    html[data-sidebar="folded"] .sidebar-step-label,
    html[data-sidebar="folded"] .sidebar-main-fold-chevron,
    html[data-sidebar="folded"] .sidebar-project-name,
    html[data-sidebar="folded"] .sidebar-account-name,
    html[data-sidebar="folded"] .sidebar-account .bi-chevron-up,
    html[data-sidebar="folded"] .sidebar-gpus .gpu-status-list { display: none; }
    html[data-sidebar="folded"] .sidebar-head { flex-direction: column; padding: 1rem 0 0.75rem; }
    html[data-sidebar="folded"] .sidebar-body { padding: 0.25rem 0.5rem; }
    html[data-sidebar="folded"] .sidebar-nav a,
    html[data-sidebar="folded"] .sidebar-main-fold > summary,
    html[data-sidebar="folded"] .sidebar-account { justify-content: center; padding-left: 0; padding-right: 0; }
    html[data-sidebar="folded"] .sidebar-nav a .bi,
    html[data-sidebar="folded"] .sidebar-main-fold > summary .bi { font-size: 1.125rem; }
    html[data-sidebar="folded"] .sidebar-project { padding-top: 0.75rem; }
    html[data-sidebar="folded"] .sidebar-step a { justify-content: center; padding-left: 0; padding-right: 0; }
    html[data-sidebar="folded"] .sidebar-steps::before { left: calc(50% - 1px); }
    html[data-sidebar="folded"] .sidebar-step.next .sidebar-step-marker { box-shadow: 0 0 0 3px rgba(232, 119, 46, 0.35); }
    /* Each step its own glyph in a larger marker; done: a teal disc with a small tick notch at its lower right, so
       done is told by shape too; next: the orange ring; not started: a faint ring, the glyph dimmed */
    html[data-sidebar="folded"] .sidebar-step-marker { flex-basis: 2rem; width: 2rem; height: 2rem; }
    html[data-sidebar="folded"] .sidebar-step-num { display: none; }
    html[data-sidebar="folded"] .sidebar-step-icon { display: inline-block; font-size: 0.95rem; line-height: 1; }
    html[data-sidebar="folded"] .sidebar-step:not(.done):not(.next) .sidebar-step-icon { opacity: 0.7; }
    html[data-sidebar="folded"] .sidebar-step-tick {
        display: inline-flex; align-items: center; justify-content: center;
        position: absolute; right: -0.3rem; bottom: -0.3rem; width: 0.95rem; height: 0.95rem;
        border-radius: 50%; background: #FFFFFF; color: var(--cotw-teal-dark, #0B5E58);
        box-shadow: 0 0 0 2px var(--cotw-deep-water);
    }
    html[data-sidebar="folded"] .sidebar-step-tick svg { width: 0.62rem; height: 0.62rem; }
    html[data-sidebar="folded"] .sidebar-step a { padding-top: 0.35rem; padding-bottom: 0.35rem; }
    html[data-sidebar="folded"] .sidebar-foot { padding: 0.75rem 0.5rem 1rem; }
    html[data-sidebar="folded"] .sidebar-gpus .gpu-status { display: flex; justify-content: center; padding: 0 0 0.5rem; }
    html[data-sidebar="folded"] .sidebar-gpus .gpu-status-word { display: none; }
    html[data-sidebar="folded"] .sidebar-gpus .gpu-status-label .bi { font-size: 1.125rem; }
}
@media (prefers-reduced-motion: reduce) { .app-sidebar-col { transition: none; } }

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: var(--cotw-topbar-height);
    padding: 0 1.5rem;
    background: var(--cotw-panel);
    border-bottom: 1px solid var(--cotw-rope);
}
.app-menu-button {
    border: 0;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--cotw-ink);
    padding: 0.25rem;
}
.app-topbar-brand { font-weight: 700; color: var(--cotw-ink); }
.app-topbar-links, .app-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.app-topbar-links { flex: 1 1 auto; min-width: 0; overflow-x: auto; }
.app-topbar .nav-link { color: var(--cotw-ink); padding: 0.375rem 0.625rem; border-radius: var(--cotw-radius); }
.app-topbar .nav-link:hover { background: var(--cotw-mist); }

/* The page's side margin is this padding plus the page column's gutter (below): 2rem, and 1rem on phones */
.app-content {
    flex: 1 0 auto;
    padding: 1.75rem 1.25rem 3rem;
}
@media (max-width: 767.98px) {
    .app-topbar { padding: 0 0.75rem; }
    .app-content { padding: 1rem 0.25rem 2rem; }
}

/* Pages: a readable width, centred in the space beside the sidebar */
.cotw .page-container {
    max-width: 75rem;
    margin: 0 auto;
    /* Bootstrap's gutter, so that .row's negative margins stay inside the column */
    padding: 0 calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
    background: transparent;
    border-radius: 0 !important;
}
.cotw .page-container.narrow { max-width: 58rem; }

/* ---------- Shared page parts ---------- */
.cotw .breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 0.5rem;
    border: 0;
    font-size: 0.875rem;
}
/* Breadcrumb links look like the other links (the rule above); the current page is plain text */
.cotw .breadcrumb-item.active { color: var(--cotw-muted); }

/* The page header: the title, and the page's actions on the right */
.cotw .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0;
    border-bottom: 0;
}
.cotw .section-header h2 { margin: 0; flex: 1 1 auto; }
.cotw .section-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Panels */
.cotw .card {
    border: 1px solid var(--cotw-rope);
    border-radius: var(--cotw-radius);
    box-shadow: none;
    background: var(--cotw-panel);
}
.cotw .card-header {
    background: var(--cotw-panel);
    border-bottom: 1px solid var(--cotw-rope);
    font-weight: 600;
}

/* Tables */
.cotw .table { --bs-table-bg: var(--cotw-panel); font-variant-numeric: tabular-nums; }
.cotw .table > thead th {
    font-weight: 600;
    color: var(--cotw-muted);
    background: var(--cotw-subtle);
    border-bottom: 1px solid var(--cotw-rope);
}

/* Form fields stand out from the page: white, with the border colour */
.cotw .form-control, .cotw .form-select {
    background-color: var(--cotw-panel);
    border-color: var(--cotw-field-border);
}
.cotw .form-control:focus, .cotw .form-select:focus { border-color: var(--cotw-teal); }

/* Messages */
.cotw .alert { border-radius: var(--cotw-radius); }

/* Menus and dialogs keep their shadow; everything else is flat */
.cotw .dropdown-menu { border-color: var(--cotw-rope); box-shadow: 0 6px 24px var(--cotw-shadow); }
.cotw .modal-content { border: 0; box-shadow: 0 12px 40px rgba(14, 42, 59, 0.25); }
/* Pop-ups are native <dialog class="cotw-dialog"> (dialogs.js), with Bootstrap's modal-content, -header, -body and
   -footer inside; Bootstrap sets their spacing and colours on .modal, so the dialog sets them instead */
dialog.cotw-dialog {
    --bs-modal-padding: 1rem;
    --bs-modal-bg: var(--cotw-panel);
    --bs-modal-color: var(--cotw-ink);
    --bs-modal-border-radius: 0.5rem;
    --bs-modal-inner-border-radius: calc(0.5rem - 1px);
    --bs-modal-header-padding-x: 1rem;
    --bs-modal-header-padding-y: 1rem;
    --bs-modal-header-padding: 1rem 1rem;
    --bs-modal-header-border-color: var(--cotw-rope);
    --bs-modal-header-border-width: 1px;
    --bs-modal-title-line-height: 1.5;
    --bs-modal-footer-gap: 0.5rem;
    --bs-modal-footer-border-color: var(--cotw-rope);
    --bs-modal-footer-border-width: 1px;
    width: min(500px, calc(100vw - 2rem));
    max-width: none;
    max-height: calc(100dvh - 2rem);
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--cotw-ink);
    overflow: visible;
}
dialog.cotw-dialog.dialog-lg { width: min(800px, calc(100vw - 2rem)); }
dialog.cotw-dialog.dialog-xl { width: min(1140px, calc(100vw - 2rem)); }
dialog.cotw-dialog > .modal-content { max-height: calc(100dvh - 2rem); border-radius: var(--bs-modal-border-radius); }
dialog.cotw-dialog.dialog-scroll > .modal-content > .modal-body { overflow-y: auto; }
dialog.cotw-dialog::backdrop { background: rgba(14, 42, 59, 0.55); }
/* A video's pop-up player (video_dialog.js): the footage framed in the sidebar's deep-water navy, as on a monitor on
   deck, with its name and one line of facts above and, for an analysed video, its lines-and-zones switch below */
dialog.cotw-dialog.video-dialog { width: min(1180px, calc(100vw - 2rem)); }
dialog.cotw-dialog.video-dialog::backdrop { background: rgba(5, 16, 23, 0.8); }
.video-dialog-content { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.9rem 1rem 1rem;
    background: var(--cotw-deep-water); color: #E9F1F4; border: 1px solid rgba(255, 255, 255, 0.06); }
.video-dialog-head { display: flex; align-items: flex-start; gap: 0.5rem; }
.video-dialog-titles { flex: 1 1 auto; min-width: 0; }
dialog.video-dialog .video-dialog-title { margin: 0; font-size: 1.0625rem; font-weight: 600; line-height: 1.35; color: #FFFFFF;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-dialog-facts { margin: 0.15rem 0 0; font-size: 0.875rem; color: rgba(201, 214, 222, 0.78); }
dialog.video-dialog .video-dialog-page { flex: 0 0 auto; padding: 0.2rem 0.4rem; border-radius: 4px; color: rgba(201, 214, 222, 0.8); line-height: 1; }
dialog.video-dialog .video-dialog-page:hover, dialog.video-dialog .video-dialog-page:focus-visible { color: #FFFFFF; background: rgba(255, 255, 255, 0.08); }
.video-dialog .btn-close { flex: 0 0 auto; filter: invert(1) grayscale(1) brightness(2); opacity: 0.75; }
.video-dialog .btn-close:hover, .video-dialog .btn-close:focus-visible { opacity: 1; }
.video-dialog-screen .video-player { margin: 0; border-radius: 4px; overflow: hidden; background: #000; }
/* The whole picture on the screen, however tall the video (the player letterboxes it) */
.video-dialog-screen .video-player { max-height: calc(100dvh - 10.5rem); }
.video-dialog-foot { margin: 0; font-size: 0.875rem; color: rgba(225, 232, 236, 0.88); }
.video-dialog-foot .form-check-input { background-color: transparent; border-color: rgba(225, 232, 236, 0.6); }
.video-dialog-foot .form-check-input:checked { background-color: var(--cotw-teal); border-color: var(--cotw-teal); }
.video-dialog-discard { color: #FF8A3D; }
.video-dialog-retain { color: #3DDC84; }
@media (max-width: 575.98px) {
    dialog.cotw-dialog.video-dialog { width: calc(100vw - 1rem); }
    .video-dialog-content { padding: 0.6rem 0.6rem 0.75rem; }
}
/* The page behind stays still while a dialog is open */
html:has(dialog.cotw-dialog[open]) { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    .cotw *, .cotw *::before, .cotw *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- Home dashboard (cow_home.html) ---------- */
/* Home's welcome panel (components/welcome_panel.html) */
.welcome-panel {
    position: relative;
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background: var(--cotw-panel);
    border: 1px solid var(--cotw-rope);
    border-left: 4px solid var(--cotw-teal);
    border-radius: var(--cotw-radius);
}
.welcome-panel h3 { font-size: 1.375rem; margin: 0 5.5rem 0.5rem 0; }
.welcome-close { position: absolute; top: 1rem; right: 1rem; }
.welcome-lead { max-width: 44rem; margin-bottom: 1rem; }
.welcome-steps {
    list-style: none; margin: 0 0 1.25rem; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.625rem 1.5rem;
    counter-reset: welcome-step;
}
.welcome-steps li { display: flex; gap: 0.625rem; align-items: flex-start; font-size: 0.9375rem; counter-increment: welcome-step; }
.welcome-steps strong { display: block; color: var(--cotw-ink); }
.welcome-steps strong::before { content: counter(welcome-step) ". "; color: var(--cotw-muted); font-weight: 400; }
.welcome-step-icon {
    flex: none; display: inline-flex; align-items: center; justify-content: center;
    width: 2rem; height: 2rem; border-radius: 50%;
    background: var(--cotw-teal-soft); color: var(--cotw-teal-text);
}
.welcome-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.welcome-foot { margin: 0.875rem 0 0; color: var(--cotw-muted); font-size: 0.875rem; }
@media (max-width: 575.98px) { .welcome-panel { padding: 1rem; } .welcome-panel h3 { margin-right: 0; padding-right: 5.5rem; } }

.dash-section { margin-bottom: 2rem; }
.dash-section h3 { font-size: 1.25rem; margin-bottom: 0.75rem; }
.dash-columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.5rem; }
@media (max-width: 991.98px) { .dash-columns { grid-template-columns: 1fr; } }

.dash-projects, .dash-jobs, .dash-notices {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--cotw-panel);
    border: 1px solid var(--cotw-rope);
    border-radius: var(--cotw-radius);
}
.dash-project, .dash-job, .dash-notice { padding: 0.875rem 1rem; }
.dash-project + .dash-project, .dash-job + .dash-job, .dash-notice + .dash-notice { border-top: 1px solid var(--cotw-rope); }

.dash-project {
    display: grid;
    grid-template-columns: minmax(12rem, 1fr) auto minmax(11rem, auto);
    align-items: center;
    gap: 1.25rem;
}
@media (max-width: 767.98px) {
    .dash-project { grid-template-columns: 1fr; gap: 0.625rem; }
}
.dash-project-name { font-weight: 600; font-size: 1.0625rem; color: var(--cotw-ink); }
.dash-project-facts { margin: 0.125rem 0 0; color: var(--cotw-muted); font-size: 0.875rem; }
.dash-project-desc { margin: 0.125rem 0 0; font-size: 0.9375rem; max-width: 40rem; }
.dash-project-next { justify-self: end; display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }
@media (max-width: 767.98px) { .dash-project-next { justify-self: start; justify-content: flex-start; } }

/* The project's steps, as in the sidebar */
.dash-steps { display: flex; align-items: center; list-style: none; margin: 0; padding: 0; }
.dash-step { display: flex; align-items: center; }
.dash-step + .dash-step::before { content: ""; width: 0.75rem; height: 2px; background: var(--cotw-rope); }
.dash-step.done + .dash-step::before { background: var(--cotw-teal); }
.dash-step a {
    width: 1.625rem;
    height: 1.625rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--cotw-rope);
    background: var(--cotw-panel);
    color: var(--cotw-muted);
    font-size: 0.8125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.dash-step a:hover { text-decoration: none; border-color: var(--cotw-teal); }
.dash-step a svg { width: 0.875rem; height: 0.875rem; }
.dash-step.done a { background: var(--cotw-teal); border-color: var(--cotw-teal); color: #FFFFFF; }
.dash-step.next a { border-color: var(--cotw-signal); color: var(--cotw-warn-text); }

.dash-job, .dash-notice { display: flex; align-items: center; gap: 0.75rem; }
.dash-job-what { flex: 1 1 auto; min-width: 0; }
.dash-job-what a, .dash-notice a { font-weight: 600; }
.dash-job-where { display: block; color: var(--cotw-muted); font-size: 0.875rem; }
.dash-notice.unread a { color: var(--cotw-ink); }
.dash-badge {
    flex: 0 0 auto;
    padding: 0.125rem 0.625rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}
.dash-badge-waiting { background: var(--cotw-waiting-bg); color: var(--cotw-waiting-text); }
.dash-badge-running { background: var(--cotw-teal-soft); color: var(--cotw-teal-dark-text); }
.dash-more { display: inline-block; margin-top: 0.5rem; font-size: 0.875rem; }

.dash-empty {
    padding: 1.25rem 1rem;
    background: var(--cotw-panel);
    border: 1px dashed var(--cotw-field-border);
    border-radius: var(--cotw-radius);
    color: var(--cotw-muted);
}
.dash-empty p { margin: 0 0 0.75rem; }
.dash-empty p:last-child { margin-bottom: 0; }

/* ---------- Narrow screens: lists of videos wrap instead of pushing the page wider ---------- */
.cotw .video_outline { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
    .cotw div.inference_video_thumb_and_outline, .cotw div.video_thumb_and_outline { flex-wrap: wrap; }
    .cotw div.inference_video_thumb_and_outline div.video_outline { flex: 1 1 10rem; margin-right: 0; }
    .cotw div.inference_video_thumb_and_outline div.video_results { flex: 1 1 100%; margin-left: 2rem; }
}

/* ---------- Manual (catchmonitor/manual.html): contents beside the steps on wide screens ---------- */
.manual { display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); gap: 2rem; align-items: start; }
.manual-contents {
    position: sticky;
    top: calc(var(--cotw-topbar-height) + 1rem);
    background: var(--cotw-panel);
    border: 1px solid var(--cotw-rope);
    border-radius: var(--cotw-radius);
    padding: 1rem 1rem 0.75rem;
}
.manual-contents h3 { font-size: 1rem; margin-bottom: 0.5rem; }
/* Each part of the contents folds, one open at a time; the section being read is marked (manual.js) */
.manual-toc-part > summary { cursor: pointer; font-size: 0.875rem; font-weight: 600; padding: 0.3rem 0; list-style: none;
    display: flex; align-items: baseline; gap: 0.4rem; }
.manual-toc-part > summary::-webkit-details-marker { display: none; }
.manual-toc-part > summary::after { content: ""; margin-left: auto; width: 0.45rem; height: 0.45rem; align-self: center;
    border-right: 2px solid var(--cotw-muted); border-bottom: 2px solid var(--cotw-muted); transform: rotate(-45deg);
    transition: transform 0.15s; }
.manual-toc-part[open] > summary::after { transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) { .manual-toc-part > summary::after { transition: none; } }
.manual-toc-part > summary:focus-visible { outline: 2px solid var(--cotw-teal); outline-offset: 2px; border-radius: 4px; }
.manual-toc-part > ul { list-style: none; margin: 0 0 0.5rem; padding-left: 0; font-size: 0.875rem; }
.manual-toc-part > ul > li { margin-bottom: 0.3rem; }
.manual-toc-part > ul > li > a { display: flex; }
.manual-toc-num { display: inline-block; flex: none; min-width: 1.9rem; color: var(--cotw-muted); font-variant-numeric: tabular-nums; }
.manual-contents a[aria-current] { font-weight: 600; }
.manual-contents li { margin-bottom: 0.3rem; }
.manual-body { max-width: 52rem; }
.manual-body p, .manual-body li { line-height: 1.6; }
.manual-lead { font-size: 1.125rem; }
.manual-tip { margin: 0.75rem 0 1.25rem; padding: 0.625rem 0.875rem; border-left: 4px solid var(--cotw-teal); background: var(--cotw-teal-soft); border-radius: 0 var(--cotw-radius) var(--cotw-radius) 0; max-width: 44rem; }
.manual-tip .bi { color: var(--cotw-teal-text); margin-right: 0.25rem; }
.manual-step { padding-top: 1.75rem; margin-top: 1.75rem; border-top: 1px solid var(--cotw-rope); scroll-margin-top: calc(var(--cotw-topbar-height) + 1rem); }
.manual-step h3 { display: flex; align-items: center; gap: 0.625rem; font-size: 1.25rem; margin-bottom: 0.75rem; }
/* The manual's four parts; the first section of each follows its introduction without a rule */
.manual-part { margin: 2.75rem 0 0.25rem; padding-top: 1.25rem; border-top: 3px solid var(--cotw-teal); font-size: 1.5rem;
    scroll-margin-top: calc(var(--cotw-topbar-height) + 1rem); }
.manual-part-num { display: block; font-size: 0.875rem; font-weight: 600; color: var(--cotw-teal-text); margin-bottom: 0.15rem; }
.manual-part-intro { color: var(--cotw-muted); margin-bottom: 0; }
.manual-part-intro + .manual-step { border-top: 0; margin-top: 0.5rem; }
.manual-sub { font-size: 1.0625rem; font-weight: 600; margin: 1.5rem 0 0.5rem; scroll-margin-top: calc(var(--cotw-topbar-height) + 1rem); }
.manual-sub-minor { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 0.5rem; color: var(--cotw-muted);
    scroll-margin-top: calc(var(--cotw-topbar-height) + 1rem); }
.manual-kinds { font-size: 0.9375rem; margin: 0.5rem 0 1rem; }
.manual-kinds th[scope=row] { white-space: nowrap; font-weight: 600; }
.manual-contents-sub { list-style: none; margin: 0.2rem 0 0; padding-left: 1.9rem; font-size: 0.8125rem; }
.manual-num {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    min-width: 1.75rem; height: 1.75rem; padding: 0 0.45rem; border-radius: 999px;
    background: var(--cotw-teal); color: #fff; font-size: 0.875rem; font-weight: 700;
}
.model-availability { margin: 0 0 1.25rem; padding: 0.75rem 1rem; background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); }
.manual-figure { margin: 1rem 0 1.25rem; }
.manual-video { margin: 0.5rem 0 1rem; }
.manual-video summary { cursor: pointer; font-weight: 600; color: var(--cotw-teal-dark-text); }
.manual-video video { display: block; max-width: 100%; height: auto; margin-top: 0.5rem; border-radius: var(--cotw-radius); background: #000; }
.manual-figure img {
    display: block; width: 100%; height: auto;
    border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); background: var(--cotw-panel);
}
.manual-figure figcaption { margin-top: 0.4rem; font-size: 0.875rem; color: var(--cotw-muted); }
.manual-end { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--cotw-rope); color: var(--cotw-muted); }
@media (max-width: 991.98px) {
    .manual { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
    .manual-contents { position: static; }
}

/* The Species list page: where a species came from, folded under its name */
.species-source summary { cursor: pointer; width: fit-content; }
.species-source[open] summary { margin-bottom: 0.125rem; }

/* ---------- A project's page (catchmonitor/survey_type_home.html): next step, running, latest, models, steps ---------- */
.proj-desc { color: var(--cotw-muted); max-width: 44rem; margin-top: -0.5rem; }
/* The one thing to do next: the only panel on the page with the signal colour */
.proj-next {
    margin-top: 1.25rem; padding: 1rem 1.25rem 1.125rem; background: var(--cotw-panel);
    border: 1px solid var(--cotw-rope); border-left: 4px solid var(--cotw-signal); border-radius: var(--cotw-radius);
}
.proj-next-kicker { margin: 0; font-size: 0.8125rem; font-weight: 600; color: var(--cotw-warn-text); }
.proj-next h3 { font-size: 1.25rem; margin: 0.125rem 0 0.375rem; }
.proj-next-what { margin: 0 0 0.75rem; max-width: 44rem; }
.proj-next .proj-bar { margin: -0.25rem 0 0.875rem; }
.proj-next-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0; }
.lab-train-now { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; margin-top: 0.75rem; }
.proj-section { margin-top: 1.75rem; }
.proj-section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 0.5rem; }
.proj-section-head h3 { font-size: 1.125rem; margin: 0; }
.proj-section-head a:not(.btn) { font-size: 0.875rem; }
/* The latest analyses: video, counts and the way to review each */
.proj-results { list-style: none; margin: 0; padding: 0; background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); }
.proj-result { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.5rem 1.25rem; align-items: center; padding: 0.75rem 1rem; }
.proj-result + .proj-result { border-top: 1px solid var(--cotw-rope); }
.proj-result-what { min-width: 0; }
.proj-result-what > a { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-result-counts { font-size: 0.9375rem; white-space: nowrap; }
.proj-result-counts .rv-badge { margin-left: 0.5rem; }
.proj-result-actions { display: flex; gap: 0.375rem; }
@media (max-width: 767.98px) {
    .proj-result { grid-template-columns: minmax(0, 1fr); gap: 0.375rem; }
    .proj-result-counts { white-space: normal; }
}
/* The six steps, one line each: mark, name, facts, more */
.proj-steps { list-style: none; padding: 0; margin: 0; background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); }
.proj-step { display: grid; grid-template-columns: 1.75rem 9rem minmax(0, 1fr) auto; gap: 0.25rem 0.875rem; align-items: baseline; padding: 0.625rem 1rem; scroll-margin-top: 1rem; }
.proj-step + .proj-step { border-top: 1px solid var(--cotw-rope); }
.proj-step.next { box-shadow: inset 3px 0 0 var(--cotw-signal); }
.proj-step-mark {
    align-self: center; width: 1.75rem; height: 1.75rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8125rem;
    background: var(--cotw-panel); color: var(--cotw-muted); border: 2px solid var(--cotw-rope);
}
.proj-step-mark svg { width: 0.875rem; height: 0.875rem; }
.proj-step.done .proj-step-mark { background: var(--cotw-teal); border-color: var(--cotw-teal); color: #fff; }
.proj-step.next .proj-step-mark { border-color: var(--cotw-signal); color: var(--cotw-signal); }
.proj-step-name { font-weight: 600; }
.proj-step-facts { margin: 0; font-size: 0.9375rem; color: var(--cotw-muted); min-width: 0; }
.proj-step-facts strong { color: var(--cotw-ink); font-weight: 600; }
.proj-step-links { font-size: 0.875rem; }
.proj-step-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.proj-bar { height: 0.5rem; max-width: 22rem; border-radius: 0.25rem; background: var(--cotw-rope); overflow: hidden; }
.proj-bar span { display: block; height: 100%; background: var(--cotw-teal); }
.proj-list { list-style: none; padding: 0; margin: 0.25rem 0 0; }
.proj-list li { padding: 0.375rem 0; border-top: 1px solid var(--cotw-rope); }
.proj-list li:first-child { border-top: 0; }
.proj-list-meta { display: block; color: var(--cotw-muted); font-size: 0.8125rem; }
.proj-table { margin: 0.25rem 0 0; font-size: 0.9375rem; }
.proj-table td, .proj-table th { vertical-align: top; }
/* How the steps fit together: folded once the first step is done */
.proj-intro { margin-top: 0.75rem; }
.proj-intro > summary { cursor: pointer; font-size: 0.9375rem; font-weight: 600; color: var(--cotw-teal-text); padding: 0.25rem 0; }
.proj-intro > summary:focus-visible { outline: 2px solid var(--cotw-teal); outline-offset: 2px; border-radius: 4px; }
.proj-intro ol { margin: 0.5rem 0 0.75rem; padding-left: 1.25rem; max-width: 44rem; }
.proj-intro li { margin-bottom: 0.375rem; }
.proj-intro p { max-width: 44rem; color: var(--cotw-muted); margin: 0; }
@media (max-width: 575.98px) {
    .proj-step { grid-template-columns: 1.75rem minmax(0, 1fr); }
    .proj-step-facts, .proj-step-links { grid-column: 2; }
    .proj-table th:nth-child(2), .proj-table td:nth-child(2) { display: none; }
}

/* ---------- Train a model (model_create.html): name and Train first, the settings folded ---------- */
.train-quick { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem 1.5rem; align-items: start; padding: 1rem 1.25rem; background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); }
.train-quick-name .form-label { font-weight: 600; }
.train-quick-name .train-help { margin: 0.375rem 0 0; }
.train-quick-go { display: flex; flex-direction: column; gap: 0.5rem; align-items: stretch; padding-top: 1.85rem; }
@media (max-width: 575.98px) { .train-quick { grid-template-columns: 1fr; } .train-quick-go { padding-top: 0; flex-direction: row; } }
.train-fold { margin-top: 1.25rem; border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); background: var(--cotw-panel); }
.train-fold > summary { cursor: pointer; padding: 0.75rem 1.25rem; font-weight: 600; color: var(--cotw-teal-text); }
.train-fold > summary:focus-visible { outline: 2px solid var(--cotw-teal); outline-offset: -2px; border-radius: var(--cotw-radius); }
.train-fold[open] > summary { border-bottom: 1px solid var(--cotw-rope); }
.train-fold > :not(summary) { margin-left: 1.25rem; margin-right: 1.25rem; }
.train-fold > .train-fold-intro { margin-top: 0.75rem; }
.train-fold > ol.train-steps { margin: 0.75rem 1.25rem 1rem 2.5rem; }
.train-steps li { margin-bottom: 0.25rem; max-width: 80ch; }
.train-fold > :last-child { margin-bottom: 1rem; }

/* ---------- "How the counting works" and other explanations, folded (components/how_counting_works.html) ---------- */
.how-fold { margin: 0.5rem 0 1rem; max-width: 44rem; font-size: 0.9375rem; }
.how-fold > summary { cursor: pointer; font-weight: 600; color: var(--cotw-teal-text); padding: 0.2rem 0; }
.how-fold > summary:focus-visible { outline: 2px solid var(--cotw-teal); outline-offset: 2px; border-radius: 4px; }
.how-fold > p { margin: 0.5rem 0 0; color: var(--cotw-ink); }
.rv-species-text { font-size: 0.875rem; align-self: center; }
.rv-species-change { font-size: 0.8125rem; padding: 0 0.25rem; }
.rv-actions { display: flex; flex-wrap: wrap; gap: 0.375rem; justify-content: flex-end; }
@media (max-width: 767.98px) { .rv-actions { justify-content: flex-start; } }

/* ---------- The Analyse page's video tiles: camera, date and length first, the technical facts folded ---------- */
.video-facts { margin-bottom: 0.25rem; }
.video-details { font-size: 0.8125rem; }
.video-details > summary { cursor: pointer; color: var(--cotw-teal-text); font-weight: 600; }
.video-details > summary:focus-visible { outline: 2px solid var(--cotw-teal); outline-offset: 2px; border-radius: 4px; }
.fc-hint { margin: 0.5rem 0 0.25rem; max-width: 44rem; }

/* ---------- The Train page's model type: two described choices ---------- */
.train-choices { display: grid; gap: 0.5rem; }
.train-choice { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.625rem; align-items: start; padding: 0.625rem 0.75rem; border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); cursor: pointer; margin: 0; font-weight: normal; }
.train-choice:has(input:checked), .train-choice.is-chosen { border-color: var(--cotw-teal); box-shadow: inset 3px 0 0 var(--cotw-teal); background: var(--cotw-teal-soft); }
.train-choice:has(input:focus-visible) { outline: 2px solid var(--cotw-teal); outline-offset: 2px; }
.train-choice input { margin-top: 0.3rem; }
.train-choice-body { display: grid; gap: 0.2rem; font-size: 0.875rem; }
.train-choice-body > strong { font-size: 0.9375rem; }
.train-choice-sub { color: var(--cotw-muted); font-size: 0.8125rem; }

/* ---------- Simple forms (project, camera): one column, a panel ---------- */
.form-panel { max-width: 40rem; background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); padding: 1.25rem 1.25rem 1rem; }
.form-panel .form-text { margin-top: 0.25rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.danger-zone { max-width: 40rem; margin-top: 1.5rem; padding: 1rem 1.25rem; border: 1px solid var(--cotw-danger-border); border-radius: var(--cotw-radius); background: var(--cotw-danger-bg); }
.danger-zone h3 { font-size: 1rem; margin-bottom: 0.25rem; }

/* ---------- Uploads (training_videos, video_upload, video_frame_chooser, upload_dataset_zip) ---------- */
/* Page buttons some pages put in the top bar were light-on-dark; the top bar is white now */
.app-topbar .btn-outline-light { color: var(--cotw-ink); border-color: var(--cotw-rope); background: var(--cotw-panel); }
.app-topbar .btn-outline-light:hover { color: var(--cotw-ink); background: var(--cotw-mist); border-color: var(--cotw-hover-border); }

/* Cameras: white panels with a quiet header, like the project's steps */
.cotw .cam { border-color: var(--cotw-rope); border-radius: var(--cotw-radius); }
.cotw .cam-head { background: var(--cotw-panel); color: var(--cotw-ink); border-radius: var(--cotw-radius); }
.cotw .cam:has(.collapse.show) .cam-head, .cotw .cam:has(.collapsing) .cam-head {
    border-radius: var(--cotw-radius) var(--cotw-radius) 0 0; border-bottom: 1px solid var(--cotw-rope);
}
.cotw .cam-name { font-size: 1.125rem; }
.cotw .cam-counts, .cotw .cam-desc { color: var(--cotw-muted); }
.cotw .cam-chevron { color: var(--cotw-ink); font-size: 1.05rem; }
.cotw .cam-head .cam-btn-primary, .cotw .cam-empty .cam-btn-primary { background: var(--cotw-teal); color: #fff; border: 1px solid var(--cotw-teal); }
.cotw .cam-head .cam-btn-primary:hover, .cotw .cam-empty .cam-btn-primary:hover { background: var(--cotw-teal-dark); color: #fff; }
.cotw .cam-btn-ghost { color: var(--cotw-ink); border: 1px solid var(--cotw-rope); background: var(--cotw-panel); }
.cotw .cam-btn-ghost:hover, .cotw .cam-btn-ghost:focus-visible { color: var(--cotw-ink); background: var(--cotw-mist); border-color: var(--cotw-hover-border); }
.cotw .cam-body { background: var(--cotw-panel); border-radius: 0 0 var(--cotw-radius) var(--cotw-radius); }

/* The frame chooser's save bar stays beside the sidebar, not under it */
@media (min-width: 992px) {
    .cotw .fc-savebar { left: var(--cotw-sidebar-width); }
}

/* The upload page (video_upload.html): Fine Uploader's gallery, as one drop area with a real button */
.up-page { max-width: 58rem; }
.cotw .qq-gallery.qq-uploader.up-drop {
    min-height: 13rem; max-height: none; padding: 1.75rem 1.25rem 1.25rem; text-align: center;
    border: 2px dashed var(--cotw-dash-border); border-radius: var(--cotw-radius); background: var(--cotw-panel);
}
.cotw .qq-gallery.qq-uploader.up-drop::before { content: none; }
.cotw .up-drop .qq-upload-drop-area {
    border-radius: var(--cotw-radius); border: 2px solid var(--cotw-teal); background: var(--cotw-drop-bg);
}
.cotw .up-drop .qq-upload-drop-area-active { background: var(--cotw-drop-bg-active); }
.up-drop-hint { color: var(--cotw-muted); }
.up-drop-hint .bi { font-size: 2.25rem; color: var(--cotw-teal-text); display: block; line-height: 1; margin-bottom: 0.5rem; }
.up-drop-hint p { margin: 0 0 0.75rem; font-size: 1.0625rem; }
.cotw .qq-gallery .qq-upload-button.btn {
    display: inline-block; float: none; width: auto; padding: 0.5rem 1.25rem; margin: 0 auto;
    background: var(--cotw-teal); border: 1px solid var(--cotw-teal); border-radius: var(--cotw-radius);
    color: #fff; font-weight: 600; box-shadow: none; text-shadow: none;
}
.cotw .qq-gallery .qq-upload-button.btn:hover, .cotw .qq-gallery .qq-upload-button-hover { background: var(--cotw-teal-dark); }
.cotw .qq-gallery .qq-upload-button-focus { outline: 3px solid var(--cotw-signal); outline-offset: 2px; }
.cotw .qq-gallery .qq-upload-list { text-align: left; margin-top: 1rem; }
.cotw .qq-gallery .qq-total-progress-bar-container { margin: 0 0 1rem; }
.cotw .qq-gallery .qq-total-progress-bar, .cotw .qq-gallery .qq-progress-bar { background: var(--cotw-teal); }
.up-rules { margin: 0.875rem 0 0; padding-left: 1.125rem; color: var(--cotw-muted); font-size: 0.9375rem; }
.up-rules li + li { margin-top: 0.25rem; }
.up-rules strong { color: var(--cotw-ink); }
.up-previous { margin-top: 1.75rem; }
.up-previous h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.up-fallback { margin-top: 1.5rem; color: var(--cotw-muted); font-size: 0.9375rem; }
.up-fallback summary { cursor: pointer; color: var(--cotw-teal-text); }
.up-fallback p { margin: 0.5rem 0; }
/* The ZIP page's Dropzone, like the upload page's drop area */
.cotw .dropzone {
    min-height: 11rem; border: 2px dashed var(--cotw-dash-border); border-radius: var(--cotw-radius); background: var(--cotw-panel);
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1rem;
}
.cotw .dropzone.dz-drag-hover { border-color: var(--cotw-teal); border-style: solid; background: var(--cotw-teal-soft); }
.cotw .dropzone .dz-message { margin: 0; color: var(--cotw-muted); font-size: 1.0625rem; }
.cotw .dropzone .dz-message .dz-button { color: var(--cotw-teal-text); font-weight: 600; text-decoration: underline; }

/* ---------- Label images (labelling_home.html) ---------- */
.lab-start { background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); padding: 1rem 1.25rem 1.125rem; max-width: 44rem; }
.lab-progress-text { margin: 0 0 0.375rem; }
.lab-h { font-size: 1rem; margin: 1.75rem 0 0.375rem; }
.lab-table { max-width: 44rem; background: var(--cotw-panel); }
.lab-table td a { font-weight: 600; }
.lab-cameras { max-width: 44rem; }
.lab-camera .proj-bar { margin-top: 0.375rem; }
.lab-fold { margin-top: 1.5rem; max-width: 44rem; }
.lab-fold > summary { cursor: pointer; font-weight: 600; font-size: 1rem; color: var(--cotw-ink); padding: 0.25rem 0; }
.lab-fold > summary:focus-visible { outline: 2px solid var(--cotw-teal); outline-offset: 2px; border-radius: 4px; }
#label_stats_container .table { max-width: 30rem; margin-top: 0.75rem; background: var(--cotw-panel); }

/* ---------- The schema editor (static/schema_editor/schema_editor.css), in the site's look ---------- */
.cotw div.colour_scheme_panel { border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); background: var(--cotw-panel); box-shadow: none; }
.cotw div.colour_scheme_panel_header {
    background: var(--cotw-mist); border-bottom: 1px solid var(--cotw-rope); color: var(--cotw-ink); font-weight: 600;
    border-radius: var(--cotw-radius) var(--cotw-radius) 0 0;
}
.cotw table.colour_scheme_table { border-color: var(--cotw-rope); border-radius: var(--cotw-radius); }
.cotw table.colour_scheme_table thead tr { background: var(--cotw-mist); color: var(--cotw-muted); }
.cotw table.colour_scheme_table tbody tr:nth-child(even) { background: var(--cotw-subtle); }
.cotw table.colour_scheme_table tbody td { color: var(--cotw-ink); }
.cotw table.colour_scheme_table td { padding: 0.3rem 0.5rem; }
.lab-filename { overflow-wrap: anywhere; }

/* ---------- The Classes editor (inline/schema_editor_vue_templates.html): one wide table per group ---------- */
.cotw .classes_toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-bottom: 0.75rem; }
.cotw .classes_search { max-width: 22rem; }
.cotw .classes_start { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; margin-bottom: 0.75rem; }
.cotw .classes_start select { width: auto; max-width: 100%; }
.cotw div.group_panel { border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius);
    background: var(--cotw-panel); margin-bottom: 0.75rem; }
.cotw .group_panel_header { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius) var(--cotw-radius) 0 0; }
.cotw .group_panel.is-folded .group_panel_header { border-bottom: 0; }
.cotw .group_fold { border: 0; background: none; color: var(--cotw-muted); padding: 0 0.25rem; line-height: 1; font-size: 1rem; }
.cotw .group_fold:hover { color: var(--cotw-ink); }
.cotw .group_fold:focus-visible { outline: 2px solid var(--cotw-teal); outline-offset: 2px; border-radius: 4px; }
.cotw .group_panel_header .input_group_name { width: 14rem; max-width: 100%; font-weight: 600; }
.cotw .group_panel_header .group_actions { margin-left: auto; display: flex; gap: 0.35rem; align-items: center; }
.cotw .group_handle, .cotw .lcls_handle { cursor: grab; color: var(--cotw-muted); }
.cotw .group_body { padding: 0.5rem 0.75rem 0.75rem; }
.cotw .classes_add_row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem 1rem; padding: 0.75rem;
    margin: 0 0 0.75rem; border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); background: var(--cotw-mist); }
.cotw .classes_add_name { flex: 1 1 16rem; max-width: 26rem; }
.cotw .classes_add_code { flex: 0 1 10rem; }
.cotw .classes_add_buttons { display: flex; gap: 0.35rem; align-self: flex-end; flex-wrap: wrap; }
.cotw .class_table_wrap { overflow-x: auto; }
.cotw table.class_labels_table { width: 100%; border-collapse: collapse; }
.cotw table.class_labels_table thead th { font-weight: 600; font-size: 0.85rem; color: var(--cotw-muted);
    border-bottom: 1px solid var(--cotw-rope); padding: 0.3rem 0.5rem; white-space: nowrap; }
.cotw table.class_labels_table tbody td { color: var(--cotw-ink); padding: 0.2rem 0.5rem; vertical-align: middle;
    border-bottom: 1px solid var(--cotw-subtle); }
.cotw table.class_labels_table tbody tr:hover { background: var(--cotw-subtle); }
.cotw table.class_labels_table .btn-sm { padding: 0.1rem 0.4rem; }
.cotw .lcls_handle_col, .cotw .lcls_swatch_col { width: 1.75rem; }
.cotw .lcls_added_col { width: 4.5rem; text-align: center; }
.cotw .lcls_actions_col { width: 8.5rem; }
.cotw .lcls_code_under { display: block; font-size: 0.8em; color: var(--cotw-muted); }
/* The same column widths in every group, so the tables line up whatever their contents */
@media (min-width: 576px) {
    .cotw table.class_labels_table { table-layout: fixed; }
    .cotw .lcls_code_col { width: 18%; }
    .cotw .lcls_count_col { width: 7rem; }
    .cotw table.class_labels_table td { overflow-wrap: anywhere; }
}
@media (max-width: 575.98px) {
    .cotw .lcls_handle_col, .cotw .lcls_swatch_col { width: 1.25rem; }
    .cotw table.class_labels_table tbody td, .cotw table.class_labels_table thead th { padding: 0.2rem 0.3rem; }
}
.cotw .lcls_count { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cotw .lcls_code code { color: var(--cotw-ink); background: none; padding: 0; font-size: 0.9em; }
.cotw .lcls_swatch { display: inline-block; width: 0.9rem; height: 0.9rem; border-radius: 3px;
    border: 1px solid var(--cotw-rope); vertical-align: middle; }
#cr-video { max-width: 100%; }
.lab-prelabel { max-width: 44rem; margin-top: 1rem; background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); padding: 1rem 1.25rem; }
.lab-prelabel-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin-top: 0.75rem; }
.lab-prelabel-form .form-select { min-width: 12rem; }

/* ---------- An analysis's summary (inference_video_results_summary.html) ---------- */
.sum-counts { display: flex; flex-wrap: wrap; gap: 0; margin: 0.5rem 0 0.75rem; max-width: 36rem;
    border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); background: var(--cotw-panel); overflow: hidden; }
.sum-counts > div { flex: 1 1 8rem; padding: 0.75rem 1rem; border-right: 1px solid var(--cotw-rope); }
.sum-counts > div:last-child { border-right: 0; }
.sum-counts dt { font-size: 0.875rem; color: var(--cotw-muted); font-weight: 400; }
.sum-counts dd { margin: 0.125rem 0 0; font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.sum-table { max-width: 44rem; background: var(--cotw-panel); }
.sum-counts dd small { font-size: 0.8125rem; font-weight: 400; color: var(--cotw-muted); }
.sum-review { margin: 0 0 0.5rem; max-width: 44rem; }
.sum-review.done { color: var(--cotw-teal-text); }
.sum-was { color: var(--cotw-warn-text); }
.sum-tabs { max-width: 44rem; }
.sum-tab-content { max-width: 44rem; padding-top: 0.75rem; }
.sum-scroll { max-height: 60vh; overflow: auto; border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); }
.sum-scroll .sum-table { margin-bottom: 0; max-width: none; }
.sum-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--cotw-panel); box-shadow: inset 0 -1px 0 var(--cotw-rope); }
.rv-counts { font-size: 0.875rem; margin-top: 0.25rem; }

/* ---------- Reviewing an analysis (inference_review.html, static/review.js) ---------- */
.cotw .page-container.wide { max-width: 96rem; }
.rv-status { margin: 0.5rem 0 1rem; padding: 0.75rem 1rem; background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); }
.rv-progress { height: 0.4rem; border-radius: 0.2rem; background: var(--cotw-rope); overflow: hidden; margin-bottom: 0.5rem; }
.rv-progress span { display: block; height: 100%; width: 0; background: var(--cotw-teal); transition: width 0.3s; }
.rv-layout { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: 1rem; align-items: start; }
.rv-player, .rv-list-wrap { position: sticky; top: calc(var(--cotw-topbar-height) + 0.75rem); }
.rv-player-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.5rem; }
/* Adding a missed fish by clicking it (static/review.js, result_regions.js pickPoint) */
.rv-pick-hint { margin: 0.4rem 0 0; padding: 0.35rem 0.6rem; border-radius: 0.375rem; font-size: 0.875rem;
    background: var(--cotw-teal-soft); color: var(--cotw-ink); }
.rv-species-picker { position: fixed; z-index: 1070; width: 15rem; max-width: calc(100vw - 16px); padding: 0.4rem;
    background: var(--cotw-panel); color: var(--cotw-ink); border: 1px solid var(--cotw-rope);
    border-radius: var(--cotw-radius); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); }
.rv-species-options { list-style: none; margin: 0.35rem 0 0; padding: 0; max-height: 14rem; overflow-y: auto; }
.rv-species-option { display: block; width: 100%; text-align: left; border: 0; background: none; color: inherit;
    padding: 0.3rem 0.45rem; border-radius: 0.3rem; font-size: 0.875rem; }
.rv-species-option:hover, .rv-species-option:focus-visible, .rv-species-option.rv-first { background: var(--cotw-teal-soft); }
.rv-following { font-size: 0.8rem; color: var(--cotw-muted); }
.rv-following-lost { text-decoration: underline dotted; cursor: help; }
.rv-keys { margin: 0; padding: 0.5rem 0.875rem; border-bottom: 1px solid var(--cotw-rope); }
.rv-keys kbd { font-size: 0.75rem; }
.rv-list-wrap { background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); }
.rv-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--cotw-rope); }
.rv-list-head h3 { font-size: 1rem; margin: 0; }
/* The list scrolls by itself, within the window, so the video beside it stays where it is */
.rv-list { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - var(--cotw-topbar-height) - 5.25rem);
           max-height: calc(100dvh - var(--cotw-topbar-height) - 5.25rem); overflow-y: auto; overscroll-behavior: contain; }
/* A scroll bar that always shows (macOS and phones otherwise hide it until you scroll): styled with
   ::-webkit-scrollbar in Chrome, Edge and Safari, which keeps it drawn; Firefox takes scrollbar-color */
.rv-list::-webkit-scrollbar { width: 10px; }
.rv-list::-webkit-scrollbar-track { background: var(--cotw-mist); border-left: 1px solid var(--cotw-rope); }
.rv-list::-webkit-scrollbar-thumb { background: #9AABB5; border-radius: 5px; border: 2px solid var(--cotw-mist); }
.rv-list::-webkit-scrollbar-thumb:hover { background: var(--cotw-muted); }
@supports not selector(::-webkit-scrollbar) {
    .rv-list { scrollbar-color: #9AABB5 var(--cotw-mist); }
}
.rv-fish { display: flex; gap: 0.5rem; padding: 0.4rem 0.625rem; border-bottom: 1px solid var(--cotw-rope); cursor: pointer; }
.rv-fish:hover { background: var(--cotw-mist); }
.rv-fish.rv-selected { background: var(--cotw-teal-soft); box-shadow: inset 3px 0 0 var(--cotw-teal); }
.rv-fish.rv-in-view .rv-time { color: var(--cotw-teal-text); font-weight: 700; }
.rv-fish.rv-checked { opacity: 0.8; }
.rv-fish-body { min-width: 0; flex: 1; }
.rv-fish-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.125rem 0.5rem; font-size: 0.8125rem; margin-bottom: 0.25rem; line-height: 1.3; }
.rv-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.rv-cert { color: var(--cotw-muted); }
.rv-tag { color: var(--cotw-warn-text); font-weight: 600; }
.rv-ok { color: var(--cotw-teal-text); font-weight: 600; margin-left: auto; }
.rv-ok-not-fish { color: var(--cotw-bad-text); }
.rv-controls { display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }
.rv-controls .btn { padding: 0.1rem 0.3rem; font-size: 0.75rem; line-height: 1.4; }
.rv-controls .form-select-sm { padding-top: 0.1rem; padding-bottom: 0.1rem; font-size: 0.75rem; min-height: 0; }
.rv-species { width: auto; max-width: 100%; flex: 1 1 100%; }
.rv-was { margin: 0.25rem 0 0; font-size: 0.75rem; color: var(--cotw-warn-text); }
.rv-empty { padding: 1rem; color: var(--cotw-muted); }
.rv-badge { display: inline-block; font-size: 0.8125rem; font-weight: 600; border-radius: 999px; padding: 0.1rem 0.6rem; border: 1px solid currentColor; }
.rv-badge-todo { color: var(--cotw-warn-text); }
.rv-badge-started { color: var(--cotw-muted); }
.rv-badge-done { color: var(--cotw-teal-text); }
@media (max-width: 991.98px) {
    .rv-layout { grid-template-columns: minmax(0, 1fr); }
    /* Stacked: the video stays at the top of the window, and the fish scroll under it */
    .rv-player { top: var(--cotw-topbar-height); z-index: 6; background: var(--cotw-mist); padding: 0.5rem 0; }
    .rv-list-wrap { position: static; }
    .rv-list { max-height: none; }
    .rv-keys { display: none; }
}

/* ---------- Account: email and notifications, sign-ups (views_account.py) ---------- */
.acct-ok { color: var(--cotw-teal-text); }
.acct-wait { color: var(--cotw-warn-text); }
.settings-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: -0.25rem 0 1rem; font-size: 0.9375rem; }
.settings-part { scroll-margin-top: calc(var(--cotw-topbar-height) + 1rem); margin-bottom: 1.25rem; }
#notices { scroll-margin-top: calc(var(--cotw-topbar-height) + 1rem); }
.signup-list { display: grid; gap: 0.75rem; max-width: 44rem; }
.signup-card { background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); padding: 0.875rem 1rem; }
.signup-card h3 { font-size: 1.0625rem; margin: 0 0 0.5rem; }
.signup-card dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.125rem 1rem; margin: 0 0 0.75rem; font-size: 0.9375rem; }
.signup-card dt { font-weight: 400; color: var(--cotw-muted); }
.signup-card dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- A project's members (project_members.html) ---------- */
.members-table { max-width: 56rem; }
.members-places { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem 0.75rem; margin-bottom: 0.75rem; }
.members-limit { display: inline-flex; gap: 0.375rem; align-items: center; margin: 0; }
.members-limit input { width: 5.5rem; }
.members-table td { vertical-align: middle; }
.members-actions { white-space: nowrap; text-align: right; }
.members-actions form { display: inline; margin: 0 0 0 0.25rem; }
/* A hidden label in a scrolling table stays inside it, rather than widening the page on a phone */
.table-responsive { position: relative; }
.settings-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.settings-inline input { max-width: 16rem; }

/* ---------- A project's report (project_report.html) ---------- */
.report-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; margin: 0 0 1.25rem;
    padding: 0.875rem 1rem; background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); }
.report-filters .form-label { font-size: 0.875rem; margin-bottom: 0.25rem; }
.report-filters fieldset { margin: 0; min-width: 0; }
.report-filters legend { float: none; width: auto; }
.report-cameras { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.report-cameras label { font-size: 0.9375rem; }
.report-filter-buttons { display: flex; gap: 0.5rem; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 0 1.5rem; }
.report-grid .sum-table { max-width: none; }

/* ---------- Fish movement (inference_movement_summary.html, catchmonitor/movement.py) ---------- */
.mv-counts { max-width: 48rem; }
.mv-counts dd.mv-word { font-size: 1.25rem; }
.mv-counts dd small { font-size: 0.8125rem; font-weight: 400; color: var(--cotw-muted); }
.mv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 0 2rem; max-width: 56rem; }
.mv-compass { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; max-width: 20rem; }
.mv-cell { position: relative; display: flex; flex-direction: column; align-items: center; padding: 0.5rem 0.25rem;
    border-radius: var(--cotw-radius); border: 1px solid var(--cotw-rope); overflow: hidden;
    background: linear-gradient(to top, var(--cotw-teal-soft) var(--share), var(--cotw-panel) var(--share)); }
.mv-cell strong { font-size: 1.25rem; line-height: 1.1; }
.mv-label { font-size: 0.75rem; color: var(--cotw-muted); text-align: center; }
.mv-stayed { background: var(--cotw-mist); }
.mv-arrow { color: var(--cotw-teal-text); font-size: 1rem; line-height: 1; display: inline-block; }
.mv-right { transform: rotate(0deg); } .mv-up-right { transform: rotate(-45deg); } .mv-up { transform: rotate(-90deg); }
.mv-up-left { transform: rotate(-135deg); } .mv-left { transform: rotate(180deg); } .mv-down-left { transform: rotate(135deg); }
.mv-down { transform: rotate(90deg); } .mv-down-right { transform: rotate(45deg); }
.mv-bars { display: flex; align-items: flex-end; gap: 2px; height: 8rem; padding: 0.25rem; border-bottom: 1px solid var(--cotw-rope); }
.mv-bars span { flex: 1 1 0; min-width: 3px; background: var(--cotw-teal); border-radius: 2px 2px 0 0; }
.mv-bars-axis { display: flex; justify-content: space-between; }

/* A project's kind, beside its name (SurveyType.kind) */
.kind-badge { display: inline-block; vertical-align: middle; font-size: 0.75rem; font-weight: 600; line-height: 1.4;
    padding: 0.05rem 0.5rem; border-radius: 999px; color: var(--cotw-info-text); background: var(--cotw-info-bg); border: 1px solid var(--cotw-info-border); }

/* ---------- The example analysis (example.html) ---------- */
.ex-player { max-width: 56rem; margin-bottom: 1rem; }
.ex-video { position: relative; background: #000; border-radius: var(--cotw-radius); overflow: hidden; }
.ex-video video { display: block; width: 100%; max-height: 70vh; }
.dash-example { border-left: 4px solid var(--cotw-teal); }

/* ---------- The public pages' top bar (components/public_top.html: About, and the Manual before logging in) ---------- */
.about-top { background: var(--cotw-deep-water); }
.about-top .about-wrap { max-width: 72rem; margin: 0 auto; padding: 0 1.25rem; display: flex; align-items: center; gap: 1rem; height: 3.75rem; }
.about-brand { display: flex; align-items: center; gap: 0.6rem; color: #fff; font-weight: 700; font-size: 1.125rem; text-decoration: none; }
.about-brand:hover { color: #fff; }
.about-brand svg { width: 2rem; height: 1.25rem; color: #7FD4CB; }
.about-top nav { margin-left: auto; display: flex; align-items: center; gap: 1.25rem; }
.about-top nav a:not(.btn) { color: var(--cotw-sidebar-text); text-decoration: none; }
.about-top nav a:not(.btn):hover, .about-top nav a[aria-current="page"] { color: #fff; }
@media (max-width: 575.98px) { .about-top nav .about-nav-extra { display: none; } }

/* ---------- The legal texts (legal_base.html) and the public pages' foot (components/public_foot.html) ---------- */
body.cotw.legal { background: var(--cotw-panel); color: var(--cotw-ink); }
.legal-main { max-width: 48rem; margin: 0 auto; padding: 2rem 1rem 3.5rem; }
.legal-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--cotw-rope); }
.legal-tabs a { padding: 0.5rem 0; text-decoration: none; color: var(--cotw-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.legal-tabs a[aria-current="page"] { color: var(--cotw-ink); border-bottom-color: var(--cotw-teal); font-weight: 600; }
.legal-admin-note { display: flex; gap: 0.6rem; align-items: baseline; }
.legal-text h1 { font-size: 2rem; font-weight: 700; margin-bottom: 0.25rem; }
.legal-date { color: var(--cotw-muted); margin-bottom: 1.75rem; }
.legal-text h2 { font-size: 1.25rem; font-weight: 650; margin: 2rem 0 0.6rem; }
.legal-text p, .legal-text li { line-height: 1.65; }
.legal-text li + li { margin-top: 0.3rem; }
.legal-text table { width: 100%; margin: 0.5rem 0 1rem; border-collapse: collapse; font-size: 0.9375rem; display: block; overflow-x: auto; }
.legal-text th, .legal-text td { padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--cotw-rope); vertical-align: top; text-align: left; }
.legal-text th { font-weight: 600; }
.legal-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; }
.legal-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.about-foot .legal-links a { color: inherit; }
.about-foot .legal-links a:hover { color: #fff; }

/* ---------- A model imported from outside the site (model_edit.html) ---------- */
.model-imported { display: grid; gap: 0.35rem; margin: 0 0 1.25rem; max-width: 48rem; }
.model-imported > div { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0.75rem; }
.model-imported dt { font-weight: 600; }
.model-imported dd { margin: 0; overflow-wrap: anywhere; }
.model-import-form { max-width: 48rem; }

/* ---------- The review page's switches and key (inference_review.html) ---------- */
.rv-switches { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.rv-hide-path .rv-path { display: none; }
.rv-highlight-pulse { transform-box: fill-box; transform-origin: center; opacity: 0; }
.rv-highlight-pulse.rv-pulsing { animation: rv-pulse 0.9s ease-out 3; }
@keyframes rv-pulse { from { transform: scale(1); opacity: 0.9; } to { transform: scale(2.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .rv-highlight-pulse.rv-pulsing { animation: none; } }
.rv-key { margin-top: 0.875rem; padding: 0.5rem 1rem; background: var(--cotw-panel); border: 1px solid var(--cotw-rope); max-width: none; font-size: inherit;
          border-radius: var(--cotw-radius); }
.rv-key > summary { font-size: 0.9375rem; }
.rv-key > p { font-size: 0.875rem; }
.rv-key[open] > summary { margin-bottom: 0.25rem; }
.rv-key-part { font-size: 0.8125rem; color: var(--cotw-muted); margin: 0.5rem 0 0.25rem; }
.rv-key ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.35rem; font-size: 0.875rem; }
.rv-key li { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: 0.5rem; align-items: start; }
.rv-key li > span:only-child { grid-column: 1 / -1; }
.rv-key-mark { width: 2.5rem; height: 1rem; margin-top: 0.15rem; background: #3b4a55; border-radius: 3px; }
.rv-key-swatch { width: 1.6rem; height: 0.95rem; margin: 0.15rem 0 0 0.45rem; border: 2px solid; border-radius: 3px;
                 background: #cfd6db; }
.rv-key-count { justify-self: start; margin-top: 0.05rem; padding: 0 0.4rem; font-size: 0.75rem; font-weight: 600;
                color: #fff; background: rgba(0, 0, 0, 0.7); border-radius: 3px; }

/* ---------- Inbox (catchmonitor/inbox.html): by day, one line a notice; a model's analyses of one day are one row ---------- */
.inbox-day { font-size: 0.9375rem; font-weight: 600; color: var(--cotw-muted); margin: 1.5rem 0 0.5rem; }
.inbox-list { list-style: none; margin: 0; padding: 0; background: var(--cotw-panel); border: 1px solid var(--cotw-rope);
    border-radius: var(--cotw-radius); }
.inbox-row + .inbox-row { border-top: 1px solid var(--cotw-rope); }
.cotw .inbox-link { display: flex; align-items: baseline; gap: 0.6rem; padding: 0.6rem 0.9rem; color: var(--cotw-ink);
    font-weight: 400; text-decoration: none; cursor: pointer; }
.cotw .inbox-link:hover { background: var(--cotw-mist); color: var(--cotw-ink); }
.inbox-group summary { list-style: none; }
.inbox-group summary::-webkit-details-marker { display: none; }
.inbox-text { flex: 1; min-width: 0; }
.inbox-title { display: block; }
.inbox-row.unread .inbox-title { font-weight: 700; }
.inbox-row.unread { box-shadow: inset 3px 0 0 var(--cotw-teal); }
.inbox-body { display: block; font-size: 0.875rem; color: var(--cotw-muted); overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; }
.inbox-time { flex: none; font-size: 0.8125rem; color: var(--cotw-muted); font-variant-numeric: tabular-nums; }
.inbox-good { color: var(--cotw-good-text); }
.inbox-bad { color: var(--cotw-bad-text); }
.inbox-group details[open] > summary { background: var(--cotw-mist); }
.inbox-items { list-style: none; margin: 0; padding: 0.25rem 0.9rem 0.25rem 2.5rem; }
.inbox-items li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.25rem 0; font-size: 0.9375rem; }
.inbox-items li.unread a { font-weight: 700; }
.inbox-items time { font-size: 0.8125rem; color: var(--cotw-muted); font-variant-numeric: tabular-nums; }
.inbox-group-all { display: inline-block; margin: 0.25rem 0 0.75rem 2.5rem; font-size: 0.875rem; }

/* ---------- Analyse videos: the analysis panel (catchmonitor/inference_video_home.html, analyse_bar.js): a bar at the
   foot of the page, and from 1200 px a column beside the videos (below) ---------- */
.analyse-bar { position: sticky; bottom: 0.5rem; z-index: 20; margin: 1.5rem 0 0.5rem; padding: 0.75rem 1rem;
    border: 1px solid var(--cotw-rope); border-top-width: 3px; border-radius: var(--cotw-radius);
    background: var(--cotw-panel); box-shadow: 0 -4px 24px rgba(14, 42, 59, 0.10);
    transition: border-color 0.2s; }
.analyse-bar.is-ready { border-top-color: var(--cotw-teal); }
@media (prefers-reduced-motion: reduce) { .analyse-bar { transition: none; } }
.analyse-bar-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 0.25rem 1.25rem; align-items: end; }
.analyse-bar .form-label { margin-bottom: 0.2rem; font-size: 0.8125rem; color: var(--cotw-muted); }
/* The Model and Speed lists shrink with the bar instead of widening it to their longest option */
.analyse-bar-field { min-width: 0; }
.analyse-bar-field .form-select { min-width: 0; width: 100%; text-overflow: ellipsis; }
.analyse-bar-ticked { display: flex; flex-wrap: wrap; gap: 0 0.9rem; margin: 0.1rem 0 0.15rem; }
.analyse-bar-ticked[hidden] { display: none; }
.analyse-bar-ticked .btn-link { font-size: 0.875rem; }
.analyse-bar-ticked .btn-link:disabled { display: none; }
.analyse-bar-count { font-weight: 600; font-size: 1.0625rem; }
.analyse-bar.is-ready .analyse-bar-count { color: var(--cotw-teal-dark-text); }
.analyse-bar-counting { color: var(--cotw-muted); margin-top: 0.15rem; }
.analyse-bar-go { display: flex; flex-direction: row-reverse; align-items: center; gap: 0.75rem; }
.analyse-bar-go .btn-primary { white-space: nowrap; }
.analyse-bar-go .btn-link { padding: 0; white-space: nowrap; }
.analyse-bar-gpu { margin-top: 0.35rem; text-align: right; color: var(--cotw-muted); }
.analyse-bar-more { padding-top: 0.9rem; margin-top: 0.9rem; border-top: 1px solid var(--cotw-rope); }
.analyse-panel-title { display: none; }
/* Two columns: the videos, and the panel stuck beside them under the top bar, scrolling on its own if it is taller
   than the screen; the panel reads top to bottom: what is ticked, the model and Speed, Analyse, More settings */
@media (min-width: 1200px) {
    .analyse-layout { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; gap: 1.25rem; align-items: start; }
    .analyse-main { min-width: 0; }
    .analyse-panel { position: sticky; top: calc(var(--cotw-topbar-height) + 1rem); bottom: auto; margin: 0.25rem 0 0;
        padding: 1rem 1rem 0.85rem; max-height: calc(100vh - var(--cotw-topbar-height) - 2rem); overflow-y: auto;
        box-shadow: none; scrollbar-width: thin; }
    .analyse-panel-title { display: block; margin: 0 0 0.6rem; font-size: 1.0625rem; font-weight: 700; }
    .analyse-panel .analyse-bar-row { display: flex; flex-direction: column; align-items: stretch; gap: 0.9rem; }
    .analyse-panel .analyse-bar-what { padding-bottom: 0.9rem; border-bottom: 1px solid var(--cotw-rope); }
    .analyse-panel .analyse-bar-go { flex-direction: column; align-items: stretch; gap: 0.4rem; }
    .analyse-panel .analyse-bar-go .btn-primary { width: 100%; }
    .analyse-panel .analyse-bar-go .btn-link { align-self: flex-start; }
    .analyse-panel .analyse-more-grid { grid-template-columns: 1fr; gap: 0.75rem; }
    .analyse-panel .analyse-bar-gpu { text-align: left; margin-top: 0.75rem; padding-top: 0.6rem; border-top: 1px solid var(--cotw-rope); }
}
.analyse-more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0.75rem 1.25rem; }
@media (max-width: 991.98px) {
    .analyse-bar-row { grid-template-columns: 1fr 1fr; }
    .analyse-bar-what { grid-column: 1 / -1; }
    .analyse-bar-go { grid-column: 1 / -1; justify-content: flex-start; }
    .analyse-bar-gpu { text-align: left; }
}
/* On a phone the bar would cover much of the screen: it sits at the end of the list instead */
@media (max-width: 575.98px) { .analyse-bar-row { grid-template-columns: 1fr; } .analyse-bar { position: static; box-shadow: none; } }


/* ---------- Analyse videos: the list, one section per camera, one row per video (components/analyse_video_row.html) ---------- */
.analyse-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin: 0.25rem 0 0.75rem; }
.analyse-search { width: 14rem; max-width: 100%; }
.analyse-tick-buttons { display: flex; align-items: center; gap: 0.25rem; margin-left: auto; }
.camera-group { background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); margin-bottom: 0.75rem; }
.camera-group > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; padding: 0.6rem 0.9rem;
    cursor: pointer; list-style: none; }
.camera-group > summary::-webkit-details-marker { display: none; }
.camera-group > summary::before { content: "\25B8"; color: var(--cotw-muted); transition: transform 0.15s; }
.camera-group[open] > summary::before { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .camera-group > summary::before { transition: none; } }
.camera-group[open] > summary { border-bottom: 1px solid var(--cotw-rope); }
.camera-group-name { font-weight: 700; font-size: 1.0625rem; }
.camera-group-n { color: var(--cotw-muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.camera-group-counting { color: var(--cotw-muted); flex: 1 1 9rem; min-width: 0; }
/* Each camera's switch: one joined row of buttons, the chosen one filled; the report links only at Ready to export */
.stage-switch { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--cotw-rope); border-radius: 999px; overflow: hidden;
    background: var(--cotw-panel); }
.stage-button { border: 0; background: transparent; color: var(--cotw-ink); padding: 0.2rem 0.75rem; font-size: 0.875rem; line-height: 1.4; }
.stage-button + .stage-button { border-left: 1px solid var(--cotw-rope); }
.stage-button:hover { background: var(--cotw-mist); }
.stage-button:focus-visible { outline: 2px solid var(--cotw-teal); outline-offset: -2px; }
.stage-button[aria-pressed="true"] { background: var(--cotw-teal); color: #fff; }
.stage-n { font-variant-numeric: tabular-nums; opacity: 0.75; margin-left: 0.15rem; }
.camera-export { display: none; }
.camera-group[data-stage="export"] .camera-export { display: inline; }
.camera-group-actions { display: flex; align-items: center; gap: 0.25rem; margin-left: auto; }
.camera-group-nomatch { margin: 0; padding: 0.75rem 0.9rem; }
/* A long list keeps its bearings: an open camera's line sticks under the top bar while its videos scroll by, and the
   recording day's line under it (--camera-head: the camera line's height, set by analyse_bar.js) */
.camera-group { scroll-margin-top: calc(var(--cotw-topbar-height) + 0.5rem); }
.camera-group[open] > summary { position: sticky; top: var(--cotw-topbar-height); z-index: 6; background: var(--cotw-panel);
    border-radius: var(--cotw-radius) var(--cotw-radius) 0 0; }
.camera-index { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem 0.5rem; margin: 0 0 0.75rem; font-size: 0.875rem; }
.camera-index-label { color: var(--cotw-muted); }
.camera-index-link { padding: 0.1rem 0.6rem; border: 1px solid var(--cotw-rope); border-radius: 999px; background: var(--cotw-panel);
    color: var(--cotw-ink); text-decoration: none; }
.camera-index-link:hover, .camera-index-link:focus-visible { border-color: var(--cotw-teal); color: var(--cotw-ink); text-decoration: none; }
.camera-index-n { color: var(--cotw-muted); font-variant-numeric: tabular-nums; margin-left: 0.15rem; }
/* One line per recording day, like a page of a catch log: the date, its videos' span, what is left to do, what was counted */
.day-group { scroll-margin-top: calc(var(--cotw-topbar-height) + var(--camera-head, 3rem)); }
.day-group + .day-group { border-top: 1px solid var(--cotw-rope); }
.day-group-head { position: sticky; top: calc(var(--cotw-topbar-height) + var(--camera-head, 3rem)); z-index: 5;
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 1rem; padding: 0.45rem 0.9rem 0.45rem 0.9rem;
    background: var(--cotw-mist); cursor: pointer; list-style: none; font-size: 0.875rem; }
.day-group[open] > .day-group-head { border-bottom: 1px solid var(--cotw-rope); }
.day-group-head::-webkit-details-marker { display: none; }
.day-group-head::before { content: "\25B8"; color: var(--cotw-muted); align-self: center; transition: transform 0.15s; margin-right: -0.4rem; }
.day-group[open] > .day-group-head::before { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .day-group-head::before { transition: none; } }
.day-group-date { font-weight: 700; font-size: 0.9375rem; color: var(--cotw-ink); }
.day-group-span { color: var(--cotw-muted); font-variant-numeric: tabular-nums; }
.day-group-work { display: inline-flex; flex-wrap: wrap; gap: 0 0.75rem; }
.day-work { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-work-todo { color: var(--cotw-waiting-text); }
.day-work-running, .day-work-review, .day-work-done { color: var(--cotw-teal-dark-text); }
.day-work-failed { color: var(--cotw-bad-text); }
.day-work-ticked { color: var(--cotw-ink); font-weight: 400; }
.day-group-counts { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--cotw-ink); }
.day-group-tick { margin-left: auto; padding: 0 0.25rem; font-size: 0.8125rem; align-self: center; }
.analyse-empty-cameras { margin: 0.25rem 0 0.75rem; }
.analyse-empty-camera { white-space: nowrap; }
.an-counts { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--cotw-ink); font-size: 0.9375rem; }
.analyse-row { display: grid; grid-template-columns: 1.5rem 80px minmax(12rem, 1fr) minmax(11rem, 15rem) auto;
    gap: 0.25rem 0.9rem; align-items: center; padding: 0.5rem 0.9rem; }
.analyse-row + .analyse-row { border-top: 1px solid var(--cotw-rope); }
.analyse-row:has(.inference_choose_videos_check:checked) { background: var(--cotw-teal-soft); }
.analyse-row-tick .form-check-input { margin: 0; width: 1.15rem; height: 1.15rem; cursor: pointer; }
.analyse-row-thumb { position: relative; margin: 0; cursor: pointer; line-height: 0; }
.analyse-row-thumb img, .analyse-row-blank { display: block; width: 80px; height: 60px; border-radius: 4px; object-fit: cover;
    background: var(--cotw-mist); border: 1px solid var(--cotw-rope); }
.analyse-row-length { position: absolute; right: 3px; bottom: 3px; padding: 0 0.25rem; border-radius: 3px; line-height: 1.4;
    font-size: 0.6875rem; background: rgba(14, 42, 59, 0.8); color: #fff; font-variant-numeric: tabular-nums; }
/* A video being worked on: an indicator over its picture (components/analyse_video_row.html). Analysing: the share
   done, large on a gallery card and alone on a list row's small picture, with a bar along the bottom edge that
   job_status.js moves as the worker reports (--p); waiting or being prepared: what for, with a slow sweeping bar */
.an-progress { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 0.15rem; padding: 0 0.3rem 0.35rem; border-radius: 4px; overflow: hidden;
    background: rgba(14, 42, 59, 0.6); color: #FFFFFF; text-align: center; line-height: 1.15; pointer-events: none; }
.an-progress-figure { font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.an-progress-word { font-size: 0.6875rem; font-weight: 600; }
.an-progress-sub { font-size: 0.6875rem; opacity: 0.85; }
.an-progress-run .an-progress-word { display: none; }
.an-progress-sub { display: none; }
.an-progress-track { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.22); }
.an-progress-fill { display: block; height: 100%; width: var(--p, 0%); background: #7FD4CB; transition: width 0.9s ease; }
.an-progress-wait .an-progress-fill { width: 30%; animation: an-progress-sweep 1.8s ease-in-out infinite; }
@keyframes an-progress-sweep { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) {
    .an-progress-fill { transition: none; }
    .an-progress-wait .an-progress-fill { animation: none; width: 100%; opacity: 0.45; }
}
/* On a gallery card the picture is large: the share done in big figures, and what is happening under it */
[data-view="gallery"] .an-progress { gap: 0.25rem; }
[data-view="gallery"] .an-progress-figure { font-size: 2.25rem; }
[data-view="gallery"] .an-progress-run .an-progress-word { display: block; }
[data-view="gallery"] .an-progress-word { font-size: 0.9375rem; }
[data-view="gallery"] .an-progress-sub { display: block; font-size: 0.8125rem; }
[data-view="gallery"] .an-progress-track { height: 6px; }
.analyse-row-facts { min-width: 0; }
/* A row's menu: All analyses of this video first; the rest folded under More options (a <details> in the menu) */
.menu-more > summary { list-style: none; cursor: pointer; color: var(--cotw-muted); }
.menu-more > summary::-webkit-details-marker { display: none; }
.menu-more > summary::after { content: "\25B8"; margin-left: 0.4rem; display: inline-block; transition: transform 0.15s; }
.menu-more[open] > summary::after { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .menu-more > summary::after { transition: none; } }
.menu-more[open] { border-top: 1px solid var(--cotw-rope); margin-top: 0.25rem; padding-top: 0.25rem; }
/* A video's analyses in a pop-up (static/analyses_dialog.js) */
.analyses-dialog .modal-header { align-items: flex-start; gap: 0.5rem; }
.analyses-dialog-title { flex: 1 1 auto; min-width: 0; }
.analyses-dialog-title p { overflow-wrap: anywhere; }
.analyses-dialog-page { flex: 0 0 auto; padding: 0.2rem 0.4rem; color: var(--cotw-muted); line-height: 1; }
.analyses-dialog-page:hover, .analyses-dialog-page:focus-visible { color: var(--cotw-ink); }
/* Short forms in a pop-up (static/form_dialog.js) */
.form-dialog-page { padding: 0.2rem 0.4rem; color: var(--cotw-muted); line-height: 1; }
.form-dialog-page:hover, .form-dialog-page:focus-visible { color: var(--cotw-ink); }
.form-dialog-form .form-actions { margin-top: 1rem; }
.form-dialog .modal-body > :first-child { margin-top: 0; }
.form-dialog .modal-body > :last-child { margin-bottom: 0; }
.analyse-row-when { margin: 0; font-weight: 600; cursor: pointer; }
.analyse-row-name { font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analyse-row-facts .video-details summary { font-size: 0.8125rem; color: var(--cotw-muted); }
.analyse-row-state { min-width: 0; }
.analyse-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.35rem; }
.an-badge { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.an-badge-none { background: var(--cotw-mist); color: var(--cotw-ink); border: 1px solid var(--cotw-rope); }
.an-badge-waiting { background: var(--cotw-waiting-bg); color: var(--cotw-waiting-text); }
.an-badge-running { background: var(--cotw-teal-soft); color: var(--cotw-teal-dark-text); }
.an-badge-failed { background: var(--cotw-failed-bg); color: var(--cotw-bad-text); }
.an-badge-done { color: var(--cotw-teal-dark-text); padding-left: 0; }
.an-reviewed { color: var(--cotw-teal-dark-text); font-weight: 600; }
.analyse-archived-link { margin: 0.25rem 0 0; }
.analyse-archived-link a { font-weight: 600; }
@media (max-width: 767.98px) {
    .analyse-row { grid-template-columns: 1.5rem 80px minmax(0, 1fr); }
    .analyse-row-state { grid-column: 3; }
    .analyse-row-actions { grid-column: 2 / -1; justify-content: flex-start; }
    .analyse-tick-buttons { margin-left: 0; }
    .camera-group-actions { margin-left: 0; }
    /* The switch as a 2 × 2 grid of equal buttons */
    .stage-switch { display: grid; grid-template-columns: 1fr 1fr; width: 100%; border-radius: var(--cotw-radius); }
    .stage-button { border-left: 0; }
    .stage-button + .stage-button { border-left: 0; }
    .stage-button:nth-child(even) { border-left: 1px solid var(--cotw-rope); }
    .stage-button:nth-child(n+3) { border-top: 1px solid var(--cotw-rope); }
    /* A phone has no room for two stuck lines: only the day's sticks */
    .camera-group[open] > summary { position: static; }
    .day-group-head { top: var(--cotw-topbar-height); gap: 0 0.75rem; font-size: 0.8125rem; }
    .day-group-span { display: none; }
    .day-group { scroll-margin-top: calc(var(--cotw-topbar-height) + 0.5rem); }
}

/* Analyse videos as a gallery (the form's data-view, analyse_bar.js): each video a card, the picture first, its tick
   box on the picture; the rows' own grid (above) is the List */
.view-switch .bi { margin-right: 0.15rem; }
[data-view="gallery"] .video-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
    gap: 0.75rem; padding: 0.75rem 0.9rem; }
[data-view="gallery"] .analyse-row { position: relative; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 0.3rem 0.5rem;
    padding: 0.5rem 0.5rem 0.6rem; border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); background: var(--cotw-panel); }
[data-view="gallery"] .analyse-row + .analyse-row { border-top: 1px solid var(--cotw-rope); }
[data-view="gallery"] .analyse-row-tick { position: absolute; top: 0.85rem; left: 0.85rem; z-index: 1; line-height: 0; }
[data-view="gallery"] .analyse-row-tick .form-check-input { width: 1.35rem; height: 1.35rem; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85); }
[data-view="gallery"] .analyse-row-thumb, [data-view="gallery"] .analyse-row-facts { grid-column: 1 / -1; }
/* The stored thumbnails are 4:3 with the picture letterboxed: cropped to 16:9, the bars go */
[data-view="gallery"] .analyse-row-thumb img, [data-view="gallery"] .analyse-row-blank { width: 100%; height: auto; aspect-ratio: 16 / 9; }
[data-view="gallery"] .analyse-row:has(.inference_choose_videos_check:checked) { border-color: var(--cotw-teal); box-shadow: 0 0 0 1px var(--cotw-teal); }
[data-view="gallery"] .analyse-row-state { grid-column: 1 / -1; align-self: start; }
[data-view="gallery"] .analyse-row-actions { grid-column: 1 / -1; justify-content: flex-end; }
/* When and with which model it was analysed: in List; a card keeps to the counts and the review */
[data-view="gallery"] .an-counts + .small.text-muted { display: none; }

/* The design handbook (catchmonitor/handbook.html, handbook_doc.html) */
.handbook-group { margin-bottom: 1.25rem; }
.handbook-list { padding-left: 1.25rem; }
.handbook-list li { margin: 0.3rem 0; }
.handbook-list .text-muted { margin-left: 0.5rem; }
.handbook-doc { max-width: 52rem; line-height: 1.6; }
.handbook-doc h1 { font-size: 1.6rem; margin: 0 0 0.9rem; }
.handbook-doc h2 { font-size: 1.25rem; margin: 1.75rem 0 0.5rem; }
.handbook-doc h3 { font-size: 1.05rem; margin: 1.25rem 0 0.4rem; }
.handbook-doc table { border-collapse: collapse; margin: 0 0 1rem; display: block; overflow-x: auto; }
.handbook-doc th, .handbook-doc td { border: 1px solid var(--cotw-rope); padding: 0.35rem 0.6rem; vertical-align: top; }
.handbook-doc th { background: var(--cotw-mist); }
.handbook-doc pre { background: var(--cotw-mist); padding: 0.75rem; border-radius: var(--cotw-radius); overflow-x: auto; }
.handbook-doc code { font-size: 0.875em; }


/* The dark/light switch in the top bar (components/theme_toggle.html): the icon of what pressing it does */
.theme-toggle { background: none; border: 0; padding: 0.375rem 0.5rem; color: var(--cotw-muted); line-height: 1;
    border-radius: var(--cotw-radius); }
.theme-toggle:hover { color: var(--cotw-ink); background: var(--cotw-mist); }
.theme-toggle .bi { font-size: 1.1rem; }
.theme-to-light { display: none; }
[data-bs-theme="dark"] .theme-to-light { display: inline; }
[data-bs-theme="dark"] .theme-to-dark { display: none; }


/* ---------- The dark theme: what isn't a token ---------- */
/* Outline buttons: teal text a dark page can carry; the grey ones fill grey, not light, on hover */
[data-bs-theme="dark"] .cotw .btn-outline-primary {
    --bs-btn-color: var(--cotw-teal-text);
    --bs-btn-border-color: var(--cotw-teal-text);
    --bs-btn-hover-color: #FFFFFF;
}
[data-bs-theme="dark"] .cotw .btn-outline-secondary {
    --bs-btn-border-color: #6B7C86;
    --bs-btn-hover-color: var(--cotw-ink);
    --bs-btn-hover-bg: #33444E;
    --bs-btn-hover-border-color: #7D8D97;
    --bs-btn-active-color: var(--cotw-ink);
    --bs-btn-active-bg: #3B4D58;
}
/* fish_counter.css's own colours */
[data-bs-theme="dark"] {
    --slate: var(--cotw-muted);
    --mist: var(--cotw-subtle);
    --rule: var(--cotw-rope);
    --text-secondary: var(--cotw-muted);
}
[data-bs-theme="dark"] :is(.cam, .cam-tabs, .fc-card, .fc-act, .fc-savebar, .fc-filter, .project-steps-panel,
                           .project-steps-tab) { background: var(--cotw-panel); }
[data-bs-theme="dark"] :is(.blank_video_thumb, input[type="password"]) { background: var(--cotw-subtle); }
[data-bs-theme="dark"] :is(.breadcrumb-item.active, .breadcrumb-item + .breadcrumb-item::before) { color: var(--cotw-muted); }
[data-bs-theme="dark"] :is(.upload-status[data-state="uploading"], .fc-savebar.has-changes,
                           .model-status-not_started, .model-status-started, .model-status-training_complete) {
    background: var(--cotw-waiting-bg); color: var(--cotw-waiting-text); }
[data-bs-theme="dark"] :is(.upload-status[data-state="done"], .model-status-complete, .gpu-badge-available) {
    background: #173A26; color: #8EE0A8; border-color: #2F6B45; }
[data-bs-theme="dark"] :is(.upload-status[data-state="failed"], .model-status-error) {
    background: var(--cotw-failed-bg); color: var(--cotw-bad-text); border-color: var(--cotw-danger-border); }
[data-bs-theme="dark"] .gpu-badge-busy { background: var(--cotw-info-bg); color: var(--cotw-info-text); }
[data-bs-theme="dark"] :is(.gpu-badge-unknown, .model-status-retired) { background: #26323A; color: #B5C2CA; }
[data-bs-theme="dark"] :is(a.model-status-link:hover, a.model-status-link:focus) { background: #1F4A33; color: #A8EBC0; }
[data-bs-theme="dark"] .gpu-summary-dot { border-color: var(--cotw-panel); }
[data-bs-theme="dark"] .train-timeline { color: var(--cotw-ink); }

/* A gentle note: a dataset whose fish are all "Fish, species unknown" (components/fish_only_note.html) */
.fish-only-note { max-width: 70ch; margin: 0 0 1rem; padding: 0.625rem 0.875rem; border-left: 4px solid var(--cotw-teal);
    background: var(--cotw-teal-soft); border-radius: 0 var(--cotw-radius) var(--cotw-radius) 0; font-size: 0.9375rem; }
.fish-only-note .bi { color: var(--cotw-teal-text); margin-right: 0.25rem; }

/* Label images: the folded Marked as unusable section (labelling_home.html) */
.lab-unusable > summary { cursor: pointer; list-style: revert; }
.lab-unusable-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }

/* The gallery of labelled images (labelling_gallery.html): outlines drawn over each thumbnail */
.gal-filter { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1rem; }
.gal-chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.7rem; border: 1px solid var(--cotw-rope);
    border-radius: 999px; background: var(--cotw-panel); color: var(--cotw-ink); font-size: 0.875rem; }
.cotw a.gal-chip { text-decoration: none; font-weight: 400; }
.gal-chip:hover { border-color: var(--cotw-teal); }
.gal-chip.is-on { background: var(--cotw-teal); border-color: var(--cotw-teal); color: #fff; }
.gal-chip-n { opacity: 0.75; font-variant-numeric: tabular-nums; }
.gal-dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; vertical-align: -0.05rem; margin-right: 0.15rem;
    border: 1px solid rgba(0, 0, 0, 0.25); }
.gal-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.gal-tile { min-width: 0; }
.gal-link { display: block; border-radius: var(--cotw-radius); overflow: hidden; border: 1px solid var(--cotw-rope); }
.gal-link:hover, .gal-link:focus-visible { border-color: var(--cotw-teal); box-shadow: 0 0 0 2px var(--cotw-teal-soft); }
.gal-thumb { position: relative; display: block; background: #000; }
.gal-thumb img { display: block; width: 100%; height: 100%; object-fit: fill; }
.gal-thumb svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.gal-thumb svg * { fill-opacity: 0.22; stroke-width: 2; vector-effect: non-scaling-stroke; }
.gal-name { margin-top: 0.35rem; font-size: 0.8125rem; color: var(--cotw-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gal-species { font-size: 0.875rem; }
.gal-pages { display: flex; align-items: center; gap: 0.75rem; margin-top: 1.25rem; }
/* The gallery's pop-up viewer (labelling_gallery.html, static/gallery_viewer.js): the picture as large as fits, its
   aspect ratio (--ar) given by the script so the outlines' SVG, the picture's own pixels, lies exactly on it */
dialog.cotw-dialog.gallery-viewer { width: min(1100px, calc(100vw - 2rem)); }
.gv-head { display: flex; align-items: baseline; gap: 0.75rem; min-width: 0; }
.gv-place { white-space: nowrap; }
.gv-frame { position: relative; margin: 0 auto; background: #000; aspect-ratio: var(--ar, 4 / 3);
    width: min(100%, calc(68vh * var(--ar, 1.333))); }
.gv-img { display: block; width: 100%; height: 100%; }
.gv-shapes { position: absolute; inset: 0; width: 100%; height: 100%; }
.gv-shapes * { fill-opacity: 0.18; stroke-width: 2; vector-effect: non-scaling-stroke; }
.gv-frame.is-loading .gv-img { opacity: 0.4; }
.gallery-viewer .modal-footer { flex-wrap: wrap; gap: 0.5rem; }
.gallery-viewer .modal-footer > * { margin: 0; }

/* ---------- Label images (labelling_home.html): two columns, and the classes chart (components/class_status.html) ---------- */
:root { --lab-done: #0F766E; --lab-todo: #6CC2B6; }      /* one teal, two steps: checked with the dataviz validator */
[data-bs-theme="dark"] { --lab-done: #6FD8CC; --lab-todo: #2E6B63; }
.lab-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.lab-main { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.lab-main > .lab-start, .lab-main > .lab-card { margin: 0; max-width: none; }
.lab-card { background: var(--cotw-panel); border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); padding: 1.125rem 1.25rem; }
.lab-progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.lab-progress-head .lab-progress-text { margin: 0; font-size: 1.125rem; }
.lab-progress-pct { font-size: 1.5rem; font-weight: 700; color: var(--cotw-teal-text); font-variant-numeric: tabular-nums; }
.lab-bar { width: 100%; max-width: none; margin: 0.5rem 0 0.75rem; }
.lab-stats { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; list-style: none; margin: 0 0 1rem; padding: 0;
    color: var(--cotw-muted); font-size: 0.875rem; }
.lab-stats strong { color: var(--cotw-ink); font-variant-numeric: tabular-nums; }
.lab-cameras { list-style: none; margin: 0; padding: 0; }
.lab-camera { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 1rem; align-items: baseline;
    padding: 0.6rem 0; }
.lab-camera + .lab-camera { border-top: 1px solid var(--cotw-rope); }
.lab-camera a { font-weight: 600; }
.lab-camera-n { color: var(--cotw-muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.lab-camera .proj-bar { grid-column: 1 / -1; width: 100%; max-width: none; }
.lab-classes { position: sticky; top: calc(var(--cotw-topbar-height) + 1rem); }
.lab-legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.8125rem; color: var(--cotw-muted); margin-bottom: 0.75rem; }
.lab-swatch { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 2px; margin-right: 0.35rem; vertical-align: -0.1rem; }
.lab-chart { display: flex; flex-direction: column; gap: 0.5rem; }
.lab-class-row { display: grid; grid-template-columns: minmax(6rem, 9.5rem) minmax(0, 1fr) 2.75rem; gap: 0.75rem;
    align-items: center; font-size: 0.875rem; padding: 0.1rem 0; border-radius: 4px; }
.lab-class-row:hover { background: var(--cotw-mist); }
.lab-class-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lab-class-bar { display: flex; gap: 2px; height: 0.875rem; }   /* 2px gap between the two parts */
.lab-seg { display: block; height: 100%; min-width: 2px; }
.lab-seg:last-child { border-radius: 0 4px 4px 0; }             /* rounded at the data end, square at the baseline */
.lab-done { background: var(--lab-done); }
.lab-todo { background: var(--lab-todo); }
.lab-class-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--cotw-ink); }
.lab-chart-more { display: flex; flex-direction: column; gap: 0.5rem; }
.lab-chart-more > summary { cursor: pointer; font-size: 0.8125rem; color: var(--cotw-teal-text); font-weight: 600; }
.lab-chart-more[open] > summary { margin-bottom: 0.25rem; }
.lab-unused { margin: 1rem 0 0; color: var(--cotw-muted); }
.lab-unused strong { color: var(--cotw-ink); }
.lab-table { margin-top: 0.875rem; font-size: 0.875rem; }
.lab-table > summary { cursor: pointer; color: var(--cotw-teal-text); font-weight: 600; font-size: 0.8125rem; }
@media (max-width: 991.98px) {
    .lab-layout { grid-template-columns: 1fr; }
    .lab-classes { position: static; }
}
@media (max-width: 575.98px) { .lab-class-row { grid-template-columns: minmax(4.5rem, 6.5rem) minmax(0, 1fr) 2.5rem; gap: 0.5rem; } }

/* ---------- The site notice under the top bar (components/site_notice.html) ---------- */
.cotw .site-notice { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1.25rem;
    background: var(--cotw-teal-soft); color: var(--cotw-ink); border-bottom: 1px solid var(--cotw-rope); }
.cotw .site-notice[hidden] { display: none; }
.cotw .site-notice-icon { color: var(--cotw-teal); font-size: 1.1rem; }
.cotw .site-notice-text { margin: 0; flex: 1 1 auto; }
.cotw .site-notice-close { margin: 0; flex: 0 0 auto; }
@media (max-width: 575.98px) {
    .cotw .site-notice { padding: 0.5rem 1rem; align-items: flex-start; }
}

/* ---------- Create dataset (dataset_builder.html, inline/dataset_builder_vue_templates.html): the split by camera
   and video, and the summary card beside it; train is teal and test orange everywhere on the page ---------- */
.cotw { --dsb-train: var(--cotw-teal); --dsb-test: var(--cotw-signal); }
.dsb-layout { grid-template-columns: minmax(0, 1.6fr) minmax(18rem, 1fr); }
.dsb-side { position: sticky; top: calc(var(--cotw-topbar-height) + 1rem); display: flex; flex-direction: column; gap: 0.25rem;
    /* taller than the window (many classes): it scrolls inside, so Create dataset stays within reach */
    max-height: calc(100vh - var(--cotw-topbar-height) - 2rem); overflow-y: auto; }
.dsb-side .lab-h:first-child { margin-top: 0; }
.dsb-form { border-top: 1px solid var(--cotw-rope); padding-top: 0.75rem; margin-top: 0.5rem; }
.dsb-form .lab-h { margin-top: 0; }
.dsb-totals { margin: 0 0 0.5rem; }
.dsb-key { font-weight: 600; }
.dsb-key.dsb-train { color: var(--dsb-train); }
.dsb-key.dsb-test { color: var(--dsb-test); }
.dsb-bar, .dsb-mini-bar { display: flex; gap: 2px; overflow: hidden; }
.dsb-bar { height: 0.625rem; border-radius: 0.3125rem; }
.dsb-bar-train { background: var(--dsb-train); }
.dsb-bar-test { background: var(--dsb-test); }
.dsb-warn { margin: 0.625rem 0 0; color: var(--dsb-test); font-weight: 600; font-size: 0.9375rem; }
.dsb-classes { border-top: 1px solid var(--cotw-rope); margin-top: 0.75rem; padding-top: 0.25rem; }
.dsb-class-n { white-space: nowrap; width: auto; }
.dsb-classes .lab-class-row { grid-template-columns: minmax(5.5rem, 8rem) minmax(0, 1fr) auto; }
.dsb-class-n { min-width: 4.5rem; font-size: 0.875rem; }

.dsb-random { display: grid; gap: 0.5rem; padding-bottom: 0.875rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--cotw-rope); }
.dsb-random-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.dsb-random-fields label { margin: 0; font-size: 0.9375rem; }
.dsb-num { width: 7rem; }
.dsb-level { width: auto; }
.dsb-more-toggle { padding-left: 0; padding-right: 0; }

/* A camera: its header row, then its videos (and stills) as rows: name, images and their split, the controls */
.dsb-camera { border: 1px solid var(--cotw-rope); border-radius: var(--cotw-radius); margin-top: 0.625rem; }
.dsb-main { container-type: inline-size; }
.dsb-camera-head, .dsb-row {
    display: grid; grid-template-columns: minmax(7rem, 1fr) auto auto; align-items: center; gap: 0.5rem 1rem;
    padding: 0.5rem 0.75rem;
}
.dsb-camera-head { grid-template-columns: auto minmax(7rem, 1fr) auto auto; background: var(--cotw-mist);
    border-radius: var(--cotw-radius) var(--cotw-radius) 0 0; }
.dsb-camera.is-folded .dsb-camera-head { border-radius: var(--cotw-radius); }
.dsb-camera-head .dsb-name { font-weight: 600; }
.dsb-rows .dsb-row { border-top: 1px solid var(--cotw-rope); padding-left: 2.25rem; }
.dsb-name { min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; line-height: 1.3; }
/* A narrow split column: the counts' words go (the bar and its tooltip say the same) */
@container (max-width: 46rem) { .dsb-count-text { display: none; } }
.dsb-fold { border: 0; background: none; color: var(--cotw-muted); padding: 0 0.25rem; line-height: 1; font-size: 1rem; }
.dsb-fold:hover { color: var(--cotw-ink); }
.dsb-fold:focus-visible { outline: 2px solid var(--cotw-teal); outline-offset: 2px; border-radius: 4px; }
.dsb-count { display: flex; align-items: center; gap: 0.5rem; font-variant-numeric: tabular-nums; }
.dsb-count-n { min-width: 2.25rem; text-align: right; }
.dsb-mini-bar { width: 4.5rem; height: 0.4375rem; border-radius: 0.25rem; flex: none; background: var(--cotw-rope); }
.dsb-count-text { font-size: 0.8125rem; color: var(--cotw-muted); white-space: nowrap; }
.dsb-split { display: flex; align-items: center; gap: 0.375rem; }
.dsb-split-label { font-size: 0.9375rem; }

/* Train | Test: the chosen one filled in its colour; one with both shows neither */
.dsb-choice { border: 1px solid var(--cotw-rope); background: var(--cotw-panel); color: var(--cotw-ink); min-width: 3.5rem; }
.dsb-choice:hover { background: var(--cotw-mist); }
.dsb-choice.dsb-on-train, .dsb-choice.dsb-on-train:hover { background: var(--dsb-train); border-color: var(--dsb-train); color: #fff; }
.dsb-choice.dsb-on-test, .dsb-choice.dsb-on-test:hover { background: var(--dsb-test); border-color: var(--dsb-test); color: #fff; }
.dsb-lock { border: 1px solid var(--cotw-rope); background: transparent; color: var(--cotw-muted); min-width: 5.25rem; }
.dsb-lock.dsb-fixed { background: var(--cotw-mist); color: var(--cotw-ink); }

@media (max-width: 991.98px) {
    .dsb-layout { grid-template-columns: 1fr; }
    .dsb-side { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 575.98px) {
    .dsb-camera-head { grid-template-columns: auto minmax(0, 1fr); }
    .dsb-row { grid-template-columns: minmax(0, 1fr); padding-left: 0.75rem; }
    .dsb-camera-head .dsb-count, .dsb-camera-head .dsb-split, .dsb-camera-head .dsb-split-label { grid-column: 1 / -1; }
}

/* ---------- Train a model's Help (components/train_help.html) ---------- */
.train-more { font-size: inherit; vertical-align: baseline; }
.train-help-body section { scroll-margin-top: 0.5rem; padding-top: 0.25rem; }
.train-help-body section:focus { outline: none; }
.train-help-body section:focus-visible h3 { text-decoration: underline; }
.train-help-toc { font-size: 0.875rem; padding: 0.5rem 0.75rem; margin-bottom: 1rem; background: var(--cotw-mist);
    border-radius: var(--cotw-radius); line-height: 1.8; }

/* ---------- The maintenance banner site administrators see while the switch is on (components/maintenance_banner.html) ---------- */
.cotw-maintenance-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding: 0.5rem 1.25rem; background: #7A1F1A; color: #fff; font-size: 0.9375rem; }
.cotw-maintenance-banner form { margin: 0; }
.cotw-maintenance-banner button { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.7); border-radius: 0.3rem; padding: 0.15rem 0.7rem; font: inherit; font-size: 0.875rem; cursor: pointer; }
.cotw-maintenance-banner button:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- The recording time dialog's first frame (components/recorded_dialog.html) ---------- */
.recorded-frame { margin: 0; display: grid; gap: 0.4rem; }
.recorded-frame img { display: block; border-radius: 0.3rem; background: var(--cotw-mist, #eef2f4); }
/* The stamp strips keep their enlarged size and scroll sideways, rather than shrinking to the dialog's width */
.recorded-strip-wrap { overflow-x: auto; border: 1px solid var(--cotw-rope); border-radius: 0.3rem; }
.recorded-strip-wrap:focus-visible { outline: 2px solid var(--cotw-teal); outline-offset: 1px; }
.recorded-strip { height: 4.5rem; width: auto; max-width: none; border-radius: 0; }
.recorded-whole { width: 100%; height: auto; max-height: 40vh; object-fit: contain; }

/* The Jobs menu beside the Inbox (components/job_queue.html, static/job_queue.js): the button's ring fills with the
   running jobs' progress, or turns, in the waiting colour, while they only wait; each job has a thin bar below it */
.job-queue-toggle { display: flex; align-items: center; gap: 0.4rem; }
.job-ring { position: relative; display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; }
.job-ring .bi { font-size: 0.8rem; line-height: 1; }
.job-ring::before {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
}
.job-ring-running::before { background: conic-gradient(var(--cotw-teal) calc(var(--p, 0) * 1%), var(--cotw-rope) 0); }
.job-ring-waiting::before {
    background: repeating-conic-gradient(var(--cotw-signal) 0 20deg, transparent 20deg 40deg);
    animation: job-ring-turn 4s linear infinite;
}
.job-ring-idle .bi { color: var(--cotw-muted); }
@keyframes job-ring-turn { to { transform: rotate(1turn); } }
.job-queue-count { background: var(--cotw-teal); color: #FFFFFF; font-variant-numeric: tabular-nums; }
.job-queue-menu { min-width: 20rem; max-width: min(26rem, calc(100vw - 2rem)); max-height: 70vh; overflow-y: auto; padding: 0.35rem 0; }
.job-row { display: grid; gap: 0.1rem; padding: 0.5rem 0.9rem; color: var(--cotw-ink); text-decoration: none; }
.job-row:hover, .job-row:focus-visible { background: var(--cotw-teal-soft); color: var(--cotw-ink); }
.job-row-title { font-weight: 600; font-size: 0.9rem; overflow-wrap: anywhere; }
.job-row-meta { font-size: 0.8rem; color: var(--cotw-muted); }
.job-row-bar { position: relative; height: 3px; margin-top: 0.3rem; border-radius: 2px; overflow: hidden; background: var(--cotw-rope); }
.job-row-bar > span { display: block; height: 100%; width: calc(var(--p, 0) * 1%); background: var(--cotw-teal); transition: width 0.9s ease; }
.job-row-bar-waiting > span, .job-row-bar-preparing > span {
    width: 30%; background: var(--cotw-signal); animation: an-progress-sweep 1.8s ease-in-out infinite;
}
.job-queue-empty { margin: 0; padding: 0.5rem 0.9rem; max-width: 22rem; font-size: 0.875rem; color: var(--cotw-muted); }
/* Placed by CSS (data-bs-display="static"): under the button's right edge, and across a phone's screen */
.job-queue { position: relative; }
.job-queue .job-queue-menu { top: 100%; right: 0; left: auto; margin-top: 0.25rem; }
@media (max-width: 575.98px) {
    .job-queue .job-queue-menu { position: fixed; top: var(--cotw-topbar-height); left: 0.5rem; right: 0.5rem;
        min-width: 0; max-width: none; }
}
.job-queue-foot { display: block; margin-top: 0.25rem; padding: 0.5rem 0.9rem 0.2rem; border-top: 1px solid var(--cotw-rope); font-size: 0.85rem; }
@media (prefers-reduced-motion: reduce) {
    .job-ring-waiting::before { animation: none; }
    .job-row-bar > span { transition: none; }
    .job-row-bar-waiting > span, .job-row-bar-preparing > span { animation: none; width: 100%; opacity: 0.45; }
}
