/* ============================================================================
   Cuaderno de acordes — hoja de estilos base y del editor.

   Sistema visual "Harmonic Modernism":
     · superficies lavanda (#faf8ff / #f2f3ff) y tarjetas blancas
     · azul eléctrico #1d4ed8 para acciones y acordes
     · verde esmeralda #059669 para las secciones musicales
     · ámbar #d97706 para tono, tempo y valoraciones
     · Plus Jakarta Sans para el texto, JetBrains Mono para acordes y metadatos

   Los tokens de Tailwind (tailwind/input.css) y estas variables CSS son los
   mismos valores: aquí se usan para el editor, que no usa utilidades Tailwind.
   ========================================================================== */

:root {
    --bg: #faf8ff;
    --surface: #ffffff;
    --surface-2: #f2f3ff;
    --surface-3: #eaedff;
    --surface-4: #e2e7ff;

    --ink: #131b2e;
    --ink-soft: #434655;
    --muted: #64748b;
    --faint: #94a3b8;

    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --grid: #e6ecf5;

    --blue: #1d4ed8;
    --blue-strong: #1e40af;
    --blue-soft: #eff6ff;
    --blue-fixed: #dce1ff;
    --blue-fixed-dim: #b7c4ff;
    --blue-ink: #0039b5;

    --green: #059669;
    --green-strong: #047857;
    --green-soft: #ecfdf5;

    --amber: #d97706;
    --amber-soft: #fef3c7;

    --red: #ba1a1a;
    --red-soft: #ffdad6;

    --cell-w: 1.28ch;
    --cell-h: 1.6em;

    --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    --mono: var(--font-mono);

    --shadow-1: 0 1px 3px rgba(15, 23, 42, .05), 0 1px 2px rgba(15, 23, 42, .03);
    --shadow-2: 0 4px 12px -2px rgba(15, 23, 42, .08), 0 2px 6px -1px rgba(15, 23, 42, .04);
    --shadow-3: 0 20px 25px -5px rgba(15, 23, 42, .12), 0 10px 10px -5px rgba(15, 23, 42, .04);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

.page {
    height: 100%;
}

/* Texto monoespaciado (acordes, metadatos, cifras). */
.mono {
    font-family: var(--font-mono);
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

/* ---------------- barra superior ---------------- */

.topbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    color: var(--ink);
    text-decoration: none;
    flex: 0 0 auto;
}

/* El cuadrado azul de la marca: el mismo lenguaje que el botón primario. */
.brand-mark {
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 10px;
    background: var(--blue);
    color: #fff;
    flex: 0 0 auto;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-name {
    font-size: .98rem;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--ink);
    white-space: nowrap;
}

.brand-sub {
    font-family: var(--font-mono);
    font-size: .58rem;
    font-weight: 500;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--faint);
    white-space: nowrap;
}

.topbar-spacer {
    flex: 1 1 auto;
}

.status {
    font-size: .8rem;
    color: var(--muted);
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status.hidden {
    visibility: hidden;
}

/* ---------------- navegación principal (pestañas) ---------------- */

.topnav {
    display: flex;
    align-items: center;
    gap: .15rem;
    margin-left: .35rem;
    padding: .2rem;
    border-radius: 12px;
    background: var(--surface-2);
}

.navlink {
    padding: .4rem .8rem;
    border-radius: 9px;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: .84rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease;
}

.navlink:hover {
    background: var(--surface-4);
    color: var(--ink);
}

.navlink.active {
    background: var(--blue);
    color: #fff;
    box-shadow: var(--shadow-1);
}

/* ---------------- sesión, idioma y tema ---------------- */

.lang-btn {
    font-weight: 700;
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.user-box {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.user-name {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .85rem;
    font-weight: 600;
    color: var(--ink);
}

/* Avatar circular con la inicial del usuario. */
.avatar {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background: var(--blue);
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    flex: 0 0 auto;
    text-decoration: none;
}

/* Pastilla verde de "sincronizado" del diseño. */
.sync-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .7rem;
    border-radius: 9999px;
    background: var(--green-soft);
    color: var(--green-strong);
    font-size: .76rem;
    font-weight: 700;
    white-space: nowrap;
}

.sync-pill .dot {
    width: .45rem;
    height: .45rem;
    border-radius: 9999px;
    background: var(--green);
}

/* ---------------- estructura del editor ---------------- */

.workspace {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Consola de metadatos (banda superior del editor). */
.console {
    flex: 0 0 auto;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: .85rem 1rem .6rem;
}

.console-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-1);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.console-fields {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: .6rem .75rem;
}

.console-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1.1rem;
}

/* La casilla «Pública» vive en la rejilla de campos: no se alinea a la derecha. */
.console-fields > .check {
    margin-left: 0;
    align-self: end;
    padding-bottom: .35rem;
}

/* Barra de comandos: se pega al borde inferior de la tarjeta. */
.cmdbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin: 0 -1rem -1rem;
    padding: .55rem 1rem;
    background: rgba(242, 243, 255, .7);
    border-top: 1px solid var(--line);
    border-radius: 0 0 15px 15px;
}

