/* Lirik — Apple-style reading surface: translucent chrome, light-catching edges,
   system type with size-specific tracking, springs and 1:1 press feedback. */

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

/* The hidden attribute must win: a component that sets its own display
   (grid, inline-grid, flex) would otherwise keep showing an element the app
   has hidden — an empty-state card or the back button on the home page. */
[hidden] { display: none !important; }

:root {
  color-scheme: light dark;

  --bg: #f7f5f2;
  --surface: rgba(255, 255, 255, 0.62);
  --surface-solid: #fffdfa;
  --stroke: rgba(28, 25, 20, 0.08);
  --stroke-strong: rgba(28, 25, 20, 0.14);
  --ink: #1b1917;
  --ink-soft: #615b53;
  --accent: #0a6cff;
  --accent-soft: rgba(10, 108, 255, 0.14);
  --edge: rgba(255, 255, 255, 0.45);
  --shadow: 0 1px 2px rgba(28, 25, 20, 0.05), 0 16px 40px -16px rgba(28, 25, 20, 0.24);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --bg-image:
    radial-gradient(90rem 40rem at 8% -14%, rgba(255, 255, 255, 0.92), transparent 62%),
    radial-gradient(70rem 34rem at 94% -8%, rgba(255, 213, 176, 0.45), transparent 60%),
    var(--bg);
  --bg-image-dark:
    radial-gradient(90rem 40rem at 10% -16%, rgba(58, 86, 140, 0.38), transparent 62%),
    radial-gradient(70rem 34rem at 94% -6%, rgba(120, 70, 120, 0.26), transparent 60%),
    var(--bg);
}

/* Dark palette applies to the system preference unless the user chose light,
   and always when the user chose dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0e;
    --surface: rgba(30, 32, 37, 0.6);
    --surface-solid: #16181c;
    --stroke: rgba(255, 255, 255, 0.08);
    --stroke-strong: rgba(255, 255, 255, 0.16);
    --ink: #f4f2ef;
    --ink-soft: #a8a29a;
    --accent: #6fa8ff;
    --accent-soft: rgba(111, 168, 255, 0.18);
    --edge: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 20px 44px -18px rgba(0, 0, 0, 0.8);
    --bg-image: var(--bg-image-dark);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c0e;
  --surface: rgba(30, 32, 37, 0.6);
  --surface-solid: #16181c;
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-strong: rgba(255, 255, 255, 0.16);
  --ink: #f4f2ef;
  --ink-soft: #a8a29a;
  --accent: #6fa8ff;
  --accent-soft: rgba(111, 168, 255, 0.18);
  --edge: rgba(255, 255, 255, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 20px 44px -18px rgba(0, 0, 0, 0.8);
  --bg-image: var(--bg-image-dark);
}

:root[data-theme="light"] { color-scheme: light; }

html {
  -webkit-text-size-adjust: 100%;
  /* No smooth scrolling: the autoscroll loop writes scrollTop every frame and
     smooth-behavior would animate (and throttle) each of those writes. */
  scroll-behavior: auto;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-optical-sizing: auto;
  color: var(--ink);
  background: var(--bg-image);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 240ms var(--ease), color 240ms var(--ease);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}
.skip:focus { left: 16px; }

/* ---------- Floating chrome ---------- */

.chrome {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: max(14px, env(safe-area-inset-top)) clamp(16px, 4vw, 32px) 16px;
}

/* Material: translucent layer that content scrolls under, with a soft bottom edge. */
.chrome::before {
  content: "";
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-mask-image: linear-gradient(to bottom, #000 58%, transparent);
  mask-image: linear-gradient(to bottom, #000 58%, transparent);
  pointer-events: none;
}

.chrome::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -18px;
  height: 18px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 70%, transparent), transparent);
  pointer-events: none;
}

.chrome-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 46rem;
  margin: 0 auto;
}

