/* Phone / tablet / home-screen layer (design audit 2026-11-17).
   Loaded AFTER styles.css. It only ever adds: bigger touch targets for
   finger (pointer:coarse) devices and safe-area room for notches. Desktop
   mouse layout is untouched. Editor-internal controls are NOT here -- the
   editor owns those (see docs/DESIGN-AUDIT-2026-11-17.md, M2). */

/* -- Safe areas (notch, home bar, landscape cut-outs). env() is 0 on desktop. */
.topbar {
  padding-left: max(var(--sp-4), env(safe-area-inset-left, 0px));
  padding-right: max(var(--sp-4), env(safe-area-inset-right, 0px));
}
@supports (padding-top: env(safe-area-inset-top)) {
  .topbar {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  }
}
.auth-gate {
  padding-left: max(var(--sp-4), env(safe-area-inset-left, 0px));
  padding-right: max(var(--sp-4), env(safe-area-inset-right, 0px));
  padding-bottom: max(var(--sp-4), env(safe-area-inset-bottom, 0px));
}
.toasts { bottom: max(var(--sp-4), env(safe-area-inset-bottom, 0px)); right: max(var(--sp-4), env(safe-area-inset-right, 0px)); }
.team-dialog, .import-mode-dialog { max-height: calc(100dvh - 32px); overflow: auto; }

/* -- Finger-sized targets: 44 px minimum, on ANY touch device (a landscape
   tablet is 1180 px wide and still a finger -- decide by pointer, not width). */
@media (pointer: coarse) {
  /* top bar */
  .topbar .btn, .topbar .chip-credits, .topbar .brand, .topbar .crumb-home,
  .topbar .view-tab, .topbar .walkthrough-launcher, .topbar .auth-signout {
    min-height: 44px; min-width: 44px;
  }
  .topbar .chip-credits { padding-inline: 12px; }
  .topbar .view-tab { padding-inline: 14px; }
  .topbar-actions .btn, .topbar-actions .walkthrough-launcher { width: auto; }
  .topbar-actions .btn-icon, .topbar-actions .auth-signout, .topbar-actions .walkthrough-launcher { width: 44px; }
  .topbar { gap: 6px; height: auto; min-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); flex-wrap: wrap; row-gap: 4px; padding-top: calc(4px + env(safe-area-inset-top, 0px)); padding-bottom: 4px; }
  .topbar-actions { gap: 4px; }

  /* board + clip grid */
  .library .btn, .board .btn, #boardFindBtn, #trashBtn, .js-import,
  #favFilter, #hiddenClipsFilter, #pausePreviewsBtn, #selectModeBtn,
  .seg-btn, .mode-option, #selectBar .btn, #createSurfaceGoBtn {
    min-height: 44px;
  }
  .seg-btn, .mode-option { padding-inline: 14px; }
  #boardCount, #momentSearch, #projectClipMode, #createSurfaceUrl, #promptInput {
    min-height: 44px; font-size: 16px;
  }
  .proj-drag-handle { width: 44px; height: 44px; }

  /* dialogs */
  .import-mode-dialog button, .team-dialog .btn, .team-dialog button { min-height: 44px; }
  #teamClose, #workspaceSelect, #inviteEmail { min-height: 44px; }

  /* login / sign up / forgot */
  .auth-link { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 4px; }
  .auth-consent { align-items: center; gap: 12px; min-height: 44px; }
  .auth-consent input { width: 24px; height: 24px; margin: 0; }

  /* the small print is read by thumb-size eyes */
  #creditText, .credit-left, .proj-length, .proj-when, .card-dur, .card-state,
  .card-watched, .library label { font-size: 12px; }
}

/* -- Nothing you type into is under 16 px on a touch screen, at any width (phone test, 22 Nov 2026).
   iPhone Safari zooms the whole page in when a text box under 16 px is tapped, and does not zoom back:
   the Rename box was 12 px; at 750-768 px the account picker, clip count and music picker were 12 px
   and the prompt, describe, hook, title and description boxes 14 px. One rule for every text box, picker
   and text area, whatever rule sized it before; ticks, sliders and colour wells are not typed into. */
@media (pointer: coarse) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]):not([type=hidden]):not([type=button]):not([type=submit]):not([type=image]),
  select, textarea { font-size: 16px !important; }
}

