/* ==========================================================================
   Rock Sleeve
   Orden: tokens, base, controles, cabecera, paneles, tarjetas, diapasón,
   acordes, armonía, modales, inicio, varios, responsive.
   Los estados se marcan con clases (.is-active, .hidden); el JS solo pinta
   estilos inline en las notas del diapasón.
   ========================================================================== */

:root {
    /* Paleta de roplylabs.com.ar: negro, naranja y texto claro */
    --bg-color: #050505;
    --panel-bg: #0e0e0e;
    --raised-bg: #191919;
    --hover-bg: #262626;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(255, 87, 34, 0.35);
    --text-color: #f0f0f0;
    --muted-color: #a0a0a0;
    --primary-color: #FF5722;
    --primary-hover: #FF7A00;
    --primary-soft: rgba(255, 87, 34, 0.14);
    --focus-color: #FF5722;
    --accent-color: #FF5722;
    --danger-color: #f85149;

    /* Colores por función de la nota (la tónica lleva el color de la marca) */
    --root-color: #FF5722;
    --third-color: #c9a2ff;
    --fifth-color: #6cc4ff;
    --seventh-color: #a5d6ff;
    --tension-color: #8d8d8d;

    --radius: 14px;
    --radius-sm: 8px;
    --radius-pill: 999px;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
    --font-main: 'Outfit', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* --- Base --- */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    /* Resplandor naranja tenue arriba a la derecha, como en la web principal */
    background: radial-gradient(900px 600px at 100% 0%, rgba(255, 87, 34, 0.09), transparent 70%) fixed, var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    font-size: 15px;
    line-height: 1.45;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.2;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

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

.noscript {
    padding: 20px;
    text-align: center;
}

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

/* --- Controles --- */

button, input, select {
    font: inherit;
    color: var(--text-color);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 14px;
    background: var(--raised-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

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

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

.btn-primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
}

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

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

/* Botón de un solo símbolo */
.btn-square {
    width: 36px;
    padding: 0;
}

/* Enlace dentro de un texto */
.link-btn {
    padding: 0;
    background: none;
    border: none;
    font: inherit;
    color: var(--primary-color);
    white-space: nowrap;
    cursor: pointer;
}

.link-btn:hover {
    text-decoration: underline;
}

.btn.is-active {
    background: var(--focus-color);
    border-color: var(--focus-color);
    color: #fff;
}

input[type="text"], input[type="number"], select {
    min-height: 36px;
    padding: 6px 10px;
    background: var(--raised-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

select {
    cursor: pointer;
}

input[type="text"]:hover, input[type="number"]:hover, select:hover {
    border-color: var(--primary-color);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Etiqueta + control en línea */
.field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--muted-color);
    white-space: nowrap;
}

.field select, .field input {
    color: var(--text-color);
}

/* Etiqueta arriba, control a todo el ancho (paneles) */
.field-block {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-bottom: 12px;
}

.field .select-strong {
    font-weight: 700;
    color: var(--primary-color);
}

.check-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
}

.check-row input {
    flex: 0 0 auto;
}

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--raised-bg);
    color: var(--muted-color);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.help-icon:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.toggle-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 4px 14px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--raised-bg);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.toggle-pill.is-active {
    background: var(--primary-soft);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
}

.toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* --- Cabecera --- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 12px 20px;
    padding: 10px 20px;
    background: rgba(5, 5, 5, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

/* Marca: el nombre y, debajo, el enlace de vuelta al sitio principal */
.brand {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}

/* Un círculo con una flecha que se estira hasta mostrar el texto */
.back-link {
    display: inline-flex;
    align-items: center;
    height: 18px;
    max-width: 18px;
    overflow: hidden;
    background: var(--raised-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    color: var(--muted-color);
    transition: max-width 0.25s ease, color 0.15s, border-color 0.15s;
}

.back-link svg {
    flex: 0 0 16px;
    width: 16px;
    height: 10px;
}

.back-link span {
    padding: 0 8px 0 1px;
}

.back-link:hover, .back-link:focus-visible {
    max-width: 160px;
    border-color: var(--primary-color);
    color: var(--primary-color);
    text-decoration: none;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Selector de idioma: una píldora de dos mitades, del mismo alto que el enlace de al lado */
.lang-toggle {
    display: inline-flex;
    height: 18px;
    overflow: hidden;
    background: var(--raised-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
}

.lang-toggle button {
    padding: 0 6px;
    background: none;
    border: none;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1;
    color: var(--muted-color);
    cursor: pointer;
}

.lang-toggle button:hover {
    color: var(--text-color);
}

.lang-toggle button.is-active {
    background: var(--primary-color);
    color: #fff;
}

/* En la pantalla de inicio la cabecera está tapada: el selector se repite arriba a la derecha */
.startup-lang {
    position: absolute;
    top: 14px;
    right: 14px;
    height: 28px;
}

.startup-lang button {
    padding: 0 12px;
    font-size: 0.8rem;
}

/* Sin cursor no hay "pasar por encima": se muestra desplegado y más alto para el dedo */
@media (hover: none) {
    .back-link {
        height: 22px;
        max-width: 160px;
    }

    .brand-row .lang-toggle {
        height: 22px;
    }

    .brand-row .lang-toggle button {
        padding: 0 8px;
        font-size: 0.7rem;
    }
}

.text-logo {
    flex: 0 0 auto;
    line-height: 1;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    white-space: nowrap;
    color: transparent;
    /* Mismo degradado que el logo de Roply Labs: de blanco a naranja */
    background: linear-gradient(90deg, #ffffff 0%, #ffb199 45%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.header-main {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
}

.header-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--raised-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.icon-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.icon-btn.is-active {
    background: var(--focus-color);
    border-color: var(--focus-color);
    color: #fff;
}

/* Silenciar: alterna entre los dos íconos */
#btn-global-mute .icon-off,
#btn-global-mute.is-active .icon-on {
    display: none;
}

#btn-global-mute.is-active .icon-off {
    display: block;
}

#btn-global-mute.is-active {
    background: var(--primary-soft);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.search {
    position: relative;
    flex: 1 1 200px;
    max-width: 280px;
}

.search > svg {
    position: absolute;
    left: 10px;
    top: 50%;
    width: 16px;
    height: 16px;
    transform: translateY(-50%);
    color: var(--muted-color);
    pointer-events: none;
}

.search input {
    width: 100%;
    padding-left: 32px;
    border-radius: 999px;
}

.search-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 600;
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.search-suggestions-title {
    padding: 4px 8px;
    font-size: 0.75rem;
    color: var(--muted-color);
}

.search-suggestion-item {
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.search-suggestion-item:hover {
    background: var(--hover-bg);
}

.search-suggestion-item.is-history {
    color: var(--primary-color);
}

/* --- Paneles desplegables (instrumento, círculo, metrónomo) --- */

.mod-panel {
    position: fixed;
    top: 68px;
    right: 16px;
    z-index: 700;
    width: 340px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 84px);
    overflow-y: auto;
    padding: 18px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.mod-panel h3 {
    margin-bottom: 14px;
    font-size: 1.05rem;
    color: var(--primary-color);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.panel-title h3 {
    margin-bottom: 0;
}

.panel-check {
    margin-top: 14px;
    font-size: 0.85rem;
    color: var(--muted-color);
}

/* Afinación personalizada: un selector por cuerda, de la más grave a la más aguda */
.custom-tuning {
    margin-bottom: 12px;
}

.custom-tuning-strings {
    display: grid;
    grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 6px;
}

.custom-tuning-string {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.75rem;
    color: var(--muted-color);
    text-align: center;
}

/* Sin la flecha nativa: seis selectores tienen que entrar en una fila */
.custom-tuning-string select {
    padding: 6px 2px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    text-align: center;
    text-align-last: center;
    appearance: none;
    -webkit-appearance: none;
}

.custom-tuning .link-btn {
    font-size: 0.85rem;
}


/* Metrónomo */
.metro-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.metro-btn-play {
    flex: 1 1 auto;
}

#input-bpm {
    width: 72px;
    text-align: center;
    font-weight: 700;
    color: var(--primary-color);
}

.metro-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

#progression-signature {
    width: 70px;
    text-align: center;
}

#metro-led {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #333;
    border: 1px solid #111;
    transition: background-color 0.05s, box-shadow 0.05s;
}

#metro-led.metro-led-on {
    background: #ff3333;
    box-shadow: 0 0 10px 2px #ff3333;
}

/* --- Contenido y tarjetas --- */

#center-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    padding: 16px 20px 24px;
}