.bar-left,
.bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 1.02rem;
  font-weight: 660;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  border-radius: 10px;
}
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--accent) 70%, transparent);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink);
  cursor: pointer;
  transition: transform 120ms ease-out, background 200ms var(--ease), opacity 120ms linear;
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 11%, transparent); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
.back-btn { margin-right: -2px; }

.theme-btn .icon { width: 17px; height: 17px; }
.theme-btn .icon-sun {
  display: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.theme-btn.is-dark .icon-moon { display: none; }
.theme-btn.is-dark .icon-sun { display: block; }

/* ---------- Segmented control ---------- */

.segmented {
  position: relative;
  display: flex;
  width: 10.75rem;
  padding: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  box-shadow: inset 0 0 0 1px var(--stroke);
}

.segmented-thumb {
  position: absolute;
  z-index: 0;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border-radius: 999px;
  background: var(--surface-solid);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.05);
  transition: transform 380ms var(--ease);
}

.segmented[data-mode="edit"] .segmented-thumb { transform: translateX(100%); }

.segment {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 7px 0;
  border: 0;
  border-radius: 999px;
  background: none;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 220ms var(--ease), opacity 120ms linear;
}

.segment[aria-selected="true"] { color: var(--ink); }
.segment:active { opacity: 0.6; }
.segment:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Chrome only carries song controls inside a song. */
body[data-view="home"] .segmented { display: none; }

/* ---------- Views ---------- */

main {
  padding: 0 clamp(18px, 5vw, 40px) 9rem;
}

.view {
  max-width: 44rem;
  margin: 0 auto;
}
body[data-view="home"] main { padding-bottom: 4rem; }
body[data-view="home"] .dock { display: none; }

.view.is-entering { animation: view-in 340ms var(--ease-out) both; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Home ---------- */

.home-head {
  padding-top: clamp(16px, 3vw, 28px);
}

.page-title {
  margin: 0;
  font-size: clamp(2.1rem, 1.3rem + 2.8vw, 3.2rem);
  font-weight: 740;
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.library-count {
  margin: 8px 0 0;
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--ink-soft);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: clamp(16px, 3vw, 24px) 0 18px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border-radius: 14px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  box-shadow: inset 0 0 0 1px var(--stroke), inset 0 1px 0 var(--edge);
  transition: box-shadow 220ms var(--ease), background 220ms var(--ease);
}
.search:focus-within {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent), 0 0 0 4px var(--accent-soft);
}

.search-icon {
  flex: none;
  width: 17px;
  height: 17px;
  margin-right: 8px;
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 1.9;
  stroke-linecap: round;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.94rem;
  letter-spacing: -0.005em;
  color: var(--ink);
  outline: none;
}
.search input::placeholder { color: color-mix(in srgb, var(--ink-soft) 78%, transparent); }
.search input::-webkit-search-cancel-button { display: none; }

.search-clear {
  flex: none;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}
.search-clear:active { transform: scale(0.92); }

.new-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 90%, transparent);
  transition: transform 120ms ease-out, filter 200ms var(--ease);
}
.new-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.new-btn:active { transform: scale(0.94); filter: brightness(0.94); }
.new-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.ghost-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--stroke), inset 0 1px 0 var(--edge);
  transition: transform 120ms ease-out, background 200ms var(--ease);
}
.ghost-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ghost-btn:hover { background: var(--surface-solid); }
.ghost-btn:active { transform: scale(0.94); }
.ghost-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Grouped library list */

.library {
  border-radius: 20px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  box-shadow: inset 0 0 0 1px var(--stroke), inset 0 1px 0 var(--edge), var(--shadow);
  overflow: hidden;
}
.library:empty { display: none; }

.song-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  color: var(--ink);
  text-decoration: none;
  transition: background 160ms var(--ease), opacity 120ms linear;
}
.song-row + .song-row { box-shadow: inset 0 1px 0 var(--stroke); }
.song-row:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.song-row:active { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.song-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
  border-radius: 12px;
}

.song-main { min-width: 0; flex: 1; }

