/* NeuroRoyalties — v0.1
   Idea visual: un piloto de grabación (REC) rojo para registrar y el verde del dinero para lo que te toca.
   Portadas como protagonistas en el catálogo; todo lo demás sobrio y nativo. */

:root {
  --bg: #F3F3F6;
  --surface: #FFFFFF;
  --ink: #16161D;
  --ink-2: #5F6270;
  --line: #E0E1E7;
  --off: #ECEDF2;
  --rec: #D92D26;
  --rec-ink: #FFFFFF;
  --money: #0C7A68;
  --warn: #B4690E;
  --danger: #C8323A;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 58px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F0F14;
    --surface: #1A1A22;
    --ink: #EDEDF2;
    --ink-2: #9A9CAA;
    --line: #2A2A35;
    --off: #24242E;
    --rec: #FF5048;
    --rec-ink: #1A0605;
    --money: #35C2A6;
    --warn: #F0A23B;
    --danger: #FF6B70;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--rec); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Estructura ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
main {
  max-width: 820px; margin: 0 auto; outline: none;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
}
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-2); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tabs a svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[data-tab="grabar"] svg circle.dot { fill: var(--rec); stroke: none; }
.brand { display: none; }
body.sin-sesion .tabs { display: none; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; }
  .tabs {
    position: sticky; top: 0; height: 100vh; flex-direction: column; justify-content: flex-start;
    gap: 2px; padding: 22px 12px; border-top: 0; border-right: 1px solid var(--line); background: var(--surface);
  }
  .tabs a { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 9px 12px; border-radius: 10px; font-size: 15px; }
  .tabs a svg { width: 22px; height: 22px; }
  .tabs a[aria-current="page"] { background: var(--off); }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 12px 22px; font: 800 18px/1 var(--font-display); letter-spacing: -.01em; }
  .brand img { width: 30px; height: 30px; border-radius: 8px; }
  main { padding-top: 40px; padding-bottom: 48px; }
  body.sin-sesion .shell { display: block; }
}

