/* =========================================================
   Lecteur rapide — design chaleureux, doux et arrondi
   ========================================================= */

:root {
  --font-ui: "Nunito", ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI", sans-serif;
  --font-reading: var(--font-ui);
  --font-scale: 1;

  --r-xl: 30px;
  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 14px;
  --ease: cubic-bezier(.3, .7, .25, 1);
}

/* ---------- Clair : crème, pêche, terre cuite ---------- */
[data-theme="light"] {
  --bg: #f7f1e8;
  --bg-glow-1: rgba(255, 190, 150, .38);
  --bg-glow-2: rgba(255, 224, 170, .40);
  --surface: #fffbf5;
  --surface-2: #f3eadd;
  --surface-3: #ebdfcf;
  --text: #3d3029;
  --text-soft: #6e5f53;
  --muted: #a3917f;
  --line: rgba(120, 85, 55, .11);
  --accent: #e46d4f;
  --primary: #e5825c;
  --primary-2: #efa772;
  --primary-text: #fffaf4;
  --primary-soft: rgba(229, 130, 92, .14);
  --shadow: 0 1px 2px rgba(110, 70, 40, .05), 0 12px 32px -8px rgba(110, 70, 40, .14);
  --shadow-lg: 0 2px 6px rgba(110, 70, 40, .06), 0 28px 60px -16px rgba(110, 70, 40, .26);
  color-scheme: light;
}

/* ---------- Sombre : chocolat, braise, lueur de bougie ---------- */
[data-theme="dark"] {
  --bg: #1a1613;
  --bg-glow-1: rgba(233, 130, 90, .13);
  --bg-glow-2: rgba(240, 180, 110, .07);
  --surface: #241e1a;
  --surface-2: #2e2621;
  --surface-3: #3a302a;
  --text: #f4ebe1;
  --text-soft: #cdbfb1;
  --muted: #918072;
  --line: rgba(255, 225, 195, .08);
  --accent: #ff9a76;
  --primary: #ea8a63;
  --primary-2: #f1a874;
  --primary-text: #2a1a12;
  --primary-soft: rgba(234, 138, 99, .16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -10px rgba(0, 0, 0, .55);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .35), 0 30px 70px -18px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

[data-family="serif"]  { --font-reading: "Literata", Georgia, "Times New Roman", serif; }
[data-family="system"] { --font-reading: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg); transition: background-color .4s var(--ease); }
body {
  color: var(--text);
  font: 500 16px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  background:
    radial-gradient(60vmax 50vmax at 0% 0%, var(--bg-glow-1), transparent 60%),
    radial-gradient(55vmax 45vmax at 100% 100%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: color .4s var(--ease);
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.filled { fill: currentColor; stroke: none; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

[data-theme="light"] .when-dark, [data-theme="dark"] .when-light { display: none; }

.view {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 22px 40px;
  animation: fade-up .5s var(--ease) both;
}
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } }

/* ---------- En-tête ---------- */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; min-height: 48px; }
.brand { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.logo {
  width: 50px; height: 50px; border-radius: 17px; flex: none;
  display: grid; place-items: center; grid-auto-flow: column; gap: 1px;
  background: linear-gradient(145deg, var(--primary-2), var(--primary));
  color: var(--primary-text); font-size: 24px; font-weight: 800; letter-spacing: -.02em;
  box-shadow: 0 10px 22px -8px var(--primary);
}
.logo { display: flex; justify-content: center; }
.logo b { color: #fff; opacity: .75; }
[data-theme="dark"] .logo b { color: #2a1a12; opacity: .55; }
.greet { margin: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.top h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.top-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 46px; height: 46px; border-radius: 16px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-soft); background: var(--surface); box-shadow: var(--shadow);
  transition: transform .2s var(--ease), background .2s, color .2s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:active { transform: scale(.92); }
.amb-btn.on { color: var(--primary-text); background: linear-gradient(145deg, var(--primary-2), var(--primary)); }
.sheet .icon-btn { box-shadow: none; background: var(--surface-2); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px;
  font-weight: 700; font-size: 15.5px; cursor: pointer; user-select: none;
  transition: transform .2s var(--ease), box-shadow .2s, background .2s;
}
.btn svg { width: 19px; height: 19px; }
.btn:active { transform: scale(.96); }
.btn.primary {
  color: var(--primary-text);
  background: linear-gradient(145deg, var(--primary-2), var(--primary));
  box-shadow: 0 10px 22px -10px var(--primary);
  padding: 0 24px;
}
.btn.primary:hover { box-shadow: 0 14px 28px -10px var(--primary); }
.btn.soft { background: var(--surface-2); color: var(--text-soft); }
.btn.soft:hover { background: var(--surface-3); color: var(--text); }

/* ---------- Cartes ---------- */
.card {
  position: relative;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow); padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
}
.card-head h2, .section-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.card-head p { margin: 2px 0 0; }

input[type="text"], textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface-2); border: 2px solid transparent; border-radius: var(--r-md);
  padding: 13px 16px; transition: border-color .2s, background .2s;
}
input[type="text"]::placeholder, textarea::placeholder { color: var(--muted); }
input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--primary-soft); background: var(--surface); box-shadow: 0 0 0 4px var(--primary-soft); }
textarea { min-height: 150px; resize: vertical; line-height: 1.6; }
#title-input { font-weight: 700; }