/* ---------------- lateral (biblioteca) ---------------- */

.sidebar {
    width: 300px;
    flex: 0 0 300px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: .9rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .6rem;
}

.sidebar-head h2 {
    margin: 0;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: .4rem;
}

.sidebar-head-actions {
    display: flex;
    gap: .3rem;
}

/* Buscador de la biblioteca. */
.lib-search {
    width: 100%;
    margin-bottom: .7rem;
    padding: .45rem .6rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: .82rem;
}

.lib-search:focus {
    outline: 2px solid var(--blue-fixed-dim);
    border-color: var(--blue);
    background: var(--surface);
}

.set {
    margin-bottom: .7rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    overflow: hidden;
}

.set.active {
    border-color: var(--blue-fixed-dim);
    box-shadow: 0 0 0 1px var(--blue-fixed-dim);
}

.set-head {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .55rem;
    background: var(--surface-2);
}

.set.active .set-head {
    background: var(--blue-fixed);
}

.set-toggle {
    font: inherit;
    width: 1.4rem;
    height: 1.4rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    flex: 0 0 auto;
}

.set-toggle:hover {
    background: var(--surface-4);
}

.set-name {
    flex: 1 1 auto;
    min-width: 0;
    font: inherit;
    font-size: .84rem;
    font-weight: 700;
    color: var(--ink);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: .15rem .3rem;
}

.set-name:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--blue);
}

.set-name.plain {
    font-weight: 700;
    font-size: .84rem;
    color: var(--ink);
}

.set-count {
    font-family: var(--font-mono);
    font-size: .68rem;
    font-weight: 700;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 9999px;
    padding: .05rem .4rem;
    flex: 0 0 auto;
}

.set-picker {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    padding: .4rem .5rem;
    background: var(--surface-2);
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    margin-bottom: .35rem;
}

.empty {
    color: var(--muted);
    font-size: .84rem;
    line-height: 1.5;
    padding: .5rem 0;
}

.song-list {
    list-style: none;
    margin: 0;
    padding: .35rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.song-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: .4rem .45rem;
    background: var(--surface);
}

.song-list li:hover {
    background: var(--surface-2);
}

.song-list li.active {
    border-color: var(--blue-fixed-dim);
    background: var(--blue-soft);
}

/* Tarjeta de canción: nombre grande, autor, insignia de tono y BPM. */
.song-open {
    flex: 1 1 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .1rem;
    background: none;
    border: 0;
    padding: .1rem .15rem;
    cursor: pointer;
    text-align: left;
    min-width: 0;
}

.song-title {
    font-weight: 700;
    font-size: .9rem;
    line-height: 1.25;
    color: var(--ink);
    overflow: hidden;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 100%;
}

.song-meta {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-family: var(--font-mono);
    font-size: .66rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Insignia de tono dentro de la biblioteca. */
.key-chip {
    font-family: var(--font-mono);
    font-size: .62rem;
    font-weight: 700;
    color: var(--blue-ink);
    background: var(--blue-fixed);
    border-radius: 9999px;
    padding: .05rem .4rem;
    flex: 0 0 auto;
}

.song-actions {
    display: flex;
    gap: .15rem;
    margin-left: auto;
}

/* ---------------- editor: lienzo ---------------- */

.editor {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--bg);
}

.sheet-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 1rem 1.1rem 1.5rem;
    overscroll-behavior: contain;
}

.sheet {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1.1rem 1.2rem 1.6rem;
    box-shadow: var(--shadow-1);
    min-width: max-content;
}

