/* Eclipse Lyrics — phone-first app UI
   Palette inspired by laousmail.com: gold & ember on a black stage. */

@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/outfit-400.woff2") format("woff2");
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/outfit-500.woff2") format("woff2");
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/outfit-600.woff2") format("woff2");
}

@font-face {
  font-family: "Noto Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/noto-sans-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Noto Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/noto-sans-latin-ext-400.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Noto Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/noto-sans-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Noto Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/noto-sans-latin-ext-600.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Noto Sans Tifinagh";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/noto-sans-tifinagh-400.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/noto-serif-latin-400.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Serif";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/noto-serif-latin-600.woff2") format("woff2");
}

/* Tokens live in css/tokens.css — keep a short fallback for older caches */
:root {
  /* see tokens.css */
}

.icon,
.tab-icon svg,
.dock-play svg,
.drop-icon svg,
.loaded-icon svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}

.dock-play svg {
  width: 1.35rem;
  height: 1.35rem;
}

.drop-icon svg,
.loaded-icon svg {
  width: 2rem;
  height: 2rem;
}

.line-item.is-section .text-main {
  font-style: italic;
  opacity: 0.85;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  height: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--bg);
  background: var(--bg);
  /* Allow intentional pinch (B20 a11y). Buttons/controls opt into manipulation. */
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  font: 400 1rem/1.5 var(--sans);
  color: var(--ink);
  background-color: var(--bg);
  background:
    radial-gradient(ellipse 90% 40% at 50% -5%, color-mix(in srgb, var(--feat, var(--hot)) 16%, transparent), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  overscroll-behavior: none;
  /* Fixed app shell; --kb-inset shrinks usable height when the OS keyboard opens */
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  /* Edge-to-edge under notch / home indicator when viewport-fit=cover */
  padding: 0;
  box-sizing: border-box;
}

/* Installed PWA: fill the display with no letterbox / status-bar holes */
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  html,
  body {
    background-color: var(--bg);
    background: var(--bg);
    min-height: 100%;
    min-height: 100dvh;
    min-height: 100svh;
    min-height: -webkit-fill-available;
    height: 100%;
    height: 100dvh;
    height: 100svh;
    height: -webkit-fill-available;
    max-height: 100%;
    max-height: 100dvh;
  }
  body {
    position: fixed;
    inset: 0;
    width: 100%;
    overflow: hidden;
  }
  .app {
    height: 100%;
    min-height: 100%;
    max-height: 100%;
    background-color: var(--bg);
  }
}

/* iOS home-screen launch (navigator.standalone) — same edge-to-edge fill */
html.standalone-ios,
html.standalone-ios body {
  background-color: var(--bg);
  min-height: -webkit-fill-available;
  height: -webkit-fill-available;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: 99px;
  font-weight: 600;
}
.skip-link:focus {
  left: 1rem;
  top: calc(0.5rem + var(--safe-t));
}

a {
  color: var(--gold);
}
a:hover {
  color: var(--hot);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 8px;
}

.muted {
  color: var(--mute);
}

.warn {
  margin: 0.5rem 0 0;
  color: var(--warn);
  font-size: 0.92rem;
}

.danger-text {
  color: var(--danger);
}

/* ——— App shell ——— */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: transparent;
  overflow: hidden;
  /* Landscape notches: keep chrome clear of safe edges */
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  box-sizing: border-box;
}

.app-topbar {
  /* Flex sibling of .app-screens — not sticky on the phone shell.
     Sticky + wrap previously painted the header over screen titles. */
  position: relative;
  z-index: 40;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 0.65rem;
  min-height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) var(--gutter) 0;
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--feat, var(--line)) 22%, var(--line));
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1 1 auto;
  padding: 0.45rem 0;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  flex-shrink: 0;
  background:
    radial-gradient(circle at 35% 35%, #ffd29a 0%, var(--gold) 28%, var(--hot) 62%, #2a0808 100%);
  box-shadow: 0 0 18px color-mix(in srgb, var(--hot) 40%, transparent);
}

.brand-text {
  min-width: 0;
}

.brand-name {
  margin: 0;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.brand-tag {
  margin: 0.05rem 0 0;
  font-size: 0.72rem;
  color: var(--mute);
  letter-spacing: 0.04em;
}

.icon-btn {
  width: var(--touch);
  height: var(--touch);
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}

.icon-dots {
  width: 1rem;
  height: 1rem;
  background:
    radial-gradient(circle, currentColor 1.6px, transparent 1.7px) center top / 100% 33% no-repeat,
    radial-gradient(circle, currentColor 1.6px, transparent 1.7px) center / 100% 33% no-repeat,
    radial-gradient(circle, currentColor 1.6px, transparent 1.7px) center bottom / 100% 33% no-repeat;
}

/* ——— Screens ——— */
.app-screens {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem var(--gutter) 1.25rem;
  /* Keep focused fields clear of dock/tabbar/keyboard */
  scroll-padding-bottom: calc(var(--kb-inset, 0px) + var(--tabbar-h) + var(--safe-b) + 1.25rem);
  scroll-padding-top: 1rem;
}

body.dock-on .app-screens {
  padding-bottom: calc(var(--dock-h) + 0.75rem);
  scroll-padding-bottom: calc(var(--kb-inset, 0px) + var(--dock-h) + var(--tabbar-h) + var(--safe-b) + 1.25rem);
}

body.has-tabbar .app-screens {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 0.75rem);
}

body.dock-on.has-tabbar .app-screens {
  padding-bottom: calc(var(--dock-h) + var(--tabbar-h) + var(--safe-b) + 1rem);
}