.status { margin: 0; font-size: 14px; color: var(--text-soft); background: var(--primary-soft); padding: 10px 14px; border-radius: var(--r-sm); }
.status:empty { display: none; }

.drop-overlay {
  position: fixed; inset: 14px; z-index: 40; border-radius: var(--r-xl);
  border: 3px dashed var(--primary); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center; font-weight: 800; font-size: 20px; color: var(--primary);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.drop-overlay > div { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.drop-overlay svg { width: 40px; height: 40px; }
body.dragging .drop-overlay { opacity: 1; }

/* ---------- Bibliothèque ---------- */
.lib { margin-top: 6px; }
.section-head { display: flex; align-items: center; gap: 10px; margin: 0 4px 16px; }
.section-head h2 { font-size: 22px; }
.section-head .small-btn { min-height: 42px; padding: 0 16px; font-size: 14.5px; }
.lib > .status { margin-bottom: 14px; }
.empty .btn { margin-top: 18px; }
.empty strong { color: var(--text-soft); }
.sheet-intro { margin: -8px 0 0; }
#paste-sheet textarea { min-height: 200px; }
.section-head h2 { white-space: nowrap; }
@media (max-width: 420px) {
  .hide-xs, .section-head .count { display: none; }
  .section-head { gap: 8px; }
  .section-head h2 { font-size: 20px; }
  .section-head #btn-paste { padding: 0 12px; }
}
.count { font-size: 13px; font-weight: 800; color: var(--primary); background: var(--primary-soft); padding: 2px 10px; border-radius: 999px; }
.count:empty { display: none; }

.doc-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.doc {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 14px 12px 14px 14px; cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s;
  animation: fade-up .45s var(--ease) both;
}
.doc:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.doc:active { transform: scale(.99); }
.avatar {
  width: 52px; height: 52px; border-radius: 17px; flex: none;
  display: grid; place-items: center; font-size: 22px; font-weight: 800;
  color: #4a3326; background: var(--hue);
}
[data-theme="dark"] .avatar { color: #2a1c15; filter: saturate(.85) brightness(.92); }
.doc-main { flex: 1; min-width: 0; }
.doc-name { font-weight: 800; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 13.5px; color: var(--muted); margin-top: 1px; }
.doc-bar { height: 6px; background: var(--surface-2); border-radius: 999px; margin-top: 9px; overflow: hidden; }
.doc-bar > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary-2), var(--primary)); }
.doc .icon-btn { box-shadow: none; background: transparent; color: var(--muted); width: 40px; height: 40px; }
.doc .icon-btn:hover { background: var(--surface-2); color: var(--accent); }
.doc .icon-btn svg { width: 19px; height: 19px; }