/* Cabecera de la canción dentro del lienzo. */
.sheet-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    padding-bottom: .8rem;
    margin-bottom: .6rem;
    border-bottom: 1px solid var(--line);
}

.sheet-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -.015em;
    color: var(--ink);
}

.sheet-title .dot {
    width: .55rem;
    height: .55rem;
    border-radius: 9999px;
    background: var(--green);
    flex: 0 0 auto;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 9999px;
    font-family: var(--font-mono);
    font-size: .7rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--ink-soft);
    border: 1px solid var(--line);
    white-space: nowrap;
}

.pill.blue {
    background: var(--blue-fixed);
    color: var(--blue-ink);
    border-color: transparent;
}

.pill.green {
    background: var(--green-soft);
    color: var(--green-strong);
    border-color: transparent;
}

.pill.amber {
    background: var(--amber-soft);
    color: var(--amber);
    border-color: transparent;
}

/* ---------------- hoja cuadriculada ---------------- */

.nb-line {
    margin-bottom: .25rem;
}

.nb-row {
    display: grid;
    align-items: end;
}

.nb-cell {
    position: relative;
    font-family: var(--font-mono);
    font-size: 1.02rem;
    line-height: var(--cell-h);
    height: var(--cell-h);
    white-space: pre;
    text-align: left;
    padding-left: 1px;
    border-right: 1px solid var(--grid);
    border-bottom: 1px solid var(--grid);
    color: var(--ink);
    cursor: text;
    user-select: none;
}

.nb-chordrow {
    height: 1.35em;
    align-items: start;
}

/* Segunda fila de acordes: se usa cuando dos etiquetas se solapan. La de abajo
   (la más cercana a la letra) es la que se apartó, y conserva su ancla. */
.nb-chordrow-2 {
    border-top: 1px dashed rgba(148, 163, 184, .5);
    margin-top: .05rem;
}

/* La letra donde arranca un acorde queda marcada: así se sabe exactamente
   en qué sílaba empieza cada signo. */
.nb-cell.anchor {
    background: rgba(29, 78, 216, .06);
    box-shadow: inset 0 -2px 0 var(--blue);
}

.nb-chordcell {
    border-color: transparent;
    position: relative;
    overflow: visible;
}

.nb-chord {
    position: absolute;
    left: 0;
    top: 0;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: .82rem;
    font-weight: 700;
    color: var(--blue);
    cursor: pointer;
    padding: 0 1px;
    border-radius: 3px;
}

.nb-chord.sel {
    background: var(--blue-soft);
    outline: 1px dashed var(--blue-fixed-dim);
    outline-offset: 1px;
}

.nb-cell.cur {
    outline: 2px solid var(--blue);
    outline-offset: -2px;
    background: rgba(29, 78, 216, .07);
}

/* Cursor visible dentro de la celda: se ve exactamente dónde se va a escribir. */
.nb-cell.cur::after {
    content: "";
    position: absolute;
    left: 0;
    top: 1px;
    bottom: 1px;
    width: 2px;
    background: var(--blue);
    animation: blink 1.1s steps(2, start) infinite;
}

/* Celdas de cola: se pueden pulsar para escribir al final de la línea. */
.nb-cell.nb-tail {
    border-right-color: #f1f5f9;
    border-bottom-color: #f1f5f9;
    background: repeating-linear-gradient(
        -45deg,
        rgba(148, 163, 184, .10) 0 2px,
        transparent 2px 7px
    );
}

.nb-cell.nb-tail:hover {
    background: rgba(29, 78, 216, .07);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Etiqueta de sección (VERSO, CORO...): verde esmeralda, en mayúsculas. */
.nb-section {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 1rem 0 .4rem;
    font-weight: 800;
    font-size: .78rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--green);
}

.nb-section .section-name {
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
}

.nb-blank {
    height: .7rem;
}

/* ---------------- vista de lectura (sin cuadros) ---------------- */

.reader {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1.5rem 1.6rem 2rem;
    box-shadow: var(--shadow-1);
    max-width: 60rem;
    margin: 0 auto;
}

.reader-head h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.015em;
}

.reader-author {
    margin: .2rem 0 0;
    color: var(--muted);
    font-size: .92rem;
}

.reader-meta {
    margin: .5rem 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    font-family: var(--font-mono);
    font-size: .72rem;
    color: var(--muted);
}