/* -- Account & managers dialog on a phone. */
#workspaceSelect { text-overflow: ellipsis; }
@media (max-width: 480px) {
  .team-dialog h2, .team-dialog h3 { letter-spacing: .06em; overflow-wrap: anywhere; }
}

/* -- Disabled primary reads as "not yet", not as a broken brown button. */
.auth-card .btn-gold[disabled], .auth-card .btn-gold:disabled {
  opacity: .45; filter: saturate(.8);
}

/* -- Keyboard / focus on touch devices that have a keyboard attached. */
@media (pointer: coarse) { :focus-visible { outline-offset: 3px; } }

/* -- Editor timeline: the "more" button on a selected item (zoom, speed,
   sound stretch, media bar). Same menu as right-click and long-press. */
.item-more {
  /* Clear of the item's end resize grip (8 px at the right edge). */
  position: absolute; top: 1px; right: 10px; z-index: 8;
  width: 22px; height: 16px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(10,11,13,.55); border-radius: 4px;
  background: linear-gradient(180deg, #fbfcfd 0%, #e7e9ec 45%, #b7bcc4 100%);
  color: #0a0b0d; font: 700 10px/1 var(--font); letter-spacing: .06em;
  cursor: pointer; pointer-events: auto; touch-action: manipulation;
  box-shadow: 0 1px 2px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.7);
}
.item-more:hover, .item-more:focus-visible {
  background: linear-gradient(180deg, #fceca3 0%, #ffd42e 55%, #d4a70f 100%); outline: none;
}
/* An item too narrow to hold both grips and the button keeps its grips;
   right-click and long-press still open the same menu. */
.item-more.is-cramped { display: none; }
@media (pointer: coarse) {
  /* A long-press on the timeline opens the edit menu: no text selection,
     no iOS call-out bubble under the finger. */
  .trimmer { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  /* 16 px in, so the 44 px hit area below still ends short of the grip. */
  .item-more { width: 30px; height: 24px; font-size: 13px; right: 16px; }
  /* 44 px to hit, without drawing bigger */
  .item-more::before, .piece-more::before { content: ""; position: absolute; inset: -10px -7px; }
  .ctx-menu-item { min-height: 44px; }
}

/* -- Editor controls, finger-sized (design audit M2). Hit areas grow; what is
   drawn, and where, does not. */
@media (pointer: coarse) {
  /* Trim handles stay 15 px wide on screen; the finger gets 44 px. */
  .handle::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
    width: 44px; transform: translateX(-50%);
  }
  .seg-btn { min-height: 44px; padding-inline: 14px; }
  #exportBtn { min-height: 44px; }
  .transport-btn, #transportPlayBtn, #restartBtn, #splitBtn, #soundRepairBtn, #postToolsBtn, #captionToolsBtn,
  #focusToggleBtn, #focusToggleBtn.editor-mode-toggle { min-width: 44px; min-height: 44px; }
  #railReveal, #keyReveal, #layersReveal { min-width: 44px; }
}
/* A phone on its side has about 390 px of height, and the deck under the
   picture is capped. Drawn at 44 px, the export row took the last of it and the
   timeline was left with no height at all. So in a short window the row is
   drawn at its desktop size and only what the finger can hit is 44 px. */
@media (pointer: coarse) and (max-height: 500px) {
  .transport .focus-bar .seg-btn, .transport .focus-bar #exportBtn { min-height: 0; position: relative; }
  .transport .focus-bar .seg-btn::before, .transport .focus-bar #exportBtn::before {
    content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%);
  }
  /* Phone test, 22 Nov 2026: the gold Export button -- the point of the whole screen -- was drawn 30 px
     tall on a phone on its side. It is drawn 40 px; the shape pills beside it keep their compact size. */
  .transport .focus-bar #exportBtn { min-height: 40px; }
}

/* -- Account and Tools at 601-860 px (a phone on its side, an iPad upright). Phone test, 22 Nov 2026:
   both were blank boxes there -- styles.css draws every top-bar button as a 34 px icon square with its
   text at size 0, and these two have no icon. They keep their word (Account uses its short name). */