.card {
    min-width: 0;
    padding: 16px 18px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.card h2 {
    font-size: 1.1rem;
}

.card > .hint {
    margin: 4px 0 12px;
}

.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin-bottom: 14px;
}

/* Título de una tarjeta con controles pegados a él */
.card-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
}

/* Orientación del diapasón: zurdo e invertir. Van junto al título porque cambian cómo se dibuja
   todo lo de abajo. */
.orient-group {
    display: inline-flex;
    gap: 6px;
}

.orient-btn {
    min-height: 30px;
    padding: 3px 12px 3px 8px;
    font-size: 0.8rem;
    color: var(--muted-color);
}

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

.orient-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.35s ease;
}

/* El ícono acompaña al diapasón: con zurdo la cejuela pasa a la derecha; con invertir, la cuerda
   gruesa pasa arriba */
#btn-toggle-left-handed.is-active svg {
    transform: scaleX(-1);
}

#btn-invert-fretboard.is-active svg {
    transform: scaleY(-1);
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.app-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px 16px;
    max-width: 1480px;
    margin: 0 auto;
    padding: 0 20px 24px;
    font-size: 0.8rem;
    color: var(--muted-color);
}

/* --- Diapasón --- */

.fretboard-wrapper {
    margin-top: 14px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.fretboard-container {
    position: relative;
    display: flex;
    flex-direction: column;
    /* --frets lo define Fretboard.render(): cada traste necesita un ancho mínimo para leer la nota */
    min-width: calc(var(--frets, 22) * 40px + 60px);
    padding: 14px 0 6px;
    background: linear-gradient(180deg, #2a2019 0%, #1a140f 100%);
    border: 1px solid #3d332a;
    border-radius: var(--radius);
}

.string {
    position: relative;
    display: flex;
    align-items: center;
    height: 30px;
}

.string-line {
    position: absolute;
    left: 25px;
    top: 50%;
    z-index: 1;
    width: calc(100% - 25px);
    height: 2px;
    background: #a8a8a8;
    transform: translateY(-50%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Grosor creciente hacia las cuerdas graves */
.string:nth-child(1) .string-line { height: 1px; }
.string:nth-child(2) .string-line { height: 1.2px; }
.string:nth-child(3) .string-line { height: 1.5px; }
.string:nth-child(4) .string-line { height: 2px; }
.string:nth-child(5) .string-line { height: 2.5px; }
.string:nth-child(n+6) .string-line { height: 3px; }

.string-number-label {
    z-index: 5;
    flex: 0 0 25px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted-color);
}

.fret {
    position: relative;
    z-index: 2;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    border-right: 2px solid #c9a53a; /* Alambre del traste */
}

.fret.nut {
    flex: 0.5;
    border-right: 6px solid #e6e1d6;
}

.fret-numbers {
    height: 24px;
}

.fretboard-container .string.fret-numbers .fret {
    /* Borde invisible pero presente: mantiene los números alineados con los trastes */
    border-color: transparent;
    font-size: 0.75rem;
    color: var(--muted-color);
}

.fret-spacer {
    flex: 0 0 25px;
}

.fret-marker {
    position: absolute;
    top: 100%; /* Entre esta cuerda y la siguiente */
    left: 50%;
    z-index: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.note {
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #10151c;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease-out, transform 0.15s ease-out, box-shadow 0.15s ease-out;
}

/* Los nombres latinos (Sol#, Sib) son más largos */
.notation-latin .note {
    font-size: 9.5px;
    letter-spacing: -0.3px;
}

.note-open {
    color: var(--text-color);
}

/* Notas que forman la posición de acorde elegida */
.note.shape-note {
    outline: 2px solid #fff;
    outline-offset: 1px;
}

.note-finger {
    font-size: 1.2em;
}

/* Modo zurdo: el mástil se dibuja espejado */
.left-handed .string {
    flex-direction: row-reverse;
}

.left-handed .fret {
    border-right: none;
    border-left: 2px solid #c9a53a;
}

.left-handed .fret.nut {
    border-right: none;
    border-left: 6px solid #e6e1d6;
}

.left-handed .string-line {
    left: auto;
    right: 25px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: 10px;
    list-style: none;
    font-size: 0.8rem;
    color: var(--muted-color);
}

.legend li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-root { background: var(--root-color); }
.dot-third { background: var(--third-color); }
.dot-fifth { background: var(--fifth-color); }
.dot-tension { background: var(--tension-color); }
.dot-shape { background: var(--fifth-color); outline: 2px solid #fff; outline-offset: 1px; }

#note-tooltip {
    position: fixed;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    background: var(--bg-color);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 0.85rem;
    pointer-events: none;
}

#tooltip-note-name {
    font-size: 1rem;
    color: var(--primary-color);
}

#tooltip-note-function {
    color: var(--third-color);
}

/* --- Acordes --- */

.chord-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 14px;
}

#circle-dynamic-info {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    font-size: 0.9rem;
}