.reader-meta span {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 9999px;
    padding: .1rem .55rem;
}

.reader-body {
    margin-top: 1.2rem;
}

.reader-section {
    margin: 1.5rem 0 .4rem;
    font-weight: 800;
    font-size: .78rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--green);
}

.reader-section:first-child {
    margin-top: 0;
}

.reader-line {
    margin-bottom: .1rem;
}

/* Las filas usan 1ch por columna: las dos (acordes y letra) comparten el mismo
   tamaño de letra para que las columnas coincidan exactamente. */
.reader-chordrow,
.reader-lyricrow {
    display: grid;
    align-items: end;
    font-family: var(--font-mono);
    font-size: 1.02rem;
    line-height: 1.35;
}

.reader-chordrow {
    height: 1.35em;
}

.reader-chord {
    font-family: var(--font-mono);
    font-size: .82rem;
    font-weight: 700;
    color: var(--blue);
    white-space: pre;
    line-height: 1.15;
}

/* La primera letra del acorde es la que marca el ancla. Se marca de forma discreta:
   la línea bajo la letra de la canción es la que destaca el sitio. */
.reader-chord b {
    font-weight: 700;
    color: var(--blue-ink);
}

.reader-cell {
    white-space: pre;
    color: var(--ink);
}

/* La letra donde arranca un acorde: solo la línea de abajo, sin fondo. */
.reader-cell.anchor {
    background: transparent;
    box-shadow: inset 0 -2px 0 var(--blue);
}

.reader-blank {
    height: .75rem;
}

/* ---------------- paleta de acordes (bandeja inferior) ---------------- */

.palette-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    gap: .5rem;
    background: rgba(255, 255, 255, .95);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
}

.palette-bar > .field.inline {
    flex: 0 0 auto;
    padding: .45rem .6rem;
    border-right: 1px solid var(--line);
}

.palette {
    flex: 1 1 auto;
    display: flex;
    gap: .4rem;
    padding: .5rem .7rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

.pal-btn {
    font-family: var(--font-mono);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    min-width: 3.4rem;
    padding: .3rem .45rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    cursor: pointer;
    flex: 0 0 auto;
    transition: background .15s ease, border-color .15s ease;
}

.pal-btn:hover {
    border-color: var(--blue-fixed-dim);
    background: var(--blue-soft);
}

.pal-name {
    font-size: .95rem;
    font-weight: 700;
    color: var(--blue);
    line-height: 1.15;
}

.pal-sub {
    font-size: .6rem;
    color: var(--muted);
    line-height: 1.2;
}

.pal-btn.changed .pal-sub {
    color: var(--amber);
}

/* ---------------- controles de formulario ---------------- */

.field {
    display: flex;
    flex-direction: column;
    gap: .22rem;
    min-width: 8.5rem;
}

.field.grow {
    flex: 1 1 12rem;
}

.field.narrow {
    min-width: 5rem;
}

/* Campo en línea (etiqueta al lado del control), para la barra de acciones. */
.field.inline {
    flex-direction: row;
    align-items: center;
    gap: .4rem;
    min-width: 0;
}

.field.inline .text-input {
    width: auto;
    min-width: 7.5rem;
    padding: .3rem .45rem;
}

/* Etiqueta en monoespaciada y en mayúsculas: es la firma del diseño. */
.field > span {
    font-family: var(--font-mono);
    font-size: .64rem;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

.text-input {
    font: inherit;
    font-size: .88rem;
    padding: .42rem .55rem;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--ink);
    width: 100%;
    transition: background .15s ease, border-color .15s ease;
}

.text-input:focus {
    outline: 2px solid var(--blue-fixed-dim);
    outline-offset: 1px;
    border-color: var(--blue);
    background: var(--surface);
}

/* ---------------- botones ---------------- */

.btn {
    font: inherit;
    font-size: .84rem;
    font-weight: 600;
    padding: .45rem .75rem;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, transform .1s ease;
}

.btn:hover {
    background: var(--surface-2);
    border-color: var(--faint);
}

.btn:active {
    transform: scale(.98);
}

.btn.primary {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
    box-shadow: var(--shadow-1);
}

.btn.primary:hover {
    background: var(--blue-strong);
    border-color: var(--blue-strong);
}

.btn.good {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.btn.good:hover {
    background: var(--green-strong);
}

.btn.ghost {
    background: transparent;
    border-color: transparent;
    color: var(--ink-soft);
}

.btn.ghost:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.btn.icon {
    padding: .42rem .55rem;
    font-size: 1rem;
    line-height: 1;
}

.btn:disabled {
    opacity: .4;
    cursor: default;
}

.btn:disabled:hover {
    background: var(--surface);
    border-color: var(--line-strong);
}

.sep {
    width: 1px;
    align-self: stretch;
    margin: .1rem .25rem;
    background: var(--line);
}

.mode-hint {
    font-size: .78rem;
    color: var(--muted);
}

.mini-btn {
    font: inherit;
    font-size: .7rem;
    font-weight: 600;
    line-height: 1;
    padding: .3rem .42rem;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .2rem;
}

.mini-btn:hover {
    color: var(--ink);
    border-color: var(--faint);
    background: var(--surface-2);
}

.mini-btn.danger:hover {
    color: var(--red);
    border-color: var(--red);
    background: var(--red-soft);
}

.check {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .82rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-left: auto;
}

.icon-btn {
    font: inherit;
    font-size: 1.05rem;
    line-height: 1;
    padding: .35rem .55rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, color .15s ease;
}

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

/* ---------------- barra de error y carga ---------------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    padding: .7rem 1rem;
    background: var(--amber-soft);
    border-top: 1px solid #fde68a;
    color: #664d03;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .08);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: .75rem;
    top: .55rem;
}

/* Detalle real del error (lo rellena el script de diagnóstico del index.html). */
#blazor-error-ui .error-detail {
    display: none;
    font-family: var(--font-mono);
    font-size: .78rem;
    line-height: 1.35;
    color: #8a4b00;
    background: rgba(255, 255, 255, .65);
    border: 1px solid #ffe08a;
    border-radius: 6px;
    padding: .3rem .5rem;
    margin-bottom: .4rem;
    max-height: 5.5rem;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--surface-3);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
    animation: progress-spin 1.4s ease-in-out infinite;
}

