/* Workspaces reserve the viewport for the current task. Long collections scroll
   within their named panel; switching tabs never reloads the player. */
body[data-auth=signed-in] { height:100dvh; display:flex; flex-direction:column; overflow:hidden; }
body[data-auth=signed-in] .app-header { flex-shrink:0; }
body[data-auth=signed-in] #main { width:100%; flex:1; min-height:0; overflow:auto; }
#navigation { overflow-x:auto; flex-shrink:0; }
#navigation a { flex-shrink:0; }
#main.flight-workspace,#main.preparation-workspace,#main.library-workspace,#main.collection-workspace { display:flex; flex-direction:column; overflow:hidden; padding-block:18px; }
.flight-workspace > .heading,.preparation-workspace > .heading,.library-workspace > .heading { flex-shrink:0; margin-bottom:16px; }
.flight-workspace > .heading .back-link { margin-bottom:6px; }
.flight-workspace > .heading h1 { font-size:23px; margin-bottom:4px; }
.workspace-tabs { display:flex; gap:20px; border-bottom:1px solid var(--line); flex-shrink:0; margin-bottom:16px; overflow-x:auto; }
.workspace-tabs button { background:transparent; border:0; border-radius:0; border-bottom:2px solid transparent; padding:10px 4px; color:var(--muted); white-space:nowrap; }
.workspace-tabs [aria-selected=true] { color:var(--accent); border-bottom-color:var(--accent); }
.workspace-pane { flex:1; min-height:0; overflow:auto; margin-bottom:0; }
.workspace-section-heading { display:flex; align-items:start; justify-content:space-between; gap:20px; margin-bottom:16px; flex-shrink:0; }
.workspace-section-heading h2 { margin-bottom:8px; }
.workspace-section-heading p { margin:0; }
.workspace-list { min-height:0; flex:1; overflow:auto; overscroll-behavior:contain; padding:4px; }
.workspace-list:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
.workspace-pagination { flex-shrink:0; justify-content:space-between; border-top:1px solid var(--line); padding-top:12px; margin-top:12px; font-size:13px; color:var(--muted); }
.workspace-empty { padding:24px 0; color:var(--muted); }
.flight-workspace .review-layout { flex:1; min-height:0; align-items:stretch; }
.flight-workspace .source-pane { display:flex; flex-direction:column; min-height:0; }
.flight-workspace .replay-desk { flex:1; min-height:0; display:flex; flex-direction:column; }
.flight-workspace .replay-heading,.flight-workspace .replay-transport { flex-shrink:0; }
.flight-workspace .replay-stages { flex:1; min-height:0; }
.flight-workspace .analysis-panel { display:flex; flex-direction:column; min-height:0; }
.flight-workspace .replay-canvas-wrap { height:auto; flex:1; min-height:80px; }
.flight-workspace .replay-source { min-height:0; }
.flight-workspace .replay-source .footage-frame { min-height:80px; height:auto; }
.flight-workspace .replay-source video { max-height:none; min-height:0; }
.flight-workspace .replay-message { padding:16px; font-size:14px; }
.flight-workspace .moment-panel { min-height:0; display:flex; flex-direction:column; align-self:stretch; }
.flight-workspace .detail-tabs { flex-shrink:0; margin:0; gap:2px; }
.flight-workspace .detail-tabs button { font-size:13px; }
.flight-workspace .moment-panel > [role=tabpanel] { min-height:0; flex:1; overflow:auto; }
.flight-workspace .moment-list { max-height:none; overflow:visible; }
.flight-workspace #detail-context { padding:18px; }
.flight-workspace #footage-error:empty { display:none; }
.result-row { padding:18px 0; border-bottom:1px solid var(--line); display:flex; gap:20px; justify-content:space-between; align-items:center; }
.result-row p { font-size:13px; color:var(--muted); margin:6px 0 0; overflow-wrap:anywhere; }
.result-row button { flex-shrink:0; }
.flight-footage-content .footage-manage { padding:0; border:0; margin:0; }
.footage-manage.is-matching > .footage-table-wrap,.footage-manage.is-matching > .footage-note { display:none; }
/* Flight footage: one compact row per angle; rarer actions sit in its menu. */
.footage-table { width:100%; border-collapse:collapse; font-size:14px; }
.footage-table th { padding:6px 12px; border-bottom:1px solid var(--line); font-size:12px; font-weight:500; color:var(--quiet); text-align:left; white-space:nowrap; }
.footage-table td { padding:8px 12px; border-bottom:1px solid var(--hover); color:var(--muted); vertical-align:middle; }
.footage-table tr.is-removed td { opacity:.72; }
.footage-angle { display:flex; align-items:center; gap:10px; min-width:0; color:var(--text); }
.footage-angle strong { font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.footage-angle-icon { display:grid; place-items:center; width:30px; height:30px; flex-shrink:0; border-radius:6px; background:var(--raised); color:var(--muted); }
.footage-chip { padding:0 8px; border-radius:999px; background:var(--raised); color:var(--text); font-size:12px; font-weight:500; line-height:20px; white-space:nowrap; }
.footage-chip[data-tone=accent] { background:var(--selection); color:var(--accent); }
.footage-chip[data-tone=warn] { color:var(--warning); }
.footage-chip[data-tone=muted] { color:var(--muted); }
.footage-range { font-variant-numeric:tabular-nums; white-space:nowrap; }
.footage-actions { text-align:right; white-space:nowrap; }
.footage-actions > div { display:inline-flex; align-items:center; gap:6px; }
.row-menu { position:relative; display:inline-block; }
.row-menu > summary { list-style:none; }
.row-menu > summary::-webkit-details-marker { display:none; }
.row-menu[open] > summary { background:var(--hover); }
.row-menu-list { position:absolute; right:0; top:calc(100% + 6px); z-index:5; min-width:210px; padding:6px 0; background:var(--raised); border:1px solid var(--line); border-radius:6px; box-shadow:var(--shadow); text-align:left; }
.row-menu-list button { display:block; width:100%; min-height:0; padding:9px 14px; border:0; border-radius:0; background:transparent; color:var(--text); font-size:14px; font-weight:400; text-align:left; }
.row-menu-list button:hover { background:var(--hover); }
.row-menu-list .row-menu-danger { color:var(--danger); }
.footage-note { margin:12px 0 0; }
.footage-manage #timing-details { margin-top:14px; }
.footage-manage #timing-details > summary { display:inline-flex; list-style:none; cursor:pointer; }
.footage-manage #timing-details > summary::-webkit-details-marker { display:none; }
@media(max-width:720px) { .footage-table th:nth-child(2),.footage-table td:nth-child(2),.footage-table th:nth-child(3),.footage-table td:nth-child(3) { display:none; } .footage-table th,.footage-table td { padding-inline:8px; } }
.footage-manage.is-matching #timing-details { margin-top:0; }
.mobile-details-tab { display:none; }
.footage-library { display:flex; flex-direction:column; flex:1; min-height:0; margin:0; }
.footage-library-filters { display:grid; grid-template-columns:minmax(0,2fr) minmax(0,1fr); gap:16px; margin-bottom:16px; flex-shrink:0; }
.footage-library-filters label { display:block; margin-bottom:6px; }
.footage-library-filters input,.footage-library-filters select { width:100%; }
.source-library-row { border-bottom:1px solid var(--line); padding:18px 0; }
.source-library-heading { display:flex; align-items:start; justify-content:space-between; gap:20px; }
.source-library-heading h2 { font-size:17px; overflow-wrap:anywhere; margin-bottom:6px; }
.source-library-heading > div { min-width:0; }
.source-membership { display:flex; align-items:center; justify-content:space-between; gap:20px; padding-top:12px; }
.source-membership p { margin:4px 0 0; }
.source-membership button { flex-shrink:0; }
.preparation-workspace .heading p { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.preparation-workspace .heading > div { min-width:0; }
.preparation-workspace .footage-workspace { min-height:0; flex:1; margin:0; display:flex; flex-direction:column; padding:18px; }
.prep-layout { min-height:0; flex:1; display:grid; grid-template-columns:minmax(0,1.4fr) minmax(320px,1fr); gap:24px; }
.prep-player { position:relative; min-height:0; background:var(--input); display:flex; }
.prep-player #import-preview { width:100%; height:100%; min-height:0; max-height:none; margin:0; object-fit:contain; }
.preparation-workspace .import-layout { display:flex; flex-direction:column; margin:0; min-height:0; max-width:none; }
.preparation-workspace .import-main { min-height:0; flex:1; display:flex; flex-direction:column; }
.preparation-workspace .import-section { border:0; padding:0 4px; }
.prep-tabs { gap:16px; margin-bottom:16px; }
.preparation-workspace .import-main > [role=tabpanel] { min-height:0; flex:1; overflow:auto; }
.preparation-workspace #import-review .panel-title { display:none; }
.preparation-workspace:not(.preparation-ready) .prep-layout { display:flex; }
.preparation-workspace:not(.preparation-ready) .import-layout { flex:1; }
.preparation-workspace:not(.preparation-ready) #import-review .panel-title { display:flex; }
.preparation-workspace .trim-track { height:52px; }
.preparation-workspace #import-trimmer { margin-bottom:12px; }
.preparation-workspace #import-exact-range { margin-bottom:6px; }
.preparation-workspace #import-source-details { margin-bottom:6px; }
.preparation-workspace .track-candidates { grid-template-columns:1fr; }
.preparation-workspace .prep-details #import-save { padding-top:18px; }
.prep-footer { display:flex; justify-content:flex-end; flex-shrink:0; border-top:1px solid var(--line); padding-top:12px; margin-top:16px; }
.prep-footer #import-save-button { margin:0; }
.prep-footer .actions { flex:1; display:flex; flex-wrap:wrap; align-items:center; justify-content:flex-end; }
/* Saving: progress, errors and the outcome beside the buttons that started it. */
.save-status { margin:0 auto 0 0; font-size:13px; color:var(--muted); max-width:56ch; outline:none; }
.save-status:empty { display:none; }
.save-status.error { color:var(--danger); }
.save-status.busy::before, button.is-busy::before { content:""; display:inline-block; width:12px; height:12px; margin-right:8px; vertical-align:-1px; border:2px solid currentColor; border-right-color:transparent; border-radius:50%; animation:save-turn .8s linear infinite; }
button.is-busy::before { margin-right:0; }
button.is-busy:disabled { opacity:.85; }
@keyframes save-turn { to { transform:rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .save-status.busy::before, button.is-busy::before { animation:none; } }
.preparation-workspace #import-match-hint { margin-top:18px; }
@media(max-width:1100px) {
 .flight-workspace .review-layout { grid-template-columns:minmax(0,1fr) 300px; gap:16px; }
 .result-control { flex-wrap:wrap; }
 .result-control [data-result-source] { width:100%; }
 .prep-layout { grid-template-columns:minmax(0,1fr) minmax(300px,1fr); gap:16px; }
}
/* Desktop flight review: the flight's name, actions, task tabs and status head the
   detail column, so the replay runs from the app header to the page bottom. The
   review panel's player and details share the page grid through subgrid. */
@media(min-width:821px) {
 #main.flight-workspace { --detail-width:340px; display:grid; grid-template-columns:minmax(0,1fr) var(--detail-width); grid-template-rows:auto auto auto auto minmax(0,1fr); column-gap:20px; }
 #main.flight-workspace > * { grid-column:1 / -1; min-width:0; }
 .flight-workspace > :is(.heading,.workspace-tabs,.flight-status,#footage-error) { grid-column:2; position:relative; z-index:1; }
 .flight-workspace > .heading { grid-row:1; flex-direction:column; align-items:stretch; gap:12px; margin-bottom:14px; }
 .flight-workspace > .heading h1 { overflow-wrap:anywhere; }
 .flight-workspace > .heading .actions { flex-wrap:nowrap; gap:8px; }
 .flight-workspace > .heading .actions .button { min-height:34px; padding:6px 12px; font-size:13px; white-space:nowrap; }
 .flight-workspace > .workspace-tabs { grid-row:2; margin-bottom:14px; }
 .flight-workspace > .flight-status { grid-row:3; margin:0 0 14px; }
 .flight-workspace > #footage-error { grid-row:4; margin:0 0 14px; }
 .flight-workspace > .review-layout { grid-row:1 / -1; display:grid; grid-template-columns:subgrid; grid-template-rows:subgrid; }
 .flight-workspace > .review-layout > .source-pane { grid-column:1; grid-row:1 / -1; }
 .flight-workspace > .review-layout > .moment-panel { grid-column:2; grid-row:5; }
 .flight-workspace > #workspace-footage { grid-column:1; grid-row:1 / -1; }
}
@media(min-width:821px) and (max-width:1100px) {
 #main.flight-workspace { --detail-width:300px; column-gap:16px; }
 .flight-workspace > .heading .actions .button { padding-inline:9px; }
}
@media(max-width:820px) {
 #main.flight-workspace,#main.preparation-workspace,#main.library-workspace,#main.collection-workspace { padding:12px 18px; }
 .flight-workspace > .heading { gap:8px; margin-bottom:10px; flex-direction:row; align-items:center; }
 .flight-workspace > .heading h1 { font-size:19px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
 .flight-workspace > .heading > div { min-width:0; }
 .flight-workspace > .heading .actions { width:auto; flex-wrap:nowrap; }
 .flight-workspace > .heading .actions .button { white-space:nowrap; font-size:12px; min-height:36px; padding:6px 8px; }
 .flight-workspace > .heading .actions a[href$="/sharing"] { display:none; }
 .workspace-tabs { gap:18px; margin-bottom:10px; }
 .workspace-tabs button { padding-block:8px; }
 .mobile-details-tab { display:inline-flex; }
 .flight-workspace .review-layout { grid-template-columns:minmax(0,1fr); }
 .flight-workspace[data-flight-panel=review] .moment-panel { display:none; }
 .flight-workspace[data-flight-panel=details] .source-pane { display:none; }
 .flight-workspace .replay-heading h2 { display:none; }
 .flight-workspace .replay-heading { padding:8px; }
 .flight-workspace .replay-stages { grid-template-columns:minmax(0,1fr); }
 /* The 3D view takes the screen between the tabs and the playback controls.
    Only when that leaves less than a usable view does the panel scroll. */
 .flight-workspace .source-pane { overflow:auto; }
 .flight-workspace .replay-desk:not(:fullscreen):not(.replay-expanded) { flex:1 0 auto; }
 .flight-workspace .replay-desk:not(:fullscreen):not(.replay-expanded) .replay-stages { flex:1 0 auto; }
 .flight-workspace .replay-desk:not(:fullscreen):not(.replay-expanded) .replay-canvas-wrap { flex:1 0 auto; height:auto; min-height:220px; }
 .flight-workspace .replay-desk:not(:fullscreen):not(.replay-expanded) .footage-frame { min-height:260px; }
 .workspace-pane { padding:16px; }
 .workspace-section-heading { gap:12px; margin-bottom:10px; }
 .result-row,.source-library-heading,.source-membership { flex-direction:column; align-items:stretch; gap:10px; }
 .result-row button { align-self:start; }
 .footage-library-filters { grid-template-columns:minmax(0,1fr); gap:8px; }
 .footage-library-filters label { font-size:13px; }
 .prep-layout { display:flex; flex-direction:column; gap:12px; }
 .prep-player { flex:0 0 clamp(110px,23vh,200px); }
 .preparation-workspace .import-layout { flex:1; }
 .preparation-workspace .footage-workspace { padding:12px; }
 .preparation-workspace > .heading { margin-bottom:10px; }
 .preparation-workspace .heading h1 { font-size:21px; }
 .preparation-workspace .heading .activity-link { font-size:13px; }
 .prep-tabs { margin-bottom:8px; }
 .prep-footer { margin-top:8px; padding-top:8px; }
 .prep-footer .actions { gap:8px; }
 .prep-footer button { font-size:12px; padding:7px 9px; }
 .preparation-workspace .trim-heading { margin:4px 0 8px; flex-direction:row; }
 .preparation-workspace .trim-track { height:40px; }
 .preparation-workspace .trim-times { margin:8px 0; }
 .preparation-workspace #import-trimmer .hint { margin:8px 0; }
}
@media(max-height:550px) and (orientation:landscape) {
 .flight-workspace > .heading p,.result-control [data-result-source] { display:none; }
 .flight-workspace .replay-camera { display:none; }
 .prep-layout { display:grid; grid-template-columns:1fr 1fr; }
 .prep-player { min-height:90px; }
}
@media(max-width:820px) and (max-height:700px) {
 .preparation-workspace .prep-layout { display:flex; overflow:auto; }
 .preparation-workspace .import-layout,.preparation-workspace .import-main { flex:none; }
 .preparation-workspace .import-main > [role=tabpanel] { flex:none; overflow:visible; }
}

.collection-workspace > .heading { flex-shrink:0; margin-bottom:16px; }
.collection-workspace > .panel,.library-workspace > .flight-library { display:flex; flex-direction:column; min-height:0; flex:1; margin-bottom:0; }
.collection-workspace > .section-nav,.library-workspace > .section-nav { flex-shrink:0; }
.flight-library #flight-results { min-height:0; flex:1; overflow:auto; overscroll-behavior:contain; }
.flight-library > :not(#flight-results) { flex-shrink:0; }
.flight-library .library-more[open] { max-height:32vh; overflow:auto; }
.flight-library .library-pages { padding-top:12px; }
.context-edit { display:flex; gap:16px; }
@media(max-width:820px) {
 .flight-library .library-filters { grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:8px; }
 .flight-library .library-filters label { font-size:13px; }
 .flight-library .library-filters input,.flight-library .library-filters select { min-width:0; width:100%; }
 .collection-workspace > .heading,.library-workspace > .heading { margin-bottom:12px; }
 .collection-workspace > .panel { padding:16px; }
}

/* Longer readiness explanations must not squeeze the Results list to zero on phones. */
@media (max-width: 820px) {
 #main.flight-workspace[data-flight-panel=results] { overflow: auto; }
 .flight-workspace[data-flight-panel=results] #workspace-results { flex: none; min-height: 480px; }
}

.flight-removal { max-width: 760px; }
.flight-removal fieldset { margin: 24px 0; }
.flight-removal .check { align-items: start; margin-block: 12px; }
.flight-removal ul { padding-inline-start: 24px; }
.flight-removal li { margin-block: 16px; overflow-wrap: anywhere; }
.flight-removal li p { margin: 4px 0; color: var(--muted); }
.flight-removal h3 { margin-top: 24px; }
.flight-removal .danger { color: var(--danger); border-color: var(--danger); }
.flight-removal .actions { flex-wrap: wrap; margin-top: 24px; }
.removal-pending { flex-shrink: 0; }
.removal-pending h2 { font-size: 16px; }
@media (max-width: 520px) {
 .flight-workspace > .heading { flex-wrap: wrap; }
 .flight-removal { padding: 18px; }
}
/* Remove video: a second, in-place question before anything is deleted. */
.remove-confirm { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 5px; background: var(--raised); }
.remove-confirm p { margin: 0 0 8px; }
.remove-confirm .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.remove-confirm .danger-button { color: var(--danger); border-color: var(--danger); }