#circle-info-title {
    color: var(--primary-color);
}

#circle-info-title.is-power {
    color: var(--primary-hover);
}

#circle-info-desc {
    color: var(--muted-color);
}

.chord-diagrams-container {
    display: flex;
    gap: 12px;
    padding: 2px 0 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.chord-box {
    flex: 0 0 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px 6px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    scroll-snap-align: start;
    cursor: pointer;
    transition: border-color 0.15s;
}

.chord-box:hover {
    border-color: var(--primary-color);
}

.chord-box svg {
    width: 100%;
    height: auto;
}

.chord-box h4 {
    font-size: 1rem;
    color: var(--text-color);
}

.chord-box-sub {
    margin: 2px 0 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
}

.chord-box.is-power .chord-box-sub {
    color: var(--primary-hover);
}

.chord-empty {
    width: 100%;
    padding: 20px;
    text-align: center;
    font-style: italic;
    color: var(--muted-color);
}

/* --- Armonía --- */

.chords-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chord-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 12px;
    background: var(--raised-bg);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.chord-chip:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
}

.chord-chip small {
    font-size: 0.75em;
    font-weight: 400;
    color: var(--muted-color);
    pointer-events: none;
}

.chord-chip.status-orange {
    border-color: var(--primary-color);
    border-style: dashed;
}

.chord-chip.status-red {
    border-color: var(--danger-color);
}

.chord-chip.is-playing {
    background: var(--focus-color);
    border-color: var(--focus-color);
    color: #fff;
}

.chord-chip.is-playing small {
    color: #fff;
}

#progression-generator .toolbar {
    margin: 4px 0 14px;
}

#progression-display {
    min-height: 36px;
    margin-bottom: 10px;
}

#progression-display:empty::before {
    content: 'Toca "Dame una" para crear una progresión.';
    font-size: 0.85rem;
    color: var(--muted-color);
}

/* Único texto que vive en el CSS: su traducción también */
html[lang="en"] #progression-display:empty::before {
    content: 'Tap "Give me one" to create a progression.';
}

.chords-empty {
    font-size: 0.85rem;
    color: var(--muted-color);
}