.loading-progress circle:last-child {
    stroke: var(--blue);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.2s ease-out;
}

.loading-progress-text {
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
}

@keyframes progress-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ---------------- entrada oculta ---------------- */

/* El campo de captura recibe el teclado (incluido el del móvil) pero no se ve.
   Tiene tamaño real porque algunos navegadores móviles ignoran el foco en
   elementos de 1x1 píxeles. */
.capture {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 160px;
    height: 24px;
    padding: 0;
    border: 0;
    opacity: 0;
    background: transparent;
    color: transparent;
    font-size: 12px;
}

/* ---------------- línea de instrumento y pistas ---------------- */

.concert-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .4rem .9rem;
    padding: .4rem .9rem;
    background: var(--blue-soft);
    border-bottom: 1px solid var(--line);
    font-size: .82rem;
    color: var(--ink-soft);
}

.concert-badge b {
    color: var(--blue);
}

/* Nombre de la sección editable. */
.section-name {
    font: inherit;
    font-weight: 700;
    color: var(--green);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: .05rem .25rem;
    min-width: 4rem;
}

.section-name:hover {
    border-color: var(--line);
}

.section-name:focus {
    outline: 2px solid var(--blue-fixed-dim);
    border-color: var(--blue);
    background: var(--surface);
}

/* ---------------- marcadores de voz ---------------- */

.voice-cue {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .1rem .35rem;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    color: var(--ink);
    font-size: .78rem;
}

.reader-voice {
    margin: .55rem 0 .1rem;
    font-weight: 700;
    color: var(--blue);
}

/* ---------------- pie de estado ---------------- */

.statusbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .4rem 1rem;
    background: var(--surface);
    border-top: 1px solid var(--line);
    font-size: .72rem;
    color: var(--muted);
}

.statusbar .dot {
    display: inline-block;
    width: .45rem;
    height: .45rem;
    border-radius: 9999px;
    background: var(--green);
    margin-right: .35rem;
    vertical-align: middle;
}

.statusbar a {
    color: var(--muted);
    text-decoration: none;
    margin-left: 1rem;
}

.statusbar a:hover {
    color: var(--blue);
    text-decoration: underline;
}

/* ---------------- navegación inferior (móvil) ---------------- */