.empty { text-align: center; color: var(--muted); padding: 34px 20px; border: 2px dashed var(--line); border-radius: var(--r-xl); }
.empty p { margin: 12px 0 0; }
.empty-icon { width: 64px; height: 64px; margin: 0 auto; border-radius: 22px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty-icon svg { width: 30px; height: 30px; }

/* ---------- Lecteur ---------- */
#reader { display: flex; flex-direction: column; height: 100dvh; padding-bottom: 18px; }
.doc-title { flex: 1; min-width: 0; text-align: center; padding: 0 6px; display: flex; flex-direction: column; align-items: center; }
.doc-title > div, .chapter-name { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-title > div { font-weight: 800; font-size: 16px; }
.chapter-name { font-size: 13px; font-weight: 700; color: var(--primary); padding: 1px 10px; border-radius: 999px; }
.chapter-name:hover { background: var(--primary-soft); }

/* ---------- Chapitres ---------- */
.chapter-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.chapter-list button {
  width: 100%; display: flex; align-items: baseline; gap: 12px; text-align: left;
  padding: 11px 14px; border-radius: 16px; transition: background .2s;
  padding-left: calc(14px + var(--depth, 0) * 18px);
}
.chapter-list button:hover { background: var(--surface-2); }
.chapter-list .ch-title { flex: 1; font-weight: 700; line-height: 1.35; }
.chapter-list [data-depth="0"] .ch-title { font-weight: 800; }
.chapter-list .ch-meta { font-size: 12.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chapter-list .done .ch-title { color: var(--muted); }
.chapter-list .current { background: var(--primary-soft); }
.chapter-list .current .ch-title { color: var(--text); }
.chapter-list .current .ch-meta { color: var(--primary); }

.stage {
  position: relative; flex: none;
  height: clamp(190px, 34vh, 300px);
  display: flex; flex-direction: column; justify-content: center;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  cursor: pointer; user-select: none; -webkit-user-select: none; overflow: hidden;
  transition: transform .3s var(--ease);
}
.stage:active { transform: scale(.995); }
.guide { position: relative; height: 26px; margin: 0 12%; }
.guide-top    { background: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent) top / 100% 2px no-repeat; }
.guide-bottom { background: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent) bottom / 100% 2px no-repeat; }
.guide::after {
  content: ""; position: absolute; left: 50%; width: 4px; height: 12px; border-radius: 4px;
  background: var(--accent); opacity: .45; transform: translateX(-2px);
}
.guide-top::after { top: 0; }
.guide-bottom::after { bottom: 0; }

.word {
  display: grid; grid-template-columns: 1fr auto 1fr;
  font-family: var(--font-reading);
  font-size: calc(clamp(36px, 7.6vw, 62px) * var(--font-scale) * var(--fit, 1));
  line-height: 1.3; font-weight: 600; white-space: pre; padding: 12px 0;
  letter-spacing: .005em; font-variant-ligatures: none;
}
[data-family="serif"] .word { font-weight: 500; }
.word .pre { text-align: right; overflow: hidden; }
.word .post { text-align: left; overflow: hidden; }
.word .orp { color: var(--accent); }

.state-hint {
  position: absolute; left: 0; right: 0; bottom: 12px; text-align: center;
  font-size: 13px; font-weight: 700; color: var(--muted); transition: opacity .3s;
}
.stage.playing .state-hint { opacity: 0; }

.context {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; white-space: pre-wrap;
  margin: 18px 4px 0; padding: 4px 8px;
  color: var(--muted); font-family: var(--font-reading); font-size: 17.5px; line-height: 1.75;
  transition: opacity .35s var(--ease);
  mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent);
  -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent);
}
.context span { cursor: pointer; border-radius: 6px; }
.context span:hover { color: var(--text-soft); }
.context mark { background: var(--primary-soft); color: var(--text); font-weight: 700; padding: 1px 4px; border-radius: 8px; }
.context.hidden-ctx { opacity: 0; pointer-events: none; }

.dock {
  margin-top: 14px; background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow); padding: 14px 18px 18px;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; cursor: pointer;
  --pct: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) var(--pct), var(--surface-2) var(--pct));
}
input[type="range"]::-moz-range-track { height: 8px; border-radius: 999px; background: var(--surface-2); }
input[type="range"]::-moz-range-progress { height: 8px; border-radius: 999px; background: var(--primary); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; margin-top: -7px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--primary); box-shadow: 0 3px 10px -2px rgba(0,0,0,.25);
  transition: transform .15s;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary);
}
.progress-info { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 2px; }

.controls { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 12px; }
.ctrl {
  width: 50px; height: 50px; border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-soft); background: var(--surface-2);
  transition: transform .2s var(--ease), background .2s, color .2s;
}
.ctrl:hover { background: var(--surface-3); color: var(--text); }
.ctrl:active { transform: scale(.9); }
.ctrl.play {
  width: 74px; height: 74px; border-radius: 26px;
  color: var(--primary-text); background: linear-gradient(145deg, var(--primary-2), var(--primary));
  box-shadow: 0 14px 28px -12px var(--primary);
}
.ctrl.play svg { width: 30px; height: 30px; }
.i-pause { display: none; }
.playing-ui .controls .i-play { display: none; }
.playing-ui .controls .i-pause { display: block; }