.idea-tip {
    margin-top: 14px;
    padding: 10px 14px;
    background: var(--primary-soft);
    border-left: 3px solid var(--accent-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.idea-tip strong {
    display: block;
    margin-bottom: 2px;
}

.suggested-chord-link {
    font-weight: 700;
    cursor: pointer;
}

/* --- Selector de dos o tres opciones --- */

.segmented {
    display: inline-flex;
    flex: 0 0 auto;
    padding: 3px;
    background: var(--raised-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
}

.segmented button {
    min-height: 30px;
    padding: 4px 14px;
    background: transparent;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted-color);
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.segmented button:hover {
    color: var(--text-color);
}

.segmented button.is-active {
    background: var(--primary-color);
    color: #fff;
}

/* --- Zonas del mástil --- */

.zone-picker {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.zone-label {
    flex: 0 0 auto;
    padding-top: 8px;
    font-size: 0.85rem;
    color: var(--muted-color);
}

/* Los botones bajan de renglón: nunca se pisan ni se cortan */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-height: 34px;
    padding: 5px 14px;
    background: var(--raised-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chip small {
    font-size: 0.8em;
    color: var(--primary-color);
}

.chip:hover {
    border-color: var(--primary-color);
}

/* La zona recomendada para empezar */
.chip.is-tonic {
    border-color: var(--border-accent);
}

.chip.is-active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.chip.is-active small {
    color: rgba(255, 255, 255, 0.85);
}

.zone-hint {
    margin: 8px 0 0;
}

.fretboard-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 20px;
    margin-top: 12px;
}

#fretboard-section {
    /* Al saltar acá desde otra pestaña, que no quede debajo de la cabecera fija */
    scroll-margin-top: 76px;
}

/* --- Menú inferior (pestañas) --- */

.tabs {
    display: flex;
    gap: 4px;
    margin: -4px -4px 16px;
    padding: 4px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-color);
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    position: relative;
    flex: 0 0 auto;
    padding: 10px 16px;
    background: transparent;
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--muted-color);
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s;
}

.tab:hover {
    color: var(--text-color);
}

.tab.is-active {
    color: var(--text-color);
}

.tab.is-active::after {
    content: '';
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -5px;
    height: 3px;
    border-radius: 3px;
    background: var(--primary-color);
}

.tab-panel {
    animation: panel-in 0.22s ease-out;
}

@keyframes panel-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.tab-panel > .hint {
    margin-bottom: 12px;
    max-width: 110ch;
}

.tab-panel > .toolbar + .hint {
    margin-top: 12px;
}

.mini-title {
    margin: 0 0 8px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted-color);
}

/* --- Círculo de quintas --- */

.circle-layout {
    display: grid;
    grid-template-columns: minmax(240px, 340px) 1fr;
    gap: 24px;
    align-items: center;
}

#circle-container {
    width: 100%;
    max-width: 340px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
}

.circle-dial {
    fill: var(--bg-color);
    stroke: var(--border-color);
    stroke-width: 2;
}

.circle-ring {
    fill: none;
    stroke: var(--border-color);
    stroke-dasharray: 4;
}

.circle-divider {
    stroke: rgba(255, 255, 255, 0.06);
}

.circle-hub {
    fill: var(--panel-bg);
    stroke: var(--border-color);
    stroke-width: 2;
}

.circle-sector {
    cursor: pointer;
}

.sector-bg {
    fill: transparent;
    stroke: transparent;
    transition: fill 0.15s, stroke 0.15s;
}

.circle-sector text {
    fill: var(--text-color);
    font-weight: 600;
    transition: fill 0.15s;
}

.minor-sector text {
    fill: var(--muted-color);
    font-weight: 500;
}

.circle-sector:hover .sector-bg {
    stroke: var(--primary-color);
}

/* El "vecindario": los seis acordes que combinan con la tonalidad */
.circle-sector.neighbor .sector-bg {
    fill: var(--primary-soft);
    stroke: var(--border-accent);
}

.circle-sector.neighbor text {
    fill: #ffb199;
}