@media (min-width: 601px) and (max-width: 860px) {
  .topbar-actions #teamButton, .topbar-actions #focusToggleBtn, .topbar-actions #focusToggleBtn.editor-mode-toggle {
    width: auto; flex: 0 0 auto; min-width: 44px; height: 36px; padding-inline: 12px; font-size: 12px; white-space: nowrap;
  }
  .topbar-actions #teamButton { max-width: 150px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text); }
  .topbar-actions #teamButton[data-short] { font-size: 0; }
  .topbar-actions #teamButton[data-short]::before { content: attr(data-short); font-size: 12px; }
}
/* The fixed drawer tabs are 44 px wide for a finger, so their reserved lane is
   too: at 32 px they sat on top of the timeline's left edge. */
@media (pointer: coarse) and (min-width: 768px) {
  .layout.focus:not(.view-board) .stage { padding-left: 44px; }
}
@media (pointer: coarse) {
  /* Caption blocks on the timeline keep their size; the tap area is taller. */
  /* 14 px above and below a 16 px block: 44 px. (13 px left it at 42, which no
     test saw while the phone timeline was squeezed and this lane was cut off.) */
  .transcript-region::before { content: ""; position: absolute; inset: -14px 0; }
}

/* -- Board card: "this needs a plan" (free plan limit). A prompt, not an error. */
.proj-status.tone-plan { color: var(--text); font-weight: 600; white-space: normal; overflow: visible; text-overflow: clip; }
.proj-plan-why { flex: 1 0 100%; font-size: 12px; line-height: 1.45; color: var(--text-dim); white-space: normal; overflow-wrap: anywhere; }
.proj-plans { flex: 0 0 auto; min-height: 44px; padding-inline: 18px; display: inline-flex; align-items: center; text-decoration: none; margin-top: 4px; }
.project-card.is-plan-prompt .proj-meta { align-items: flex-start; }
.project-card.is-plan-prompt .proj-status { flex: 1 0 100%; }

/* -- Clip card: an explicit Edit button for fingers (live test, 19 Nov 2026).
   The whole card still opens the editor; on a phone its middle is the Watched
   switch, so the way in has to be a button of its own. A mouse never sees it. */
.card-open { display: none; }
@media (pointer: coarse), (max-width: 600px) {
  .card-review .card-open {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 76px; min-height: 44px; padding: 0 18px; border-radius: 999px;
    border: 1px solid rgba(245,197,24,.55); background: rgba(245,197,24,.08);
    color: var(--accent); font: 700 13px/1 var(--font); letter-spacing: .02em;
  }
  .card-review .card-open:hover, .card-review .card-open:active { background: rgba(245,197,24,.16); color: var(--accent); }
}
@media (pointer: coarse) {
  /* The card's small corner buttons keep their size; the finger gets 44 px. */
  .card-thumb .card-more::before { content: ""; position: absolute; inset: -9px -9px -11px -11px; }
  .board-tools #favFilter, .board-tools #hiddenClipsFilter, .board-tools #selectModeBtn { min-height: 44px; }
  .card-post .post-copy { position: relative; }
  .card-post .post-copy::before { content: ""; position: absolute; inset: -9px; }
}
@media (max-width: 600px) {
  /* The Edit row sits across the middle of the phone card, where a thumb lands. */
  .clip-card .card-review { margin-top: 10px; gap: 8px; }
}

/* -- Phone editor sheets (Tools, Captions, Transcript, Sound, Media, Picture,
   Full Qlip, Post, a tapped piece): every control a fingertip tall and wide
   (live test, 19 Nov 2026 -- they were 22 to 32 px). Only the bottom sheet a
   phone gets (.is-sheet); the desktop cards and inspector are untouched. */