.song-row-title {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-row-sub {
  margin-top: 2px;
  font-size: 0.8rem;
  letter-spacing: 0.002em;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-row .chev {
  flex: none;
  width: 7px;
  height: 7px;
  margin-right: 2px;
  border-right: 1.8px solid color-mix(in srgb, var(--ink-soft) 75%, transparent);
  border-bottom: 1.8px solid color-mix(in srgb, var(--ink-soft) 75%, transparent);
  transform: rotate(-45deg);
}

.library-empty {
  display: grid;
  gap: 8px;
  justify-items: start;
  padding: 26px 20px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--stroke);
}
.library-empty p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.5; }
.library-empty strong { color: var(--ink); font-weight: 600; }
.library-empty button {
  margin-top: 6px;
  padding: 9px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 620;
  cursor: pointer;
}
.library-empty button:active { transform: scale(0.97); }

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
}

.page-arrow,
.page-btn {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--stroke), inset 0 1px 0 var(--edge);
  transition: transform 120ms ease-out, background 200ms var(--ease), filter 200ms var(--ease);
}

.page-arrow { padding: 0; border-radius: 999px; }
.page-arrow svg { width: 16px; height: 16px; fill: currentColor; }

.page-arrow:hover:not(:disabled),
.page-btn:hover { background: var(--surface-solid); }
.page-arrow:active:not(:disabled),
.page-btn:active { transform: scale(0.94); }
.page-arrow:disabled { opacity: 0.38; cursor: default; }

.page-btn.is-current {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px -10px color-mix(in srgb, var(--accent) 90%, transparent);
}
.page-btn.is-current:hover { background: var(--accent); filter: brightness(1.04); }

/* The dark palette's accent is a light blue, so white numerals on it would
   wash out; dark ink reads clearly on the same chip. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .page-btn.is-current { color: #0b0c0e; }
}
:root[data-theme="dark"] .page-btn.is-current { color: #0b0c0e; }

.page-gap {
  display: inline-grid;
  place-items: center;
  min-width: 12px;
  height: 36px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  letter-spacing: 0.02em;
}

.page-summary {
  margin-left: auto;
  padding-left: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
}

.page-arrow:focus-visible,
.page-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Song ---------- */

.song-title {
  display: block;
  width: 100%;
  margin: clamp(14px, 3vw, 26px) 0 2px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: clamp(1.8rem, 1.1rem + 2.4vw, 2.9rem);
  font-weight: 720;
  line-height: 1.04;
  letter-spacing: -0.035em;
  color: var(--ink);
}
.song-title::placeholder { color: color-mix(in srgb, var(--ink) 24%, transparent); }
.song-title:focus { outline: none; }
.song-title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.song-artist {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 550;
  letter-spacing: 0.005em;
  color: var(--ink-soft);
}
.song-artist::placeholder { color: color-mix(in srgb, var(--ink) 24%, transparent); }
.song-artist:focus { outline: none; }
.song-artist:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.reader {
  padding: 1.1rem 0 2rem;
  font-size: clamp(1.06rem, 0.94rem + 0.5vw, 1.32rem);
  line-height: 1.62;
  letter-spacing: -0.008em;
  outline: none;
}
.reader:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
  border-radius: 12px;
}
.reader.is-entering { animation: view-in 320ms var(--ease-out) both; }

/* One lyric line is a row of columns: chord on top, the syllable it belongs
   to underneath. Chords therefore sit exactly over their word and reflow with
   the text instead of drifting out of alignment. */
.line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  min-height: 1.2em;
}

.phrase {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.phrase-lyric { white-space: pre-wrap; }

.gap { height: 0.85em; }

.section {
  margin: 1.9em 0 0.75em;
  font-size: 0.7rem;
  font-weight: 680;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.chord-row {
  margin: 0.95em 0 0.1em;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82em;
  font-weight: 650;
  letter-spacing: 0.015em;
  color: var(--accent);
  white-space: pre;
  overflow-x: auto;
  scrollbar-width: none;
}
.chord-row::-webkit-scrollbar { display: none; }

.chord {
  margin-bottom: 0.1em;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.74em;
  font-weight: 680;
  line-height: 1.25;
  letter-spacing: 0.005em;
  color: var(--accent);
  white-space: nowrap;
}
.chord:empty { display: none; }

.marker {
  margin-right: 0.3em;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ink-soft) 80%, transparent);
}

