:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #d2d2d7;
  --accent: #ff5500;
  --accent-text: #ffffff;
  --ok: #248a3d;
  --err: #d70015;
  --track: #e5e5ea;
  --hover: rgba(0, 0, 0, 0.04);
  /* Detailed waveform: bass, mids, treble (like DJ software) */
  --wave-low: #1f5fe0;
  --wave-mid: #f08a00;
  --wave-high: #1d1d1f;
  --wave-silence: rgba(0, 0, 0, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --panel: #2c2c2e;
    --text: #f5f5f7;
    --muted: #98989d;
    --border: #3a3a3c;
    --ok: #30d158;
    --err: #ff453a;
    --track: #3a3a3c;
    --hover: rgba(255, 255, 255, 0.05);
    --wave-low: #3d7bfd;
    --wave-mid: #ff9f2e;
    --wave-high: #f5f5f7;
    --wave-silence: rgba(255, 255, 255, 0.07);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  display: flex;
  flex-direction: column;
}
/* Like a native app: no text selection on click or ⇧-click in the lists.
   Still selectable: the fields, the log and the panel info (file name, style…). */
body { user-select: none; -webkit-user-select: none; }
input, textarea, .log pre, .p-info dd { user-select: text; -webkit-user-select: text; }
.hidden { display: none !important; }
.item[hidden] { display: none !important; }

