/* RDM emedigital: estética de estudio de radio. Papel cálido, tinta y un acento bermellón. */

:root {
  color-scheme: light dark;
  --bg: #f5f0e6;
  --surface: #fbf8f1;
  --surface-2: #ebe4d6;
  --line: #d9d0be;
  --ink: #221c16;
  --muted: #6b6155;
  --accent: #b93a1e;
  --accent-strong: #b93a1e;
  --on-accent: #ffffff;
  --gold: #8a6414;
  --danger: #a82a1c;
  --danger-bg: #a82a1c;
  --scrim: rgb(34 28 22 / 0.5);
  --shadow: 0 10px 34px rgb(58 42 24 / 0.18);

  --font-ui: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

  --nav-height: 62px;
  --mini-height: 66px;
  --player-height: 88px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130f;
    --surface: #211b16;
    --surface-2: #2e2720;
    --line: #3d342b;
    --ink: #f1e9dc;
    --muted: #ac9f8f;
    --accent: #ff8a63;
    --accent-strong: #e8623d;
    --on-accent: #1a0f09;
    --gold: #dcb063;
    --danger: #ff8d7d;
    --danger-bg: #d9503d;
    --scrim: rgb(0 0 0 / 0.62);
    --shadow: 0 12px 38px rgb(0 0 0 / 0.5);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: none;
}

body.player-open { overflow: hidden; }

[hidden] { display: none !important; }

h1, h2, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
img { display: block; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon {
  width: 24px;
  height: 24px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted { color: var(--muted); }
.spacer { flex: 1; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Marca ---------- */

.brand {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand em, .login h1 em {
  font-weight: 400;
  color: var(--accent);
}

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
  font-size: 0.93rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms, border-color 120ms, transform 80ms;
}

.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn .icon { width: 19px; height: 19px; }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn.primary {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--on-accent);
}

.btn.primary:hover { filter: brightness(1.08); }

.btn.danger {
  border-color: var(--danger-bg);
  background: var(--danger-bg);
  color: #fff;
}

.btn.danger-text { color: var(--danger); }

.icon-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
}

.icon-btn:hover { background: var(--surface-2); }
.icon-btn.active { color: var(--accent); }
.icon-btn.danger { color: var(--danger); }

.link-btn {
  min-height: 36px;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 0.87rem;
  font-weight: 600;
}

/* ---------- Inicio de sesión ---------- */

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
}

.login-card {
  display: flex;
  flex-direction: column;
  width: min(100%, 370px);
  padding: 30px 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-logo { border-radius: 16px; margin-bottom: 16px; }
.login h1 { font-family: var(--font-display); font-size: 1.9rem; line-height: 1.15; }
.login p { color: var(--muted); }
.login-card > p:not(.form-error) { margin: 4px 0 24px; }
.login label { margin-bottom: 6px; font-size: 0.88rem; font-weight: 600; }
.login .btn { margin-top: 18px; }

input[type="password"], input[type="text"], input[type="search"], select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  /* 16 px evita que iOS haga zoom al enfocar */
  font-size: 16px;
}

.form-error {
  margin-top: 10px;
  color: var(--danger) !important;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---------- Estructura (primero el celular) ---------- */

.app { min-height: 100vh; min-height: 100dvh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 4px) 8px 4px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.sidenav { display: none; }

.content {
  padding: 0 16px calc(var(--nav-height) + var(--safe-bottom) + 28px);
}

body.has-player .content {
  padding-bottom: calc(var(--nav-height) + var(--mini-height) + var(--safe-bottom) + 28px);
}

.bottomnav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.tab-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.tab-link.active { color: var(--accent); }
.nav-icon { display: inline-flex; }

/* ---------- Vistas ---------- */

.view { position: relative; padding-top: 18px; }

.view-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 18px;
  margin-bottom: 12px;
}

.view-head h1 {
  font-family: var(--font-display);
  font-size: 1.95rem;
  line-height: 1.1;
}

.usage { width: min(100%, 230px); font-size: 0.85rem; }
.usage-text { color: var(--muted); }
.usage-text strong { color: var(--ink); }

.usage-bar {
  height: 5px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-2);
}

