/* Mew — feuille de style. Thème clair/sombre selon le système. */

:root {
  color-scheme: light dark;
  --bg: #f5f4fa;
  --surface: #ffffff;
  --surface-2: #eeedf5;
  --surface-3: #e2e0ee;
  --text: #191624;
  --muted: #625d75;
  --accent: #5b3fe0;
  --accent-strong: #4a2fcf;
  --on-accent: #ffffff;
  --border: #dfdcea;
  --danger: #c62f3d;
  --shadow: 0 10px 30px rgb(30 20 70 / 0.14);
  --radius: 14px;
  --nav-w: 220px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0d14;
    --surface: #17151f;
    --surface-2: #211e2c;
    --surface-3: #2e2a3c;
    --text: #edebf5;
    --muted: #a29db5;
    --accent: #a08fff;
    --accent-strong: #b6a9ff;
    --on-accent: #140f26;
    --border: #2b2838;
    --danger: #ff7480;
    --shadow: 0 10px 30px rgb(0 0 0 / 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
h1, h2 { letter-spacing: -0.01em; }
h1 { font-size: 28px; margin: 0; line-height: 1.15; }
h2 { font-size: 18px; margin: 0 0 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.icon { width: 22px; height: 22px; fill: currentColor; flex: none; }
.icon-sm { width: 16px; height: 16px; }

/* ------------------------------------------------------------------ boutons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; min-height: 40px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
  font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn .icon { width: 20px; height: 20px; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-danger { color: var(--danger); }
.btn-small { padding: 5px 12px; min-height: 32px; font-size: 13px; }
.btn-block { width: 100%; }
.btn.is-busy { border-color: var(--accent); color: var(--accent); }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ------------------------------------------------------------------ connexion */

#login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgb(143 116 255 / 0.25), transparent 45%),
    radial-gradient(circle at 85% 90%, rgb(75 39 214 / 0.22), transparent 45%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; padding: 32px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { border-radius: 16px; }
.login-card h1 { margin-top: 12px; font-size: 30px; }
.login-card .muted { margin: 4px 0 18px; }
.login-card .field { text-align: left; }
.login-message:empty { display: none; }
.login-message {
  margin: 0 0 16px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); font-size: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select {
  width: 100%; padding: 11px 13px; min-height: 44px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2);
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 0; background: var(--surface); }
.form-error { color: var(--danger); font-size: 14px; margin: 0 0 12px; min-height: 1.2em; }
.form-error:empty { min-height: 0; margin: 0; }

/* ------------------------------------------------------------------ structure */

#app {
  display: grid; height: 100dvh;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "banner banner" "nav main" "player player";
}

.topbar {
  grid-area: top; display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  min-width: calc(var(--nav-w) - 36px);
  font-weight: 750; font-size: 20px;
}
.brand img { border-radius: 8px; }
.search { position: relative; flex: 1; max-width: 520px; }
.search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }
.search input {
  width: 100%; padding: 10px 14px 10px 42px; min-height: 42px;
  border: 1px solid transparent; border-radius: 999px;
  background: var(--surface-2);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 0; background: var(--surface); }

.banners { grid-area: banner; }
.offline-banner {
  padding: 8px 20px; text-align: center; font-size: 14px;
  background: var(--surface-3);
}

.nav {
  grid-area: nav; display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border);
}
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--accent); }

#view {
  grid-area: main; overflow-y: auto; overscroll-behavior: contain;
  padding: 28px 32px 48px; outline: none;
}

.view-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px 20px; margin-bottom: 24px;
}
.view-head .actions { margin-top: 0; }
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.section { margin-top: 32px; }
.loading, .empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.segmented a { padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--muted); }
.segmented a[aria-current] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }

/* ------------------------------------------------------------------ pochettes et grilles */