@media (pointer: coarse) {
  .piece-tools.is-sheet :is(button, select, textarea, input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color])) { min-height: 44px; }
  .piece-tools.is-sheet :is(button, select) { min-width: 44px; }
  .piece-tools.is-sheet .insp-door { height: auto; }
  .piece-tools.is-sheet input[type=color] { width: 44px; height: 44px; }
  .piece-tools.is-sheet input[type=range] { min-height: 44px; }
  .piece-tools.is-sheet label:has(> input[type=checkbox], > input[type=radio]) { min-height: 44px; align-items: center; }
  .piece-tools.is-sheet summary { min-height: 44px; padding-block: 12px; box-sizing: border-box; }
  .piece-tools.is-sheet .tr-section-remove { width: 44px; height: 44px; }
  .piece-tools.is-sheet .tr-para { padding-right: 46px; }
  /* The Keys / Clips / Layers drawer. */
  .rail .btn, #railHide, #railSwitch, #railLayersSwitch, #analyzeBtn, #targetCount { min-height: 44px; min-width: 44px; }
  /* "Retry" under the picture is a word in a sentence: the finger gets 44 px around it. */
  .queued-audio-retry { position: relative; }
  .queued-audio-retry::before { content: ""; position: absolute; inset: -14px -6px; }
}

/* -- Phone editor: the timeline is never squeezed (live test, 20 Nov 2026).
   The editor did not scroll, so the timeline only got what the picture and the
   export row left over: 85 px at 390x844 once Share/Download showed, 42 px at
   360x740, 10 px (no strip, no handles) at 390x664. Now the deck under the
   picture always takes its full height -- Play, the tools, Export AND the whole
   timeline -- and the PICTURE gives way, down to a floor. If even that does not
   fit, the editor scrolls (the stage is the scroller, so the top bar stays). */
