/*
  Captio Player — look "velvet tray"

  The page is a black velvet tray. Jackets lie on it untouched: never cropped
  by a shade, never recoloured, corners barely eased.
  Blue appears in one form only — the sapphire stud — and it means "here":
  the song that is playing, the playback position, the things that are chosen.
  Everything you press is silver. Titles are set in Mincho, controls in Gothic.

  To change a face or a colour, edit the tokens in :root. Nothing else names them.
*/

:root {
  color-scheme: dark;

  --black: #000;
  --graphite: #101113;
  --graphite-up: #1b1c20;
  --hairline: rgba(255, 255, 255, 0.1);
  --hairline-strong: rgba(255, 255, 255, 0.24);
  --silver: #edeef0;
  --pewter: #a0a2a9;
  --smoke: #777980;
  --sapphire: #1f5bd0;
  --sapphire-line: #3f78ec;
  --sapphire-lit: #7aa5f8;
  --rose: #e39aa0;

  --stone: url("./assets/brand/sapphire-stud-120.png");

  --font-ui: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Helvetica Neue", "Yu Gothic UI", "Noto Sans CJK JP", sans-serif;
  --font-title: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "Noto Serif CJK JP", "Noto Serif JP", serif;
  --font-mark: Didot, "Bodoni 72", "Hoefler Text", "Hiragino Mincho ProN", "Noto Serif CJK JP", serif;

  --gutter: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  font-family: var(--font-ui);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--black);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: var(--black);
  color: var(--silver);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