/* While typing: hide chrome that would cover the field; pad for keyboard */
body.keyboard-open .app-tabbar,
body.keyboard-open .player-dock,
body.keyboard-open .screen-tip,
body.keyboard-open .ios-install-hint,
body.keyboard-open .install-soft-tip {
  visibility: hidden;
  pointer-events: none;
}

body.keyboard-open.has-tabbar .app-screens,
body.keyboard-open.dock-on.has-tabbar .app-screens,
body.keyboard-open.dock-on .app-screens {
  padding-bottom: calc(var(--kb-inset, 0px) + 1.25rem);
  scroll-padding-bottom: calc(var(--kb-inset, 0px) + 1.5rem);
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.screen.screen-enter {
  animation: screen-in 0.32s var(--ease);
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen-head h2 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.screen-head-compact h2 {
  font-size: 1.45rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--feat, var(--gold));
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* Per-screen eyebrow accents (fallback if body[data-screen] not set yet) */
.screen[data-screen="projects"] .eyebrow { color: var(--feat-projects); }
.screen[data-screen="prepare"] .eyebrow { color: var(--feat-song); }
.screen[data-screen="sync"] .eyebrow { color: var(--feat-sync); }
.screen[data-screen="video"] .eyebrow { color: var(--feat-film); }
.screen[data-screen="export"] .eyebrow { color: var(--feat-export); }

.screen-lead {
  margin: 0.55rem 0 0;
  color: var(--mute);
  font-size: 0.95rem;
  max-width: 34ch;
}

.subhead {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}

/* ——— Controls ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: var(--touch-lg);
  padding: 0 1.35rem;
  border: 0;
  border-radius: 99px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.15s, filter 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
  filter: brightness(1.08);
}

.btn-fill {
  background: var(--grad);
  color: var(--on);
  box-shadow: 0 10px 28px -12px color-mix(in srgb, var(--hot) 70%, transparent);
}

/* One primary look on every screen, like laousmail.com; screens keep their accent
   in eyebrows, tabs and the Tap dock only. */

.btn-ghost {
  background: none;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.btn-ghost:hover:not(:disabled),
.btn-ghost:active:not(:disabled) {
  box-shadow: inset 0 0 0 1.5px var(--feat, var(--gold));
}

.btn-ok {
  background: color-mix(in srgb, var(--ok) 22%, var(--bg3));
  color: var(--ok-strong);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ok) 55%, var(--line));
}

.ok-text {
  color: var(--ok-strong);
}

.btn-sm {
  min-height: var(--touch);
  padding: 0 1rem;
  font-size: 0.9rem;
}

.btn-stack {
  display: grid;
  gap: 0.65rem;
}

.file-btn {
  cursor: pointer;
}

.field-stack {
  display: grid;
  gap: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--mute);
  min-width: 0;
}

/* ≥16px on controls — prevents iOS focus-zoom (label text can stay smaller) */
.field input,
.field textarea,
.field select,
.speed-chip select,
.url-row input,
.lyrics-row-fields input,
#field-rename,
input[type="text"],
input[type="search"],
input[type="url"],
input[type="email"],
input[type="number"],
textarea,
select {
  font-size: 16px;
  line-height: 1.35;
  color: var(--ink);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  min-height: var(--touch);
  width: 100%;
  max-width: 100%;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
}

.field textarea,
textarea {
  font-family: var(--lyric);
  min-height: 14rem;
  line-height: 1.45;
  resize: vertical;
  padding: 0.9rem;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.speed-chip select:focus {
  border-color: var(--gold);
  outline: none;
}

.field select,
.speed-chip select {
  background-image: linear-gradient(45deg, transparent 50%, var(--mute) 50%),
    linear-gradient(135deg, var(--mute) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--hot);
  min-height: 2rem;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.35;
  padding: 0.35rem 0;
}

.check-row input {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--hot);
}

.status-pill {
  margin: 0;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--mute);
  font-size: 0.9rem;
  word-break: break-word;
}

/* Drop zone as big button */
.drop-zone {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 1.75rem 1rem;
  border: 1.5px dashed color-mix(in srgb, var(--hot) 45%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--hot) 6%, var(--bg2));
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.dragover {
  border-color: var(--hot);
  background: color-mix(in srgb, var(--hot) 12%, var(--bg2));
}

.drop-zone:active {
  transform: scale(0.99);
}

.drop-icon {
  font-size: 1.75rem;
  line-height: 1;
  color: var(--gold);
  margin-bottom: 0.25rem;
}

/* Lyric language segments */
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  border-radius: 99px;
  background: var(--bg2);
  border: 1px solid var(--line);
}

.seg-btn {
  min-height: 2.4rem;
  border: 0;
  border-radius: 99px;
  background: none;
  color: var(--mute);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.seg-btn.is-active {
  background: var(--ink);
  color: var(--bg);
}

.lyric-panes {
  min-width: 0;
}

.lyric-pane {
  min-width: 0;
}

/* Sync */
.preview-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 0.2rem;
  min-height: 7.5rem;
  padding: 1.1rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse at 50% 90%, color-mix(in srgb, var(--hot) 18%, transparent), transparent 60%),
    var(--bg2);
}

.preview-prev,
.preview-next {
  margin: 0;
  min-height: 1.25em;
  font-size: 0.85rem;
  color: var(--mute);
  opacity: 0.75;
  font-family: var(--lyric);
}