/* ---- Title bar + tabs ---- */
.titlebar {
  position: relative;
  -webkit-app-region: drag;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tabs {
  -webkit-app-region: no-drag;
  display: flex;
  background: var(--track);
  border-radius: 8px;
  padding: 2px;
}
.tab {
  border: 0;
  background: transparent;
  padding: 4px 14px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
}
.tab.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.help-btn {
  -webkit-app-region: no-drag;
  position: absolute; right: 16px; top: 14px;
  width: 24px; height: 24px; padding: 0; border-radius: 50%;
  color: var(--muted); font-weight: 600; line-height: 1;
}

/* The views and the player panel, shared by all views */
.app-body { flex: 1; min-height: 0; display: flex; }
.views { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 20px 12px;
}

/* ---- At the bottom (all tabs): status bar then player ---- */
.bottom { flex-shrink: 0; border-top: 1px solid var(--border); background: var(--panel); }
.statusbar { border-top: 1px solid var(--border); }
.statusbar .progress { border-radius: 0; height: 3px; }
.statusbar .progress.idle { visibility: hidden; }
.statusbar-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 20px; min-height: 26px; font-size: 12px; }
.statusbar .message { min-height: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-analysis { border: 0; background: transparent; padding: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.sb-analysis:hover:not(:disabled) { filter: none; color: var(--text); }

/* Player */
.player-bar {
  display: grid;
  /* cover and title at their own size (title cut off beyond 280 px), the waveform takes all the rest */
  grid-template-columns: 48px fit-content(280px) minmax(200px, 1fr) auto auto auto;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
}
.player-bar .p-controls { gap: 10px; }
/* Two tracks play together (transition): the background pulses slightly, on the beats when the transition is beat-matched */
.player-bar { position: relative; isolation: isolate; }
.player-bar.mixing::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--accent); opacity: 0.05;
  animation: mix-pulse var(--mix-beat, 1.2s) ease-out var(--mix-delay, 0s) infinite;
}
@keyframes mix-pulse { 0% { opacity: 0.14; } 100% { opacity: 0.04; } }
@media (prefers-reduced-motion: reduce) { .player-bar.mixing::before { animation: none; opacity: 0.08; } }
.filters-panel { padding: 2px 0; }
.pb-cover { padding: 0; border: 0; background: var(--track); width: 48px; height: 48px; border-radius: 6px; overflow: hidden; display: block; }
.pb-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pb-cover img:not([src]) { visibility: hidden; }
.pb-text { min-width: 0; max-width: 280px; }
.pb-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-artist { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-wave { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pb-wave .p-wave-wrap { height: 36px; }
.pb-queue { gap: 6px; align-items: center; color: var(--muted); border-radius: 6px; padding: 5px 8px; }
.pb-fade { gap: 5px; align-items: center; color: var(--muted); border-radius: 6px; padding: 5px 8px; }
.pb-fade.on { color: var(--accent); }
.pb-fade-label { font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.p-fade-info { color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; }
.pb-queue-count { font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.popover-item.current .label { color: var(--accent); font-weight: 600; }
.popover-item.hint { color: var(--muted); }

/* ---- Controls ---- */
input, select {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 0; }
button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(0.96); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger:not(:disabled) { color: var(--err); }
.icon-btn { padding: 5px 9px; font-size: 14px; line-height: 1; display: inline-flex; align-items: center; gap: 6px; }
.icon-btn span:empty { display: none; }
.toolbar .icon-btn { height: 30px; }
.toolbar .mk-toggle { font-size: 12px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar #search { width: 220px; }
.spacer { flex: 1; }
.segmented { display: flex; }
.segmented button { padding: 5px 9px; display: flex; align-items: center; color: var(--muted); }
.segmented button:first-child { border-radius: 6px 0 0 6px; }
.segmented button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.segmented button.active { background: var(--track); color: var(--text); }

.hint { margin: 0; color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.row.wrap { flex-wrap: wrap; }
label.check { display: flex; flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
/* Fixed-size checkbox, aligned on the first line when the text spans several */
label.check input[type="checkbox"] { flex: none; width: 14px; height: 14px; margin: 0; }
label.check:has(.sub) { align-items: flex-start; }
label.check:has(.sub) input[type="checkbox"] { margin-top: 2px; }
label.check .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }

/* ---- Chips (filters, artists, tags) ---- */
.counts { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip-ok:not(.active) { color: var(--ok); }
.chip-failed:not(.active) { color: var(--err); }
.chip-todo:not(.active) { color: var(--accent); }
.chip-broken:not(.active) { color: var(--err); }
.chip-similar { font-weight: 600; }
.chip-queue { color: var(--accent); }

/* ---- Messages and progress ---- */
.message { min-height: 18px; }
.message.error { color: var(--err); }
.progress { height: 5px; background: var(--track); border-radius: 3px; overflow: hidden; }
#bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* ---- Library: items (list or thumbnails) ---- */
.library-body { flex: 1; min-height: 0; display: flex; gap: 12px; }
.list-col { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.items {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.item { cursor: default; contain: layout style; }
.item .cover {
  display: block;
  border-radius: 4px;
  object-fit: cover;
}
.item .meta { min-width: 0; }
.item .title, .item .artist { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .artist { color: var(--muted); font-size: 12px; }
.item .artist:empty { display: none; }
.item .state { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .idx { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 12px; }
.item.playing .title::before { content: "♪ "; color: var(--accent); }
.item.excluded .title { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }

.item[data-status="done"] .state, .item[data-status="present"] .state { color: var(--ok); }
.item[data-status="failed"] .state, .item.broken .state { color: var(--err); }
.item[data-status="running"] .state { color: var(--accent); }
.item[data-status="drm"] .state { font-style: italic; }
.item[data-status="drm"] .title { color: var(--muted); }
.item[data-status="drm"] .cover, .item[data-status="failed"] .cover { filter: grayscale(1); opacity: 0.6; }

/* No cover: musical note on a neutral background */
.item .cover, .p-cover-wrap {
  background-color: var(--track);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M9 17.5V6l10-2v11.5' fill='none' stroke='%238e8e93' stroke-width='1.6' stroke-linejoin='round'/><circle cx='6.5' cy='17.5' r='2.5' fill='%238e8e93'/><circle cx='16.5' cy='15.5' r='2.5' fill='%238e8e93'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 45%;
}

/* List */
.view-list .item {
  display: grid;
  grid-template-columns: 32px 40px 1fr minmax(0, 260px);
  gap: 10px;
  align-items: center;
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
}
.view-list .item:last-child { border-bottom: 0; }
.view-list .item:hover { background: var(--hover); }
.view-list .item[data-status="running"] { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.view-list .item.selected { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.view-list .item.multi { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.view-list .cover { width: 40px; height: 40px; }
.view-list .state { text-align: right; }

/* Thumbnails */
.view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  padding: 16px;
  align-content: start;
}
.view-grid .item { display: flex; flex-direction: column; gap: 4px; min-width: 0; position: relative; }
.view-grid .idx { display: none; }
.view-grid .cover { width: 100%; aspect-ratio: 1; border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.view-grid .title { font-weight: 500; }
.view-grid .state {
  position: absolute;
  top: 6px;
  left: 6px;
  max-width: calc(100% - 12px);
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff !important;
  font-size: 11px;
}
.view-grid .item[data-status="present"] .state,
.view-grid .item[data-status="done"] .state { background: color-mix(in srgb, var(--ok) 85%, black); }
.view-grid .item[data-status="failed"] .state { background: color-mix(in srgb, var(--err) 85%, black); }
.view-grid .item[data-status="running"] .state { background: var(--accent); }
.view-grid .item[data-status="running"] .cover { outline: 2px solid var(--accent); outline-offset: 2px; }
.view-grid .item.selected .cover, .view-grid .item.multi .cover { outline: 3px solid var(--accent); outline-offset: 2px; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---- Playlists ---- */
.pl-list li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.pl-list li:last-child { border-bottom: 0; }
.pl-list li:hover { background: var(--hover); }
.pl-list .pl-text { flex: 1; min-width: 0; }
.pl-list .pl-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-list .pl-meta { color: var(--muted); font-size: 12px; }
.pl-list button { font-size: 12px; padding: 4px 10px; white-space: nowrap; }

/* ---- Floating menu ---- */
.popover {
  position: fixed; z-index: 50;
  min-width: 220px; max-width: 320px; max-height: 60vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.popover-title { font-size: 11px; color: var(--muted); padding: 4px 8px; }
.popover-section { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
.popover-item:disabled { color: var(--muted); opacity: 0.7; cursor: default; }
.popover-item { border: 0; background: transparent; text-align: left; padding: 6px 8px; border-radius: 6px; display: flex; justify-content: space-between; gap: 10px; }
.popover-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popover-item:hover:not(:disabled) { background: var(--hover); filter: none; }
.popover-item.danger { color: var(--err); }
.popover-form { display: flex; gap: 6px; padding: 8px 4px 2px; margin-top: 4px; border-top: 1px solid var(--border); }
.popover-form input { flex: 1; min-width: 0; }

/* ---- Shortcuts sheet ---- */
dialog.help { border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); padding: 18px 22px; max-width: 480px; }
dialog.help::backdrop { background: rgba(0, 0, 0, 0.3); }
.help h2 { margin: 0 0 12px; font-size: 14px; }
.help-list { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 12px; margin: 0 0 14px; }
.help-list dt { font-family: ui-monospace, Menlo, monospace; color: var(--muted); white-space: nowrap; }
.help-list dd { margin: 0; }
.help form { text-align: right; }
dialog.guide { max-width: 680px; width: calc(100vw - 80px); max-height: calc(100vh - 80px); padding: 0; display: none; }
dialog.guide[open] { display: flex; flex-direction: column; }
.guide-head { padding: 16px 22px 10px; border-bottom: 1px solid var(--border); }
.guide-head h2 { margin: 0 0 8px; }
.guide-nav { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; }
.guide-nav a { color: var(--accent); text-decoration: none; }
.guide-nav a:hover { text-decoration: underline; }
.guide-body { overflow-y: auto; padding: 6px 22px 4px; }
.guide-body h3 { font-size: 13px; margin: 14px 0 8px; }
.guide-note { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.guide-list dt { font-family: inherit; color: var(--text); font-weight: 600; white-space: normal; max-width: 150px; }
.guide-list dd { color: var(--text); line-height: 1.45; }
dialog.guide form { padding: 10px 22px 14px; border-top: 1px solid var(--border); }
.link-btn { border: 0; background: transparent; color: var(--accent); padding: 2px 6px; margin-left: auto; margin-right: 6px; cursor: pointer; font-size: 12px; }
.link-btn:hover { text-decoration: underline; filter: none; }

/* ---- Log ---- */
.log summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.log pre {
  max-height: 320px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: 11px/1.4 ui-monospace, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- Account and settings ---- */
#viewAccount { overflow: auto; max-width: 720px; width: 100%; margin: 0 auto; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card h2 { margin: 0; font-size: 13px; font-weight: 600; }
.card label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.card label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.account { display: flex; align-items: center; gap: 10px; }
.account-status { flex: 1; }
.account.ok .account-status { color: var(--ok); font-weight: 500; }
.banner {
  background: color-mix(in srgb, var(--err) 12%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--err) 40%, var(--border));
  border-radius: 8px;
  padding: 10px 12px;
}
.banner code { font-family: ui-monospace, Menlo, monospace; }

/* ---- Detail panel + player ---- */
.app-body > .panel { margin: 0 20px 16px 0; }
.panel {
  width: 300px;
  flex-shrink: 0;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.panel > * { flex-shrink: 0; }
.p-close {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 5px;
  border-radius: 50%;
  display: flex;
  background: var(--panel);
  color: var(--muted);
  z-index: 1;
}
.p-cover-wrap { width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; }
.p-cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.p-cover:not([src]) { visibility: hidden; }
.p-title { font-size: 15px; font-weight: 600; line-height: 1.3; word-break: break-word; }
.p-artist { color: var(--muted); }
.p-wave-wrap { position: relative; height: 36px; }
.p-wave { display: block; width: 100%; height: 100%; }

/* The position slider remains a real <input type="range">, invisible, on top of the waveform */
.p-seek { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; background: transparent; opacity: 0; cursor: pointer; }
.p-seek:disabled { cursor: default; }
.p-times { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.p-controls { display: flex; justify-content: center; align-items: center; gap: 14px; }
.p-btn { border: 0; background: transparent; color: var(--text); padding: 6px; border-radius: 50%; display: flex; }
.p-btn:hover:not(:disabled) { background: var(--hover); filter: none; }
.p-play { background: var(--accent); color: #fff; padding: 10px; }
.p-play:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.p-play .i-pause, .p-play.is-playing .i-play { display: none; }
.p-play.is-playing .i-pause { display: block; }

.p-info { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 4px 0 0; font-size: 12px; }
.p-info dt { color: var(--muted); }
.p-info dd { margin: 0; word-break: break-word; font-variant-numeric: tabular-nums; }
.p-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.p-actions button { font-size: 12px; padding: 4px 10px; }
.p-more summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.p-more .p-info { margin-top: 6px; }
.p-more .p-tags { margin-top: 8px; }
.p-desc-text { white-space: pre-wrap; font-size: 12px; margin: 8px 0 0; max-height: 200px; overflow: auto; user-select: text; -webkit-user-select: text; }
.p-rate { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.p-rate label.check { font-size: 12px; }
.p-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.p-tags .chip { font-size: 11px; padding: 1px 8px; cursor: default; }

/* Rating (stars) */
.stars { display: inline-flex; gap: 1px; }
.stars .star { border: 0; background: transparent; padding: 0 1px; font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; }
.stars .star.on { color: #f5a623; }
.stars .star:hover { filter: none; transform: scale(1.15); }
.stars.small .star { font-size: 13px; }

/* ---- Explorer ---- */
.maker { flex: 1; min-height: 0; display: flex; gap: 12px; }
.maker.filters-hidden .maker-controls { display: none; }
.mk-toggle { font-size: 12px; padding: 4px 10px; color: var(--muted); }
.mk-toggle[aria-pressed="true"] { background: var(--track); color: var(--text); }

/* Left column: wheel and filters */
.maker-controls { width: 280px; flex-shrink: 0; overflow: auto; }
.maker-controls > * { flex-shrink: 0; }
.maker-controls select, .maker-controls #mkSaved { width: 100%; }
.maker-controls .range { align-items: center; }
.maker-controls .range input, .maker-controls .range select { width: 0; flex: 1; }
.maker-controls .row.two { display: flex; gap: 8px; }
.maker-controls .row.two > label { flex: 1; min-width: 0; }
.maker-key { text-align: center; font-size: 15px; }
.mk-more { display: flex; flex-direction: column; gap: 10px; }
.mk-more summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.mk-more[open] summary { color: var(--text); }
.wheel { width: 100%; max-width: min(250px, 36vh); align-self: center; display: block; }
.wheel .seg { cursor: pointer; stroke: var(--panel); stroke-width: 1.5; transition: opacity 0.15s; }
.wheel .seg.dim { opacity: 0.22; }
.wheel .seg.sel { stroke: var(--text); stroke-width: 3; }
.wheel text { font-size: 9px; font-weight: 600; fill: #fff; pointer-events: none; text-anchor: middle; dominant-baseline: middle; }
.wheel text.count { font-size: 6.5px; font-weight: 400; opacity: 0.9; }

/* Right column: header, table, actions */
.maker-result { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.maker-head { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.maker-head #mkTitle { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.maker-head #mkTotal { flex: 0 0 auto; white-space: nowrap; }
.maker-head:has(.save-form:not(.hidden)) .spacer { display: none; }
.mk-hint { margin: -2px 0 0; color: var(--accent); }
#mkArtists { flex-wrap: nowrap; overflow: hidden; mask-image: linear-gradient(to right, #000 92%, transparent); }
#mkArtists .chip { flex-shrink: 0; font-size: 11px; }

/* "Nom de la playlist" form */
.save-form { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.save-form label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.save-form input { flex: 1; min-width: 120px; font-weight: 600; }

.mk-table-wrap { flex: 1; min-height: 0; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.mk-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mk-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel); text-align: left; font-weight: 500; color: var(--muted);
  padding: 7px 8px; border-bottom: 1px solid var(--border); cursor: pointer; white-space: nowrap; user-select: none;
}
.mk-table th.sorted { color: var(--text); }
.mk-table th:first-child, .mk-table td.idx { width: 28px; color: var(--muted); }
.mk-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mk-table td.t { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.mk-table td.t .artist { color: var(--muted); }
.mk-table td:nth-last-child(1) { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.mk-table td.rate { white-space: nowrap; }
/* Remove a track from the playlist: subtle, visible when hovering the row or when it is selected */
.mk-table td.rm { width: 24px; padding: 0 6px; text-align: center; }
.row-rm { border: 0; background: none; color: var(--muted); font-size: 15px; line-height: 1; padding: 2px 4px; border-radius: 4px; cursor: pointer; opacity: 0; }
.mk-table tr:hover .row-rm, .mk-table tr.selected .row-rm, .row-rm:focus-visible { opacity: 1; }
.row-rm:hover { color: var(--text); background: var(--border); }
.mk-table tr:hover td { background: var(--hover); }
.mk-table tr.selected td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.mk-table tr.excluded td:not(.rate) { opacity: 0.55; }
.mk-table img.cover { width: 32px; height: 32px; border-radius: 3px; object-fit: cover; display: block; }
.mk-table .key { display: inline-block; min-width: 30px; padding: 1px 6px; border-radius: 4px; color: #fff; font-weight: 600; text-align: center; cursor: default; }
.mk-table .warn { color: var(--err); }
.mk-table .okc { color: var(--ok); }
.mk-table .excl { margin-left: 6px; color: var(--err); }
.mk-table .stars.small .star:not(.on) { opacity: 0.22; }
.mk-table tr:hover .stars.small .star:not(.on) { opacity: 0.7; }

/* Current track in the Explorer */
.mk-table tr.playing td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.mk-table tr.playing td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.mk-table tr.playing td.t > div > div:first-child { color: var(--accent); font-weight: 600; }
.mk-table tr.playing td.t > div > div:first-child::before { content: "♪ "; }

/* Playlist: drag and drop of rows */
.mk-table tr[draggable="true"] { cursor: grab; }
.mk-table tr.dragging td { opacity: 0.4; }
.mk-table tr.drop-before td { box-shadow: inset 0 2px 0 var(--accent); }
.mk-table tr.drop-after td { box-shadow: inset 0 -2px 0 var(--accent); }

.maker-actions { justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 6px; row-gap: 8px; }
.maker-actions button, .maker-actions select { white-space: nowrap; flex-shrink: 0; }
.maker-actions #mkDur { width: 82px; }
.maker-actions #mkMode { width: 92px; }
.maker-actions label.check { font-size: 12px; white-space: nowrap; gap: 5px; }

/* ---------- Detail sheet ---------- */
.detail { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.45); padding: 24px; }
.detail.hidden { display: none; }
.d-sheet { width: min(1180px, 100%); max-height: 100%; overflow: auto; background: var(--panel); color: var(--text); border-radius: 14px; padding: 20px 22px 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.d-head { display: flex; gap: 16px; align-items: flex-start; }
.d-cover { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; background: var(--track); flex: none; }
.d-titles { flex: 1; min-width: 0; }
.d-titles h2 { margin: 2px 0 4px; font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
.d-artist { margin: 0 0 6px; color: var(--muted); }
.d-summary { margin: 0; font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; }
.d-summary span { padding: 2px 8px; border-radius: 999px; background: var(--track); font-variant-numeric: tabular-nums; }
.d-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.d-close { min-width: 34px; }
.d-wave { margin: 18px 0 14px; }
.d-wave canvas { display: block; width: 100%; height: 170px; border-radius: 8px; background: var(--bg); cursor: pointer; }
.d-wave-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.d-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; }
.d-legend i:first-child { margin-left: 0; }
.lw-low { background: var(--wave-low); }
.lw-mid { background: var(--wave-mid); }
.lw-high { background: var(--wave-high); }
.lw-silence { background: var(--wave-silence); border: 1px solid var(--border); }
.d-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.d-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.d-card h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.d-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
.d-card dt { color: var(--muted); }
.d-card dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.d-card dd.big { font-size: 22px; font-weight: 600; line-height: 1.1; }
.d-wide { grid-column: span 2; }
.d-keys { display: flex; flex-wrap: wrap; gap: 4px; }
.d-keys span { padding: 1px 7px; border-radius: 999px; font-size: 12px; color: #fff; }
.d-bars { display: grid; grid-template-columns: minmax(110px, auto) 1fr auto; gap: 4px 10px; align-items: center; font-size: 13px; }
.d-bars .bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.d-bars .bar > i { display: block; height: 100%; background: var(--accent); }
.d-bars .sep { grid-column: 1 / -1; height: 1px; background: var(--border); margin: 4px 0; }
.d-bars .num { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .detail { padding: 0; }
  .d-sheet { border-radius: 0; height: 100%; max-height: none; }
  .d-head { flex-wrap: wrap; }
  .d-cover { width: 64px; height: 64px; }
  .d-wide { grid-column: auto; }
}

/* ---------- "Enchaînements" panel ---------- */
.mix-panel { position: fixed; z-index: 40; width: min(440px, calc(100vw - 16px)); background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); padding: 12px 14px 14px; }
.mix-panel.hidden { display: none; }
.mix-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mix-head h3 { margin: 0; font-size: 15px; }
.mix-group { padding: 10px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.mix-group:first-of-type { border-top: 0; }
.mix-label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.mix-hint { margin: 0; font-size: 12px; color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: fit-content; max-width: 100%; }
.seg button { border: 0; border-left: 1px solid var(--border); border-radius: 0; background: transparent; padding: 5px 10px; font-size: 13px; color: var(--text); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.seg button:disabled { color: var(--muted); }
.seg-small button { font-size: 12px; padding: 4px 9px; }
.mix-status { border-top: 1px solid var(--border); padding-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.mix-status b { color: var(--text); font-weight: 600; }

/* ---- Browser (server): no Finder, no folder choice ---- */
html.web #pReveal, html.web #choose, html.web #open, html.web #engine { display: none; }
html.web .web-only.hidden { display: flex !important; }
#serverAccount { align-items: center; }

/* ==== Phone and small widths ==== */
@media (max-width: 760px) {
  /* Height of the screen actually visible (Safari's toolbar included), no scrolling of the page itself */
  html, body { height: 100%; height: 100svh; overflow: hidden; }
  body { font-size: 14px; }
  /* Tabs move to the bottom, in the flow (no overlap with the player) */
  .titlebar { order: 3; height: auto; margin: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-bottom: 0; border-top: 1px solid var(--border); -webkit-app-region: no-drag; }
  .titlebar .tabs { width: 100%; }
  .tab { flex: 1; padding: 8px 4px; text-align: center; font-size: 13px; }
  .help-btn { display: none; }
  .app-body { order: 1; }
  .bottom { order: 2; }
  .view { padding: 10px 12px 8px; gap: 8px; }
  .toolbar { gap: 6px; }
  .toolbar .spacer { display: none; }
  .toolbar #search { width: 100%; order: 10; }
  .toolbar #sort { flex: 1; min-width: 0; }
  /* Single-column list, smaller thumbnails */
  .view-list .item { grid-template-columns: 40px 1fr auto; padding: 6px 8px; }
  .view-list .idx { display: none; }
  .view-list .state { max-width: 90px; }
  .view-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; padding: 10px; }
  /* Detail panel: full-screen sheet */
  .app-body > .panel { position: fixed; inset: 0; width: auto; margin: 0; border-radius: 0; z-index: 45; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .p-cover-wrap { width: 60%; margin: 0 auto; }
  /* Compact player: cover, title, play; expands when the title is tapped */
  .player-bar { grid-template-columns: 40px 1fr auto; gap: 10px; padding: 8px 12px; }
  .pb-cover { width: 40px; height: 40px; }
  .player-bar .pb-wave, .player-bar #pbPrev, .player-bar #pbNext, .player-bar .pb-queue { display: none; }
  .player-bar .p-play { padding: 8px; }
  .player-bar.expanded { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px; }
  .player-bar.expanded .pb-cover { width: 56px; height: 56px; }
  .player-bar.expanded .pb-text { flex: 1; min-width: 0; }
  .player-bar.expanded .pb-wave { display: flex; width: 100%; order: 3; }
  .player-bar.expanded .p-controls { display: flex; width: 100%; order: 4; justify-content: center; gap: 24px; }
  .player-bar.expanded #pbPrev, .player-bar.expanded #pbNext { display: flex; }
  .player-bar.expanded .pb-queue { display: inline-flex; order: 5; margin-left: auto; }
  .statusbar-row { font-size: 11px; padding: 3px 12px; }
  /* Explorer: wheel and filters above the table, collapsible */
  .maker { flex-direction: column; }
  .maker-controls { width: auto; max-height: 48svh; flex-shrink: 0; }
  .maker-result { flex: 1; min-height: 0; }
  .wheel { max-width: min(220px, 40vh); }
  .mk-table td.t { max-width: 180px; }
  .maker-head { flex-wrap: wrap; }
  .maker-actions { flex-wrap: wrap; }
  .maker-actions #mkM3u, .maker-actions #mkRb { display: none; } /* exports are done from a computer */
  #viewAccount { max-width: none; }
  .pl-list li { flex-wrap: wrap; }
  .popover { max-width: calc(100vw - 16px); }
}