.usage-bar span {
  display: block;
  width: var(--fill, 0%);
  min-width: 2px;
  height: 100%;
  background: var(--gold);
}

.usage.warn .usage-bar span { background: var(--danger); }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  margin-bottom: 12px;
  font-size: 0.94rem;
  overflow-wrap: anywhere;
}

.breadcrumb a {
  display: inline-block;
  padding: 3px 0;
  color: var(--muted);
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--ink); text-decoration: underline; }
.breadcrumb a.current { color: var(--ink); font-weight: 600; }
.crumb-sep { color: var(--line); }

.toolbar, .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.summary { margin-left: 4px; font-size: 0.88rem; }

.selection-bar {
  position: sticky;
  top: 54px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  margin-bottom: 14px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

/* ---------- Filas ---------- */

.rows { border-top: 1px solid var(--line); }

.row {
  display: flex;
  align-items: center;
  min-height: 60px;
  border-bottom: 1px solid var(--line);
}

.row.selected { background: var(--surface-2); }
.row.pending { opacity: 0.62; }
.check-spacer { flex: none; width: 40px; }

/* Botón para instalar la app */
.install-btn {
  min-height: 38px;
  padding: 5px 12px;
  font-size: 0.84rem;
}

.install-btn .icon { width: 17px; height: 17px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.login .install-btn { align-self: center; margin-top: 12px; border: 0; background: none; color: var(--accent); }
.nav-install { margin: 0 4px 6px; }

.install-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 22px;
  list-style: decimal;
}

.install-steps .icon { width: 20px; height: 20px; margin: 0 2px; vertical-align: -5px; color: var(--accent); }

.row-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 60px;
  padding: 7px 4px;
  border: 0;
  background: none;
  text-align: left;
  text-decoration: none;
}

.row-main:hover .row-title { color: var(--accent); }
.row-main > .icon { color: var(--muted); }

.row-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
}

.row-icon.folder { color: var(--gold); }
.row-icon.audio { color: var(--accent); }

.row-cover, .queue-main img {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.row-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }

.row-title, .row-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 0.84rem; }

.row-time {
  flex: none;
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.row.playing .row-title { color: var(--accent); }

.row.playing .row-cover {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.reorder { display: flex; flex: none; }
.reorder .icon-btn { width: 36px; }
.reorder .icon { width: 20px; height: 20px; }

.check {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 44px;
  cursor: pointer;
}

.check input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.check-box {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1.6px solid var(--muted);
  border-radius: 6px;
  color: transparent;
}

.check-box .icon { width: 16px; height: 16px; stroke-width: 3; }

.check input:checked + .check-box {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--on-accent);
}

.check input:focus-visible + .check-box { outline: 2px solid var(--accent); outline-offset: 2px; }

.sentinel { height: 1px; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 12px;
  color: var(--ink);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
}

.empty-icon .icon { width: 34px; height: 34px; }

/* ---------- Música ---------- */

.tabs {
  display: flex;
  gap: 22px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 9px 0 10px;
  margin-bottom: -1px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.tab.active { border-color: var(--accent); color: var(--ink); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.search {
  position: relative;
  display: flex;
  flex: 1 1 260px;
  align-items: center;
}

.search .icon {
  position: absolute;
  left: 11px;
  width: 20px;
  height: 20px;
  color: var(--muted);
  pointer-events: none;
}

.search input { padding-left: 38px; }

.select {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.select select { width: auto; color: var(--ink); }

.playlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 18px 14px;
}

.playlist-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-decoration: none;
}

.playlist-card img {
  width: 100%;
  height: auto;
  margin-bottom: 8px;
  border-radius: var(--radius);
  aspect-ratio: 1;
}

.playlist-card:hover .row-title { color: var(--accent); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 40px;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.back-link .icon { width: 20px; height: 20px; }

.playlist-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.playlist-head img {
  flex: none;
  width: 96px;
  height: 96px;
  border-radius: var(--radius);
}

.playlist-title { min-width: 0; }

.playlist-title h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

/* ---------- Reproductor: barra compacta en el celular ---------- */

.player {
  --cover-hue: 20;
  position: fixed;
  right: 8px;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 6px);
  left: 8px;
  z-index: 25;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  height: var(--mini-height);
  padding-right: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pl-top, .pl-extra { display: none; }

.pl-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 100%;
  padding: 8px;
  border: 0;
  background: none;
  text-align: left;
}

.pl-cover {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 9px;
}

.pl-info { display: flex; flex-direction: column; min-width: 0; }

.pl-title, .pl-artist {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-title { font-size: 0.95rem; font-weight: 650; }
.pl-artist { color: var(--muted); font-size: 0.82rem; }

.pl-controls { display: flex; align-items: center; gap: 2px; }
.pl-secondary { display: none; }

.pl-play {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent-strong);
  color: var(--on-accent);
}

.pl-play:hover { filter: brightness(1.08); }
.pl-play .icon { width: 25px; height: 25px; stroke-width: 1; }

.pl-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  pointer-events: none;
}

.pl-progress .pl-clock { display: none; }

.pl-progress .slider {
  position: absolute;
  inset: 0;
  height: 3px;
}

.pl-progress .slider::-webkit-slider-thumb { opacity: 0; }
.pl-progress .slider::-moz-range-thumb { opacity: 0; }

/* Control deslizante */

.slider {
  --fill: 0%;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--line) var(--fill));
}

.slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--line) var(--fill));
}

.slider::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  appearance: none;
  -webkit-appearance: none;
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- Reproductor: pantalla completa en el celular ---------- */

.player.expanded {
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  height: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 24px calc(var(--safe-bottom) + 18px);
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(180deg, hsl(var(--cover-hue) 45% 42% / 0.32), transparent 62%),
    var(--bg);
  box-shadow: none;
}

.player.expanded .pl-top {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  margin: 0 -12px 4px;
}

.pl-top-label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.pl-top-space { width: 44px; }

.player.expanded .pl-identity {
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 20px;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 8px 0;
  cursor: default;
}

.player.expanded .pl-cover {
  align-self: center;
  width: min(100%, 44vh, 420px);
  height: auto;
  border-radius: 18px;
  box-shadow: var(--shadow);
  aspect-ratio: 1;
}

.player.expanded .pl-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1.2;
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.player.expanded .pl-artist { font-size: 1rem; }

.player.expanded .pl-progress {
  position: static;
  display: grid;
  flex: none;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  height: auto;
  margin-top: 10px;
  pointer-events: auto;
}

.player.expanded .pl-progress .slider {
  position: static;
  grid-column: 1 / -1;
  grid-row: 1;
  height: 28px;
}

.player.expanded .pl-progress .slider::-webkit-slider-thumb { opacity: 1; }
.player.expanded .pl-progress .slider::-moz-range-thumb { opacity: 1; }

.player.expanded .pl-clock {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.player.expanded #pl-total { text-align: right; }

.player.expanded .pl-controls {
  flex: none;
  justify-content: space-between;
  margin: 8px 0;
}

.player.expanded .pl-secondary { display: inline-flex; }
.player.expanded .pl-controls .icon-btn { width: 52px; height: 52px; }
.player.expanded .pl-controls .icon { width: 28px; height: 28px; }
.player.expanded .pl-play { width: 72px; height: 72px; }
.player.expanded .pl-play .icon { width: 36px; height: 36px; }

.player.expanded .pl-extra {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.pl-volume {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pl-volume-icon { display: inline-flex; color: var(--muted); }

/* ---------- Subidas ---------- */

.uploads {
  position: fixed;
  right: 8px;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 8px);
  left: 8px;
  z-index: 22;
  display: flex;
  flex-direction: column;
  max-height: 46vh;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

body.has-player .uploads {
  bottom: calc(var(--nav-height) + var(--mini-height) + var(--safe-bottom) + 14px);
}

.uploads-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 2px 4px 2px 12px;
  background: var(--surface-2);
}

.uploads-head-icon { display: inline-flex; color: var(--accent); }
.uploads-head-icon .icon { width: 20px; height: 20px; }
.uploads-title { flex: 1; min-width: 0; font-size: 0.92rem; }
.uploads-list { overflow-y: auto; }
.uploads.collapsed .uploads-list { display: none; }

.upload-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 4px 8px 12px;
  border-top: 1px solid var(--line);
}

.upload-text { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }

.upload-name {
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-status { color: var(--muted); font-size: 0.79rem; overflow-wrap: anywhere; }
.upload-item.error .upload-status { color: var(--danger); font-weight: 600; }
.upload-actions { display: flex; flex: none; }

.upload-bar {
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--surface-2);
}

.upload-bar span {
  display: block;
  width: var(--fill, 0%);
  height: 100%;
  background: var(--accent);
  transition: width 120ms linear;
}

.upload-item.done .upload-bar span { background: var(--gold); }
.upload-item.error .upload-bar, .upload-item.done .upload-bar { display: none; }

/* ---------- Arrastrar y soltar ---------- */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  background: var(--scrim);
  color: #fff;
  font-size: 1.15rem;
  text-align: center;
  pointer-events: none;
}

