/* Cadence on a phone: layout for narrow touch screens. Loaded after css/app.css, only in the phone build
   (dist-mobile). Desktop-only things are hidden here or by mobile/web-shell.js. */
:root { --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); --tabbar: 58px; }
html.is-mobile, html.is-mobile body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; touch-action: manipulation; }
html.is-mobile body { position: fixed; inset: 0; }
html.is-mobile input, html.is-mobile select, html.is-mobile textarea { font-size: 16px; }   /* iOS zooms into anything smaller */
html.is-mobile kbd, html.is-mobile .keys { display: none !important; }

/* things a phone can't do */
html.is-mobile .discover-card,
html.is-mobile .media-switches .switch-chip + .switch-chip,
html.is-mobile #heartPill,
html.is-mobile #drop { display: none !important; }
html.no-fullscreen #game .corner .icon-btn:nth-last-child(2) { display: none; }

/* ---------- top bar: the name and Start; the tabs move to the bottom ---------- */
html.is-mobile .bar { height: calc(48px + var(--safe-t)); padding: var(--safe-t) calc(12px + var(--safe-r)) 0 calc(14px + var(--safe-l)); gap: 12px; }
html.is-mobile .bar-right { gap: 8px; min-width: 0; }
html.is-mobile .lib-status { display: none; }
html.is-mobile #startBtn { max-width: 52vw; overflow: hidden; }
html.is-mobile #startLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.is-mobile .tabs, html[data-theme] .is-mobile .tabs, html.is-mobile[data-theme] .tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--tabbar) + var(--safe-b)); padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0; border: 0; border-top: 1px solid var(--line-2); border-radius: 0; background: var(--bg);
}
html.is-mobile[data-theme] .tabs button { margin: 0; padding: 0; height: var(--tabbar); border: 0 !important; border-radius: 0; background: none; color: var(--text-2); font-size: 11px; box-shadow: none; }
html.is-mobile[data-theme] .tabs button.on { background: none; color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
html.is-mobile #views { top: calc(48px + var(--safe-t)); bottom: calc(var(--tabbar) + var(--safe-b)); }
html.is-mobile .view { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* ---------- Today ---------- */
html.is-mobile .today { padding: 20px calc(16px + var(--safe-r)) 32px calc(16px + var(--safe-l)); }
html.is-mobile .today h1 { font-size: 30px; margin-bottom: 16px; }
html.is-mobile .dial-hero { grid-template-columns: minmax(0, 1fr); justify-items: stretch; padding: 18px; gap: 16px; }
html.is-mobile .dial-hero .dial { justify-self: center; width: min(62vw, 240px); }
html.is-mobile .dial-meta .name { font-size: 30px; }
html.is-mobile .readouts { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 8px; }
html.is-mobile .readouts div:nth-child(3) { border-left: 0; padding-left: 0; }
html.is-mobile .readouts b { font-size: 22px; }
html.is-mobile .dial-lab { font-size: 9px; }
html.is-mobile .today-more { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.is-mobile .today-actions .btn { min-height: 40px; }

/* ---------- sheets and dialogs fill the width, above the tab bar ---------- */
html.is-mobile .sheet-backdrop { inset: 0; z-index: 60; padding: var(--safe-t) 0 var(--safe-b); }
html.is-mobile .sheet { width: calc(100% - 24px); max-height: calc(100% - 24px); padding: 18px; }
html.is-mobile .sheet-foot { flex-wrap: wrap; }
html.is-mobile .sheet-foot .btn { min-height: 44px; }
html.is-mobile #toasts { bottom: calc(var(--tabbar) + var(--safe-b) + 8px); left: 12px; right: 12px; }
html.is-mobile .toast { max-width: none; }

/* a quiet line while picked photos are being kept on the phone */
.mobile-busy { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar) + var(--safe-b) + 12px); z-index: 90; padding: 12px 14px; border-radius: 6px; background: var(--surface-3); color: var(--text); border: 1px solid var(--line-2); font-size: 14px; }

/* buttons big enough for a thumb */
html.is-mobile .btn { min-height: 38px; }
html.is-mobile .btn.small { min-height: 34px; }

/* ---------- the session ---------- */
html.is-mobile body:has(#game:not([hidden])) .tabs { display: none; }
html.is-mobile #toasts { transform: none; align-items: stretch; z-index: 80; }
html.is-mobile body:has(#game:not([hidden])) #toasts { bottom: calc(var(--safe-b) + 96px); }
html.is-mobile #game .task, html.is-mobile #game.essential .task.plate { top: calc(var(--safe-t) + 16px); left: calc(var(--safe-l) + 16px); max-width: calc(100% - 104px - var(--safe-l) - var(--safe-r)); padding: 0; }
html.is-mobile #game .t-title, html.is-mobile #game.essential .t-title { font-size: 30px; }
html.is-mobile #game .t-sub { font-size: 14px; }
html.is-mobile #game .t-say { font-size: 14px; }
html.is-mobile #game .ring, html.is-mobile #game.essential .ring, html.is-mobile #game.essential.fs .ring { right: calc(var(--safe-r) + 14px); top: calc(var(--safe-t) + 14px); padding: 6px; margin: -6px; }
html.is-mobile #game .ring-dial { width: 66px; height: 66px; }
html.is-mobile #game .meter { right: calc(var(--safe-r) + 12px); top: calc(var(--safe-t) + 12px); touch-action: none; }
html.is-mobile #game .note { left: 16px; right: 16px; max-width: none; top: auto; bottom: calc(var(--safe-b) + 150px); }
html.is-mobile #game.essential .capsule { bottom: calc(var(--safe-b) + 14px); max-width: calc(100% - 20px); gap: 10px; }
html.is-mobile #game.essential .capsule .beat { width: auto; flex: 1 1 120px; min-width: 100px; }
html.is-mobile #game.essential .capsule .btn { height: 44px; padding: 0 16px; }
html.is-mobile #game.essential .capsule .pause-only { width: 44px; }
html.is-mobile #game .controls { bottom: calc(var(--safe-b) + 16px); flex-wrap: wrap; padding: 0 12px; }
html.is-mobile #game .controls .btn { min-height: 46px; }
html.is-mobile #game .corner { right: calc(var(--safe-r) + 10px); bottom: calc(var(--safe-b) + 80px); gap: 6px; }
html.is-mobile #game .corner .icon-btn { width: 42px; height: 42px; }
html.is-mobile #game .side-arrow { width: 34px; height: 64px; }
html.is-mobile #game.idle .side-arrow { opacity: 0; }
html.is-mobile #game .meta { top: auto; bottom: calc(var(--safe-b) + 140px); right: calc(var(--safe-r) + 12px); }
html.is-mobile #game .quick { top: calc(var(--safe-t) + 12px); bottom: calc(var(--safe-b) + 12px); left: 12px; right: 12px; width: auto; z-index: 8; }
html.is-mobile #game .panel { width: calc(100% - 24px); max-height: calc(100% - 24px - var(--safe-t) - var(--safe-b)); overflow: auto; padding: 22px 18px; }
html.is-mobile #game .panel h2 { font-size: 26px; }
html.is-mobile #game .panel .actions .btn { min-height: 46px; }
html.is-mobile #game .folder-tag { display: none; }

/* sheets with a row of quick buttons wrap them */
html.is-mobile .sheet-head { flex-wrap: wrap; }
html.is-mobile .sheet-quick { flex-wrap: wrap; }
html.is-mobile #game .quick { z-index: 30; background: rgba(10,10,10,0.97); }
html.is-mobile #game:has(.overlay) .side-arrow, html.is-mobile #game:has(.quick:not([hidden])) .side-arrow { display: none; }

/* ---------- Settings: the pages in a strip across the top, one page below at full width ---------- */
html.is-mobile .settings-layout { display: flex; flex-direction: column; height: 100%; }
html.is-mobile[data-theme] .settings-rail { flex: none; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 6px; overflow-x: auto; overflow-y: hidden; padding: 10px 12px; border-right: 0 !important; border-bottom: 1px solid var(--line-2); scrollbar-width: none; }
html.is-mobile .settings-rail::-webkit-scrollbar { display: none; }
html.is-mobile .settings-rail h1, html.is-mobile .settings-rail .rail-group { display: none; }
html.is-mobile .settings-rail .settings-search { flex: 0 0 140px; margin: 0; height: 36px; }
html.is-mobile .settings-rail .preset-item { flex: none; white-space: nowrap; padding: 8px 12px; border-radius: 999px; min-height: 36px; }
html.is-mobile .settings-pane { flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
html.is-mobile .settings-pane .page, html.is-mobile[data-theme] .page { padding-left: calc(16px + var(--safe-l)); padding-right: calc(16px + var(--safe-r)); padding-top: 16px; }
html.is-mobile .row { flex-wrap: wrap; row-gap: 8px; }
html.is-mobile .row > .label { min-width: 0; flex: 1 1 180px; }
html.is-mobile .row > .ctl.wide, html.is-mobile .row > .seg { flex: 1 1 100%; }
html.is-mobile .seg { flex-wrap: wrap; }
html.is-mobile #game { touch-action: none; }   /* swipes and the ring are handled by Cadence, not scrolled or zoomed by the browser */

/* phones show their own thin scrollbar only while scrolling: the desktop's always-visible bars are turned off */
html.is-mobile, html.is-mobile * { scrollbar-width: none; }
html.is-mobile ::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* the one-time "add to your home screen" hint (web-shell.js) */
.install-hint { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar) + var(--safe-b) + 12px); z-index: 85; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 14px 14px 12px; background: var(--surface-3); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); font-size: 14px; line-height: 1.45; }
.install-hint p { margin: 0; flex: 1 1 100%; }
.install-hint .btn { min-height: 38px; }
.install-hint .btn.ghost { margin-left: auto; }
.install-hint .share-ic { display: inline-block; width: 14px; height: 17px; vertical-align: -3px; border: 1.6px solid currentColor; border-top: 0; border-radius: 0 0 2px 2px; position: relative; margin: 0 2px; }
.install-hint .share-ic::before { content: ""; position: absolute; left: 50%; top: -6px; width: 1.6px; height: 12px; background: currentColor; transform: translateX(-50%); }
.install-hint .share-ic::after { content: ""; position: absolute; left: 50%; top: -6px; width: 6px; height: 6px; border-left: 1.6px solid currentColor; border-top: 1.6px solid currentColor; transform: translateX(-50%) rotate(45deg); }

/* "Watch how it works" (views/preview.js): a portrait phone screen instead of a 16:9 one, no side reels */
html.is-mobile .pv { padding: calc(var(--safe-t) + 12px) 12px calc(var(--safe-b) + 12px); overflow: auto; place-items: start center; }
html.is-mobile .pv-frame { width: 100%; gap: 10px; }
html.is-mobile .pv-screen { aspect-ratio: 9 / 16; height: min(56vh, 520px); width: auto; justify-self: center; --rw: 0% !important; }
html.is-mobile .pv-reel { display: none; }
html.is-mobile .pv-task { left: 6%; top: 4%; }
html.is-mobile .pv-title { font-size: 24px; }
html.is-mobile .pv-sub { font-size: 9.5px; }
html.is-mobile .pv-beat { bottom: 5%; padding: 8px 12px; gap: 10px; }
html.is-mobile .pv-track { width: 90px; }
html.is-mobile .pv-e { right: 6%; bottom: 14%; font-size: 12px; }
html.is-mobile .pv-quick { left: 6%; right: 6%; width: auto; top: auto; bottom: 16%; transform: translateY(140%); }
html.is-mobile .pv-screen.quick-open .pv-quick { transform: none; }
html.is-mobile .pv-caption { font-size: 15px; min-height: 4.5em; }
html.is-mobile .pv-foot { flex-wrap: wrap; }
html.is-mobile .pv-foot .btn { min-height: 44px; }
html.is-mobile .pv { background: var(--bg); }
html.is-mobile .pv-e { display: block !important; }   /* it reads "At the edge" on a phone, so it stays although keys are hidden */
html.is-mobile .pv-stage span { padding: 0 14%; text-align: center; font-size: 11px; }
html.is-mobile details.more-rows:not(:has(.row)) { display: none; }   /* a fold whose rows are all desktop-only */

/* =====================================================================================================================
   Phone standards (Apple HIG / Material): 44 pt touch targets, readable type, safe areas, focus, motion, contrast
   ===================================================================================================================== */
/* readable type: 16 px body text; small print never under 13 px, uppercase labels never under 12 px */
html.is-mobile, html.is-mobile[data-theme] { --body-size: 16px; }
html.is-mobile body { font-size: 16px; line-height: 1.5; }
html.is-mobile :is(small, .hint, p.hint, .theme-desc, .ti-note, .reason, .lede) { font-size: 14px; }
html.is-mobile :is(.side-card h3, .wk b, .wk small, .today .when, .dial-meta .eyebrow, .readouts div, .sec-title, .section > h2, .seg button,
  .lay-head span, .other-looks summary, .rail-group, .tour-count, .switch-chip small, .ti-label, .ti-tile b, .theme-pick, .ts-btn, .brand span) { font-size: 12.5px !important; }
html.is-mobile .dial-lab { font-size: 10.5px !important; letter-spacing: 0.06em; }
html.is-mobile .btn, html.is-mobile .btn.small { font-size: 14px; }
html.is-mobile .today-more small { font-size: 14px; }
/* quieter grey text was under 4.5:1 against the background: one step stronger */
html.is-mobile :is(.hint, p.hint, .wk:not(.is-today) small, .wk:not(.is-today) b, .readouts div, .lay-head span) { color: var(--text-2); }

/* 44 px touch targets everywhere */
html.is-mobile :is(.btn, .btn.small, .icon-btn, .switch-chip, .seg button, .preset-item, summary, .search-hit, .linkish, .help-btn, .side-arrow) { min-height: 44px; }
html.is-mobile :is(.icon-btn, .help-btn) { min-width: 44px; }
html.is-mobile .help-btn { width: 44px; height: 44px; font-size: 17px; }
html.is-mobile .seg button { padding-left: 12px; padding-right: 12px; }
html.is-mobile summary { display: flex; align-items: center; }
html.is-mobile .linkish { display: inline-flex; align-items: center; }
html.is-mobile input[type="range"] { height: 44px; }
/* switches at the size of the phone's own (iOS 51x31), with a hit area that reaches 44 px */
html.is-mobile .toggle { width: 50px; height: 30px; }
html.is-mobile .toggle span { border-radius: 15px; }
html.is-mobile .toggle span::after { width: 24px; height: 24px; top: 2px; left: 2px; }
html.is-mobile .toggle input:checked + span::after { transform: translateX(20px); }
html.is-mobile .toggle input { inset: -8px -4px; }
html.is-mobile .row { min-height: 56px; }
html.is-mobile .settings-search { min-height: 44px; }

/* the tab bar: an icon over each name, as phones do */
html.is-mobile[data-theme] .tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px !important; letter-spacing: 0.04em; }
html.is-mobile .tabs button::before { content: ""; width: 24px; height: 24px; background: currentColor; -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat; }
html.is-mobile .tabs button[data-view="play"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M12 3.5v3M12 12l3.5-3.5'/%3E%3C/svg%3E"); }
html.is-mobile .tabs button[data-view="library"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Crect x='3.5' y='5' width='17' height='14' rx='2'/%3E%3Cpath d='M3.5 16l5-5 4 4 3-3 5 5'/%3E%3Ccircle cx='15.5' cy='9' r='1.4'/%3E%3C/svg%3E"); }
html.is-mobile .tabs button[data-view="history"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19.5h16M6 16l4-5 3.5 3L18 7.5'/%3E%3C/svg%3E"); }
html.is-mobile .tabs button[data-view="settings"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M4 7h10M18 7h2M4 17h4M12 17h8'/%3E%3Ccircle cx='16' cy='7' r='2'/%3E%3Ccircle cx='10' cy='17' r='2'/%3E%3C/svg%3E"); }
/* the keyboard is up: the tab bar steps aside instead of riding on top of it */
html.is-mobile.kb-open .tabs { display: none; }
html.is-mobile.kb-open #views { bottom: 0; }

/* safe areas: sheets, the tour and the help menu stay clear of the notch, the home bar and rounded corners */
html.is-mobile .tour-tip { max-height: calc(100% - var(--safe-t) - var(--safe-b) - 24px); }
html.is-mobile .help-menu { max-width: calc(100vw - 24px - var(--safe-l) - var(--safe-r)); }
@media (orientation: landscape) {
  html.is-mobile .today, html.is-mobile .page { padding-left: calc(20px + var(--safe-l)) !important; padding-right: calc(20px + var(--safe-r)) !important; }
}

/* focus that can be seen, for keyboards and switch control (never on a plain tap) */
html.is-mobile :focus { outline: none; }
html.is-mobile :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* reduced motion: no slides, springs or pulses (the beat itself still moves, it is what you follow) */
@media (prefers-reduced-motion: reduce) {
  html.is-mobile *, html.is-mobile *::before, html.is-mobile *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* smooth, native-feeling scrolling, no tap flashes or text selection on controls */
html.is-mobile .view, html.is-mobile .settings-pane, html.is-mobile .sheet-list, html.is-mobile .quick { overscroll-behavior: contain; scroll-padding-bottom: 24px; }
html.is-mobile :is(button, .btn, .tabs, .toggle, summary) { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html.is-mobile :is(button, .btn):active { opacity: 0.75; }

html.is-mobile .wk.is-today small { opacity: 1; }
html.is-mobile .dial-lab { font-size: 12px !important; letter-spacing: 0.02em; }
html.is-mobile .thumb .kind { font-size: 12px; padding: 2px 7px; }
html.is-mobile .swatches { gap: 8px; flex-wrap: wrap; }
html.is-mobile .swatches .swatch { width: 44px; height: 44px; }
html.is-mobile input[type="color"].swatch { width: 44px; height: 44px; }
html.is-mobile .lay-tick { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
html.is-mobile .lay-tick input, html.is-mobile input[type="checkbox"]:not(.toggle input) { width: 22px; height: 22px; }
html.is-mobile .theme-pick { color: inherit !important; font-weight: 600; }
html.is-mobile #game .note, html.is-mobile #game.essential .note { left: 16px; right: 16px; transform: none; max-width: none; bottom: calc(var(--safe-b) + 150px); }
/* page headings with buttons beside them: the words above, the buttons below, full width */
html.is-mobile .head-row { flex-wrap: wrap; align-items: center; gap: 12px; }
html.is-mobile .head-row > div:first-child { flex: 1 1 100%; }
html.is-mobile .head-row > .btn.primary { margin-left: auto; }
html.is-mobile #game .side-arrow { width: 44px; height: 72px; background: rgba(22,23,27,0.28); }
/* five tabs (Community joined): equal columns for however many there are */
html.is-mobile .tabs, html.is-mobile[data-theme] .tabs { grid-template-columns: none !important; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
html.is-mobile[data-theme] .tabs button { font-size: 11px !important; letter-spacing: 0.02em; overflow: hidden; }
html.is-mobile .tabs button[data-view="community"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='3.2'/%3E%3Ccircle cx='17' cy='10' r='2.4'/%3E%3Cpath d='M3.5 19c.6-3.2 3-5 5.5-5s4.9 1.8 5.5 5M15 15.2c.6-.3 1.3-.4 2-.4 2 0 3.6 1.4 4 4.2'/%3E%3C/svg%3E"); }
/* the Advanced settings switch sits in the strip as one compact chip */
html.is-mobile .settings-rail .adv-switch { flex: none; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; min-height: 44px; padding: 0 6px; margin: 0; }
html.is-mobile .settings-rail .adv-switch small { display: none; }
html.is-mobile .settings-rail .adv-switch span { display: inline; }
/* Community: search, sort and colour filters at thumb size */
html.is-mobile #view-community :is(input[type="search"], input[type="text"], select) { min-height: 44px; font-size: 16px; }
html.is-mobile #view-community :is(button, [role="button"]) { min-height: 44px; min-width: 44px; }
html.is-mobile input[type="color"].swatch-custom { width: 44px; height: 44px; min-width: 44px; }
