:root {
  --bg: #f4f4f7; --card: #ffffff; --text: #17171c; --muted: #6b6b76; --line: #e3e3ea;
  --field: #f7f7fa; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.06);
  --ok: #16a34a; --warn: #d97706; --error: #dc2626; --info: #2563eb;
  --g1: #ff0050; --g2: #ff6a3d; --accent: #ff0050;
  --radius: 16px; --nav-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0f13; --card: #1a1a21; --text: #f1f1f4; --muted: #9c9ca8; --line: #2b2b35;
          --field: #22222b; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
          --ok: #22c55e; --warn: #f59e0b; --error: #f87171; --info: #60a5fa; }
}
body[data-kind="audio"]  { --g1: #ff0050; --g2: #ff6a3d; --accent: #ff2d55; }
body[data-kind="video"]  { --g1: #6d28d9; --g2: #2563eb; --accent: #5b5bf0; }
body[data-kind="images"] { --g1: #f97316; --g2: #db2777; --accent: #e0306f; }
body[data-kind="library"], body[data-kind="settings"] { --g1: #0f766e; --g2: #0ea5e9; --accent: #0e9fb0; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ── barra superior ── */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; letter-spacing: -.2px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.spacer { flex: 1; }
.jobs-pill { display: flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 6px 12px;
  background: var(--accent); color: #fff; font-weight: 650; font-size: 13px; cursor: pointer; }
.jobs-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ── navegación ── */
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line); }
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--muted); font-size: 11.5px; font-weight: 600; cursor: pointer; }
.nav button .ico { font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .75; transition: .15s; }
.nav button.active { color: var(--accent); }
.nav button.active .ico { filter: none; opacity: 1; transform: translateY(-1px) scale(1.08); }
@media (min-width: 900px) {
  body { padding-bottom: 32px; }
  .nav { position: sticky; top: 57px; height: auto; padding: 10px 0; justify-content: center; gap: 6px;
    background: transparent; border: 0; }
  .nav button { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 9px 16px; border-radius: 999px;
    font-size: 14px; background: var(--card); box-shadow: var(--shadow); }
  .nav button.active { background: var(--accent); color: #fff; }
  .nav button .ico { font-size: 17px; }
}

main { max-width: 860px; margin: 0 auto; padding: 14px 14px 0; }

/* ── tarjetas ── */
.hero { border-radius: 20px; padding: 20px 20px 18px; color: #fff; margin-bottom: 12px;
  background: linear-gradient(135deg, var(--g1), var(--g2)); box-shadow: var(--shadow); }
.hero h1 { margin: 0; font-size: 23px; letter-spacing: -.3px; }
.hero p { margin: 5px 0 0; opacity: .92; font-size: 14px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow); border: 1px solid var(--line); }
.step { display: flex; align-items: center; gap: 9px; font-weight: 700; margin: 0 0 10px; font-size: 15.5px; }
.step .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 13px; flex: none; }
.step .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12.5px; }

/* ── campos ── */
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
input[type=text], input[type=url], input[type=password], select {
  width: 100%; border: 1px solid var(--line); background: var(--field); border-radius: 12px;
  padding: 11px 13px; outline: none; min-height: 46px; font-size: 16px; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
label.field { display: block; margin: 0 0 10px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 650; color: var(--muted); margin: 0 0 4px 2px; }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; padding: 4px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--field); border-radius: 12px; padding: 10px 16px; min-height: 44px; font-weight: 650;
  cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.main { border: 0; color: #fff; background: linear-gradient(135deg, var(--g1), var(--g2));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--g1) 35%, transparent); }
.btn.big { width: 100%; min-height: 52px; font-size: 16.5px; border-radius: 14px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--error); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }

/* ── estado / progreso ── */
.status { margin: 10px 2px 0; font-size: 14px; font-weight: 550; }
.status.info { color: var(--info); } .status.ok { color: var(--ok); }
.status.warn { color: var(--warn); } .status.error { color: var(--error); }
.status:empty { display: none; }
.bar { height: 10px; border-radius: 999px; background: var(--field); overflow: hidden; margin-top: 12px;
  border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; width: 0; border-radius: 999px; transition: width .35s ease;
  background: linear-gradient(90deg, var(--g1), var(--g2)); }