.preview-current {
  margin: 0.2rem 0;
  font-family: var(--lyric);
  font-size: clamp(1.15rem, 4.5vw, 1.4rem);
  font-weight: 600;
  text-shadow: 0 0 22px color-mix(in srgb, var(--hot) 45%, transparent);
  word-break: break-word;
}

.preview-tr {
  margin: 0;
  min-height: 1.2em;
  font-family: var(--lyric);
  font-size: 0.92rem;
  color: var(--gold);
}

.waveform-wrap {
  min-width: 0;
}

#waveform {
  display: block;
  width: 100%;
  height: 110px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  touch-action: none;
  cursor: default;
}

.tip {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
}

.sync-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.speed-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--mute);
  font-size: 0.82rem;
}

.speed-chip select {
  min-height: 2.35rem;
  width: auto;
  padding: 0.35rem 2rem 0.35rem 0.7rem;
}

.time-display {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}

.line-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(42vh, 22rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  -webkit-overflow-scrolling: touch;
}

.line-item {
  display: grid;
  grid-template-columns: 4.25rem 1fr;
  gap: 0.5rem;
  padding: 0.9rem 0.9rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  cursor: pointer;
  min-height: 3.25rem;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s var(--ease);
}

.line-item.next-tap {
  background: color-mix(in srgb, var(--gold) 10%, transparent);
  box-shadow: inset 3px 0 0 var(--gold);
}

.line-item:last-child {
  border-bottom: 0;
}

.line-item:active,
.line-item.selected {
  background: color-mix(in srgb, var(--hot) 12%, transparent);
}

.line-item.selected {
  box-shadow: inset 3px 0 0 var(--hot);
}

.line-item.active-play {
  background: color-mix(in srgb, var(--hot) 18%, transparent);
}

.line-item .time {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--hot);
  padding-top: 0.2rem;
}

.line-item.untimed .time {
  color: var(--mute);
}

.line-item .text-main {
  margin: 0;
  font-family: var(--lyric);
  word-break: break-word;
}

.line-item .text-tr {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--mute);
  font-family: var(--lyric);
}

.shortcuts {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.7;
}

kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg3);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.desktop-only {
  display: none;
}

/* Export */
.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.export-tile {
  min-height: 3.5rem;
  width: 100%;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

.export-cards {
  display: grid;
  gap: 0.85rem;
}

.export-card {
  display: grid;
  gap: 0.45rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg2);
}

.export-desc {
  margin: 0;
  color: var(--mute);
  font-size: 0.88rem;
  line-height: 1.4;
}

/* Video */
.video-stage {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
  aspect-ratio: 9 / 16;
  max-height: 55vh;
  margin-inline: auto;
  width: min(100%, 280px);
}

.video-stage-compact {
  max-height: 32vh;
  width: min(100%, 200px);
}

#video-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.film-sticky {
  /* Sticky inside .app-screens (header is a sibling, not overlaid) */
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  padding-top: 0.15rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.35rem;
}

.film-scrub {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.35rem;
}

.film-scrub-field input[type="range"] {
  width: 100%;
}

.film-scrub-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.film-scrub-meta .field-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.film-scrub-meta select {
  max-width: 10rem;
}

.film-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
  margin: 0.5rem 0 0.65rem;
}

.film-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--fg-muted, var(--muted));
  border-radius: var(--radius-sm, 8px);
  padding: 0.45rem 0.25rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.film-tab.is-active {
  color: var(--fg);
  border-color: var(--accent, #ff6b35);
  background: color-mix(in srgb, var(--accent, #ff6b35) 14%, var(--bg2));
}

.film-panels {
  margin-bottom: 0.5rem;
}

.film-panel {
  animation: film-panel-in 0.22s ease;
}

@keyframes film-panel-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.film-section-range {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem 0.75rem;
  margin: 0.35rem 0;
}

.film-section-range legend {
  padding-inline: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.video-fields {
  margin-top: 0.25rem;
}

.record-progress {
  margin-top: 0.25rem;
}

.record-progress .bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg2);
  overflow: hidden;
  border: 1px solid var(--line);
}

.record-progress .bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--grad);
  transition: width 0.2s linear;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ——— Player dock ——— */
.player-dock {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 0.15rem);
  z-index: 45;
  width: min(100%, 480px);
  display: grid;
  grid-template-columns: var(--touch-lg) 1fr var(--touch) var(--touch) var(--touch);
  gap: 0.55rem;
  align-items: center;
  padding: 0.7rem max(var(--gutter), var(--safe-r)) 0.65rem max(var(--gutter), var(--safe-l));
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid color-mix(in srgb, var(--feat-sync) 25%, var(--line));
  box-shadow: 0 -12px 40px -20px rgba(0, 0, 0, 0.65);
  box-sizing: border-box;
}

.player-dock[hidden] {
  display: none !important;
}

.dock-play {
  width: var(--touch-lg);
  height: var(--touch-lg);
  border-radius: 50%;
  border: 0;
  /* Secondary to Tap — quiet surface, not competing with primary ember */
  background: var(--bg3);
  color: var(--ink);
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: inset 0 0 0 1.5px var(--line);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s var(--ease), background 0.15s, box-shadow 0.15s;
}

.dock-play:active {
  transform: scale(0.94);
  background: var(--bg2);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--feat-sync) 40%, var(--line));
}

.dock-tap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  min-height: var(--touch-lg);
  border: 0;
  border-radius: 99px;
  /* Primary sync action — hotter ember than secondary Play */
  background: var(--grad-sync);
  color: var(--on);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px -10px color-mix(in srgb, var(--feat-sync) 70%, transparent);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}