/* ---------- Cabeceras ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 18px; }
.head h1 { margin: 0; font: 800 32px/1.1 var(--font-display); letter-spacing: -.02em; text-wrap: balance; }
.head p { margin: 4px 0 0; color: var(--ink-2); max-width: 60ch; }
h2.group { margin: 28px 2px 10px; font-size: 13px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--ink); color: var(--bg); font-weight: 650; text-decoration: none; white-space: nowrap;
}
.btn--money { background: var(--money); color: #fff; }
.btn--quiet { background: var(--off); color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink-2); padding: 0 10px; }
.btn--danger { background: transparent; color: var(--danger); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:not(:disabled):active { transform: scale(.97); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }

/* ---------- Tarjetas y avisos ---------- */
.card { background: var(--surface); border-radius: var(--r-lg); padding: 18px; }
.card + .card { margin-top: 12px; }
.banner {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--r-md); background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  font-size: 15px; margin-bottom: 14px;
}
.nota { color: var(--ink-2); font-size: 14px; }
.vacio { text-align: center; color: var(--ink-2); padding: 34px 16px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; letter-spacing: .03em;
  padding: 3px 8px; border-radius: 999px; background: var(--off); color: var(--ink-2); white-space: nowrap;
}
.pill--as { background: color-mix(in srgb, #6E56CF 18%, transparent); color: #7C66DC; }
.pill--warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill--rec { background: color-mix(in srgb, var(--rec) 14%, transparent); color: var(--rec); }
.pill--ok { background: color-mix(in srgb, var(--money) 15%, transparent); color: var(--money); }

/* ---------- Grabar ---------- */
.grabadora { display: grid; justify-items: center; gap: 14px; padding: 26px 18px 20px; }
.rec {
  position: relative; width: 112px; height: 112px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--rec); color: var(--rec-ink); display: grid; place-items: center;
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--rec) 14%, transparent), 0 10px 30px color-mix(in srgb, var(--rec) 30%, transparent);
}
.rec svg { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.rec.grabando { animation: latido 1.3s ease-in-out infinite; }
.rec.grabando::after { content: ""; position: absolute; inset: -14px; border-radius: 50%; border: 3px solid var(--rec); animation: onda 1.3s ease-out infinite; }
@keyframes latido { 50% { transform: scale(.94); } }
@keyframes onda { from { opacity: .8; transform: scale(.9); } to { opacity: 0; transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { .rec.grabando, .rec.grabando::after { animation: none; } }
.rec-estado { font-weight: 650; font-size: 15px; min-height: 1.4em; }
.rec-estado.on { color: var(--rec); }
textarea.nota-voz {
  width: 100%; min-height: 110px; resize: vertical; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--bg); padding: 12px 14px; line-height: 1.5;
}
.ejemplo { font-size: 13px; color: var(--ink-2); border-left: 3px solid var(--line); padding-left: 10px; margin: 0; max-width: 62ch; justify-self: start; }

/* ---------- Propuestas ---------- */
.propuestas { display: grid; gap: 14px; margin-top: 18px; }
.prop { background: var(--surface); border-radius: var(--r-lg); padding: 16px; display: grid; gap: 14px; border-left: 5px solid var(--money); }
.prop--act { border-left-color: var(--warn); }
.prop--dup { border-left-color: var(--rec); }
.prop-top { display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: start; }
.prop-top .info { display: grid; gap: 4px; min-width: 0; }
.prop-top .tit { font-weight: 750; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.prop-top .art { color: var(--ink-2); overflow-wrap: anywhere; }
.prop-top .det { font-size: 13px; color: var(--ink-2); }
.duda { font-size: 14px; color: var(--warn); }
.dup {
  border-radius: var(--r-md); padding: 12px 14px; display: grid; gap: 10px;
  background: color-mix(in srgb, var(--rec) 10%, var(--surface)); font-size: 15px;
}
.cambios { display: grid; gap: 4px; font-size: 14px; }
.cambios div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.cambios b { font-weight: 650; }

/* ---------- Portadas ---------- */
.cover {
  position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--off);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 8%, transparent);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover--vacia { display: grid; place-items: center; color: var(--ink-2); }
.cover--vacia svg { width: 42%; height: 42%; fill: none; stroke: currentColor; stroke-width: 1.4; opacity: .7; }
.cover-btn { border: 0; padding: 0; background: none; cursor: pointer; }

/* ---------- Formularios ---------- */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); font-weight: 550; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  padding: 10px 11px; font-size: 16px; color: var(--ink); font-weight: 400;
}
.field textarea { min-height: 70px; resize: vertical; }
.field .ayuda { font-weight: 400; font-size: 12px; }
.seg { display: inline-flex; background: var(--off); border-radius: 999px; padding: 3px; gap: 2px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 650; color: var(--ink-2); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg input:focus-visible + span { outline: 3px solid var(--rec); }
.efectivo { font-size: 14px; color: var(--ink-2); }
.efectivo b { color: var(--money); font-size: 16px; }
details.mas summary { cursor: pointer; font-weight: 650; font-size: 14px; color: var(--ink-2); padding: 4px 0; }
details.mas[open] summary { margin-bottom: 10px; }

/* ---------- Catálogo ---------- */
.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.buscar { flex: 1 1 220px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 10px 16px; font-size: 16px; min-width: 0; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
select.orden { border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 8px 12px; font-size: 14px; }
.lista { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; }
.fila {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 14px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line);
}
.fila:last-child { border-bottom: 0; }
.fila:hover { background: color-mix(in srgb, var(--off) 55%, transparent); }
.fila .cover { width: 56px; border-radius: 7px; }
.fila .txt { min-width: 0; display: grid; gap: 2px; }
.fila .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .s { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .pills { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.fila .der { text-align: right; display: grid; gap: 2px; }
.fila .eur { font-weight: 700; color: var(--money); font-variant-numeric: tabular-nums; }
.fila .str { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.resumen-cat { font-size: 14px; color: var(--ink-2); margin: -6px 2px 12px; }

/* ---------- Ficha de tema ---------- */
.volver { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 15px; margin-bottom: 12px; }
.ficha-top { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 20px; align-items: end; margin-bottom: 18px; }
.ficha-top h1 { margin: 0; font: 800 30px/1.12 var(--font-display); letter-spacing: -.02em; overflow-wrap: anywhere; text-wrap: balance; }
.ficha-top .art { color: var(--ink-2); font-size: 17px; margin: 4px 0 10px; }
@media (max-width: 560px) { .ficha-top { grid-template-columns: 1fr; } .ficha-top .cover-btn { max-width: 240px; } }
.datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 18px; }
.dato { display: grid; gap: 2px; min-width: 0; }
.dato .k { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.dato .v { font-weight: 600; overflow-wrap: anywhere; }
.plat { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 14px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.plat:last-child { border-bottom: 0; }
.plat .n { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.plat .e { color: var(--money); font-variant-numeric: tabular-nums; text-align: right; min-width: 72px; }
.plat .f { grid-column: 1 / -1; font-size: 12px; color: var(--ink-2); }
.enlaces { display: flex; gap: 8px; flex-wrap: wrap; }
.yt { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; }
.yt img { width: 120px; border-radius: 8px; display: block; }
.cuenta { display: grid; gap: 6px; font-size: 15px; }
.cuenta div { display: flex; justify-content: space-between; gap: 10px; }
.cuenta .total { font-weight: 750; font-size: 18px; color: var(--money); border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }

/* ---------- Visor ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border-radius: var(--r-lg); padding: 16px 18px; display: grid; gap: 4px; }
.tile .k { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.tile .v { font: 800 28px/1.1 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile .s { font-size: 12px; color: var(--ink-2); }
.tile--hero .v { color: var(--money); }
.actualizar { display: grid; gap: 10px; }
.vu { height: 10px; border-radius: 6px; background: var(--off); overflow: hidden; }
.vu i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--money) 0 70%, var(--warn) 85%, var(--rec)); background-size: 100vw 100%; transition: width .3s; }
.bars { display: grid; gap: 11px; }
.bar { display: grid; grid-template-columns: 128px 1fr 86px; gap: 10px; align-items: center; font-size: 14px; }
.bar .track { height: 12px; border-radius: 6px; background: var(--off); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 6px; background: var(--money); }
.bar .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
@media (max-width: 460px) { .bar { grid-template-columns: 96px 1fr 70px; font-size: 13px; } }
.rank .fila { grid-template-columns: 22px 44px 1fr auto; }
.rank .fila .cover { width: 44px; }
.rank .pos { color: var(--ink-2); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- Ajustes ---------- */
.ajuste { display: grid; gap: 10px; }
.ajuste h3 { margin: 0; font-size: 17px; }
.estado-ok { color: var(--money); font-weight: 650; }
.estado-no { color: var(--ink-2); font-weight: 650; }
.pasos { margin: 0; padding-left: 20px; font-size: 14px; color: var(--ink-2); display: grid; gap: 4px; }
.pasos code, .nota code { background: var(--off); padding: 1px 6px; border-radius: 5px; font-size: 13px; word-break: break-all; }
.tarifa { display: grid; grid-template-columns: 1fr 110px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tarifa:last-child { border-bottom: 0; }
.tarifa small { display: block; color: var(--ink-2); font-size: 12px; }
.tarifa input { border: 1px solid var(--line); border-radius: 9px; background: var(--bg); padding: 8px 10px; text-align: right; font-variant-numeric: tabular-nums; width: 100%; font-size: 16px; }
.switch { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.switch input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--money); flex: none; }

/* ---------- Login ---------- */
.login { max-width: 380px; margin: 9vh auto 0; display: grid; gap: 14px; text-align: center; }
.login-logo { width: 84px; height: 84px; border-radius: 20px; justify-self: center; }
.login h1 { margin: 0; font: 800 30px/1.1 var(--font-display); }
.login p { margin: 0; color: var(--ink-2); }
.login form { text-align: left; grid-template-columns: 1fr; }
.login-error { color: var(--danger); min-height: 1.4em; font-size: 14px; }

/* ---------- Hoja (diálogo) ---------- */
dialog#sheet {
  border: 0; padding: 0; width: min(640px, 100%); max-height: min(92vh, 900px); border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
dialog#sheet::backdrop { background: rgba(8, 8, 12, .5); }
@media (max-width: 640px) {
  dialog#sheet { margin: auto 0 0; max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; }
}
.sheet-bar {
  position: sticky; top: 0; z-index: 1; display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
  padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.sheet-bar h2 { margin: 0; font-size: 16px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-bar button { border: 0; background: none; font-weight: 650; color: var(--ink-2); cursor: pointer; padding: 6px 4px; }
.sheet-bar button[type="submit"] { color: var(--money); }
.sheet-body { padding: 16px; display: grid; gap: 16px; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.cands { display: grid; gap: 8px; }
.cand {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; text-align: left;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); padding: 8px; cursor: pointer; width: 100%;
}
.cand[aria-pressed="true"] { border-color: var(--money); box-shadow: 0 0 0 2px color-mix(in srgb, var(--money) 40%, transparent); }
.cand .cover { width: 64px; border-radius: 7px; }
.cand .t { font-weight: 650; }
.cand .s { font-size: 13px; color: var(--ink-2); }

/* ---------- Aviso flotante ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s;
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-size: 15px;
  max-width: calc(100% - 32px); display: flex; gap: 12px; align-items: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
@media (min-width: 900px) { #toast { bottom: 24px; } }
