/* 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; }
}

/* -- 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,
  #focusToggleBtn { 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%);
  }
}
/* 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. */
  .transcript-region::before { content: ""; position: absolute; inset: -13px 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%; }