.bar.indeterminate > i { width: 35% !important; animation: slide 1.1s infinite ease-in-out; }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }
.bar.ok > i { background: var(--ok); } .bar.error > i { background: var(--error); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600;
  background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--text); }

/* ── vista previa ── */
.preview { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 620px) { .preview { grid-template-columns: 240px 1fr; } }
.cover { width: 100%; max-width: 320px; margin: 0 auto; display: block; border-radius: 14px; background: var(--field);
  box-shadow: 0 6px 22px rgba(0,0,0,.18); object-fit: cover; }
.title { font-weight: 750; font-size: 17px; line-height: 1.25; word-break: break-word; }
.note { font-size: 13px; color: var(--muted); background: var(--field); border-radius: 10px; padding: 9px 11px;
  margin-top: 8px; line-height: 1.45; }
.note.warn { color: var(--warn); }

/* listas (playlists) */
.list-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.entries { max-height: 460px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.entry { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.entry:last-child { border-bottom: 0; }
.entry input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.entry img, .entry .ph { width: 72px; height: 41px; border-radius: 6px; object-fit: cover; background: var(--field); flex: none; }
.entry .t { font-size: 14px; font-weight: 600; line-height: 1.25; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* galería de imágenes */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { position: relative; border: 2px solid var(--line); border-radius: 14px; padding: 6px; cursor: pointer;
  background: var(--field); transition: border-color .15s; }
.tile.on { border-color: var(--accent); }
.tile img { width: 100%; height: 170px; object-fit: contain; border-radius: 9px; display: block; }
.tile input { position: absolute; top: 12px; left: 12px; width: 22px; height: 22px; accent-color: var(--accent); }
.tile .info { font-size: 12px; text-align: center; color: var(--muted); margin-top: 5px; line-height: 1.35; }
.tile .info b { color: var(--text); }

/* resultado */
.result { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 14px; }
.file { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.file:last-child { border-bottom: 0; }
.file .ico { font-size: 22px; }
.file .name { font-weight: 650; font-size: 14px; word-break: break-word; }

details.log { margin-top: 10px; }
details.log summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; padding: 6px 2px; }
details.log pre { max-height: 260px; overflow: auto; background: #0d0d12; color: #d6d6de; border-radius: 10px;
  padding: 10px; font-size: 11.5px; white-space: pre-wrap; word-break: break-word; margin: 4px 0 0; }

/* biblioteca */
.lib-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lib-item:last-child { border-bottom: 0; }
.lib-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex: none;
  background: var(--field); }
.lib-actions { display: flex; gap: 6px; flex: none; }
.confirm { display: flex; gap: 6px; align-items: center; }

/* ajustes */
.qr { width: 170px; height: 170px; background: #fff; border-radius: 12px; padding: 6px; display: block; }
.url-box { font-family: ui-monospace, Consolas, monospace; font-size: 14px; background: var(--field);
  border-radius: 10px; padding: 9px 12px; word-break: break-all; border: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13.5px; }
.kv b { font-weight: 650; }
ol.steps { padding-left: 20px; margin: 8px 0; line-height: 1.6; }

/* login */
.center-card { max-width: 400px; margin: 8vh auto 0; text-align: center; }
.center-card .logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 8px; }

/* diálogo compartir */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: grid; place-items: end center; }
@media (min-width: 620px) { .modal-bg { place-items: center; } }
.modal { background: var(--card); width: 100%; max-width: 460px; border-radius: 22px 22px 0 0; padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 620px) { .modal { border-radius: 22px; } }
.choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.choice button { border: 1px solid var(--line); background: var(--field); border-radius: 14px; padding: 14px 6px;
  font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.choice button span { font-size: 28px; }
.choice button.suggested { border: 2px solid #e0306f; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #222; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 90vw; }