.circle-sector.active .sector-bg {
    fill: var(--primary-color);
}

.circle-sector.active text {
    fill: #fff;
}

.circle-side {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.circle-explain p {
    margin-bottom: 8px;
    max-width: 70ch;
}

.circle-explain strong {
    color: var(--primary-color);
    font-weight: 600;
}

.circle-side .mini-title {
    margin-top: 6px;
}

/* --- Solear una canción --- */

.song-advice {
    margin-top: 18px;
    padding: 14px 16px;
    background: var(--primary-soft);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-sm);
    animation: panel-in 0.22s ease-out;
}

.song-advice strong {
    font-weight: 600;
}

.song-view {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.solo-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.solo-option {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.solo-option span {
    font-size: 0.82rem;
    color: var(--muted-color);
}

.solo-option:hover {
    border-color: var(--primary-color);
}

.solo-option.is-active {
    border-color: var(--primary-color);
    background: var(--raised-bg);
}

.solo-option.is-active strong {
    color: var(--primary-color);
}

/* --- Guía --- */

.guide-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    list-style: none;
    counter-reset: step;
}

.guide-steps li {
    position: relative;
    padding: 14px 16px 14px 52px;
    background: var(--raised-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    counter-increment: step;
}

.guide-steps li::before {
    content: counter(step);
    position: absolute;
    left: 14px;
    top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
}

.guide-steps h3 {
    margin-bottom: 4px;
    font-size: 1rem;
}

.guide-steps p {
    font-size: 0.9rem;
    color: var(--muted-color);
}

.guide-steps p strong {
    color: var(--text-color);
    font-weight: 500;
}

.guide-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Colores citados en la ayuda del diapasón */
.c-root { color: var(--root-color); }
.c-third { color: var(--third-color); }
.c-fifth { color: var(--fifth-color); }
.c-tension { color: var(--tension-color); }

.modal-content h2 {
    padding-right: 32px;
    font-size: 1.35rem;
    color: var(--primary-color);
}

/* --- Modales --- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.75);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 760px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 28px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.9);
}

.close-modal {
    position: absolute;
    top: 12px;
    right: 18px;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s;
}

.close-modal:hover {
    color: var(--root-color);
}

.modal-body {
    margin-top: 16px;
}

.modal-body h3 {
    margin: 22px 0 10px;
    font-size: 1.05rem;
}

.modal-body p,
.modal-body li {
    margin-bottom: 12px;
    line-height: 1.6;
}

.modal-body ul {
    padding-left: 20px;
}

/* --- Inicio --- */

.startup-content {
    max-width: 720px;
    text-align: center;
}

.startup-title {
    font-size: 1.6rem;
    color: var(--primary-color);
}

.startup-version {
    margin-top: 2px;
    font-size: 0.8rem;
    color: var(--muted-color);
}

.startup-intro {
    margin-top: 12px;
}

.startup-subtitle {
    margin: 20px 0 12px;
    font-size: 1.05rem;
}

.instrument-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
}

.guitar-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 0 0 124px;
    padding: 10px 8px;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
}

.guitar-option:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.guitar-option img {
    width: 72px;
    height: 72px;
    margin-bottom: 4px;
    border-radius: 4px;
    object-fit: cover;
}

.guitar-option h4 {
    font-size: 0.9rem;
}

.guitar-option span {
    font-size: 0.75rem;
    color: var(--muted-color);
}

/* Casillas de la bienvenida, una debajo de la otra */
.startup-checks {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.startup-note {
    margin-top: 14px;
    font-size: 0.8rem;
    color: var(--muted-color);
}

/* --- Varios --- */

#ux-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    z-index: 1100;
    max-width: calc(100vw - 32px);
    padding: 10px 22px;
    background: var(--raised-bg);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow);
    color: var(--text-color);
    font-weight: 500;
    transform: translateX(-50%);
    transition: opacity 0.3s;
}

.guide-tour-btn {
    margin-bottom: 18px;
}