.dock-tap:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.dock-tap:active:not(:disabled) {
  transform: scale(0.98);
}

.dock-tap-label {
  font-size: 1rem;
  line-height: 1.1;
}

.dock-tap-hint {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dock-seek {
  min-width: var(--touch);
  min-height: var(--touch);
  border: 0;
  border-radius: 99px;
  background: none;
  color: var(--mute);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s var(--ease), color 0.15s;
}

.dock-seek:active {
  transform: scale(0.94);
  color: var(--ink);
}

/* ——— Tab bar ——— */
.app-tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  z-index: 50;
  width: min(100%, 480px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  min-height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0.35rem max(0.15rem, var(--safe-r)) calc(0.35rem + var(--safe-b)) max(0.15rem, var(--safe-l));
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  touch-action: manipulation;
  box-sizing: border-box;
}

/* Subtle top edge tint matches active tab feature (no pills / no rainbow strip) */
.app-tabbar:has(.tab[data-goto="projects"].is-active) {
  border-top-color: color-mix(in srgb, var(--feat-projects) 40%, var(--line));
}
.app-tabbar:has(.tab[data-goto="prepare"].is-active) {
  border-top-color: color-mix(in srgb, var(--feat-song) 40%, var(--line));
}
.app-tabbar:has(.tab[data-goto="sync"].is-active) {
  border-top-color: color-mix(in srgb, var(--feat-sync) 45%, var(--line));
}
.app-tabbar:has(.tab[data-goto="video"].is-active) {
  border-top-color: color-mix(in srgb, var(--feat-film) 45%, var(--line));
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 3.4rem;
  min-width: 0;
  padding: 0.3rem 0.1rem;
  border: 0;
  background: none;
  color: var(--mute);
  font: inherit;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: 12px;
  touch-action: manipulation;
  transition: color 0.18s var(--ease), transform 0.15s var(--ease), background 0.18s;
}

.tab > span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab:active {
  transform: scale(0.96);
  background: color-mix(in srgb, var(--feat, var(--hot)) 10%, transparent);
}

.tab-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.tab.is-active {
  color: var(--feat, var(--gold));
}

.tab.is-active .tab-icon {
  color: var(--feat, var(--hot));
}

.tab[data-goto="projects"].is-active,
.tab[data-goto="projects"].is-active .tab-icon {
  color: var(--feat-projects);
}
.tab[data-goto="prepare"].is-active,
.tab[data-goto="prepare"].is-active .tab-icon {
  color: var(--feat-song);
}
.tab[data-goto="sync"].is-active,
.tab[data-goto="sync"].is-active .tab-icon {
  color: var(--feat-sync);
}
.tab[data-goto="video"].is-active,
.tab[data-goto="video"].is-active .tab-icon {
  color: var(--feat-film);
}

/* ——— Sheets ——— */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(0, 0, 0, 0.62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.sheet-overlay[hidden] {
  display: none !important;
}

.sheet {
  width: min(100%, 480px);
  max-height: min(85dvh, 36rem);
  overflow: auto;
  padding: 1.25rem var(--gutter) calc(1.25rem + var(--safe-b));
  border-radius: 20px 20px 0 0;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-bottom: 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
  animation: sheet-up 0.28s var(--ease);
}

@keyframes sheet-up {
  from {
    transform: translateY(12%);
    opacity: 0.6;
  }
}

.sheet-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.sheet-actions {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.sheet-actions-stack .btn {
  width: 100%;
}

.sheet-list {
  display: grid;
  margin: 0.75rem 0 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg);
}

.sheet-row {
  display: flex;
  align-items: center;
  min-height: 3.15rem;
  padding: 0 1rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.sheet-row:last-child {
  border-bottom: 0;
}

.sheet-row:active {
  background: color-mix(in srgb, var(--hot) 10%, transparent);
}

.file-row {
  cursor: pointer;
}

.sheet-dismiss {
  width: 100%;
}

.site-footer {
  display: none;
}

/* ——— Desktop / wide ——— */
@media (min-width: 900px) {
  body {
    position: static;
    height: auto;
    overflow-x: clip;
    overscroll-behavior: auto;
    background:
      radial-gradient(ellipse 60% 45% at 70% 0%, color-mix(in srgb, var(--hot) 14%, transparent), transparent 55%),
      radial-gradient(ellipse 40% 30% at 10% 80%, color-mix(in srgb, var(--gold) 8%, transparent), transparent 50%),
      var(--bg);
  }

  .app {
    max-width: 720px;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--line);
    border-radius: 24px;
    overflow: hidden;
    min-height: calc(100dvh - 5rem);
    height: auto;
    background: color-mix(in srgb, var(--bg2) 70%, transparent);
    box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.85);
  }

  .app-topbar {
    position: sticky;
  }

  .app-tabbar,
  .player-dock {
    position: sticky;
    left: auto;
    transform: none;
    width: 100%;
  }

  .player-dock {
    bottom: auto;
    order: 2;
  }

  .app-tabbar {
    bottom: auto;
    order: 3;
  }

  .app {
    display: flex;
    flex-direction: column;
  }

  .app-screens {
    order: 1;
  }

  body.dock-on.has-tabbar .app-screens,
  body.has-tabbar .app-screens,
  body.dock-on .app-screens {
    padding-bottom: 1.25rem;
  }

  .desktop-only {
    display: block;
  }

  .site-footer.desktop-credit {
    display: block;
    text-align: center;
    padding: 0 1rem 2rem;
    color: var(--mute);
    font-size: 0.85rem;
  }

  .video-stage {
    width: min(100%, 320px);
  }

  .line-list {
    max-height: 28rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Keyboard open: keep dock usable on iOS */
@supports (height: 100dvh) {
  .app {
    min-height: 100%;
  }
}

/* ——— Lang switch ——— */
.topbar-tools {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
  min-width: 0;
}

/* Install never lives in the header — More sheet only */
#btn-install {
  display: none !important;
}

.app-topbar .topbar-tools {
  flex: 0 0 auto;
  gap: 0.25rem;
}

/* Progressive disclosure for secondary chrome.
   Explicit hide: our .btn/.field display rules otherwise beat the UA
   details:not([open]) > *:not(summary) { display:none }. */
details.simple-more:not([open]) > *:not(summary),
details.export-more:not([open]) > *:not(summary),
details.export-preview:not([open]) > *:not(summary) {
  display: none !important;
}

.simple-more {
  margin: 0.35rem 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  padding: 0.15rem 0.75rem 0.55rem;
}

.simple-more > summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--mute);
  padding: 0.55rem 0.15rem;
  -webkit-tap-highlight-color: transparent;
}