.bottomnav {
    display: none;
    position: relative;
    flex: 0 0 auto;
    z-index: 45;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
}

/* El contenido público que se puede desplazar (el resto de la app ya lo hace). */
.app-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.bottomnav-inner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: center;
}

.bottomnav a,
.bottomnav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .1rem;
    padding: .3rem 0;
    color: var(--muted);
    font-size: .66rem;
    font-weight: 600;
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
}

.bottomnav a.active,
.bottomnav button.active {
    color: var(--blue);
}

/* Botón central: abre el editor. */
.fab {
    width: 3.1rem;
    height: 3.1rem;
    border-radius: 9999px;
    background: var(--blue);
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-2);
    border: 0;
    cursor: pointer;
    justify-self: center;
    transform: translateY(-.55rem);
    transition: transform .12s ease, background .15s ease;
}

.fab:active {
    transform: translateY(-.55rem) scale(.95);
}

/* ---------------- responsive ---------------- */

.only-mobile {
    display: none;
}

/* Lo que solo se ve en escritorio (por ejemplo, el botón de salir con texto). */
.only-desktop {
    display: inline-flex;
}

@media (max-width: 1100px) {
    .console-fields {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Por debajo de 1100 px las pestañas de la barra superior no caben: la
   navegación pasa a la barra inferior (la del diseño móvil). */
@media (max-width: 1100px) {
    .topnav {
        display: none;
    }

    .bottomnav {
        display: block;
    }

    .only-mobile {
        display: inline-flex;
    }

    .only-desktop {
        display: none;
    }

    .statusbar {
        display: none;
    }
}

@media (max-width: 860px) {
    .only-mobile {
        display: inline-flex;
    }

    .only-desktop {
        display: none;
    }

    .console {
        padding: .6rem .7rem .4rem;
    }

    /* En móvil la consola de metadatos se pliega: si no, no cabe la hoja. */
    .console.collapsed {
        display: none;
    }

    .meta-toggle {
        display: flex;
        align-items: center;
        gap: .5rem;
        padding: .45rem .7rem;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
    }

    .console-card {
        padding: .75rem;
        border-radius: 14px;
        gap: .6rem;
    }

    .console-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cmdbar {
        margin: 0 -.75rem -.75rem;
        padding: .5rem .75rem;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 60;
        width: min(86vw, 320px);
        flex-basis: auto;
        transform: translateX(-102%);
        transition: transform .18s ease;
        box-shadow: var(--shadow-3);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .field {
        min-width: 7.5rem;
        flex: 1 1 7.5rem;
    }

    .check {
        margin-left: 0;
    }

    .sheet-scroll {
        padding: .7rem .6rem 1rem;
    }

    .sheet {
        padding: .85rem .7rem 1.1rem;
        border-radius: 14px;
    }

    .sheet-title {
        font-size: 1.1rem;
    }

    :root {
        --cell-w: 1.22ch;
    }

    .nb-cell {
        font-size: 1.1rem;
    }

    .bottomnav {
        display: block;
    }

    .statusbar {
        display: none;
    }
}
@media (max-width: 640px) {
    .brand-sub {
        display: none;
    }

    .topnav {
        display: none;
    }

    .user-name {
        display: none;
    }
}

/* ---------------- tema oscuro ---------------- */
/* Se activa con <html data-theme="oscuro">. El botón de la barra superior
   alterna entre "claro" y "oscuro" y la preferencia se guarda en el navegador. */

[data-theme="oscuro"] {
    --bg: #0f1220;
    --surface: #171b2e;
    --surface-2: #1e2338;
    --surface-3: #252b44;
    --surface-4: #2d3450;

    --ink: #eef0ff;
    --ink-soft: #c3c8e0;
    --muted: #9aa2c0;
    --faint: #6f7796;

    --line: #2b3350;
    --line-strong: #3a4467;
    --grid: #232a45;

    --blue: #8ab0ff;
    --blue-strong: #a8c4ff;
    --blue-soft: #1a2547;
    --blue-fixed: #24325c;
    --blue-fixed-dim: #3d4f85;
    --blue-ink: #cad3ff;

    --green: #4ade80;
    --green-strong: #86efac;
    --green-soft: #10291f;

    --amber: #fbbf24;
    --amber-soft: #33280c;

    --red: #fca5a5;
    --red-soft: #3a1616;
}

[data-theme="oscuro"] body {
    background: var(--bg);
}

[data-theme="oscuro"] .topnav {
    background: var(--surface-2);
}

[data-theme="oscuro"] .navlink.active {
    background: var(--blue);
    color: #0f1220;
}

[data-theme="oscuro"] .cmdbar {
    background: rgba(30, 35, 56, .7);
}

[data-theme="oscuro"] .palette-bar,
[data-theme="oscuro"] .bottomnav {
    background: rgba(23, 27, 46, .95);
}

[data-theme="oscuro"] .set.active .set-head {
    background: var(--blue-fixed);
}

[data-theme="oscuro"] .nb-cell.nb-tail {
    border-right-color: var(--surface-2);
    border-bottom-color: var(--surface-2);
}

[data-theme="oscuro"] #blazor-error-ui {
    background: #33280c;
    border-top-color: #6b5518;
    color: #ffe9a8;
}

[data-theme="oscuro"] #blazor-error-ui .error-detail {
    background: rgba(0, 0, 0, .3);
    border-color: #6b5518;
    color: #ffd166;
}

[data-theme="oscuro"] .loading-progress circle {
    stroke: var(--surface-3);
}

[data-theme="oscuro"] .loading-progress circle:last-child {
    stroke: var(--blue);
}

/* ============================================================================
   Modo escenario: la canción a tamaño grande, para tocar en vivo.
   ========================================================================== */

.stage {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

.stage-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .4rem .8rem;
    padding: .55rem .9rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}

.stage-title {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -.015em;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.stage-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 1rem .9rem 1.5rem;
    overscroll-behavior: contain;
}

.stage-song {
    max-width: 68rem;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1.4rem 1.7rem 1.8rem;
    box-shadow: var(--shadow-2);
}

/* El tamaño de la letra se ajusta con una variable (botones +/-). */
.stage .reader {
    font-size: var(--stage-size, 1.45rem);
}

.stage .reader-head h1 {
    font-size: 1.5em;
}

.stage .reader-meta {
    font-size: .55em;
}

.stage .reader-chord {
    font-size: .62em;
    font-weight: 700;
    color: var(--blue);
}

.stage .reader-cell {
    font-weight: 500;
}

.stage .reader-section {
    font-size: .42em;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--green-strong);
    background: var(--green-soft);
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 9999px;
}