.hint {
  margin-top: 2.4rem;
  font-size: 0.76rem;
  letter-spacing: 0.01em;
  color: color-mix(in srgb, var(--ink-soft) 85%, transparent);
}

/* Empty reader */

.empty {
  display: grid;
  gap: 10px;
  padding: 2rem 0 1rem;
  max-width: 26rem;
}
.empty h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 680;
  letter-spacing: -0.02em;
}
.empty p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
.empty button {
  justify-self: start;
  margin-top: 10px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 620;
  cursor: pointer;
  transition: transform 120ms ease-out, filter 200ms var(--ease);
}
.empty button:active { transform: scale(0.97); filter: brightness(0.94); }
.empty button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Editor */

.editor {
  width: 100%;
  min-height: min(62vh, 38rem);
  margin-top: 1.1rem;
  padding: 1.25rem 1.35rem;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  box-shadow: inset 0 0 0 1px var(--stroke), inset 0 1px 0 var(--edge), var(--shadow);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.94rem;
  line-height: 1.75;
  color: var(--ink);
  tab-size: 4;
  resize: vertical;
  outline: none;
  transition: box-shadow 220ms var(--ease);
}
.editor::placeholder { color: color-mix(in srgb, var(--ink) 30%, transparent); }
.editor:focus-visible {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent), var(--shadow);
}
.editor.is-entering { animation: view-in 320ms var(--ease-out) both; }

.delete-btn {
  margin-top: 14px;
  padding: 8px 4px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 560;
  color: #d1475a;
  cursor: pointer;
}
.delete-btn:hover { color: #e05266; text-decoration: underline; text-underline-offset: 3px; }
.delete-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Prev / next song — lives in the floating dock */

.dock-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}
.dock-nav[hidden] { display: none; }

.nav-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  transition: background 200ms var(--ease), transform 140ms var(--ease-out);
}
.nav-btn[hidden] { display: none; }
.nav-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.nav-btn:active { transform: scale(0.9); }
.nav-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-btn svg { width: 17px; height: 17px; fill: currentColor; }

.dock-nav-count {
  min-width: 2.6rem;
  font-size: 0.68rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--ink-soft);
}

/* Import sheet */

.sheet {
  width: min(38rem, calc(100vw - 28px));
  max-height: min(88vh, 46rem);
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: var(--surface-solid);
  color: var(--ink);
  overflow: auto;
  box-shadow: var(--shadow), inset 0 0 0 1px var(--stroke);
}
.sheet::backdrop {
  background: color-mix(in srgb, #06070a 46%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.sheet-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 22px 18px;
}
.sheet h2 {
  margin: 0;
  font-size: 1.14rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.sheet-copy {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.sheet-copy code {
  padding: 2px 5px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  color: var(--ink);
}
.sheet-sample {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--ink-soft);
  white-space: pre-wrap;
}
.sheet-text {
  min-height: 11rem;
  margin-top: 0;
  font-size: 0.88rem;
}
.sheet-hint {
  margin: 0;
  min-height: 1.1rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.sheet-hint.is-error { color: #d1475a; }
.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.sheet-cancel,
.sheet-submit {
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 620;
  cursor: pointer;
  transition: transform 120ms ease-out, filter 200ms var(--ease);
}
.sheet-cancel { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.sheet-submit { background: var(--accent); color: #fff; }
.sheet-cancel:active,
.sheet-submit:active { transform: scale(0.97); }
.sheet-cancel:focus-visible,
.sheet-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Dock ---------- */

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 13px;
  max-width: calc(100vw - 20px);
  padding: 9px 14px 9px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-solid) 74%, transparent);
  -webkit-backdrop-filter: blur(26px) saturate(190%);
  backdrop-filter: blur(26px) saturate(190%);
  box-shadow: inset 0 0 0 1px var(--stroke), inset 0 1px 0 var(--edge), var(--shadow);
  transform: translateX(-50%);
  transition: opacity 240ms var(--ease), transform 380ms var(--ease);
}

body[data-mode="edit"] .dock {
  opacity: 0.42;
  transform: translateX(-50%) translateY(8px);
  pointer-events: none;
}

.play-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface-solid);
  cursor: pointer;
  transition: transform 140ms ease-out, background 240ms var(--ease);
}
.play-btn:active { transform: scale(0.93); }
.play-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.play-btn .icon { width: 19px; height: 19px; fill: currentColor; }
.play-btn .icon-pause { display: none; }
.play-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }
.play-btn[aria-pressed="true"] .icon-play { display: none; }
.play-btn[aria-pressed="true"] .icon-pause { display: block; }