.simple-more > summary::-webkit-details-marker {
  display: none;
}

.simple-more > summary::after {
  content: "▸";
  float: right;
  opacity: 0.7;
}

.simple-more[open] > summary::after {
  content: "▾";
}

.simple-more .gdocs-block,
.simple-more .export-options,
.simple-more .export-cards {
  margin-top: 0.35rem;
}

.lang-pill-sheet {
  margin: 0 0 0.85rem;
  width: fit-content;
}

.sheet-lang-label {
  margin: 0 0 0.35rem;
}

.sync-toolbar-simple {
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
}

.sync-toolbar-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-bottom: 0.25rem;
}

.film-customize {
  margin-top: 0.75rem;
}

.prepare-lyrics-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.slider-compact .slider-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--mute);
  margin-bottom: 0.2rem;
}

.slider-compact .slider-short {
  font-weight: 600;
  color: var(--mute);
  margin-inline-end: 0.25rem;
}

.wave-scrub-combo {
  position: relative;
  gap: 0;
}

.wave-tools-icons {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  z-index: 2;
  display: flex;
  gap: 0.2rem;
  margin: 0;
}

.wave-icon-btn {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  font-size: 0.75rem;
  padding: 0;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-color: var(--line);
}

.wave-icon-btn.is-active {
  border-color: var(--hot);
  color: var(--hot);
}

.wave-scrub-combo #waveform {
  display: block;
  width: 100%;
  border-radius: 10px 10px 0 0;
}

.wave-scrub-combo .scrubber-in-wave {
  margin-top: -0.15rem;
  height: 1.35rem;
  border-radius: 0 0 10px 10px;
  background: var(--bg2);
}

.lang-pill,
.lang-row {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 3px;
  gap: 2px;
}

.lang-row {
  margin: 0.75rem 0 1rem;
  width: fit-content;
}

.lang-btn {
  min-width: 2.6rem;
  min-height: 2.4rem;
  border: 0;
  border-radius: 99px;
  background: none;
  color: var(--mute);
  font: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s, transform 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.lang-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

.lang-btn:active {
  transform: scale(0.96);
}

/* ——— Audio loaded / URL / Google Docs ——— */
.audio-pick,
.audio-loaded {
  display: grid;
  gap: 0.85rem;
}

.url-block,
.gdocs-block {
  display: grid;
  gap: 0.45rem;
}

.url-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  align-items: stretch;
}

.url-row .btn {
  min-width: 6.5rem;
  white-space: nowrap;
}

.url-row input {
  font-size: 16px;
  color: var(--ink);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  min-height: var(--touch);
  width: 100%;
}

.url-row input:focus {
  border-color: var(--gold);
  outline: none;
}

.loaded-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--hot) 35%, var(--line));
  background: color-mix(in srgb, var(--hot) 8%, var(--bg2));
  animation: success-pop 0.4s var(--ease);
}

.loaded-icon {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--grad);
  color: var(--on);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.loaded-name {
  margin: 0;
  font-weight: 600;
  word-break: break-word;
}

.loaded-meta .muted {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
}

.meta-prompt {
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px dashed color-mix(in srgb, var(--gold) 45%, var(--line));
  background: color-mix(in srgb, var(--gold) 6%, transparent);
  animation: screen-in 0.35s var(--ease);
}

.prompt-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

@keyframes success-pop {
  from {
    opacity: 0.4;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ——— Scrubber (deliberate seek — separated from Tap) ——— */
.scrubber-block {
  display: grid;
  gap: 0.45rem;
  padding: 0.85rem 0.9rem 1rem;
  margin: 0.15rem 0;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg2);
}

.scrubber-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.scrubber {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2.75rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.scrubber::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--hot) 55%, var(--line)),
    var(--line)
  );
}

.scrubber::-moz-range-track {
  height: 8px;
  border-radius: 99px;
  background: var(--line);
}

.scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--grad);
  border: 2px solid #fff2;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--hot) 45%, transparent);
  transition: transform 0.15s var(--ease);
}

.scrubber::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: var(--grad);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--hot) 45%, transparent);
}

.scrubber.is-scrubbing::-webkit-slider-thumb,
.scrubber:active::-webkit-slider-thumb {
  transform: scale(1.12);
}

/* Tap confirmation flash */
.tap-flash {
  animation: tap-pulse 0.35s var(--ease);
}

