/* Clip Hero phone chrome and route feel. Loaded last (after shell.css).
   1. skeletons + a quicker page fade-in (all sizes)
   2. phone bar: 5-slot bottom bar with a raised Create button, slim top bar, "All pages" sheet
   3. phone layout fixes for the page modules (390px first, 360 to 430 supported)
   Tokens come from styles.css, so light and dark follow the system. */

/* ------------------------------------------------------------ 1. skeletons, page fade */
.sk { display: grid; gap: 14px; }
.sk > *, .sk-row > *, .sk-grid > * { display: block; }
.sk-h { height: 44px; width: 62%; border-radius: 10px; }
.sk-row1 { height: 18px; width: 85%; }
.sk-block { height: 150px; border-radius: 14px; }
.sk-short { height: 96px; }
.sk-bar { height: 56px; border-radius: 14px; }
.sk-row { display: flex; gap: 8px; }
.sk-chip { height: 38px; width: 84px; border-radius: 99px; }
.sk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sk-poster { aspect-ratio: 9 / 14; border-radius: 14px; }
@media (min-width: 640px) { .sk-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.view-enter { animation: view-in-fast .14s ease-out; }
@keyframes view-in-fast { from { opacity: .35; } }
.view[aria-busy="true"] { cursor: progress; }
@media (prefers-reduced-motion: reduce) { .view-enter { animation: none; } }

/* ------------------------------------------------------------ 2. phone chrome */
#tabbar.tabbar { position: fixed; }
#tabbar .uip-nav-indicator { display: none; }
.tb-back[hidden] { display: none; }
@media (min-width: 900px) {
  .tb-back, .tb-cred { display: none; }
}
.tb-ring { position: relative; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: none; border: 0; padding: 0; color: var(--text); flex: none; -webkit-tap-highlight-color: transparent; }
.tb-ring svg { position: absolute; inset: 0; width: 44px; height: 44px; }
.tb-ring.low .rr-arc { stroke: var(--warn); }
.tb-ring:focus-visible, .tb-back:focus-visible, .mtab:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.tb-credpop { padding: 16px; }
.tb-credpop .pop-h { padding-left: 0; }

@media (max-width: 899px) {
  /* top bar: [back | logo] title ............ bell ring */
  .topbar { gap: 4px; padding: env(safe-area-inset-top) 6px 0 12px; height: calc(56px + env(safe-area-inset-top)); }
  .topbar-brand { flex: none; }
  .topbar-brand .brand-name { display: none; }
  body[data-route="home"] .topbar-brand .brand-name { display: inline; }
  body.has-back .topbar-brand { display: none; }
  .page-title { display: block; flex: 1; min-width: 0; font-family: var(--display); font-stretch: 108%; font-weight: 800; font-size: 19px; letter-spacing: -.03em; line-height: 1.1; padding-left: 2px; }
  body[data-route="home"] .page-title { display: none; }
  body[data-route="home"] .topbar-right { margin-left: auto; }
  .tb-back { display: grid; place-items: center; width: 44px; height: 44px; margin-left: -8px; border: 0; border-radius: 12px; background: none; color: var(--text); flex: none; -webkit-tap-highlight-color: transparent; }
  .tb-back:active { background: var(--hover); }
  .tb-back svg { width: 24px; height: 24px; }
  .topbar-right { gap: 0; flex: none; }
  .tb-btn { width: 44px; height: 44px; border-radius: 12px; border-color: transparent; }
  .tb-btn svg { width: 22px; height: 22px; }
  .tb-count { top: 2px; right: 2px; }
  .tb-av { display: none; }
  body:not(.onboarding) .tb-cred { display: block; }
  .tb-pop { max-height: calc(100dvh - 140px); overflow: auto; }
  .nt-row { padding: 14px 8px; font-size: 15px; }
  .nt-row small { font-size: 13.5px; }

  /* bottom bar: Home, Projects, Create (raised), Editor, More */
  .tabbar.mtabs { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: end; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .mtab { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; min-height: 56px; padding: 6px 0 4px; border: 0; border-radius: 12px; background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; letter-spacing: -.005em; position: relative; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  .mtab svg { width: 25px; height: 25px; }
  .mtab:active { background: var(--hover); }
  .mtab.active { color: var(--text); }
  .mtab.active svg { color: var(--accent-text); }
  .mtab.active::before { content: ""; position: absolute; top: -4px; left: 28%; right: 28%; height: 3px; border-radius: 0 0 4px 4px; background: var(--accent); }
  .mtab-create.active::before { display: none; }
  .mtab-create { color: var(--text-2); margin-top: -20px; }
  .mtab-plus { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 0 0 5px var(--bg), 0 8px 20px -6px rgba(0, 0, 0, .55); transition: transform .12s; }
  .mtab-plus svg { width: 26px; height: 26px; color: var(--accent-ink); stroke-width: 2.2; }
  .mtab-create:active .mtab-plus { transform: scale(.94); }
  .mtab-create.active { color: var(--text); }
  .mtab-create.active svg { color: var(--accent-ink); }
  .mtab-badge { position: absolute; top: 4px; left: calc(50% + 7px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-family: var(--mono); font-size: 10.5px; font-weight: 600; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg); }
  .mtab-badge[hidden] { display: none; }
  .view { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .composer { bottom: calc(76px + env(safe-area-inset-bottom)); }

  /* slimmer banners */
  .demo-banner { flex-direction: row; text-align: left; align-items: center; gap: 10px; padding: 8px 12px; font-size: 13.5px; line-height: 1.3; }
  .demo-banner .btn { height: 40px; flex: none; white-space: nowrap; }
  .demo-banner .btn-sm { padding: 0 12px; }
  .upsell { justify-content: flex-start; text-align: left; padding: 10px 52px 10px 14px; gap: 4px 12px; font-size: 14px; line-height: 1.35; }
  .upsell button { width: 44px; height: 44px; right: 2px; }
}
@media (max-width: 899px) and (max-width: 520px) {
  .demo-banner { flex-direction: column; align-items: stretch; text-align: center; }
  .demo-banner .btn { height: 44px; }
}

/* ------------------------------------------------------------ All pages sheet */
.msheet { position: fixed; inset: 0; z-index: 120; display: none; }
.msheet:not([hidden]) { display: block; }
.ms-scrim { position: absolute; inset: 0; background: var(--scrim, rgba(6, 6, 4, .6)); opacity: 0; transition: opacity .2s; }
.msheet.in .ms-scrim { opacity: 1; }
.ms-panel { position: absolute; left: 0; right: 0; bottom: 0; top: env(safe-area-inset-top); display: flex; flex-direction: column; background: var(--bg); border-radius: 22px 22px 0 0; border: 1px solid var(--line-2); border-bottom: 0; box-shadow: var(--shadow-float); transform: translateY(100%); transition: transform .24s var(--ease-out); overscroll-behavior: contain; max-width: 640px; margin: 0 auto; }
.msheet.in .ms-panel { transform: none; }
.ms-grab { display: grid; place-items: center; height: 26px; flex: none; touch-action: none; cursor: grab; }
.ms-grab i { width: 42px; height: 5px; border-radius: 9px; background: var(--line-3); }
.ms-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 20px; flex: none; }
.ms-head h2 { margin: 0; font-family: var(--display); font-stretch: 110%; font-weight: 800; font-size: 24px; letter-spacing: -.035em; }
.ms-x { width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 14px; background: none; color: var(--text-2); }
.ms-x:active { background: var(--hover); }
.ms-x svg { width: 22px; height: 22px; }
.ms-search { flex: none; display: flex; align-items: center; gap: 10px; height: 50px; margin: 6px 16px 4px; padding: 0 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line-2); color: var(--muted); }
.ms-search:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.ms-search svg { width: 20px; height: 20px; flex: none; }
.ms-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text); font-size: 16px; -webkit-appearance: none; appearance: none; }
.ms-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.ms-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 16px calc(28px + env(safe-area-inset-bottom)); }
.ms-body h3 { margin: 22px 2px 10px; font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.ms-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ms-tile { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 12px 8px 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font: inherit; font-size: 15px; font-weight: 600; letter-spacing: -.005em; text-align: left; position: relative; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.ms-tile[hidden], .ms-grp[hidden], .ms-top[hidden], .ms-empty[hidden] { display: none; }
.ms-tile:active { background: var(--surface-2); transform: scale(.985); }
.ms-tile.on { border-color: var(--accent-line); background: var(--accent-soft); }
.ms-tile.on .ms-ic { background: var(--accent); color: var(--accent-ink); }
.ms-ic { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-3); display: grid; place-items: center; flex: none; color: var(--text-2); }
.ms-ic svg { width: 22px; height: 22px; }
.ms-lb { min-width: 0; line-height: 1.2; overflow-wrap: anywhere; }
.ms-count { position: absolute; top: 8px; right: 8px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-family: var(--mono); font-size: 11px; font-weight: 600; display: grid; place-items: center; }
.ms-top { display: grid; gap: 10px; margin-top: 10px; }
.ms-auto { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 68px; padding: 10px 16px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; }
.ms-auto.on { border-color: var(--accent-line); background: var(--accent-soft); }
.ms-auto-t b { display: block; font-size: 16px; font-weight: 700; }
.ms-auto-t small { display: block; color: var(--muted); font-size: 14px; margin-top: 1px; }
.ms-auto.on .ms-auto-t b { color: var(--accent-text); }
.ms-auto .switch { width: 54px; height: 32px; }
.ms-auto .switch .track::after { width: 24px; height: 24px; }
.ms-auto .switch input:checked + .track::after { transform: translateX(22px); }
.ms-credit { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 8px 12px 8px 16px; border-radius: 14px; border: 1px solid var(--line); }
.ms-cred-n b { font-family: var(--display); font-stretch: 112%; font-weight: 900; font-size: 26px; letter-spacing: -.04em; color: var(--accent-text); margin-right: 8px; }
.ms-cred-n span { color: var(--muted); font-size: 15px; }
.ms-credit .btn { height: 44px; padding: 0 16px; font-size: 15px; }
.ms-empty { padding: 44px 8px; text-align: center; color: var(--muted); display: grid; gap: 4px; font-size: 15px; }
.ms-empty b { color: var(--text); font-size: 17px; }
.ms-who { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.ms-who b { display: block; font-size: 16px; overflow-wrap: anywhere; }
.ms-who small { color: var(--muted); font-size: 14px; }
.ms-av { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 18px; flex: none; }
body.ms-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .ms-panel, .ms-scrim { transition: none; } }
@media (min-width: 900px) { .msheet { display: none !important; } }
.ms-panel:focus { outline: none; }

/* compact banners on phones: one line each */
@media (max-width: 899px) {
  .demo-banner .dm-x, .upsell .up-x { display: none; }
  .demo-banner, .upsell { flex-direction: row; text-align: left; }
  .demo-banner .btn { height: 40px; padding: 0 16px; }
  .upsell { padding: 4px 52px 4px 14px; min-height: 48px; align-items: center; justify-content: space-between; flex-wrap: nowrap; }
  .upsell a { white-space: nowrap; }
}

/* ------------------------------------------------------------ 3. touch targets and text floor (phones and small tablets) */
@media (max-width: 899px) {
  .btn, .btn-sm, .btn-lg { min-height: 44px; }
  .btn-sm { padding-left: 14px; padding-right: 14px; font-size: 14px; }
  .fchip, .chip, .cal-fchip, .deck-tab, .gx-tabs a, .icon-btn, .link-btn, .tm-x, .cal-mv, .ed-add, .ed-fromclips, .ed-ib, .ed-tile-x, .ed-seg button, .cal-seg button, .cal-view button, .lb-tabs button, .choice, summary { min-height: 44px; }
  .select, select { min-height: 44px; font-size: 16px; }
  .icon-btn, .ed-ib, .ed-tile-x, .tm-x { min-width: 44px; }
  .ed-tile-x { min-width: 32px; min-height: 32px; }
  .ed-seg button, .cal-seg button, .cal-view button { min-height: 40px; }
  a.link, .link { display: inline-block; padding: 10px 0; }
  input[type="checkbox"]:not(.switch input), input[type="radio"]:not(.switch input) { width: 22px; height: 22px; }
  .switch:not(.switch-lg) { width: 52px; height: 32px; }
  .switch:not(.switch-lg) .track::after { width: 24px; height: 24px; }
  .switch:not(.switch-lg) input:checked + .track::after { transform: translateX(20px); }
  /* the small print never drops below 12px, hints and captions 13.5px */
  .badge, .poster-dur, .hm-n, .fchip .n, .n, .trend-src, .trend-metric, .trend-n, .cal-t, .cal-mv, .ed-tile-dur, .ed-tile-name, .an-i, .guide-state, .bubble-time, .kicker, .eyebrow, .lb-plan, .lb-kicker, .lb-hero-note, .lb-chip, .an-t small, .an-v small, .tile-badge, .deck-tab small { font-size: 12.5px; }
  .hint, p.hint, span.hint, .muted.sm, small { font-size: 13.5px; }
  .ed-add, .ed-fromclips { font-size: 13px; }
  .an-stat > span:first-child, .an-stat span { font-size: 12px; }
  /* no hover-only reveals on touch */
  .ed-tile-x, .poster-x, .row-x { opacity: 1; }
}
@media (hover: none) {
  [class*="-x"]:not(.dm-x):not(.up-x) { opacity: 1; }
  .tile .tile-t span { display: block; }
}
@media (max-width: 899px) and (hover: none) { .tile-t span { display: none; } }

/* ------------------------------------------------------------ Editor on a phone: chat first, preview and timeline stacked and foldable */
.ed-fold { display: none; }
@media (max-width: 1023px) {
  .ed-app { grid-template-areas: "bar" "chat" "fold" "bin" "stage" "tl"; }
  .ed-fold { grid-area: fold; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit; font-size: 15px; font-weight: 600; text-align: left; width: 100%; }
  .ed-fold small { color: var(--muted); font-weight: 500; font-size: 13.5px; }
  .ed-fold svg { width: 20px; height: 20px; flex: none; color: var(--muted); transition: transform .2s; }
  .ed-app:not(.folded) .ed-fold svg { transform: rotate(180deg); }
  .ed-app.folded .ed-bin, .ed-app.folded .ed-stage, .ed-app.folded .ed-tl { display: none; }
  .ed-thread { max-height: 52vh; }
  .ed-chat { min-height: 300px; }
}

@media (max-width: 899px) {
  .td-link, .hm-sec-h a, .hm-sec a[href], .foot-links a, .acct-foot a, .view > p a, .view small a { display: inline-block; padding: 12px 6px; margin: -12px -6px; }
  .cal-num { min-width: 36px; min-height: 36px; }
  button[aria-label^="Use #"] { width: 34px !important; height: 34px !important; }
  .ed-mini, .m-t { min-height: 40px; }
  .ed-mini { padding: 0 12px; }
  .m-t { display: inline-flex; align-items: center; }
}