.stage .reader-voice {
    font-size: .42em;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.stage-foot {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .9rem calc(.45rem + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    font-size: .8rem;
    color: var(--muted);
    overflow-x: auto;
}

.stage-setlist {
    display: flex;
    gap: .35rem;
    align-items: center;
}

.stage-setlist button {
    font: inherit;
    white-space: nowrap;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-soft);
    border-radius: 9999px;
    padding: .15rem .6rem;
    cursor: pointer;
}

.stage-setlist button.active {
    background: var(--blue);
    border-color: transparent;
    color: #fff;
    font-weight: 700;
}

/* ============================================================================
   Exportar e imprimir partitura.
   ========================================================================== */

.print-sheet {
    background: #ffffff;
    color: #131b2e;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1.6rem 1.8rem 2rem;
    box-shadow: var(--shadow-1);
    max-width: 56rem;
    margin: 0 auto;
}

/* En papel no se quiere el fondo lavanda ni los botones. */
.print-sheet .reader-chord {
    color: #1d4ed8;
    font-weight: 700;
}

.print-sheet .reader-cell.anchor {
    box-shadow: inset 0 -2px 0 #1d4ed8;
}

.print-sheet.compact {
    font-size: .82rem;
}

.print-sheet.spacious {
    font-size: 1.05rem;
}

.print-sheet .reader-line {
    margin-bottom: .3rem;
}

.print-sheet.spacious .reader-line {
    margin-bottom: .85rem;
}

@media print {
    .no-print {
        display: none !important;
    }

    html,
    body {
        background: #ffffff !important;
    }

    .print-sheet {
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        max-width: none;
    }

    @page {
        margin: 14mm;
    }
}

/* ============================================================================
   Modo escenario en tema oscuro: la partitura brilla un poco más.
   ========================================================================== */

[data-theme="oscuro"] .stage .reader-chord {
    color: var(--blue-strong);
}

/* ============================================================================
   Componentes del sistema Harmonic Modernism (los que se repiten en varias
   pantallas: filtros, tarjetas de canción, tarjetas de estadística...).

   Las utilidades de Tailwind siguen cubriendo la maquetación (espaciados,
   rejillas, tipografías); aquí viven los bloques con forma propia.
   ========================================================================== */

/* --- filtros en píldoras --- */
.chip {
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .32rem .78rem;
    border-radius: 9999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.chip:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.chip.active {
    background: var(--blue);
    border-color: transparent;
    color: #fff;
    box-shadow: var(--shadow-1);
}

/* --- etiquetas de metadatos --- */
.tag {
    display: inline-flex;
    align-items: center;
    gap: .28rem;
    padding: .14rem .5rem;
    border-radius: 9999px;
    font-size: .68rem;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--ink-soft);
    border: 1px solid var(--line);
    white-space: nowrap;
}

.tag.blue {
    background: var(--blue-fixed);
    color: var(--blue-ink);
    border-color: transparent;
}

.tag.green {
    background: var(--green-soft);
    color: var(--green-strong);
    border-color: transparent;
}

.tag.amber {
    background: var(--amber-soft);
    color: var(--amber);
    border-color: transparent;
}

.tag.red {
    background: var(--red-soft);
    color: var(--red);
    border-color: transparent;
}

/* --- tarjeta de canción (explorador) --- */
.song-card {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: .95rem 1rem 1rem;
    box-shadow: var(--shadow-1);
    transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}

.song-card:hover {
    box-shadow: var(--shadow-2);
    border-color: var(--blue-fixed-dim);
}

.song-card h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--ink);
}