@media (max-width: 767px) {
  .layout.focus:not(.view-board) { --phone-pic-min: 160px; }
  /* Three rows: [title | KEYS CLIPS LAYERS], the picture, the deck. The title
     had a 27 px row of its own above the drawer tabs; on a phone that row is
     worth more to the picture. */
  .layout.focus:not(.view-board) .stage {
    overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(var(--phone-pic-min), 1fr) auto;
  }
  .layout.focus:not(.view-board) .stage-head {
    grid-row: 1; grid-column: 1; align-self: center; min-width: 0;
    justify-content: flex-start; padding: 4px 8px 4px var(--sp-3);
  }
  .layout.focus:not(.view-board) .stage-head > div:first-child { text-align: left; min-width: 0; }
  .layout.focus:not(.view-board) .stage-head h1 {
    display: block; margin: 0; max-width: none; font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .layout.focus:not(.view-board) .editor-drawer-tabs { grid-row: 1; grid-column: 2; justify-content: flex-end; padding: 4px var(--sp-3) 4px 0; }
  .layout.focus:not(.view-board) .player-wrap { grid-row: 2; grid-column: 1 / -1; }
  .layout.focus:not(.view-board) .focus-deck { grid-row: 3; grid-column: 1 / -1; }
  /* min-height: auto, not 0: with 0 the grid was free to shrink the deck's row
     below its content again, and the timeline slid under the next row. */
  .layout.focus:not(.view-board) .focus-deck { max-height: none; min-height: auto; overflow: visible; }
  .layout.focus:not(.view-board) .focus-timeline { flex: none; overflow: visible; }
}
@media (max-width: 767px) and (max-height: 700px) {
  .layout.focus:not(.view-board) { --phone-pic-min: 132px; }
}

/* -- Phone sheets keep Done on screen (live test, 20 Nov 2026). Captions and
   Picture scroll as a whole card, so their header (and its Done) scrolled away
   -- seen at y = -327. The header now stays pinned at the top of the card, the
   way Transcript, Sound, Media and Full Qlip already kept theirs (#sideTools
   pins its own header by a different route and is left alone). */
.layout.focus:not(.view-board) .player-wrap > .player-frame ~ .piece-tools.is-sheet > .piece-tools-head {
  position: sticky; top: calc(-1 * var(--sp-3)); z-index: 6;
  margin: calc(-1 * var(--sp-3)) calc(-1 * var(--sp-4)) 0;
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
  background: #0f1013; border-bottom: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
}

/* -- Phone drawers (KEYS / CLIPS / LAYERS) open UNDER the picture, over the
   deck, so a playing clip stays in view; a tap outside still closes them.
   --editor-pic-bottom is the picture's bottom edge, kept by editor.js. */
@keyframes rail-rise-in { from { transform: translateY(24px); opacity: 0; } }
@media (max-width: 767px) {
  .layout.focus:not(.view-board):not(.rail-hidden) .rail,
  .layout.focus:not(.view-board):not(.rail-hidden) .rail.rail-mode-keys,
  .layout.focus:not(.view-board):not(.rail-hidden) .rail.rail-mode-layers {
    top: clamp(var(--topbar-h), var(--editor-pic-bottom, 50dvh), calc(100dvh - 240px));
    bottom: 0; left: 0; right: 0; width: auto;
    border-right: 0; border-top: 1px solid var(--line-strong); border-radius: 14px 14px 0 0;
    box-shadow: 0 -14px 44px rgba(0, 0, 0, .6);
    overflow-y: auto; overscroll-behavior: contain;
    animation: rail-rise-in .18s ease-out;
  }
  /* The head: the drawer's name and Hide on the first line, its actions on the
     next. "CLIPS" was squeezed to 0 px under Import on one crowded line. */
  .rail-head { flex-wrap: wrap; row-gap: 6px; }
  .rail-head h2 { order: -2; flex: 1 0 auto; min-width: max-content; }
  .rail-head #railHide { order: -1; }
  .rail-head::after { content: ""; order: -1; flex: 0 0 100%; height: 0; }
}

/* -- Fingertip targets the live test measured small (20 Nov 2026). What is
   drawn keeps its size; the finger gets 44 px. Text a phone reads is 12 px. */
@media (pointer: coarse) {
  .help-sheet .sheet-close { width: 44px; height: 44px; font-size: 18px; }
  .piece-tools.is-sheet .post-field { grid-template-columns: 52px minmax(0, 1fr) 44px; }
  .piece-tools.is-sheet .post-label { font-size: 11px; }
  .topbar .chip-credits, .topbar .chip-credits #creditText { font-size: 12px; }
  .stage-fit, .picture-tools .frame-readout { font-size: 12px; }
  .piece-tools.is-sheet label:has(> input[type=checkbox]) { min-width: 44px; }
  /* The clip card's corner menu and copy buttons: a real 44 px box, the visible
     chip drawn inside it (a hit area that hangs outside the poster is clipped
     by the poster's own overflow). */
  .card-thumb .card-more, .card-post .post-copy {
    width: 44px; height: 44px; border: 0; background: transparent; backdrop-filter: none; isolation: isolate;
  }
  .card-post .post-copy { position: relative; }
  .card-thumb .card-more { top: 0; right: 0; }
  .card-thumb .card-more::before, .card-post .post-copy::before {
    content: ""; position: absolute; inset: 9px; z-index: -1;
    border: 1px solid rgba(255,255,255,.16); border-radius: 7px; background: rgba(10,11,13,.66);
  }
  .card-thumb .card-more:hover, .card-thumb .card-more:focus-visible { background: transparent; }
  .card-post .post-copy::before { background: var(--surface-3); border-color: var(--line); border-radius: 6px; }
}

/* -- Phone clip card: nothing on the poster overlaps (live test, 20 Nov 2026 --
   at 360 px the score, the length and the "..." sat on top of each other, and an
   EDITED pill sat on Play). One column of chips down the left, the menu in the
   top-right corner, Play in the middle, thumbs-down and heart along the bottom.
   The 360 px poster is as tall as the 390 px one so all of it fits. */
@media (max-width: 600px) {
  .clip-card .card-thumb { height: 176px; }
  .card-thumb > .card-score { top: 6px; left: 6px; }
  .card-thumb > .card-dur { top: 34px; left: 6px; transform: none; padding: 4px 5px; }
  .card-thumb > .card-play { top: 82px; }
  .card-thumb > .card-state { top: 108px; bottom: auto; left: 6px; right: auto; }
}
@media (max-width: 360px) { .clip-card { min-height: 194px; } }
@media (max-width: 600px) and (pointer: coarse) {
  .card-thumb .card-fav { right: 0; bottom: 0; }
  .card-thumb .card-dislike { right: 48px; bottom: 0; }
}

/* -- Phone clips page = a photo gallery; phone editor = a BIG picture.
   Eric, 21 Nov 2026: "I hate the mobile experience. The clips page needs to be a grid of all the clips you
   click then it goes into the edit mode and when in edit mode you need to see the clip WAY bigger, this tiny
   little clip looks insane to try and edit. It needs to feel more like how iPhone shows you images in its
   photo gallery and edit."
   Gallery: three tall posters per row, hairline gaps, only the score (top-left) and length (bottom-right) on
   each; a tap anywhere opens the clip in the editor (the card's own click). Heart, thumbs-down, menu, Play,
   Watched and the title live in the editor, out of the grid. Select mode still ticks posters.
   Editor: the picture is the screen -- about 58% of its height, the transport right under it -- and the
   tools and timeline scroll beneath, instead of the picture getting only what the deck left over. */
@media (max-width: 767px) {
  .layout.view-board .clip-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
  .layout.view-board .clip-grid .clip-card {
    display: block; padding: 0; min-height: 0; border: 0; background: none; border-radius: 6px; gap: 0;
  }
  .layout.view-board .clip-grid .clip-card .card-thumb {
    width: 100%; height: auto; aspect-ratio: 9 / 16; border: 0; border-radius: 6px; box-shadow: none; transform: none;
  }
  /* Every tile filled edge to edge, like Photos (the poster is cut from the centre, as the clip will be). */
  .layout.view-board .clip-grid .card-thumb > img { width: 100%; height: 100%; object-fit: cover; }
  .layout.view-board .clip-grid .clip-card :is(.card-review, .card-post) { display: none; }
  .layout.view-board .clip-grid .card-thumb > :is(.card-play, .card-fav, .card-dislike, .card-state) { display: none; }
  /* Phone test, 22 Nov 2026: a tile was a picture, a score and a length -- no name, and no way to act on
     one clip. Still the photo grid (three to a row, a tap opens the editor), now with the clip's name
     under each picture (two lines) and ONE button, "...", that opens a sheet with everything else:
     Favorite, Hide, Edit, Download, Copy post, Move to trash. */
  .layout.view-board .clip-grid .clip-card .card-title {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    font: 600 12px/1.3 var(--font); color: var(--text); min-height: 32px; margin: 4px 2px 8px;
    overflow-wrap: anywhere;
  }
  .layout.view-board .clip-grid .card-thumb > .card-more {
    display: grid; place-items: center; top: 0; right: 0; width: 44px; height: 44px; padding: 0;
    border: 0; background: transparent; backdrop-filter: none; opacity: 1; isolation: isolate; color: #fff;
  }
  .layout.view-board .clip-grid .card-thumb > .card-more::before {
    content: ""; position: absolute; inset: 7px; z-index: -1;
    border: 1px solid rgba(255,255,255,.28); border-radius: 8px; background: rgba(10,11,13,.72);
  }
  .layout.view-board .clip-grid.is-selecting .card-thumb > .card-more { display: none; }
  /* A favorite shows its heart on the tile (a mark, not a button: the button is in the sheet). */
  .layout.view-board .clip-grid .card-thumb > .card-fav.is-on {
    display: grid; place-items: center; pointer-events: none; left: 4px; right: auto; bottom: 4px; top: auto;
    width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: rgba(10,11,13,.72); color: var(--accent);
  }
  .layout.view-board .clip-grid .card-thumb > .card-fav.is-on svg { width: 12px; height: 12px; }
  .layout.view-board .clip-grid .card-thumb > .card-score {
    top: 4px; left: 4px; padding: 2px 6px; font-size: 11px; line-height: 1.2; min-width: 0;
  }
  .layout.view-board .clip-grid .card-thumb > .card-dur {
    top: auto; bottom: 4px; left: auto; right: 4px; transform: none; padding: 2px 5px; font-size: 11px; line-height: 1.2;
  }
  .layout.view-board .clip-grid.is-selecting .card-check { display: grid; }
  /* Opening the page shows the clips first -- the Find / Describe / Search card moves under the grid.
     A project with no clips yet keeps it on top: there, finding clips IS the first thing to do. */
  .layout.view-board .board:has(.clip-grid .clip-card) { display: flex; flex-direction: column; }
  .layout.view-board .board:has(.clip-grid .clip-card) > .mobile-project-name { order: 0; }
  .layout.view-board .board:has(.clip-grid .clip-card) > .board-head { order: 1; margin: 8px 0 8px; }
  .layout.view-board .board:has(.clip-grid .clip-card) > .select-bar { order: 2; }
  .layout.view-board .board:has(.clip-grid .clip-card) > .clip-grid { order: 3; }
  .layout.view-board .board:has(.clip-grid .clip-card) > .find-panel { order: 4; margin-top: 18px; }
  .layout.view-board .board:has(.clip-grid .clip-card) > .moment-hits { order: 5; }
  .layout.view-board .board:has(.clip-grid .clip-card) > :not(.mobile-project-name):not(.board-head):not(.select-bar):not(.clip-grid):not(.find-panel):not(.moment-hits) { order: 6; }
  /* The count and Mode share one line; the filters get the next. */
  .layout.view-board .board-head { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
  .layout.view-board .board-head .board-tools { flex: 0 0 100%; }
  .layout.view-board .board-head .board-mode { font-size: 12px; }
  .layout.view-board .board-head .board-mode select { height: 40px; min-height: 40px; font-size: 16px; padding: 0 26px 0 10px; }
  /* One compact, sideways-scrolling row of filters instead of three wrapped rows. */
  .layout.view-board .board-tools { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; }
  .layout.view-board .board-tools .seg { flex: 0 0 auto; }
  .layout.view-board .board-tools > .btn { flex: 0 0 auto; white-space: nowrap; }

  .layout.focus:not(.view-board) .stage { grid-template-rows: auto clamp(300px, 58dvh, 780px) auto; }
  .layout.focus:not(.view-board) .player-wrap { padding: 2px 6px; }
  .layout.focus:not(.view-board) .player-frame { --stage-pad: 4px; border-radius: 10px; }
}

/* -- A phone page never slides sideways (owner, 22 Nov 2026: "it can move left to right inside the
   screen instead of being locked"). The cause that was found is fixed where it lives (the Clip mode help
   bubbles, styles.css). This is the second layer: the projects page and the Clips page scroll up and down
   only, so one too-wide thing in them can never again drag the whole page sideways. The filter row is the
   one box meant to be swiped; it keeps the swipe to itself. */
@media (max-width: 767px) {
  .library, .layout.view-board { overflow-x: hidden; overscroll-behavior-x: none; }
  .layout.view-board .board-tools { max-width: 100%; min-width: 0; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .layout.view-board .board-tools::-webkit-scrollbar { display: none; }
}
/* A quick double tap (the heart, Play, a filter) makes iPhone Safari zoom the page in, and a zoomed page
   slides sideways until it is pinched back. Taps stay taps; pinch-to-zoom still works. */
@media (pointer: coarse) { html { touch-action: manipulation; } }

/* -- Back to the projects, and "Saved", on a phone (phone test, 22 Nov 2026). */
.mobile-back { display: none; }
.phone-save-state { display: none; }
@media (max-width: 767px) {
  .layout.view-board .mobile-back {
    display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; order: -1 !important;
    min-height: 44px; margin: -6px 0 2px -6px; padding: 0 12px 0 6px;
    border: 0; border-radius: 999px; background: none; color: var(--text-dim);
    font: 600 14px/1 var(--font); cursor: pointer;
  }
  .layout.view-board .mobile-back > span { font-size: 22px; line-height: 1; margin-top: -2px; color: var(--accent); }
  .layout.view-board .mobile-back:active { color: var(--text); }
  .layout.view-board .mobile-project-name { display: block; margin: 0 0 12px; padding: 0 2px; color: var(--text); font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* The editor's title row: the clip's name, then a small "Saving… / Saved ✓". */
  .layout.focus:not(.view-board) .stage-head > div:first-child { display: flex; align-items: center; gap: 8px; }
  .layout.focus:not(.view-board) .stage-head h1 { flex: 0 1 auto; min-width: 0; }
  .phone-save-state { display: inline-block; flex: 0 0 auto; font: 600 12px/1.2 var(--font); color: var(--text-dim); white-space: nowrap; }
  .phone-save-state:empty { display: none; }
  .phone-save-state[data-state="error"] { color: var(--err); }
}

/* -- With a piece selected, Delete joins the row of tools and the row is wider than a phone (it was cut
   off at x = 358-436 of 390). While a piece is selected Delete takes the place of Post (Post is about
   the whole clip and comes back the moment nothing is selected), so the row keeps its width and nothing
   moves under the finger. On the narrowest phones the row was already 10 px too wide; there it wraps
   instead of being cut off. Nothing here scrolls sideways. */
@media (max-width: 767px) {
  .transport .transport-tools { max-width: 100%; min-width: 0; }
  .transport .transport-tools > .trimmer-tools { flex-wrap: wrap; max-width: 100%; min-width: 0; row-gap: 4px; }
  .transport .trimmer-tools:has(#deleteSegBtn:not([hidden])) #postToolsBtn { display: none; }
}

/* -- No keyboard, no KEYS (phone test, 22 Nov 2026). The drawer of keyboard shortcuts is not offered on a
   touch-only device; a tablet with a keyboard and trackpad attached still gets it. */
@media (hover: none) and (pointer: coarse) {
  #keyReveal, #railSwitch { display: none !important; }
  .create-drop-sub:empty { display: none; }
}

/* -- Fingers on the timeline (phone test, 22 Nov 2026). The ruler and the film strip took every touch
   for themselves (touch-action: none), so a swipe up or down that began on them could not scroll the
   page. Up/down is the page's again; sideways and two-finger moves come to the editor, which pans and
   pinch-zooms the view (editor.js, "Fingers on the ruler and the film strip"). The play line, the trim
   handles and the cut grips keep touch-action: none of their own. */
@media (pointer: coarse) {
  .track, .track-scale { touch-action: pan-y; }
}

/* -- The clip tile's "..." sheet (phone test, 22 Nov 2026). The same menu a mouse gets beside the card,
   drawn as a sheet from the bottom of the screen with a row per action, each a full fingertip tall. */
.card-menu-scrim { position: fixed; inset: 0; z-index: 79; background: rgba(6, 7, 9, .62); }
.card-menu.is-sheet {
  left: 0; right: 0; bottom: 0; top: auto; min-width: 0; z-index: 80;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  border-radius: 16px 16px 0 0; border-width: 1px 0 0; background: #0f1013;
  box-shadow: 0 -14px 44px rgba(0, 0, 0, .6); animation: rail-rise-in .18s ease-out;
  max-height: calc(100dvh - 60px); overflow-y: auto; overscroll-behavior: contain;
}
.card-menu.is-sheet .card-menu-title {
  padding: 10px 8px 12px; font: 600 14px/1.3 var(--font); color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.card-menu.is-sheet .card-menu-item { min-height: 48px; padding: 0 10px; font-size: 16px; display: flex; align-items: center; white-space: normal; }
.card-menu.is-sheet .card-menu-item.is-danger { margin-top: 4px; }
.card-menu.is-sheet .card-menu-cancel { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0; color: var(--text-dim); justify-content: center; }

/* -- The Clips page's row of filters on a phone (phone test, 22 Nov 2026). Select is the only way to
   favourite, download or trash several clips, and it sat off the right edge with nothing to say the row
   scrolls. Select comes first; the cut-off end of the row fades while there is more to swipe to; and
   "Pause previews" goes where there are no moving previews to pause (phone tiles, touch screens). */
@media (max-width: 767px) {
  .layout.view-board .board-tools > #selectModeBtn { order: -1; }
  .layout.view-board .board-tools.has-more { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent); }
  .layout.view-board .board-tools.has-less { -webkit-mask-image: linear-gradient(270deg, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(270deg, #000 calc(100% - 44px), transparent); }
  .layout.view-board .board-tools.has-more.has-less { -webkit-mask-image: linear-gradient(90deg, transparent, #000 44px, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(90deg, transparent, #000 44px, #000 calc(100% - 44px), transparent); }
  /* The select bar's five buttons wrap instead of running off the screen. */
  .layout.view-board .select-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 8px 10px; }
  .layout.view-board .select-bar-actions { gap: 6px; }
  .layout.view-board .select-bar-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 767px), (hover: none) and (pointer: coarse) {
  #pausePreviewsBtn { display: none; }
}

/* -- Export shape on a phone: all three shapes, side by side (live test,
   20 Nov 2026 -- only 9:16 showed, and on a 1:1 clip it still read 9:16). */
@media (max-width: 767px) {
  .export-actions .format-seg .seg-btn { min-width: 44px; padding-inline: 8px; }
}