@keyframes tap-pulse {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  40% {
    transform: scale(1.03);
    filter: brightness(1.2);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.preview-current.tap-flash {
  text-shadow: 0 0 28px color-mix(in srgb, var(--gold) 70%, transparent);
}

.dock-tap.tap-flash {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 45%, transparent),
    0 8px 28px -8px color-mix(in srgb, var(--hot) 80%, transparent);
}

/* Clear separation: sync content vs scrub vs dock */
.screen-sync .waveform-wrap {
  margin-bottom: 0.15rem;
}

.screen-sync .line-list {
  max-height: none;
  flex: 1;
  min-height: 0;
}

/* ——— Phase 2: Sync workspace + lyrics grid ——— */
.desktop-workspace-only {
  display: none;
}

.sync-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.progress-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.55rem 0.25rem 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg2);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--mute);
  white-space: nowrap;
}

.progress-ring {
  width: 1.35rem;
  height: 1.35rem;
  transform: rotate(-90deg);
}

.progress-ring-bg,
.progress-ring-fg {
  fill: none;
  stroke-width: 3;
}

.progress-ring-bg {
  stroke: color-mix(in srgb, var(--line) 90%, transparent);
}

.progress-ring-fg {
  stroke: var(--feat-sync);
  stroke-linecap: round;
  stroke-dasharray: 94.2;
  stroke-dashoffset: 94.2;
  transition: stroke-dashoffset 0.2s var(--ease), stroke 0.2s var(--ease);
}

.progress-chip.is-complete {
  border-color: color-mix(in srgb, var(--ok) 50%, var(--line));
  color: var(--ok-strong);
}
.progress-chip.is-complete .progress-ring-fg {
  stroke: var(--ok-strong);
}

.offset-chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}

.sync-toolbar {
  margin-top: 0.55rem;
}

.screen-sync {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  gap: 0.45rem;
  padding-bottom: 0.25rem;
}

.screen-sync .screen-head-compact {
  flex: 0 0 auto;
  margin-bottom: 0;
}

.sync-workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0.4rem;
}

.sync-preview-col {
  flex: 0 0 auto;
}

.sync-list-col {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sync-wave-col {
  flex: 0 0 auto;
}

.preview-compact {
  min-height: 0;
  padding: 0.55rem 0.75rem 0.65rem;
  gap: 0.1rem;
}

.preview-compact .preview-current {
  font-size: clamp(1.35rem, 6.2vw, 1.9rem);
  line-height: 1.2;
  margin: 0;
}

.preview-compact .preview-next {
  font-size: 0.95rem;
  opacity: 0.55;
  min-height: 1.1em;
}

.preview-compact .preview-tr {
  font-size: 0.82rem;
  min-height: 0;
}

.waveform-strip {
  position: relative;
  display: grid;
  gap: 0.25rem;
}

.waveform-strip #waveform {
  height: 60px;
  border-radius: 10px;
}

.wave-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.scrubber-in-wave {
  width: 100%;
  margin: 0;
  height: 1.1rem;
}

.line-item {
  grid-template-columns: 4.25rem 1fr auto;
  align-items: start;
}

.line-item .line-actions {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-end;
}

.line-menu-btn,
.line-nudge,
.line-replay {
  min-height: 1.75rem;
  min-width: 1.75rem;
  padding: 0.15rem 0.35rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--ink);
  font-size: 0.75rem;
  cursor: pointer;
}

.line-item.is-section {
  background: color-mix(in srgb, var(--gold) 6%, transparent);
  opacity: 0.9;
}

.line-item.is-section .text-main {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: var(--gold);
}

.review-on .line-actions .line-nudge,
.review-on .line-actions .line-replay {
  display: inline-flex;
}

.line-actions .line-nudge,
.line-actions .line-replay {
  display: none;
}

.calibrate-status {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin: 0.5rem 0;
}

.calibrate-pulse {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0.5rem auto 1rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--hot) 35%, transparent);
  border: 2px solid var(--hot);
  opacity: 0.35;
  transition: transform 0.08s ease, opacity 0.08s ease;
}

.calibrate-pulse.is-beat {
  opacity: 1;
  transform: scale(1.12);
  background: color-mix(in srgb, var(--hot) 70%, transparent);
}

/* Lyrics grid */
.lyrics-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.lyrics-grid {
  display: grid;
  gap: 0.45rem;
  max-height: min(52vh, 28rem);
  overflow: auto;
  padding: 0.15rem;
  -webkit-overflow-scrolling: touch;
}

.lyrics-row {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.4rem;
  align-items: start;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
}

.lyrics-row.is-mismatch {
  border-color: color-mix(in srgb, var(--hot) 55%, var(--line));
  background: color-mix(in srgb, var(--hot) 8%, var(--bg2));
}

.lyrics-row.is-section-row {
  border-style: dashed;
  background: color-mix(in srgb, var(--gold) 7%, var(--bg2));
}

.lyrics-row.is-over {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 50%, transparent);
}

.lyrics-row-num {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--mute);
  padding-top: 0.55rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.lyrics-row-fields {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.lyrics-row-fields input {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--lyric);
  font-size: 16px; /* iOS: no focus-zoom */
}

.lyrics-row-fields input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--hot) 70%, transparent);
  outline-offset: 1px;
}

.kabyle-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.35rem 0;
}

.kabyle-key {
  min-width: 2.35rem;
  min-height: 2.35rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--ink);
  font-family: var(--lyric);
  font-size: 1.05rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.kabyle-key:active {
  background: color-mix(in srgb, var(--hot) 22%, var(--bg3));
}