/* --- Tutorial de primer uso --- */

.tour {
    position: fixed;
    inset: 0;
    z-index: 1200;
}

/* Tapa la app para que no se pueda tocar durante el recorrido */
.tour-blocker {
    position: absolute;
    inset: 0;
}

/* Marco sobre el control señalado: la sombra oscurece todo lo demás */
.tour-spotlight {
    position: fixed;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.72);
    pointer-events: none;
    transition: left 0.2s, top 0.2s, width 0.2s, height 0.2s;
}

.tour-popover {
    position: fixed;
    width: 320px;
    max-width: calc(100vw - 20px);
    padding: 16px 18px;
    background: var(--raised-bg);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Flecha: un cuadrado girado que asoma por el borde que mira al control */
.tour-arrow {
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--raised-bg);
    border: 1px solid var(--primary-color);
    transform: rotate(45deg);
}

.tour-popover[data-place="below"] .tour-arrow {
    top: -9px;
    border-right: none;
    border-bottom: none;
}

.tour-popover[data-place="above"] .tour-arrow {
    bottom: -9px;
    border-left: none;
    border-top: none;
}

.tour-count {
    font-size: 0.75rem;
    color: var(--muted-color);
}

.tour-popover h3 {
    margin: 2px 0 6px;
    font-size: 1.05rem;
    color: var(--primary-color);
}

.tour-text {
    font-size: 0.92rem;
    line-height: 1.5;
}

.tour-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
}

.tour-skip {
    font-size: 0.85rem;
    color: var(--muted-color);
}

.tour-nav {
    display: flex;
    gap: 6px;
}

.tour-prev:disabled {
    opacity: 0.4;
    cursor: default;
}

/* --- Responsive --- */

@media (max-width: 1180px) {
    .app-header {
        flex-wrap: wrap;
    }

    /* Marca y herramientas en la primera fila; tonalidad, escala y buscador debajo */
    .header-main {
        order: 3;
        flex-basis: 100%;
    }

    .header-actions {
        margin-left: auto;
    }

    /* La cabecera ocupa dos filas: los paneles se abren debajo de ella */
    .mod-panel {
        top: 116px;
        max-height: calc(100vh - 132px);
    }
}

@media (max-width: 900px) {
    .circle-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    /* En pantallas chicas la cabecera ocupa varias filas: no se deja fija para no tapar el diapasón */
    .app-header {
        position: static;
        padding: 8px 12px;
    }

    #fretboard-section {
        scroll-margin-top: 8px;
    }

    /* En el celular los interruptores de orientación quedan solo con su ícono */
    .orient-btn {
        width: 34px;
        padding: 0;
    }

    .orient-btn span {
        display: none;
    }

    .text-logo {
        font-size: 1.1rem;
    }

    .header-actions {
        gap: 4px;
    }

    .zone-label {
        display: none;
    }

    /* Tonalidad y escala en una sola fila: los rótulos se omiten (los selectores se explican solos) */
    .field-label {
        display: none;
    }

    #scale-selector {
        flex: 1 1 auto;
        min-width: 0;
    }

    .header-main .field:nth-of-type(2) {
        flex: 1 1 auto;
        min-width: 0;
    }

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

    .segmented button {
        padding: 4px 9px;
        font-size: 0.8rem;
    }

    #center-panel {
        padding: 12px;
        gap: 12px;
    }

    .card {
        padding: 14px 12px;
    }

    .search {
        max-width: none;
        flex-basis: 100%;
    }

    .mod-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: none;
        max-height: 80vh;
        border-radius: var(--radius) var(--radius) 0 0;
    }

    .fretboard-footer .field {
        flex: 1 1 auto;
        justify-content: space-between;
    }


    .modal-content {
        padding: 20px 16px;
    }

    .guitar-option {
        flex-basis: 96px;
    }

    .guitar-option img {
        width: 56px;
        height: 56px;
    }

    .app-footer {
        padding: 0 12px 20px;
    }
}

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