.song-card h3 a {
    color: inherit;
    text-decoration: none;
}

.song-card h3 a:hover {
    color: var(--blue);
    text-decoration: underline;
}

.song-card .song-sub {
    font-size: .78rem;
    color: var(--muted);
    margin: 0;
}

/* --- tarjeta promocional --- */
.promo-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .8rem 1.2rem;
    padding: 1.1rem 1.25rem;
    border-radius: 18px;
    background: linear-gradient(120deg, var(--blue-fixed) 0%, var(--surface-2) 55%, var(--surface) 100%);
    border: 1px solid var(--blue-fixed-dim);
}

.promo-card h2 {
    margin: 0 0 .2rem;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -.015em;
    color: var(--ink);
}

.promo-card p {
    margin: 0;
    font-size: .84rem;
    color: var(--ink-soft);
    max-width: 34rem;
}

/* --- tarjeta de estadística --- */
.stat-card {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .85rem .95rem;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-1);
}

.stat-card .stat-label {
    font-family: var(--font-mono);
    font-size: .62rem;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--ink);
    line-height: 1.1;
}

.stat-card .stat-note {
    font-size: .72rem;
    color: var(--muted);
}

/* --- avatar grande (perfil) --- */
.avatar-lg {
    display: grid;
    place-items: center;
    width: 4.2rem;
    height: 4.2rem;
    border-radius: 9999px;
    background: var(--blue);
    color: #fff;
    font-size: 1.6rem;
    font-weight: 800;
    flex: 0 0 auto;
}

/* --- buscador con icono --- */
.search-field {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex: 1 1 auto;
    min-width: 0;
    padding: .5rem .75rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
}

.search-field:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-fixed);
}

.search-field input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: .88rem;
}

/* --- lista de elementos (canciones dentro de una lista o un set) --- */
.row-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.row-list li {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .1rem;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.row-list li:last-child {
    border-bottom: 0;
}

/* --- aviso dentro de una tarjeta --- */
.notice {
    display: flex;
    align-items: flex-start;
    gap: .45rem;
    padding: .55rem .7rem;
    border-radius: 12px;
    font-size: .78rem;
    border: 1px solid transparent;
}

.notice.amber {
    background: var(--amber-soft);
    color: var(--amber);
    border-color: transparent;
}

.notice.blue {
    background: var(--blue-soft);
    color: var(--blue-ink);
}

.notice.red {
    background: var(--red-soft);
    color: var(--red);
}

[data-theme="oscuro"] .notice.blue {
    color: var(--blue-strong);
}

[data-theme="oscuro"] .promo-card {
    background: linear-gradient(120deg, var(--blue-fixed) 0%, var(--surface-2) 60%, var(--surface) 100%);
}