.speed { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 14px; }
.speed-btn {
  width: 42px; height: 42px; border-radius: 15px; font-size: 22px; font-weight: 700; line-height: 1;
  color: var(--text-soft); background: var(--surface-2); transition: transform .2s var(--ease), background .2s;
}
.speed-btn:hover { background: var(--surface-3); }
.speed-btn:active { transform: scale(.9); }
.speed-label { min-width: 120px; text-align: center; display: flex; flex-direction: column; line-height: 1.1; }
.speed-label strong { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.speed-label span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.hint { text-align: center; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 14px 0 0; }
@media (hover: none) { .desktop-only { display: none; } }

/* ---------- Feuilles (réglages, ambiance) ---------- */
dialog.sheet {
  border: 0; padding: 22px; color: var(--text); background: var(--surface);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  width: min(460px, calc(100vw - 28px)); max-height: min(86dvh, 760px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px;
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
dialog.sheet :focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 2px; }
dialog.sheet[open] { animation: sheet-in .35s var(--ease); }
dialog::backdrop { background: rgba(40, 24, 14, .35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 21px; font-weight: 800; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; color: var(--text-soft); font-size: 15px; }
.field-label strong { color: var(--text); font-weight: 800; }

.seg { display: flex; gap: 4px; background: var(--surface-2); padding: 5px; border-radius: 18px; }
.seg button {
  flex: 1; min-height: 40px; border-radius: 14px; font-weight: 700; color: var(--text-soft);
  transition: background .25s var(--ease), color .2s, box-shadow .25s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px -2px rgba(0,0,0,.15); }
[data-theme="dark"] .seg button.active { background: var(--surface-3); }
.f-round { font-family: "Nunito", sans-serif; }
.f-serif { font-family: "Literata", Georgia, serif; }
.f-system { font-family: -apple-system, "Segoe UI", Arial, sans-serif; }

.toggle { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.toggle > span { flex: 1; display: flex; flex-direction: column; }
.toggle strong { font-weight: 700; font-size: 15.5px; }
.toggle small { color: var(--muted); font-size: 13px; font-weight: 600; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i {
  position: relative; width: 50px; height: 30px; border-radius: 999px; flex: none;
  background: var(--surface-3); transition: background .25s var(--ease);
}
.toggle i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .3s var(--ease);
}
.toggle input:checked + i { background: var(--primary); }
.toggle input:checked + i::after { transform: translateX(20px); }
.toggle input:focus-visible + i { outline: 3px solid var(--primary-soft); outline-offset: 2px; }

/* ---------- Ambiance ---------- */
.amb-pane { display: flex; flex-direction: column; gap: 16px; }
.amb-pane[hidden] { display: none; }
.noise-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  position: relative; text-align: left; border-radius: var(--r-lg); padding: 14px;
  background: var(--surface-2); display: flex; flex-direction: column; gap: 8px;
  transition: transform .2s var(--ease), background .2s, box-shadow .2s;
}
.tile:hover { background: var(--surface-3); }
.tile:active { transform: scale(.97); }
.tile.active { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.tile-icon { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: var(--primary); background: var(--surface); }
.tile.active .tile-icon { color: var(--primary-text); background: linear-gradient(145deg, var(--primary-2), var(--primary)); }
.tile-txt { display: flex; flex-direction: column; gap: 2px; }
.tile strong { font-weight: 800; font-size: 15px; line-height: 1.2; }
.tile small { color: var(--muted); font-size: 12.5px; font-weight: 600; line-height: 1.3; }

.music-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.mtile { padding: 8px; gap: 8px; }
.mtile .thumb {
  aspect-ratio: 16 / 9; border-radius: 16px; background: var(--surface-3) center / cover no-repeat; position: relative; overflow: hidden;
}
.mtile .thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 55%, rgba(0,0,0,.35)); }
.mtile .tag {
  position: absolute; left: 8px; bottom: 7px; z-index: 1; font-size: 11px; font-weight: 800; color: #fff;
  background: rgba(0,0,0,.35); backdrop-filter: blur(6px); padding: 2px 8px; border-radius: 999px;
}
.mtile .tag.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #ff6a5a; margin-right: 5px; vertical-align: 1px; }
.mtile strong { padding: 0 4px 4px; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mtile .del {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 28px; height: 28px; border-radius: 10px;
  display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff;
}
.mtile .del svg { width: 15px; height: 15px; stroke-width: 2.4; }
.yt-add { display: flex; gap: 8px; }
.yt-add input { flex: 1; min-width: 0; padding: 11px 14px; }
.small-btn { min-height: 46px; padding: 0 18px; }

.vol { display: flex; align-items: center; gap: 14px; font-weight: 700; color: var(--text-soft); font-size: 14.5px; }
.vol input { flex: 1; }

/* ---------- Mini lecteur d'ambiance ---------- */
.nowplaying {
  position: fixed; z-index: 20; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px;
  width: min(360px, calc(100vw - 24px)); padding: 8px 8px 8px 8px;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lg);
  animation: np-in .4s var(--ease);
}
@keyframes np-in { from { opacity: 0; transform: translateY(16px); } }
.np-media { position: relative; width: 58px; height: 58px; flex: none; border-radius: 17px; overflow: hidden; background: var(--primary-soft); }
.yt-holder { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.yt-holder.show { opacity: 1; }
.yt-holder iframe { position: absolute; width: 104px; height: 58px; left: -23px; top: 0; border: 0; pointer-events: none; }
.np-wave { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 4px; }
.yt-holder.show + .np-wave { display: none; }
.np-wave i { width: 5px; height: 12px; border-radius: 4px; background: var(--primary); }
.nowplaying.is-playing .np-wave i { animation: wave 1.1s ease-in-out infinite; }
.np-wave i:nth-child(2) { animation-delay: -.3s !important; }
.np-wave i:nth-child(3) { animation-delay: -.6s !important; }
.np-wave i:nth-child(4) { animation-delay: -.85s !important; }
@keyframes wave { 0%, 100% { height: 10px; } 50% { height: 30px; } }
.np-text { flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; }
.np-title { font-weight: 800; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-sub { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-btn {
  width: 44px; height: 44px; border-radius: 15px; flex: none; display: grid; place-items: center;
  color: var(--primary-text); background: linear-gradient(145deg, var(--primary-2), var(--primary));
  transition: transform .2s var(--ease);
}
.np-btn:active { transform: scale(.9); }
.np-btn.ghost { background: var(--surface-2); color: var(--muted); width: 38px; height: 38px; border-radius: 13px; }
.np-btn svg { width: 20px; height: 20px; }
.nowplaying .i-pause { display: none; }
.nowplaying.is-playing .np-btn .i-play { display: none; }
.nowplaying.is-playing .np-btn .i-pause { display: block; }

/* Laisse de la place au mini lecteur */
body.has-np .view { padding-bottom: 110px; }
body.has-np #reader { padding-bottom: 96px; }
@media (min-width: 1100px) {
  body.has-np .view, body.has-np #reader { padding-bottom: 18px; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top)); z-index: 50;
  transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 14.5px;
  padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow-lg);
  transition: opacity .3s var(--ease), transform .3s var(--ease); max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .view { padding: 14px 16px 28px; }
  .top { margin-bottom: 18px; }
  .top h1 { font-size: 23px; }
  .logo { width: 44px; height: 44px; border-radius: 15px; font-size: 21px; }
  .icon-btn { width: 42px; height: 42px; border-radius: 14px; }
  .card { padding: 18px; border-radius: 26px; }
  .controls { gap: 8px; }
  .ctrl { width: 46px; height: 46px; border-radius: 16px; }
  .ctrl.play { width: 68px; height: 68px; border-radius: 24px; }
  .dock { padding: 12px 14px 16px; }

  dialog.sheet {
    margin: auto 0 0; width: 100%; max-width: 100%; max-height: 90dvh;
    border-radius: 30px 30px 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  }
  dialog.sheet[open] { animation: sheet-up .4s var(--ease); }
  dialog.sheet::before { content: ""; align-self: center; width: 42px; height: 5px; border-radius: 9px; background: var(--surface-3); margin: -6px 0 -6px; }
  .noise-grid { grid-template-columns: 1fr; }
  .noise-grid .tile { flex-direction: row; align-items: center; gap: 12px; }
  .nowplaying { right: 12px; left: 12px; width: auto; bottom: calc(12px + env(safe-area-inset-bottom)); }
}
@keyframes sheet-up { from { transform: translateY(100%); } }

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