button { margin: 0; color: inherit; }
button, [role="button"] { -webkit-touch-callout: none; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--sapphire-lit); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: 0.32; }
img { display: block; max-width: 100%; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
svg .fill, .fill { fill: currentColor; stroke: none; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }

.app-shell { min-height: 100dvh; }
.view { min-height: 100dvh; padding-bottom: calc(112px + var(--safe-bottom)); }

/* ---------- shared controls ---------- */

.icon-button {
  position: relative;
  display: inline-grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.icon-button:active { background: rgba(255, 255, 255, 0.09); }

.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  min-height: 48px;
  padding: 0 22px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  font-size: 0.94rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.primary-button { border: 1px solid var(--silver); background: var(--silver); color: #000; font-weight: 600; }
.secondary-button { border: 1px solid var(--hairline-strong); background: transparent; color: var(--silver); }
.danger-button { border: 1px solid rgba(227, 154, 160, 0.4); background: transparent; color: var(--rose); }
.primary-button svg, .secondary-button svg, .danger-button svg { width: 18px; height: 18px; }
.primary-button:active, .secondary-button:active, .danger-button:active { opacity: 0.7; }
.full { width: 100%; }

.quiet-link { min-height: 44px; padding: 0 2px; border: 0; background: none; color: var(--pewter); font-size: 0.78rem; text-decoration: underline; text-decoration-color: var(--hairline-strong); text-underline-offset: 4px; cursor: pointer; }
.quiet-link.align-left { justify-self: start; margin-top: 6px; text-align: left; }

/* ---------- install hint (Safari, before "add to home screen") ---------- */

.install-banner {
  position: relative;
  z-index: 40;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 44px;
  gap: 12px;
  align-items: start;
  margin: calc(10px + var(--safe-top)) 12px 0;
  padding: 14px 4px 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--graphite);
}
/* While the hint is showing it clears the status bar, so the bars below it need not. */
.install-banner:not([hidden]) + main .topbar,
.install-banner:not([hidden]) + main .floating-topbar { padding-top: 12px; }
.install-banner strong { display: block; margin: 0 0 4px; font-size: 0.9rem; font-weight: 600; }
.install-banner p { margin: 0; color: var(--pewter); font-size: 0.8rem; line-height: 1.65; }
.install-mark { display: grid; height: 22px; place-items: center; color: var(--pewter); }
.install-mark svg { width: 20px; height: 20px; }
.install-banner .icon-button { margin-top: -10px; color: var(--pewter); }

/* ---------- home: the shelf of boxes ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 10px 4px var(--gutter);
}
.wordmark { margin: 0; font: 400 2.05rem/1 var(--font-mark); letter-spacing: 0.01em; }
.wordmark::after {
  display: inline-block;
  width: 0.3em;
  height: 0.3em;
  margin-left: 0.16em;
  background: var(--stone) center / contain no-repeat;
  content: "";
}
.topbar .icon-button { color: var(--pewter); }

.shelf {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 30px 16px;
  align-items: start;
  padding: 26px var(--gutter) 0;
}
/* The grid the script fills is transparent to layout, so the "new box" tile
   sits on the shelf as the next jacket. */
.playlist-grid { display: contents; }
#playlist-grid[hidden] + .new-box { display: none; }

.playlist-card, .new-box {
  display: block;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.playlist-card-cover, .new-box-frame {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 6px;
}
.playlist-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.playlist-card:active .playlist-card-cover, .new-box:active .new-box-frame { opacity: 0.66; }
.playlist-card-copy, .new-box-label { display: block; padding: 12px 1px 0; }
.playlist-card-copy strong {
  display: block;
  overflow: hidden;
  font: 300 1.06rem/1.4 var(--font-title);
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.playlist-card-copy small { display: block; margin-top: 3px; color: var(--pewter); font-size: 0.78rem; }

.new-box-frame { display: grid; place-items: center; border: 1px solid var(--hairline-strong); color: var(--pewter); }
.new-box-frame svg { width: 28px; height: 28px; stroke-width: 1; }
.new-box-label { color: var(--pewter); font-size: 0.88rem; line-height: 1.5; }

.fine-print { margin: 48px var(--gutter) 0; color: var(--smoke); font-size: 0.72rem; letter-spacing: 0.02em; }

.empty-state {
  display: flex;
  max-width: 26rem;
  margin: 0 auto;
  padding: 5vh 32px 28px;
  align-items: center;
  flex-direction: column;
  text-align: center;
}
.empty-illustration { width: min(48vw, 196px); height: auto; aspect-ratio: 2 / 3; object-fit: contain; }
.empty-state h2 { margin: 6px 0 8px; font: 300 1.3rem/1.5 var(--font-title); letter-spacing: 0.05em; }
.empty-state p { max-width: 21rem; margin: 0 0 26px; color: var(--pewter); font-size: 0.84rem; line-height: 1.8; text-wrap: balance; }
.compact-empty { padding-top: 5vh; }
.compact-empty .empty-illustration { display: none; }

/* ---------- box page ---------- */

.playlist-view { position: relative; }
.floating-topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + var(--safe-top)) 8px 10px;
  background: linear-gradient(to bottom, #000 68%, rgba(0, 0, 0, 0));
}
.playlist-hero { width: min(64vw, 300px); margin: 2px auto 0; }
.playlist-hero img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }

.playlist-info { padding: 28px var(--gutter) 20px; }
.playlist-info h1 {
  margin: 0;
  font: 300 clamp(1.7rem, 7.6vw, 2.1rem)/1.3 var(--font-title);
  letter-spacing: 0.05em;
  overflow-wrap: anywhere;
}
.playlist-info p { margin: 8px 0 0; color: var(--pewter); font-size: 0.84rem; }
.playlist-info .mode-note { margin-top: 4px; color: var(--smoke); font-size: 0.78rem; }
.hero-actions { display: flex; margin-top: 22px; align-items: center; justify-content: space-between; }
.hero-actions .secondary-button { min-height: 44px; padding: 0 18px 0 14px; font-size: 0.86rem; }
.round-play {
  display: grid;
  width: 58px;
  height: 58px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--silver);
  color: #000;
  cursor: pointer;
}
.round-play svg { width: 28px; height: 28px; margin-left: 3px; }
.round-play:active { opacity: 0.7; }

.track-toolbar {
  display: flex;
  min-height: 52px;
  margin: 0 var(--gutter);
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}
.quiet-button {
  display: inline-flex;
  min-height: 44px;
  padding: 0;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  color: var(--pewter);
  font-size: 0.82rem;
  cursor: pointer;
}
.quiet-button svg { width: 18px; height: 18px; }
.quiet-button b { color: var(--smoke); font-weight: 400; font-variant-numeric: tabular-nums; }
.quiet-button.active { color: var(--silver); }
.quiet-button.active svg { color: var(--sapphire-lit); }
.quiet-button.active b { color: var(--silver); }
/* An empty setting. When the mode is on, the stone is in it. */
.selection-dot { width: 16px; height: 16px; border: 1.25px solid var(--smoke); border-radius: 50%; }
.quiet-button.active .selection-dot { border: 0; background: var(--stone) center / contain no-repeat; }

.track-list { margin: 0; padding: 6px 4px 0 var(--gutter); list-style: none; }
.track-row {
  position: relative;
  display: grid;
  min-height: 68px;
  grid-template-columns: minmax(0, 1fr) 44px 44px;
  align-items: center;
  border-radius: 10px;
}
.track-row.dragging {
  z-index: 20;
  background: var(--graphite-up);
  box-shadow: 0 0 0 1px var(--hairline), 0 14px 34px rgba(0, 0, 0, 0.7);
}
.track-main {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 68px;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 8px 4px 8px 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.track-main:active { opacity: 0.66; }
.track-cover { display: block; width: 52px; height: 52px; }
.track-cover img { width: 52px; height: 52px; object-fit: cover; border-radius: 4px; }

/* The mark of the song that is playing: the stud, pinned to the jacket's corner.
   The script fades it to 0.7 while paused. */
.track-cover .playing-bars {
  position: absolute;
  bottom: 3px;
  left: 41px;
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--stone) center / contain no-repeat;
  box-shadow: 0 0 0 2px var(--black);
}
.track-row.playing .playing-bars { display: block; }
.track-row.playing .playing-bars[style*="opacity: 1"] { animation: glint 3.4s ease-in-out infinite; }
@keyframes glint { 50% { filter: brightness(1.5); } }

.track-copy { display: block; min-width: 0; }
.track-copy strong, .track-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-copy strong { font: 300 1.04rem/1.45 var(--font-title); letter-spacing: 0.04em; }
.track-copy small { margin-top: 3px; color: var(--pewter); font-size: 0.78rem; }
.track-row.playing .track-copy strong { color: var(--sapphire-lit); }

.track-edit, .drag-handle {
  display: grid;
  width: 44px;
  height: 52px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--smoke);
  cursor: pointer;
}
.track-edit svg, .drag-handle svg { width: 20px; height: 20px; }
.track-edit:active { background: rgba(255, 255, 255, 0.08); color: var(--silver); }
.drag-handle { cursor: grab; touch-action: none; }
.drag-handle:active { color: var(--silver); cursor: grabbing; }