.drop-overlay .icon { width: 54px; height: 54px; margin-bottom: 8px; }
.view.dragging .drop-overlay { display: grid; }

/* ---------- Diálogos y menús ---------- */

dialog {
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

dialog::backdrop { background: var(--scrim); }

.sheet, .menu {
  width: 100%;
  margin: auto 0 0;
}

.sheet-box, .menu-box {
  display: flex;
  flex-direction: column;
  max-height: 86vh;
  max-height: 86dvh;
  padding-bottom: var(--safe-bottom);
  overflow: hidden;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sheet-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 8px 6px 18px;
}

.sheet-head h2 {
  min-width: 0;
  min-height: 44px;
  padding-top: 7px;
  font-family: var(--font-display);
  font-size: 1.28rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.sheet-body { flex: 1; min-height: 0; padding: 4px 18px 14px; overflow-y: auto; }

.sheet-foot {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}

.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; font-weight: 600; }
.field input { font-weight: 400; }

.menu-box { padding: 6px 0 calc(var(--safe-bottom) + 6px); overflow-y: auto; }

.menu-title {
  padding: 10px 18px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 50px;
  padding: 8px 18px;
  border: 0;
  background: none;
  text-align: left;
}

.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu-item .icon { width: 21px; height: 21px; }

.picker-path {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.queue-item {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.queue-item .icon-btn { width: 36px; }
.queue-item .icon-btn .icon { width: 19px; height: 19px; }

.queue-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 58px;
  padding: 6px 2px;
  border: 0;
  background: none;
  text-align: left;
}

.queue-main img { width: 40px; height: 40px; }
.queue-item.current .row-title { color: var(--accent); }

/* ---------- Editor de información y carátulas ---------- */

.row-cover, .pl-cover, .queue-main img, .playlist-card img, .playlist-head img, .editor-cover { object-fit: cover; }

.editor { display: flex; flex-direction: column; gap: 16px; }

.editor-cover-section { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px; }

.editor-cover {
  flex: none;
  width: 124px;
  height: 124px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.editor-cover-actions {
  display: flex;
  flex: 1 1 180px;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.editor-cover-actions .btn { min-height: 40px; padding: 6px 12px; font-size: 0.86rem; }
.editor-cover-actions .field-hint { flex-basis: 100%; }
.editor-cover-actions .field-hint:empty { display: none; }
.editor-fields { display: flex; flex-direction: column; gap: 12px; }
.editor-fields .field label { display: flex; flex-direction: column; gap: 6px; }

.field-hint {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.field-hint .icon { width: 15px; height: 15px; vertical-align: -3px; }
.field-hint .link-btn { min-height: 28px; padding: 2px 4px; font-size: 0.82rem; text-decoration: underline; }

.cover-search-form { display: flex; gap: 8px; margin-bottom: 12px; }
.cover-search-form input { flex: 1; min-width: 0; }

.cover-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 12px 10px;
  margin-bottom: 8px;
}

.cover-results .empty { grid-column: 1 / -1; padding: 28px 8px; }
.cover-results.busy { opacity: 0.5; pointer-events: none; }

.cover-result {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}

.cover-result img {
  width: 100%;
  height: auto;
  margin-bottom: 5px;
  border-radius: 8px;
  aspect-ratio: 1;
  object-fit: cover;
}

.cover-result .row-title { font-size: 0.84rem; }
.cover-result .row-sub { font-size: 0.76rem; }
.cover-result:hover .row-title { color: var(--accent); }
.scan-box { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Avisos ---------- */

.toasts {
  position: fixed;
  right: 12px;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  left: 12px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

body.has-player .toasts {
  bottom: calc(var(--nav-height) + var(--mini-height) + var(--safe-bottom) + 18px);
}

.toast {
  max-width: 480px;
  padding: 10px 15px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: var(--shadow);
}

.toast.error { background: var(--danger-bg); color: #fff; }

/* ---------- Computador ---------- */

@media (min-width: 820px) {
  .topbar, .bottomnav { display: none; }

  .sidenav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 15;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 224px;
    padding: 22px 12px 18px;
    border-right: 1px solid var(--line);
    background: var(--surface);
  }

  body.has-player .sidenav { bottom: var(--player-height); }

  .sidenav .brand { padding: 0 12px 20px; }

  .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 46px;
    padding: 8px 12px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--muted);
    font-weight: 600;
    text-align: left;
    text-decoration: none;
  }

  .nav-link:hover { background: var(--surface-2); color: var(--ink); }
  .nav-link.active { background: var(--surface-2); color: var(--accent); }
  .nav-install { margin-top: auto; }
  .nav-install[hidden] + .nav-logout { margin-top: auto; }
  .nav-logout { font-weight: 500; }

  .content {
    max-width: 1140px;
    margin-left: 224px;
    padding: 12px 36px 40px;
  }

  body.has-player .content { padding-bottom: calc(var(--player-height) + 32px); }

  .view-head h1 { font-size: 2.3rem; }

  .selection-bar { top: 8px; }

  .row-main { padding-inline: 8px; }
  .row:hover { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }

  .player {
    right: 0;
    bottom: 0;
    left: 0;
    grid-template-columns: minmax(180px, 1fr) minmax(320px, 1.5fr) minmax(180px, 1fr);
    gap: 18px;
    height: var(--player-height);
    padding: 0 18px 0 10px;
    overflow: visible;
    border-width: 1px 0 0;
    border-radius: 0;
    box-shadow: none;
  }

  .pl-identity { grid-column: 1; grid-row: 1 / span 2; cursor: default; }
  .pl-cover { width: 62px; height: 62px; }

  .pl-controls {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    justify-content: center;
    gap: 6px;
  }

  .pl-secondary { display: inline-flex; }
  .pl-controls .pl-play { width: 44px; height: 44px; }
  .pl-controls .icon-btn { width: 40px; height: 40px; }

  .pl-progress {
    position: static;
    display: grid;
    grid-column: 2;
    grid-row: 2;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 8px;
    align-self: start;
    height: auto;
    pointer-events: auto;
  }

  .pl-progress .pl-clock {
    display: block;
    color: var(--muted);
    font-size: 0.77rem;
    font-variant-numeric: tabular-nums;
  }

  #pl-time { text-align: right; }

  .pl-progress .slider { position: static; height: 20px; }
  .pl-progress .slider::-webkit-slider-thumb { opacity: 1; }
  .pl-progress .slider::-moz-range-thumb { opacity: 1; }

  .pl-extra {
    display: flex;
    grid-column: 3;
    grid-row: 1 / span 2;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
  }

  .pl-volume { flex: 0 1 150px; }

  .player { grid-template-rows: 1fr 1fr; }

  .uploads {
    right: 22px;
    bottom: 22px;
    left: auto;
    width: 400px;
    max-height: 58vh;
  }

  body.has-player .uploads { bottom: calc(var(--player-height) + 14px); }

  .toasts {
    right: 24px;
    bottom: 24px;
    left: 248px;
  }

  body.has-player .toasts { bottom: calc(var(--player-height) + 16px); }

  .sheet {
    width: min(92vw, 520px);
    margin: auto;
  }

  .sheet-box { max-height: 76vh; border-radius: 18px; }

  .menu {
    position: fixed;
    width: 270px;
    margin: auto;
    inset: auto;
  }

  .menu-box { border: 1px solid var(--line); border-radius: 12px; }

  .playlist-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .playlist-head img { width: 130px; height: 130px; }
}

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