.control {
  display: flex;
  align-items: center;
  gap: 9px;
  border-radius: 999px;
}

.control-label {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.divider {
  width: 1px;
  height: 24px;
  background: var(--stroke-strong);
}

.transpose,
.speed { gap: 4px; }

.step-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink);
  font: inherit;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform 120ms ease-out, background 200ms var(--ease);
}
.step-btn:hover { background: color-mix(in srgb, var(--ink) 11%, transparent); }
.step-btn:active { transform: scale(0.9); }
.step-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.step-btn:disabled { opacity: 0.34; cursor: default; }
.step-btn:disabled:active { transform: none; }

.transpose-value {
  min-width: 2.6rem;
  min-height: 40px;
  padding: 5px 2px;
  border: 0;
  border-radius: 10px;
  background: none;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 660;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ink);
  cursor: pointer;
  transition: opacity 120ms linear, background 200ms var(--ease);
}
.transpose-value:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.transpose-value:active { opacity: 0.55; }
.transpose-value:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (max-width: 560px) {
  .control-label { display: none; }
  .dock { gap: 7px; padding-right: 9px; padding-left: 6px; }
  .divider { height: 20px; }
  .control { gap: 4px; }
  .transpose-value { min-width: 1.9rem; font-size: 0.88rem; }
  .brand-word { display: none; }
  .segmented { width: 9.6rem; }
  .segment { font-size: 0.78rem; }
  .bar-right { gap: 8px; }

  .nav-btn { width: 30px; height: 30px; }
  .dock-nav-count { display: none; }

  .pagination { gap: 5px; }
  .page-summary { flex-basis: 100%; margin-left: 0; }

  .sheet-sample { display: none; }
  .sheet-inner { padding: 18px 16px 14px; }
}

/* 320-380px: dua grup stepper harus tetap muat dalam satu kapsul. */
@media (max-width: 380px) {
  .dock { gap: 2px; padding: 6px 6px 6px 4px; }
  .control { gap: 3px; }
  .nav-btn { width: 28px; height: 28px; }
  .play-btn { width: 40px; height: 40px; }
  .transpose-value { min-width: 1.3rem; font-size: 0.84rem; }
}

/* ---------- Reduced motion / transparency / contrast ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .view.is-entering, .reader.is-entering, .editor.is-entering { animation: none; }
}

@media (prefers-reduced-transparency: reduce) {
  .chrome::before,
  .dock,
  .editor,
  .search,
  .library,
  .page-arrow,
  .page-btn {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--surface-solid);
  }
}

@media (prefers-contrast: more) {
  .chrome::before,
  .dock,
  .editor,
  .search,
  .library,
  .page-arrow,
  .page-btn {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--surface-solid);
    box-shadow: inset 0 0 0 1.5px var(--ink);
  }
  .page-btn.is-current { box-shadow: inset 0 0 0 1.5px var(--ink); }
  .segment[aria-selected="false"] { color: var(--ink); }
}