.step-seg {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.2rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg2);
  flex-shrink: 1;
  min-width: 0;
  overflow-x: auto;
}

/* Must beat .step-seg { display:inline-flex } — was overlapping brand on phones */
.step-seg.desktop-workspace-only,
.desktop-workspace-only {
  display: none;
}

.step-seg-btn {
  border: 0;
  background: transparent;
  color: var(--mute);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
}

.step-seg-btn.is-active {
  background: var(--ink);
  color: var(--bg);
}

/* Mobile Sync: fit preview + list + 60px wave + dock on ~390px */
@media (max-width: 1023px) {
  #screen-sync.is-active {
    /* Fill the app screens area above dock/tabbar */
    height: calc(100dvh - var(--topbar-h, 3.5rem) - var(--tabbar-h, 3.5rem) - 4.75rem - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - var(--topbar-h, 3.5rem) - var(--tabbar-h, 3.5rem) - 4.75rem - env(safe-area-inset-bottom, 0px));
  }

  body.dock-on.has-tabbar #screen-sync.is-active {
    height: calc(100dvh - var(--topbar-h, 3.5rem) - var(--tabbar-h, 3.5rem) - 5.25rem - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - var(--topbar-h, 3.5rem) - var(--tabbar-h, 3.5rem) - 5.25rem - env(safe-area-inset-bottom, 0px));
  }

  .screen-sync .sync-toolbar {
    gap: 0.35rem;
  }

  .screen-sync .sync-toolbar .btn-sm,
  .screen-sync .offset-chip,
  .screen-sync .time-display {
    font-size: 0.7rem;
  }

  .wave-tools {
    display: none;
  }
}

@media (min-width: 720px) {
  .lyrics-row-fields {
    grid-template-columns: 1.2fr 1fr 1fr;
  }
}

/* Desktop workspace ≥1024 */
@media (min-width: 1024px) {
  .desktop-workspace-only,
  .step-seg.desktop-workspace-only {
    display: inline-flex;
  }

  body {
    position: static;
    height: auto;
    overflow-x: clip;
  }

  .app {
    max-width: min(1440px, 100%);
    width: 100%;
    margin: 0 auto;
    min-height: 100dvh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .app-topbar {
    gap: 1rem;
  }

  .app-tabbar {
    display: none;
  }

  body.has-tabbar .app-screens,
  body.dock-on.has-tabbar .app-screens,
  body.dock-on .app-screens {
    padding-bottom: 1rem;
  }

  #screen-sync.is-active {
    height: calc(100dvh - 4.5rem);
    max-height: calc(100dvh - 4.5rem);
  }

  .sync-workspace {
    display: grid;
    grid-template-columns: minmax(280px, 40%) 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "list preview"
      "wave wave";
    gap: 0.75rem;
    flex: 1;
    min-height: 0;
  }

  .sync-list-col {
    grid-area: list;
  }

  .sync-preview-col {
    grid-area: preview;
  }

  .sync-wave-col {
    grid-area: wave;
  }

  .preview-compact {
    height: 100%;
    min-height: 12rem;
    justify-content: center;
  }

  .preview-compact .preview-current {
    font-size: clamp(1.8rem, 3vw, 2.4rem);
  }

  .waveform-strip #waveform {
    height: 160px;
  }

  .wave-tools {
    display: flex;
  }

  .player-dock {
    position: static;
    transform: none;
    width: 100%;
    max-width: none;
    border-radius: 14px;
    margin: 0.5rem 0 0;
    border: 1px solid var(--line);
  }

  .site-footer.desktop-credit {
    display: none;
  }
}