.cover {
  aspect-ratio: 1; overflow: hidden; border-radius: var(--radius);
  background: var(--surface-2); color: var(--muted);
  display: grid; place-items: center;
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover--empty .icon { width: 40%; height: 40%; opacity: 0.6; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 24px 20px; }
.card { min-width: 0; }
.card-art { position: relative; }
.card-art .cover { box-shadow: 0 2px 10px rgb(0 0 0 / 0.08); transition: transform 0.15s; }
.card:hover .card-art .cover { transform: translateY(-2px); }
.card-title { display: block; margin-top: 10px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card-sub { color: var(--muted); font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card-play {
  position: absolute; right: 10px; bottom: 10px;
  width: 46px; height: 46px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(6px); transition: opacity 0.15s, transform 0.15s;
}
.card:hover .card-play, .card-play:focus-visible { opacity: 1; transform: none; }
.is-mobile .card-play { opacity: 1; transform: none; width: 38px; height: 38px; right: 8px; bottom: 8px; }
.badge-offline {
  position: absolute; left: 8px; top: 8px; padding: 4px; display: grid;
  border-radius: 999px; background: rgb(0 0 0 / 0.55); color: #fff;
}
.badge-offline .icon { width: 16px; height: 16px; }

/* ------------------------------------------------------------------ album */

.album-head { display: flex; align-items: flex-end; gap: 28px; margin-bottom: 28px; }
.cover--large { width: 232px; flex: none; box-shadow: var(--shadow); }
.album-meta { min-width: 0; }
.album-meta h1 { font-size: clamp(26px, 4vw, 42px); margin-bottom: 6px; overflow-wrap: anywhere; }
.album-artist { font-weight: 600; font-size: 17px; }
.album-artist:hover { text-decoration: underline; }
.album-meta .muted { margin: 4px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ------------------------------------------------------------------ listes de pistes */

.tracks { list-style: none; margin: 0; padding: 0; }
.track { display: flex; align-items: center; gap: 2px; border-radius: 10px; padding-right: 4px; }
.track:hover { background: var(--surface-2); }
.track-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px;
  padding: 9px 8px; border: 0; background: none; text-align: left; cursor: pointer;
}
.track-no { width: 28px; flex: none; display: flex; justify-content: flex-end; color: var(--muted); font-variant-numeric: tabular-nums; }
.track-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.track-title, .track-sub { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.track-sub { color: var(--muted); font-size: 13px; }
.track-dur { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.track.is-playing .track-title, .track.is-playing .track-no { color: var(--accent); font-weight: 600; }
.track .icon-btn { width: 36px; height: 36px; }
.track .icon-btn .icon { width: 20px; height: 20px; }

.letter-group { margin-bottom: 18px; }
.letter { font-size: 14px; color: var(--accent); margin: 0 0 6px 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list a { display: flex; align-items: center; gap: 14px; padding: 8px; border-radius: 10px; }
.list a:hover { background: var(--surface-2); }
.list-main { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.list-avatar {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-3); color: var(--muted);
}
.list-avatar--lg { width: 56px; height: 56px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: var(--surface-2); font-weight: 600; }
.chip:hover { background: var(--surface-3); }

/* ------------------------------------------------------------------ compte */

.panel {
  max-width: 720px; margin-bottom: 18px; padding: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.panel > .muted { margin-bottom: 0; }
.profile { display: flex; align-items: center; gap: 16px; }
.profile p { margin: 2px 0 0; }
.tag {
  display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 600;
}
.sessions { list-style: none; margin: 0; padding: 0; }
.session-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.session-row:first-child { border-top: 0; padding-top: 0; }
.session-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.session-text .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { max-width: 420px; }

/* ------------------------------------------------------------------ installation */

.install-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.install-banner img { border-radius: 10px; flex: none; }
.install-banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.install-banner-text span { color: var(--muted); font-size: 13px; }
.install-steps { margin: 4px 0 0; padding-left: 22px; line-height: 2; }
.inline-icon { display: inline-grid; place-items: center; vertical-align: -3px; color: var(--accent); }
.install-ok { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--accent); font-weight: 600; }
.install-panel .btn { margin-top: 4px; }

/* ------------------------------------------------------------------ dépôt d'album */

.icon-xl { width: 48px; height: 48px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  max-width: 760px; padding: 48px 24px; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--muted); transition: border-color 0.15s, background 0.15s;
}
.dropzone.is-over { border-color: var(--accent); background: var(--surface-2); }
.dropzone-title { margin: 8px 0 0; font-size: 18px; font-weight: 650; color: var(--text); }
.dropzone .actions { justify-content: center; }

.upload-bar { max-width: 760px; height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; }
.upload-bar-fill { width: 0; height: 100%; background: var(--accent); transition: width 0.2s; }
.upload-list { list-style: none; margin: 16px 0 0; padding: 0; max-width: 760px; font-size: 14px; }
.upload-list li { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-top: 1px solid var(--border); }
.upload-list li > span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.upload-list li.is-error { color: var(--danger); }

.import-top { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 20px; }
.import-cover-col { display: flex; flex-direction: column; align-items: center; gap: 10px; flex: none; }
.import-cover { width: 180px; box-shadow: var(--shadow); }
.import-album-fields { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; max-width: 640px; }
.warnings { list-style: none; margin: 0 0 16px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.warnings li { display: flex; gap: 8px; align-items: flex-start; padding: 2px 0; }
.warnings .icon { color: var(--danger); margin-top: 2px; }

.table-wrap { overflow-x: auto; margin-bottom: 12px; }
.import-tracks { width: 100%; border-collapse: collapse; font-size: 14px; }
.import-tracks th { text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 6px 6px; }
.import-tracks td { padding: 4px 6px; border-top: 1px solid var(--border); }
.import-tracks input {
  width: 100%; min-width: 140px; padding: 7px 9px; border: 1px solid transparent; border-radius: 8px;
  background: var(--surface-2);
}
.import-tracks input:focus { outline: 2px solid var(--accent); outline-offset: 0; background: var(--surface); }
.import-tracks input.input-num { width: 64px; min-width: 0; }
.import-tracks .num { font-variant-numeric: tabular-nums; }
.import-tracks .file-name { max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.is-hidden { display: none; }
.form-error ul { margin: 6px 0 10px; padding-left: 20px; }

.import-done { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 16px; }
.import-done .actions { justify-content: center; }
.done-icon { display: grid; place-items: center; width: 84px; height: 84px; margin-bottom: 12px; border-radius: 50%; background: var(--surface-2); color: var(--accent); }

/* ------------------------------------------------------------------ lecteur */

.player {
  grid-area: player;
  display: grid; align-items: center; column-gap: 20px; row-gap: 2px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
  grid-template-areas: "np buttons volume" "np progress volume";
  padding: 10px 20px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.np { grid-area: np; display: flex; align-items: center; gap: 12px; min-width: 0; }
.np-cover { width: 54px; flex: none; }
.np-cover .cover { border-radius: 8px; }
.np-text { min-width: 0; display: flex; flex-direction: column; }
.np-title { font-weight: 650; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.np-sub { color: var(--muted); font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.buttons { grid-area: buttons; justify-self: center; display: flex; align-items: center; gap: 14px; }
.play-btn {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--text); color: var(--bg);
}
.play-btn:hover { transform: scale(1.05); }
.progress {
  grid-area: progress; display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.progress span { min-width: 36px; text-align: center; }
.volume { grid-area: volume; display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: var(--muted); }
.volume .range { max-width: 120px; }

.range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; margin: 8px 0; border-radius: 4px; cursor: pointer;
  background: linear-gradient(to right, var(--accent) var(--progress, 0%), var(--surface-3) var(--progress, 0%));
}
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: 0; }
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: 0; }

/* ------------------------------------------------------------------ notifications */

.toast {
  position: fixed; z-index: 50; left: 50%; bottom: 110px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px;
  max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: 14px;
}
.toast-action { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }

/* ------------------------------------------------------------------ mobile */

@media (max-width: 760px) {
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas: "top" "banner" "main" "player" "nav";
  }
  .topbar { padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); gap: 12px; }
  .brand { min-width: 0; font-size: 18px; }
  .brand span { display: none; }
  #view { padding: 18px 16px 32px; }
  h1 { font-size: 24px; }

  .nav {
    flex-direction: row; justify-content: space-around; gap: 0;
    padding: 4px 4px max(4px, env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
  }
  .nav a { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11px; background: none !important; }

  .player {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "progress progress" "np buttons";
    padding: 2px 12px 8px; column-gap: 8px;
  }
  .has-player .nav { border-top: 0; }
  .volume { display: none; }
  .np-cover { width: 44px; }
  .buttons { gap: 4px; }
  .play-btn { width: 42px; height: 42px; }
  .progress span { min-width: 30px; font-size: 11px; }
  .range { margin: 6px 0; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 14px; }
  .album-head { flex-direction: column; align-items: center; text-align: center; gap: 18px; }
  .cover--large { width: min(64vw, 260px); }
  .actions { justify-content: center; }
  .view-head .actions { justify-content: flex-start; }
  .track-main { gap: 10px; padding: 10px 4px; }
  .track-no { width: 22px; }
  .toast { bottom: 150px; }
}