/* Choosing songs: an empty setting on each jacket; chosen ones hold the stone. */
.selection-check {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 4px;
  display: grid;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.selection-check::before {
  width: 26px;
  height: 26px;
  border: 1.5px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  content: "";
}
.selection-check svg { display: none; }
.selection-check.selected::before { border: 0; background: var(--stone) center / contain no-repeat; }
.selection-mode .track-cover img { opacity: 0.4; }
.selection-mode .playing-bars { visibility: hidden; }
/* While choosing, blue belongs to the chosen stones alone. */
.selection-mode .track-row.playing .track-copy strong { color: inherit; }

/* ---------- player ---------- */

.player-view {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 0;
  /* one lamp above the piece */
  background: radial-gradient(130% 58% at 50% 0%, #1b1c20 0%, #0a0a0c 52%, #000 100%);
}
.player-topbar {
  position: sticky;
  z-index: 4;
  top: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
  padding: calc(8px + var(--safe-top)) 8px 8px;
}
.player-topbar strong {
  overflow: hidden;
  color: var(--pewter);
  font: 300 0.9rem/1.4 var(--font-title);
  letter-spacing: 0.1em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.down-icon { transform: rotate(-90deg); }
.active-dot { position: absolute; top: 7px; right: 6px; width: 10px; height: 10px; background: var(--stone) center / contain no-repeat; }

.player-content {
  display: flex;
  width: min(100%, 520px);
  margin: 0 auto;
  flex: 1 0 auto;
  flex-direction: column;
  padding: clamp(6px, 1.6vh, 20px) 28px calc(clamp(22px, 4.4vh, 44px) + var(--safe-bottom));
}
.player-artwork-wrap { width: 100%; margin: auto; aspect-ratio: 1; overflow: hidden; border-radius: 6px; box-shadow: 0 34px 70px rgba(0, 0, 0, 0.7); }
.player-artwork-wrap img { width: 100%; height: 100%; object-fit: cover; }
.player-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 12px;
  align-items: center;
  margin-top: clamp(18px, 3vh, 30px);
  padding: 0 0 8px;
}
.player-meta h1 {
  margin: 0;
  overflow: hidden;
  font: 300 clamp(1.4rem, 6.2vw, 1.72rem)/1.4 var(--font-title);
  letter-spacing: 0.05em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-meta p { margin: 4px 0 0; overflow: hidden; color: var(--pewter); font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.player-meta .icon-button { color: var(--pewter); }

.timeline input {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.timeline input::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(to right, var(--sapphire-line) var(--progress, 0%), rgba(255, 255, 255, 0.2) var(--progress, 0%));
}
.timeline input::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -10px;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  border-radius: 50%;
  background: var(--stone) center / contain no-repeat;
}
.timeline input::-moz-range-track { height: 2px; border-radius: 1px; background: rgba(255, 255, 255, 0.2); }
.timeline input::-moz-range-progress { height: 2px; border-radius: 1px; background: var(--sapphire-line); }
.timeline input::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--stone) center / contain no-repeat; }
.timeline > div { display: flex; margin-top: -8px; justify-content: space-between; color: var(--pewter); font-size: 0.72rem; font-variant-numeric: tabular-nums; }

.transport { display: grid; grid-template-columns: 44px 1fr 72px 1fr 44px; align-items: center; margin-top: 16px; }
.transport button { display: grid; padding: 0; place-items: center; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.transport button:active { opacity: 0.66; }
.player-tool { position: relative; width: 44px; height: 44px; color: var(--pewter); }
.player-tool.active { color: var(--sapphire-lit); }
.player-tool.active::after {
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}
.transport-skip { width: 56px; height: 56px; margin: auto; }
.transport-skip svg { width: 30px; height: 30px; }
.transport .transport-play { width: 72px; height: 72px; background: var(--silver); color: #000; }
.transport-play svg { width: 32px; height: 32px; }
.repeat-tool.active::after { content: none; }
.repeat-tool span {
  position: absolute;
  top: 3px;
  right: -1px;
  display: grid;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  place-items: center;
  border-radius: 8px;
  background: var(--sapphire);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
}

.lyrics-panel {
  position: fixed;
  z-index: 60;
  inset: calc(28px + var(--safe-top)) 0 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 26px calc(48px + var(--safe-bottom));
  border-top: 1px solid var(--hairline);
  border-radius: 20px 20px 0 0;
  background: #0c0d0f;
}
.sheet-handle { width: 36px; height: 4px; margin: 10px auto 12px; border-radius: 2px; background: rgba(255, 255, 255, 0.2); }
.lyrics-panel .sheet-handle { margin-bottom: 0; }
.lyrics-panel header {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -14px 0 0;
  padding: 10px 0 14px;
  background: linear-gradient(to bottom, #0c0d0f 78%, rgba(12, 13, 15, 0));
}
.lyrics-panel h2 { min-width: 0; margin: 0; font: 300 1.4rem/1.4 var(--font-title); letter-spacing: 0.06em; overflow-wrap: anywhere; }
.lyrics-panel .icon-button { color: var(--pewter); }
.lyrics-panel pre {
  margin: 10px 0 0;
  color: #dfe0e3;
  font: 300 1.06rem/2.2 var(--font-title);
  letter-spacing: 0.05em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- mini player ---------- */

.mini-player {
  position: fixed;
  z-index: 35;
  right: 10px;
  bottom: calc(10px + var(--safe-bottom));
  left: 10px;
  display: grid;
  min-height: 64px;
  grid-template-columns: minmax(0, 1fr) 44px 44px;
  gap: 2px;
  align-items: center;
  padding: 8px 6px 8px 8px;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: rgba(22, 23, 26, 0.95);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  backdrop-filter: blur(22px) saturate(1.2);
}
.mini-open {
  display: grid;
  min-width: 0;
  min-height: 46px;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.mini-player img { width: 46px; height: 46px; object-fit: cover; border-radius: 4px; }
.mini-meta { display: block; min-width: 0; }
.mini-meta strong, .mini-meta small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-meta strong { font: 300 0.96rem/1.4 var(--font-title); letter-spacing: 0.04em; }
.mini-meta small { margin-top: 2px; color: var(--pewter); font-size: 0.74rem; }
.mini-control { display: grid; width: 44px; height: 44px; padding: 0; place-items: center; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.mini-control:active { background: rgba(255, 255, 255, 0.09); }
.mini-progress { position: absolute; right: 0; bottom: 0; left: 0; height: 2px; transform: scaleX(var(--mini-progress, 0)); transform-origin: left; background: var(--sapphire-line); }

/* ---------- dialogs ---------- */

dialog.modal {
  width: min(calc(100% - 32px), 400px);
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 20px;
  background: var(--graphite);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.75);
  color: var(--silver);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.74); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog.modal[open] { animation: rise 220ms cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.modal > form { padding: 26px 22px 22px; }
.modal h2 { margin: 0 0 22px; font: 300 1.45rem/1.35 var(--font-title); letter-spacing: 0.06em; }
.modal label { display: grid; gap: 4px; color: var(--pewter); font-size: 0.78rem; }
.modal input:not([type="radio"]):not([type="checkbox"]) {
  width: 100%;
  min-height: 48px;
  padding: 0 2px;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  border-bottom: 1px solid var(--hairline-strong);
  border-radius: 0;
  background: transparent;
  color: var(--silver);
  font: 300 1.12rem/1.4 var(--font-title);
  letter-spacing: 0.04em;
}
.modal input:not([type="radio"]):not([type="checkbox"]):focus { border-bottom-color: var(--sapphire-lit); outline: 0; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }

.choice-fieldset { min-width: 0; margin: 24px 0 0; padding: 0; border: 0; }
.choice-fieldset legend { margin-bottom: 10px; padding: 0; color: var(--pewter); font-size: 0.78rem; }
.choice-fieldset p { margin: 10px 2px 0; color: var(--smoke); font-size: 0.74rem; line-height: 1.7; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented-control label { position: relative; display: block; }
.segmented-control input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.segmented-control span {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--pewter);
  font-size: 0.92rem;
  cursor: pointer;
}
.segmented-control span::before { width: 16px; height: 16px; border: 1.25px solid var(--smoke); border-radius: 50%; content: ""; }
.segmented-control input:checked + span { border-color: var(--hairline-strong); color: var(--silver); }
.segmented-control input:checked + span::before { border: 0; background: var(--stone) center / contain no-repeat; }
.segmented-control input:focus-visible + span { outline: 2px solid var(--sapphire-lit); outline-offset: 3px; }

/* Checkboxes are settings too: empty, or holding the stone. */
.toggle-row input, .unused-track-row input {
  width: 24px;
  height: 24px;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  border: 1.5px solid var(--smoke);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.toggle-row input:checked, .unused-track-row input:checked { border: 0; background: var(--stone) center / contain no-repeat; }

.modal .toggle-row {
  display: grid;
  margin-top: 22px;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 16px 0 0;
  border-top: 1px solid var(--hairline);
  cursor: pointer;
}
.toggle-row b, .toggle-row small { display: block; }
.toggle-row b { color: var(--silver); font-size: 0.9rem; font-weight: 400; line-height: 1.5; }
.toggle-row small { margin-top: 4px; color: var(--smoke); font-size: 0.74rem; line-height: 1.7; }

.track-edit-modal label + label { margin-top: 18px; }
.track-edit-cover { display: grid; margin: 0 0 22px; grid-template-columns: 96px minmax(0, 1fr); gap: 16px; align-items: center; }
.track-edit-cover img { width: 96px; height: 96px; object-fit: cover; border-radius: 4px; }
.track-edit-cover > div { display: grid; gap: 4px; justify-items: start; }
.track-edit-cover .secondary-button { min-height: 44px; padding: 0 16px; font-size: 0.86rem; }
.edit-scope-note { margin: 12px 2px 0; color: var(--smoke); font-size: 0.74rem; line-height: 1.7; }
.track-edit-modal .danger-text {
  display: block;
  min-height: 44px;
  margin-top: 14px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--rose);
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}

/* ---------- sheets from the bottom edge ---------- */

dialog.action-sheet { width: min(100%, 520px); max-width: none; margin: auto auto 0; border-width: 1px 0 0; border-radius: 20px 20px 0 0; }
.action-sheet > form { padding: 0 12px calc(12px + var(--safe-bottom)); }
.action-sheet form > button {
  display: grid;
  width: 100%;
  min-height: 64px;
  grid-template-columns: 40px minmax(0, 1fr) 24px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.action-sheet form > button:active { background: rgba(255, 255, 255, 0.06); }
.action-sheet form > button > svg:first-child { margin: auto; color: var(--pewter); }
.action-sheet form > button > span:not(.mode-icon) { min-width: 0; }
.action-sheet b, .action-sheet small { display: block; }
.action-sheet b { font-size: 0.95rem; font-weight: 400; }
.action-sheet small { margin-top: 2px; color: var(--pewter); font-size: 0.75rem; line-height: 1.5; }
.action-sheet .danger, .action-sheet .danger > svg:first-child { color: var(--rose); }
.action-sheet .danger small { color: var(--pewter); }
.action-sheet .sheet-cancel {
  display: block;
  min-height: 48px;
  margin-top: 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  color: var(--silver);
  font-size: 0.92rem;
  text-align: center;
}
.sheet-title { padding: 4px 8px 12px; }
.sheet-title h2 { margin: 0; }
.mode-icon { display: grid; width: 40px; height: 40px; place-items: center; color: var(--pewter); font: 300 1.1rem/1 var(--font-title); }
/* The chosen repeat mode holds the stone. */
.mode-check { display: block; width: 20px; height: 20px; padding-left: 20px; overflow: hidden; background: var(--stone) center / contain no-repeat; opacity: 0; }
[data-repeat-mode].selected .mode-check { opacity: 1; }
.sleep-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 14px 0 6px; }
.sleep-grid button { min-height: 48px; border: 1px solid var(--hairline-strong); border-radius: 999px; background: transparent; color: var(--silver); font-size: 0.9rem; cursor: pointer; }
.sleep-grid button:active { background: rgba(255, 255, 255, 0.08); }
.action-sheet .danger-text { display: block; min-height: 52px; border-bottom: 0; color: var(--rose); font-size: 0.9rem; text-align: center; }

/* ---------- settings ---------- */

.settings-modal { height: min(88dvh, 720px); overflow-y: auto; overscroll-behavior: contain; }
.settings-modal > form { padding: 20px 20px calc(26px + var(--safe-bottom)); }
.settings-head { display: flex; align-items: center; justify-content: space-between; margin: 0 -8px 12px 0; }
.settings-head h2 { margin: 0; }
.settings-head .icon-button { color: var(--pewter); }
.settings-section { padding: 20px 0; border-top: 1px solid var(--hairline); }
.settings-section h3 { margin: 0 0 6px; font-size: 0.95rem; font-weight: 600; letter-spacing: 0.02em; }
.settings-section p { margin: 0 0 14px; color: var(--pewter); font-size: 0.8rem; line-height: 1.8; }
.settings-section .sub-status { margin-top: -8px; color: var(--smoke); font-size: 0.74rem; }
.settings-status { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--hairline-strong); border-radius: 12px; color: var(--silver); font-size: 0.8rem; line-height: 1.7; }
.settings-row { display: grid; gap: 10px; }
.danger-zone { padding-bottom: 0; }
.danger-zone h3 { margin-bottom: 12px; }

.unused-tracks-modal { max-height: min(82dvh, 720px); overflow-y: auto; }
.unused-tracks-modal > form { padding-top: 20px; }
.unused-tracks-list { display: grid; max-height: 46vh; margin-top: 16px; overflow-y: auto; }
.modal .unused-track-row { display: grid; min-height: 60px; grid-template-columns: 24px minmax(0, 1fr); gap: 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--hairline); cursor: pointer; }
.unused-track-row b, .unused-track-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unused-track-row b { color: var(--silver); font: 300 0.98rem/1.4 var(--font-title); letter-spacing: 0.04em; }
.unused-track-row small { margin-top: 2px; color: var(--pewter); font-size: 0.74rem; }

/* ---------- notices ---------- */

.import-progress {
  position: fixed;
  z-index: 100;
  right: 14px;
  bottom: calc(14px + var(--safe-bottom));
  left: 14px;
  display: flex;
  min-height: 68px;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border: 1px solid var(--hairline-strong);
  border-radius: 14px;
  background: var(--graphite-up);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.7);
}
.import-progress strong, .import-progress small { display: block; }
.import-progress strong { font-size: 0.88rem; font-weight: 600; }
.import-progress small { margin-top: 2px; color: var(--pewter); font-size: 0.76rem; }
.spinner { flex: none; width: 22px; height: 22px; border: 1.5px solid rgba(255, 255, 255, 0.16); border-top-color: var(--sapphire-lit); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  z-index: 120;
  right: 14px;
  bottom: calc(92px + var(--safe-bottom));
  left: 14px;
  width: fit-content;
  max-width: min(calc(100% - 28px), 400px);
  margin: auto;
  padding: 11px 20px;
  border: 1px solid var(--hairline-strong);
  border-radius: 22px;
  background: var(--graphite-up);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.7);
  color: var(--silver);
  font-size: 0.82rem;
  line-height: 1.6;
  text-align: center;
  pointer-events: none;
}

/* ---------- other sizes ---------- */

@media (min-width: 600px) {
  .boxes-view, .playlist-view { width: min(100%, 560px); margin: 0 auto; }
  .shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mini-player { width: min(calc(100% - 20px), 540px); margin: 0 auto; }
}

@media (max-height: 720px) {
  .playlist-hero { width: min(46vw, 210px); }
  .player-content { padding-top: 0; }
  .player-artwork-wrap { width: min(100%, 42vh); }
  .player-meta { margin-top: 14px; padding-bottom: 2px; }
  .transport { margin-top: 6px; }
  .transport .transport-play { width: 64px; height: 64px; }
}

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