/* ——— Toast ——— */
.toast {
  position: fixed;
  left: 50%;
  /* Sit above tabbar (+ dock when visible); rise with keyboard */
  bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--kb-inset, 0px) + 0.65rem);
  transform: translateX(-50%) translateY(0.5rem);
  z-index: 80;
  max-width: min(92vw, 22rem);
  padding: 0.7rem 1rem;
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--surface, #1a1412) 92%, #000);
  border: 1px solid color-mix(in srgb, var(--gold, #ffb347) 35%, transparent);
  color: var(--text, #f2e9dd);
  font-size: 0.9rem;
  line-height: 1.35;
  box-shadow: 0 10px 28px -12px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .screen.screen-enter,
  .tap-flash,
  .loaded-card,
  .meta-prompt {
    animation: none !important;
  }

  .toast {
    transition: none;
  }
}

/* ——— Phase 3: Projects + Export ——— */
.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast-action {
  border: 0;
  background: transparent;
  color: var(--gold);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.projects-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.projects-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.project-card {
  position: relative;
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg2);
}

.project-thumb {
  width: 96px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.project-title {
  margin: 0;
  font-weight: 600;
  font-family: var(--display, Outfit, sans-serif);
}

.project-sub,
.project-progress {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.project-progress {
  color: var(--hot);
  font-family: var(--mono);
}

.project-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.project-menu {
  position: absolute;
  right: 0.75rem;
  top: calc(100% - 0.35rem);
  z-index: 5;
  display: grid;
  min-width: 9rem;
  padding: 0.35rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg3);
  box-shadow: 0 12px 28px -16px rgba(0, 0, 0, 0.7);
}

.project-menu[hidden] {
  display: none;
}

.project-menu button {
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.project-menu button:hover,
.project-menu button:focus-visible {
  background: color-mix(in srgb, var(--hot) 16%, transparent);
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
}

.song-details-card,
.export-card-primary {
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg2);
  display: grid;
  gap: 0.65rem;
}

.export-card-primary {
  border-color: color-mix(in srgb, var(--hot) 45%, var(--line));
  background:
    radial-gradient(ellipse at 10% 0%, color-mix(in srgb, var(--hot) 16%, transparent), transparent 55%),
    var(--bg2);
}

.export-primary-title {
  margin: 0;
  font-size: 1.05rem;
}

.export-options {
  display: grid;
  gap: 0.55rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.export-more,
.export-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  background: var(--bg2);
}

.export-more summary,
.export-preview summary {
  cursor: pointer;
  font-weight: 600;
}

.export-preview-code {
  margin: 0.55rem 0 0;
  max-height: 14rem;
  overflow: auto;
  padding: 0.75rem;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 720px) {
  .export-options {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ——— Phase 5: PWA / onboarding / help ——— */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
}
.intro-overlay[hidden] { display: none !important; }
.intro-card {
  width: min(100%, 26rem);
  background: linear-gradient(165deg, var(--bg3), var(--bg2));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.25rem 1.1rem;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45);
  animation: film-panel-in 0.28s var(--ease);
}
.intro-card h2 {
  margin: 0.15rem 0 0.5rem;
  font-size: var(--fs-xl);
  line-height: var(--lh-tight);
}
.intro-body { margin: 0 0 1rem; color: var(--mute); }
.intro-dots {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.intro-dots span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 99px;
  background: var(--line);
}
.intro-dots span.is-on { background: var(--hot); }
.intro-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.intro-demo { width: 100%; margin-top: 0.65rem; }

.screen-tip {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 0.75rem);
  z-index: 80;
  width: min(100% - 1.5rem, 26rem);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}
.screen-tip[hidden] { display: none !important; }
.screen-tip p { margin: 0; flex: 1; font-size: var(--fs-sm); color: var(--ink); }

.ios-install-hint {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  /* Sit below the app header — never cover brand / lang / More */
  top: calc(var(--safe-t) + var(--topbar-h) + 0.4rem);
  z-index: 55;
  width: min(100% - 1.5rem, 24rem);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ios-install-hint[hidden] { display: none !important; }
.ios-install-hint p { margin: 0; flex: 1; font-size: var(--fs-sm); }

/* One-time soft tip above the tab bar — does not cover header or primary content */
.install-soft-tip {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 0.55rem);
  z-index: 42;
  width: min(100% - 1.5rem, 22rem);
  display: flex;
  gap: 0.45rem;
  align-items: center;
  padding: 0.45rem 0.65rem;
  background: color-mix(in srgb, var(--bg3) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px -16px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.install-soft-tip[hidden] { display: none !important; }
.install-soft-tip p {
  margin: 0;
  flex: 1;
  font-size: var(--fs-sm);
  color: var(--mute);
  line-height: 1.25;
}
body.dock-on .install-soft-tip {
  /* Stay clear of the player dock when sync/playback chrome is up */
  bottom: calc(var(--dock-h) + var(--tabbar-h) + var(--safe-b) + 0.55rem);
}
@media (min-width: 900px) {
  .install-soft-tip { display: none !important; }
}

.sheet-row-install {
  font-weight: 600;
  color: var(--feat-song);
}

#btn-sheet-export {
  color: var(--feat-export);
  font-weight: 600;
}

.install-steps {
  margin: 0.5rem 0 0.75rem;
  padding-left: 1.2rem;
  color: var(--ink);
  font-size: var(--fs-md);
  line-height: 1.45;
}
.install-steps li { margin: 0.4rem 0; }

.help-block {
  margin: 0 0 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.help-block h3 {
  margin: 0 0 0.45rem;
  font-size: var(--fs-lg);
}
.help-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--mute);
}
.help-list li { margin: 0.3rem 0; }
.help-list kbd {
  font: 600 0.78em/1 var(--mono);
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg2);
  color: var(--ink);
}
.privacy-note { font-size: var(--fs-xs); max-width: 40rem; }
.projects-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; }

body.dock-on .screen-tip {
  bottom: calc(var(--tabbar-h) + var(--dock-h) + var(--safe-b) + 0.5rem);
}

body.dock-on .toast {
  bottom: calc(var(--tabbar-h) + var(--dock-h) + var(--safe-b) + var(--kb-inset, 0px) + 0.65rem);
}

/* Keyboard open: chrome hidden — toast sits just above the keyboard */
body.keyboard-open .toast,
body.keyboard-open.dock-on .toast {
  bottom: calc(var(--kb-inset, 0px) + var(--safe-b) + 0.75rem);
}

/* Sheets: keep above keyboard when open */
body.keyboard-open .sheet-overlay {
  align-items: flex-end;
  padding-bottom: var(--kb-inset, 0px);
}

body.keyboard-open .sheet {
  max-height: min(70dvh, calc(100dvh - var(--kb-inset, 0px) - 2rem));
  overflow: auto;
}

/* Waveform: intentional pinch only here (own handlers); block browser pan-zoom */
#waveform,
.waveform-wrap {
  touch-action: none;
}

/* Primary chrome: no double-tap zoom */
.btn,
.icon-btn,
.dock-play,
.dock-tap,
.dock-seek,
.lang-btn,
.step-seg-btn,
.kabyle-key {
  touch-action: manipulation;
}

/* Ensure muted text meets contrast on dark bg */
.muted, .tip, .screen-lead, .brand-tag {
  color: var(--mute);
}
