/* Colores y letra del sistema de diseño de IASD Las Lomas (Cielo · Crema · Carbón),
   los mismos de iasdlaslomas.com y de su panel. Los nombres de las variables son los de Atril. */
:root {
  --bg: #EDEAE3;            /* crema-100 */
  --surface: #F6F4EE;       /* crema-50 */
  --surface-2: #E6E2D8;
  --border: #E1DCD0;        /* crema-200 */
  --border-strong: #B0C9D0; /* cielo-300 */
  --text: #272727;          /* carbón-800 */
  --muted: #5E5E5E;         /* gris-600 */
  --primary: #6B98A6;       /* cielo-500: botones y marcas */
  --primary-hover: #517E8C; /* cielo-600 */
  --primary-ink: #F6F4EE;
  --primary-text: #3F6A78;  /* cielo-700: el acento cuando es texto */
  --primary-soft: #DCE8EB;  /* cielo-100 */
  --inverted: #272727;
  --inverted-ink: #EDEAE3;
  --warn: #8A5A12;
  --warn-soft: #F7EBD3;
  --danger: #B23B3B;
  --danger-soft: #F6E1DE;
  --ok: #2F6B45;
  --ok-soft: #E1EEE4;
  --focus-ring: color-mix(in srgb, #6B98A6 55%, transparent);
  --radius: 8px;      /* tarjetas */
  --radius-sm: 4px;   /* botones y campos */
  --radius-xl: 14px;  /* diálogos */
  --shadow: 0 1px 2px rgba(39, 39, 39, .06);
  --shadow-lg: 0 12px 32px rgba(39, 39, 39, .14);
  --font-body: 'Quasimoda', 'Hanken Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-script: 'Cormorant Garamond', Georgia, serif;
  color-scheme: light;
}

/* data-theme lo pone el script del <head> de index.html (lo elegido con ☀/☾, o el modo del dispositivo). */
:root[data-theme="dark"] {
  --bg: #1A1B1A;
  --surface: #232423;
  --surface-2: #151615;
  --border: #2E302F;
  --border-strong: #34494F;
  --text: #EDEAE3;
  --muted: #9C978D;
  --primary: #8DB0BB;     /* cielo-400: más luminoso sobre fondo oscuro */
  --primary-hover: #A3C0C9;
  --primary-ink: #0F1213;
  --primary-text: #B0C9D0;
  --primary-soft: #1C272A;
  --inverted: #0F1213;
  --inverted-ink: #EDEAE3;
  --warn: #E3C88F;
  --warn-soft: #2E2614;
  --danger: #F2847C;
  --danger-soft: #3A1F1D;
  --ok: #8BC46A;
  --ok-soft: #1E2A1A;
  --focus-ring: color-mix(in srgb, #8DB0BB 55%, transparent);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; } /* sin zoom por doble toque */
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font-body);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary-text); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: .5rem max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 92%, transparent); color: var(--text);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: .5rem; color: inherit; text-decoration: none; }
.brand-logo { width: 30px; height: 30px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-weight: 600; text-transform: uppercase; letter-spacing: .18em; font-size: .92rem; }
.brand-text small { font-family: var(--font-script); font-style: italic; font-weight: 500; font-size: .85rem; color: var(--muted); }
.nav { display: flex; gap: .25rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a {
  color: var(--muted); text-decoration: none; padding: .45rem .75rem; border-radius: var(--radius-sm);
  white-space: nowrap; font-size: .95rem; font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--primary-text); background: var(--primary-soft); font-weight: 600; }
.user { display: flex; align-items: center; gap: .5rem; font-size: .9rem; white-space: nowrap; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: .25rem .75rem; }
  .brand-text small { display: none; }
  .nav { order: 3; flex-basis: 100%; }
  .user { margin-left: auto; }
  .user .who { display: none; }
}

.app { max-width: 1100px; margin: 0 auto; padding: 1.25rem 16px 4rem; }

/* ---------- Componentes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow);
}
.card + .card, .stack > * + * { margin-top: 1rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.section-head h1, .section-head h2 { margin: 0; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: .25rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 40px; padding: .45rem .9rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: .95rem; font-weight: 600; letter-spacing: .02em;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--primary-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger.solid, .dialog .btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { min-height: 32px; padding: .25rem .6rem; font-size: .85rem; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary-text); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: inherit; font-size: 1.1rem; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }

input, select, textarea {
  width: 100%; min-height: 42px; padding: .5rem .7rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible {
  outline: none; box-shadow: 0 0 0 3px var(--focus-ring);
}
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field-label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.hint { color: var(--muted); font-size: .8rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; }
.form-grid .full { grid-column: 1 / -1; }
.search { max-width: 320px; }

.badge {
  display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; letter-spacing: .03em; background: var(--primary-soft); color: var(--primary-text); white-space: nowrap;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.kind-pdf { background: var(--danger-soft); color: var(--danger); }
.chip {
  display: inline-flex; align-items: center; padding: .15rem .55rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: .8rem;
}

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .6rem .5rem; border-top: 1px solid var(--border); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-top: 0; }

/* Tarjetas de canciones */
.song-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem; }
.song-card { display: flex; flex-direction: column; gap: .5rem; text-decoration: none; color: inherit; }
.song-card:hover { border-color: var(--primary); }
.song-card h3 { margin: 0; }
.parts-buttons { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .25rem; }

/* ---------- Acceso ---------- */
.auth { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.auth-logo { width: 72px; height: 72px; display: block; margin: 0 auto .5rem; }
.auth h1 { margin-top: .25rem; }
.auth .display { font-size: 2.2rem; text-transform: uppercase; letter-spacing: .18em; margin-bottom: .1rem; }
.script { font-family: var(--font-script); font-style: italic; font-weight: 500; font-size: 1.2rem; }
.auth .card { text-align: left; margin-top: 1.25rem; }
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
.who-grid .btn { white-space: normal; min-height: 48px; }
.who-grid .btn.selected { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.pin-input { font-size: 1.6rem; letter-spacing: .5em; text-align: center; }

/* ---------- Segmentacion de PDF ---------- */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.thumb {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .4rem; border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer;
}
.thumb canvas { max-width: 100%; height: auto; background: #fff; box-shadow: var(--shadow); }
.thumb.selected { border-color: var(--primary); background: var(--primary-soft); }
.thumb .num { font-size: .8rem; font-weight: 600; }
.thumb .heading { font-size: .72rem; font-weight: 600; color: var(--primary-text); text-align: center; line-height: 1.2; }
.thumb .used { font-size: .7rem; color: var(--muted); text-align: center; line-height: 1.2; }
.sticky-bar {
  position: sticky; bottom: 0; margin: 1rem -1rem -1rem; padding: .75rem 1rem;
  background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
}

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.25rem; text-align: center;
  color: var(--muted); cursor: pointer;
}
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }

.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .35rem .75rem; }
.check-list label { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; }
.check-group + .check-group { margin-top: .75rem; }
.check-family { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; margin-bottom: .15rem; border-bottom: 1px solid var(--border); }
.check-family .muted { margin-left: auto; }
.check-group .check-list { padding-left: 1.5rem; }
.check-group h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
label.suggested { font-weight: 600; }

/* ---------- Dialogos y avisos ---------- */
.dialog {
  border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 1.25rem; width: min(520px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog-wide { width: min(980px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(22, 22, 22, .45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.dialog-head h2 { margin: 0; }

.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: .5rem; width: min(420px, calc(100vw - 32px)); }
.toast { padding: .7rem 1rem; border-radius: var(--radius-sm); background: var(--inverted); color: var(--inverted-ink); box-shadow: var(--shadow-lg); transition: opacity .3s; }
.toast-error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; }

/* ---------- Lector ---------- */
body.reading .topbar { display: none; }
body.reading .app { max-width: none; padding: 0; }
.reader { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--surface-2); }
.reader-bar {
  display: flex; align-items: center; gap: .25rem; padding: .25rem max(8px, env(safe-area-inset-left));
  background: var(--surface); border-bottom: 1px solid var(--border); min-height: 52px;
}
.reader-title { flex: 1; min-width: 0; line-height: 1.15; }
.reader-title strong, .reader-title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-title span { font-size: .8rem; color: var(--muted); }
.reader-page { font-size: .85rem; color: var(--muted); padding: 0 .4rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.reader-stage { flex: 1; overflow: auto; position: relative; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
.reader-stage.paged { display: flex; align-items: center; justify-content: center; padding: 8px; }
.reader-stage.paged > .pages { display: flex; align-items: center; justify-content: center; gap: 8px; }
.reader-stage.zoomed { display: block; text-align: center; }
.reader-stage.zoomed .page-wrap { display: inline-block; vertical-align: top; margin: 4px; }
.reader-stage canvas.page { background: #fff; box-shadow: var(--shadow); }
.page-wrap { position: relative; line-height: 0; }
.reader-stage .osmd { background: #fff; min-height: 100%; padding: 8px 4px 40px; display: inline-block; min-width: 100%; vertical-align: top; }
.reader.dark .reader-stage canvas.page, .reader.dark .reader-stage .osmd { filter: invert(1) hue-rotate(180deg); }
.reader.dark .reader-stage { background: #0F1213; }
.reader-audio { padding: .4rem 8px calc(.4rem + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
.reader-audio audio { width: 100%; height: 40px; }
.reader-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.reader-bar .show-sm { display: none; }
@media (max-width: 560px) {
  .reader-bar .hide-sm { display: none; }
  .reader-bar .show-sm { display: inline-grid; }
}

@media print {
  .topbar, .reader-bar, .reader-audio, .toasts { display: none !important; }
}
.song-grid > .card { margin-top: 0; }

/* ---------- Sin conexion ---------- */
.part-pair { display: inline-flex; }
.part-pair > :first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.offline-toggle { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; min-width: 36px; padding: .25rem .5rem; }
.offline-toggle.saved { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.notice { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; background: var(--primary-soft); color: var(--primary-text); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Anotaciones ---------- */
.anot-layer { position: absolute; inset: 0; pointer-events: none; }
.reader.annotating .anot-layer { pointer-events: auto; touch-action: none; cursor: crosshair; }
.reader.annotating .reader-stage { touch-action: none; }
.icon-btn[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }
.anot-tools {
  --safe-left: env(safe-area-inset-left); --safe-right: env(safe-area-inset-right); --safe-bottom: env(safe-area-inset-bottom);
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center;
  /* Panel compacto de tres renglones (herramientas / colores / acciones): asi cabe en cualquier rincon. */
  width: max-content; max-width: min(calc(100vw - 24px), 440px);
  padding: 6px; border-radius: var(--radius-xl); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
/* Arrastrada por el usuario: anotaciones.js le pone left/top dentro de la pantalla. */
.anot-tools.moved { bottom: auto; transform: none; }
.anot-tools.dragging { opacity: .92; }
.anot-tools .grip {
  display: grid; place-items: center; width: 32px; min-height: 40px; border-radius: var(--radius-sm); color: var(--muted);
  font-size: 1.2rem; line-height: 1; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.anot-tools .grip:hover { background: var(--surface-2); color: var(--text); }
.anot-tools.dragging .grip { cursor: grabbing; background: var(--primary-soft); color: var(--primary-text); }
.anot-tools .tool {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text); font: inherit; font-size: .85rem; cursor: pointer;
}
.anot-tools .tool[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }
.anot-tools .tool.done { background: var(--primary); color: var(--primary-ink); }
.anot-tools .sep { flex-basis: 100%; height: 1px; background: var(--border); }
.swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--muted); }
.tool-hl .swatch { border-radius: 3px; }
.tool-eraser .swatch { background: repeating-linear-gradient(45deg, #fff 0 3px, #f2a7b0 3px 6px); border-radius: 3px; }
.anot-colors { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; flex-basis: 100%; }
.anot-colors .color {
  display: grid; place-items: center; width: 34px; height: 40px; padding: 0; border: 0; background: transparent; cursor: pointer;
}
.anot-colors .color::before {
  content: ''; width: 22px; height: 22px; border-radius: 50%; background: var(--c);
  border: 1px solid color-mix(in srgb, var(--text) 30%, transparent);
}
.anot-colors .color.hl::before { border-radius: 5px; }
.anot-colors .color[aria-pressed="true"]::before { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }
.anot-colors .color:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; border-radius: var(--radius-sm); }
@media (max-width: 560px) {
  .anot-tools .tool { padding: 0 7px; font-size: .78rem; }
  .anot-tools .tool .label { display: none; }
  .anot-tools .tool:has(.label) { padding: 0 11px; }
  .anot-colors .color { width: 31px; }
}

/* ---------- iPad / app: respetar la barra de estado (hora, bateria) ---------- */
.topbar { padding-top: max(.5rem, env(safe-area-inset-top)); }
.reader-bar { padding-top: env(safe-area-inset-top); min-height: calc(52px + env(safe-area-inset-top)); }
.auth { padding-top: env(safe-area-inset-top); }

/* ---------- Entrar con Google / Apple ---------- */
.provider-btn { display: flex; justify-content: center; min-height: 44px; }
.apple-btn { width: 300px; max-width: 100%; margin: 0 auto; background: #000; color: #fff; border-color: #000; font-weight: 600; }
.apple-btn:hover { background: #1c1c1e; border-color: #1c1c1e; }
.anot-tools .tool.finger { text-transform: none; }
.anot-tools .tool.finger[aria-pressed="true"] { background: var(--warn-soft); border-color: var(--warn); }

/* ---------- Buscador con sugerencias ---------- */
.search-box { position: relative; margin-bottom: 1rem; }
.search-input { font-size: 1.05rem; min-height: 48px; padding-left: 2.4rem; border-radius: var(--radius); }
.search-icon { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.2rem; pointer-events: none; }
.suggestions {
  position: absolute; z-index: 15; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 60vh; overflow-y: auto;
}
.suggestions li { display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem; border-radius: var(--radius-sm); cursor: pointer; }
.suggestions li.active, .suggestions li:hover { background: var(--primary-soft); }
.suggestions li.empty-sugg { color: var(--muted); cursor: default; }
.suggestions li.empty-sugg:hover { background: none; }
.sugg-text { display: flex; flex-direction: column; min-width: 0; }
.sugg-text strong, .sugg-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg-text small { color: var(--muted); }
.song-num {
  display: inline-block; min-width: 2.6em; margin-right: .45rem; padding: .05rem .4rem; border-radius: var(--radius-sm); text-align: center;
  background: var(--primary-soft); color: var(--primary-text); font-weight: 700; font-size: .85em; font-variant-numeric: tabular-nums;
}

/* ---------- Musicos por seccion ---------- */
.segmented { display: inline-flex; padding: 3px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.segmented button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .9rem; padding: .35rem .8rem; border-radius: 3px; cursor: pointer; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.section-group > summary { display: flex; align-items: center; gap: .6rem; cursor: pointer; list-style: none; }
.section-group > summary::-webkit-details-marker { display: none; }
.section-group > summary::before { content: '▾'; color: var(--muted); transition: transform .15s; }
.section-group:not([open]) > summary::before { transform: rotate(-90deg); }
.section-group > summary h2 { margin: 0; }
.inst-group { margin-top: .9rem; }
.inst-group h3 { font-size: .95rem; margin: 0 0 .2rem; color: var(--primary-text); }
.inst-group .list > li { padding: .5rem 0; }
.nav { min-width: 0; }
.user .who { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1000px) { .user .who { display: none; } }
/* Filtro de instrumento: fila de pastillas sin caja alrededor (una caja ajustada al texto recortaba
   "Si♭" en el iPad, porque el ♭ viene de otra letra). */
.filter-bar { display: flex; gap: .4rem; max-width: 100%; overflow-x: auto; margin-bottom: 1rem; padding: 0; background: none; border: 0; scrollbar-width: none; }
.filter-bar button { flex: none; white-space: nowrap; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); padding: .35rem .9rem; }
.filter-bar button[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: none; }
.chip-extra { border-style: dashed; }

.google-btn { width: 300px; max-width: 100%; margin: 0 auto; gap: .6rem; background: #fff; color: #1f1f1f; border-color: #dadce0; font-weight: 600; }
.google-btn:hover { background: #f8f9fa; border-color: #c6c9cc; }
.inst-empty { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .8rem; padding-top: .6rem; border-top: 1px dashed var(--border); }
.btn-whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn-whatsapp:hover { filter: brightness(1.05); border-color: #25d366; }

/* ---------- Boton ☀ / ☾ (como en iasdlaslomas.com) ---------- */
.tema-btn {
  flex: none; width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 999px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.tema-btn:hover { color: var(--primary-text); background: var(--primary-soft); }
.tema-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.tema-btn svg { width: 18px; height: 18px; display: block; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tema-btn .sol { display: none; }
:root[data-theme="dark"] .tema-btn .sol { display: block; }
:root[data-theme="dark"] .tema-btn .luna { display: none; }

/* ---------- Configuracion ---------- */
.settings-tabs { max-width: 100%; overflow-x: auto; margin-bottom: 1rem; scrollbar-width: none; }
.settings-tabs button { white-space: nowrap; flex: none; }
.invite-preview {
  margin: .3rem 0 0; padding: .75rem 1rem; white-space: pre-wrap; font: inherit; font-size: .9rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
code { font-size: .85em; padding: .05rem .3rem; border-radius: 3px; background: var(--primary-soft); color: var(--primary-text); }

/* ---------- Biblioteca en lista ---------- */
.song-list { padding: .25rem 1rem; }
.song-list .list > li { padding: 0; }
.song-row { display: flex; align-items: center; gap: .75rem; width: 100%; padding: .7rem 0; color: inherit; text-decoration: none; }
.song-row:hover strong { color: var(--primary-text); }
.song-row .grow { display: flex; flex-direction: column; }
.song-row strong, .song-row .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-row .song-num { margin-right: 0; }
.song-badges { flex: none; justify-content: flex-end; }
@media (max-width: 640px) { .song-badges { display: none; } }
.song-key { flex: none; width: 7.5rem; font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-key.muted { font-weight: 400; }
.song-list-head { display: flex; gap: .75rem; padding: .6rem 0 .2rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.song-list .song-badges { width: 17.5rem; }
.song-list-head > :first-child { min-width: 3.4em; }
@media (max-width: 640px) { .song-list .song-badges { display: none; } .song-key { width: auto; max-width: 6.5rem; } }

/* ---------- Importar partituras ---------- */
.import-drop { padding: 2rem 1rem; display: grid; gap: .3rem; }
.import-song { display: grid; gap: .75rem; }
.import-song-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; }
.import-song-head select { width: auto; max-width: 100%; }
.import-song-fields { display: flex; flex-wrap: wrap; gap: .5rem .75rem; }
.import-song-fields .num { width: 6rem; }
.import-song-fields .grow { flex: 1 1 260px; }
.import-song-fields .key { width: 11rem; }
.import-file { border-top: 1px solid var(--border); padding-top: .6rem; }
.import-parts td { padding: .35rem .4rem; }
.import-parts td.pages { width: 6.5rem; }
.import-parts .pages-input { min-height: 36px; padding: .3rem .5rem; }
.import-parts tr.unknown td { background: var(--warn-soft); }
.import-parts tr.unknown td:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.song-list-head .song-key { font-size: inherit; font-weight: inherit; }

/* ---------- Reproducir / metronomo ---------- */
.play-slot { background: var(--surface); border-top: 1px solid var(--border); padding: .4rem max(8px, env(safe-area-inset-left)) calc(.4rem + env(safe-area-inset-bottom)); }
.play-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.play-bar .play-main { min-width: 7.5rem; }
.play-group { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.play-group .icon-btn { width: 36px; height: 36px; }
.play-tempo { min-width: 6.5rem; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; font-size: .92rem;
  height: 36px; padding: 0 .4rem; border: 0; border-left: 1px solid var(--border-strong); border-right: 1px solid var(--border-strong);
  background: transparent; color: inherit; font-family: inherit; cursor: pointer; }
.play-tempo:hover, .play-tempo:active { background: color-mix(in srgb, currentColor 14%, transparent); }
/* Teclado numerico del tempo */
.keypad { display: flex; flex-direction: column; align-items: center; gap: .6rem; min-width: min(280px, 80vw); }
.keypad-screen { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.keypad-note { margin: 0; text-align: center; }
.keypad-note.keypad-bad { color: var(--danger); }
.keypad-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; width: 100%; }
.keypad-key { min-height: 56px; font-size: 1.35rem; font-weight: 600; justify-content: center; }
.keypad-key.keypad-soft { color: var(--muted); }
.keypad-key.btn-primary { font-size: 1rem; }
.play-time, .play-beat { margin-left: auto; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; letter-spacing: .1em; }
.play-toggle[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); }
.play-bar select { width: auto; min-height: 38px; }
.play-note { flex-basis: 100%; }
@media (max-width: 560px) { .play-time { display: none; } .play-bar .play-main { min-width: 0; } }
/* La nota que toca ahora, en la parte del musico */
.osmd .nota-actual path, .osmd .nota-actual ellipse, .osmd .nota-actual rect { fill: #1F8FB3 !important; stroke: #1F8FB3 !important; }
.osmd .nota-actual { filter: drop-shadow(0 0 2.5px rgba(31, 143, 179, .75)); }
/* Solo se resalta la figura: la barra vertical de OSMD sigue ahi (marca donde va la musica para
   mover la pantalla) pero no se ve. */
.osmd img[id^="cursorImg"] { opacity: 0 !important; }
.osmd .bucle-marca { fill: rgba(107, 152, 166, .18); stroke: rgba(107, 152, 166, .55); stroke-width: 1; }

/* ---------- Celular (iPhone) ---------- */
.play-bar .ico { display: inline-block; min-width: 1em; text-align: center; }
.play-bar .btn { gap: .35rem; }
/* Pantalla angosta o celular en horizontal: los botones de la barra quedan solo con su icono. */
@media (max-width: 640px), (max-height: 520px) {
  .play-bar { gap: .3rem; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .play-bar .lbl { display: none; }
  .play-bar .btn { min-height: 38px; padding: .3rem .6rem; flex: none; }
  .play-bar .play-main { min-width: 3.2rem; font-size: 1.05rem; }
  .play-bar [data-count]:not([data-count=""])::after { content: attr(data-count); font-size: .78rem; font-weight: 600; }
  .play-tempo { min-width: 4.6rem; font-size: .85rem; }
  .play-group { flex: none; }
  .play-note { display: none; }
}
/* Celular en horizontal: barras delgadas para dejarle la pantalla a la partitura. */
@media (max-height: 520px) and (orientation: landscape) {
  .reader-bar { min-height: 40px; padding-top: 0; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .reader-bar .icon-btn { width: 34px; height: 34px; }
  .reader-title span { display: none; }
  .reader-bar .hide-sm { display: none; }
  .play-slot { padding: .25rem max(8px, env(safe-area-inset-right)) calc(.25rem + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .play-time { display: inline; margin-left: auto; flex: none; }
  .reader-stage { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}
/* Una sola linea: la partitura se recorre de lado y queda centrada en lo alto disponible. */
.reader-stage.una-linea { display: flex; align-items: center; overflow-x: auto; overflow-y: auto; }
.reader-stage.una-linea .osmd { min-width: 0; min-height: 0; padding: 4px 30vw 4px 8px; display: block; }
.reader-stage .osmd { position: relative; } /* el cursor de la reproduccion se coloca respecto a la partitura */
@media (max-width: 640px) and (orientation: portrait) { .play-bar { flex-wrap: wrap; overflow-x: visible; } }
.auth .btn-ghost { white-space: normal; text-align: center; line-height: 1.35; }

/* ---------- Biblioteca: seleccionar y borrar varias ---------- */
.song-check { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 2rem; min-height: 40px; cursor: pointer; }
.song-check input { margin: 0; }
.song-list .list > li { gap: .25rem; }
.song-list .list > li.is-selected { background: var(--primary-soft); border-radius: var(--radius-sm); }
.song-list-head { align-items: center; }
.song-list-head .song-check { min-height: 0; }
.song-tile { position: relative; }
.song-tile .song-check { position: absolute; top: .55rem; left: .5rem; z-index: 1; }
.song-tile .song-card { padding-left: 2.6rem; height: 100%; }
.selection-bar { position: sticky; bottom: 12px; z-index: 6; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; box-shadow: var(--shadow-lg); border-color: var(--danger); }
.delete-list { margin: .6rem 0 0; padding-left: 1.2rem; max-height: 40vh; overflow: auto; }

/* ---------- Mi perfil y directorio ---------- */
.profile-link { display: inline-flex; align-items: center; gap: .45rem; color: inherit; text-decoration: none; padding: .15rem .45rem .15rem .15rem; border-radius: 999px; }
.profile-link:hover, .profile-link.active { background: var(--primary-soft); color: var(--primary-text); }
.profile-link.active .avatar { box-shadow: 0 0 0 2px var(--primary); }
.avatar-sm { width: 30px; height: 30px; font-size: .72rem; }
@media (max-width: 720px) { .profile-link { padding: .15rem; } }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  background: var(--primary-soft); color: var(--primary-text); font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 2rem; }
.profile-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.person-card { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.person-card a { color: var(--primary-text); }

/* ---------- Mis partituras: secciones, lista y favoritos ---------- */
.my-bar { margin-bottom: .9rem; }
.song-card-head { display: flex; align-items: flex-start; gap: .5rem; }
.song-card-head h3 { flex: 1; min-width: 0; }
.fav-btn { flex: none; font-size: 1.25rem; color: var(--muted); }
.fav-btn.on { color: #D9A21B; }
.my-list .list > li { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; flex-wrap: wrap; }
.my-list .song-num { min-width: 2.6em; margin-right: 0; }
.my-title { display: flex; flex-direction: column; min-width: 8rem; }
.my-list .parts-buttons { margin-top: 0; justify-content: flex-end; }
.birthday-row select { width: auto; min-width: 6rem; }
.my-list-head { gap: .6rem; }
.my-list-head .fav-col { width: 36px; text-align: center; }
.my-list-head .num-col { min-width: 2.6em; }
.my-list-head .parts-col, .my-list .parts-buttons { width: 15rem; }
.my-list-head .parts-col { text-align: right; }
@media (max-width: 760px) {
  .my-list-head { display: none; }
  .my-list .parts-buttons { width: 100%; justify-content: flex-start; padding-left: 2.6rem; }
}

/* ---------- Lector PDF: hojas seguidas y varias hojas a la vez ---------- */
.reader-stage.seguidas > .pages { display: grid; justify-content: center; gap: 8px; padding: 4px 0 24px; }
.reader-stage.seguidas .page-wrap { display: block; margin: 0; background: #fff; }
.reader.dark .reader-stage.seguidas .page-wrap { background: transparent; }
.reader-page { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: .85rem; }

/* Renglones y tarjetas que se abren al tocarlos en cualquier parte: el enlace del titulo (.open-link)
   se estira con ::after sobre todo el renglon; estrella, botones y demas enlaces quedan por encima. */
.opens { cursor: pointer; position: relative; }
.open-link { color: inherit; text-decoration: none; }
.open-link::after { content: ''; position: absolute; inset: 0; z-index: 0; }
.opens button, .opens .btn, .opens .part-pair, .opens .parts-buttons a { position: relative; z-index: 1; }
.list > li.opens { border-radius: var(--radius-sm); transition: background .12s ease; }
.list > li.opens:hover, .list > li.opens:active { background: var(--primary-soft); }
.song-card.opens:active { border-color: var(--primary); }

.switch-row { display: flex; gap: .75rem; align-items: flex-start; cursor: pointer; }
.switch-row input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; flex: none; }

/* ---------- Afinador ---------- */
.tuner { text-align: center; padding: 1.5rem 1rem 1.25rem; }
.tuner-note { font-size: clamp(4rem, 18vw, 8rem); font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.tuner-note small { font-size: .32em; font-weight: 600; color: var(--muted); margin-left: .12em; }
.tuner-sub { margin: .4rem 0 1.4rem; font-variant-numeric: tabular-nums; }
.tuner-meter { position: relative; height: 64px; max-width: 560px; margin: 0 auto; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--danger-soft), var(--warn-soft) 30%, var(--ok-soft) 45%, var(--ok-soft) 55%, var(--warn-soft) 70%, var(--danger-soft)); }
.tuner-zone { position: absolute; left: 45%; width: 10%; top: 0; bottom: 0; background: color-mix(in srgb, var(--ok) 22%, transparent); }
.tuner-center { position: absolute; left: 50%; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; background: var(--text); opacity: .55; }
.tuner-needle { position: absolute; top: 6px; bottom: 6px; width: 8px; margin-left: -4px; border-radius: 4px; background: var(--danger);
  left: 50%; opacity: 0; transition: left .12s linear, background .12s linear; box-shadow: 0 0 0 2px var(--surface); }
.tuner-meter[data-state="cerca"] .tuner-needle { background: var(--warn); }
.tuner-meter[data-state="ok"] .tuner-needle { background: var(--ok); }
.tuner-tick { position: absolute; bottom: -1.5rem; font-size: .75rem; color: var(--muted); }
.tuner-tick.left { left: 0; } .tuner-tick.right { right: 0; }
.tuner-status { margin-top: 2.2rem; font-size: 1.15rem; font-weight: 600; min-height: 1.6em; }
.tuner-setup { align-items: flex-end; }
.tuner-la { min-width: 6.2rem; text-align: center; font-size: .9rem; font-variant-numeric: tabular-nums; }
.tuner-strings .row { justify-content: center; gap: .6rem; }
.tuner-string { display: inline-flex; flex-direction: column; align-items: center; gap: .1rem; min-width: 64px; padding: .5rem .6rem;
  border: 2px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.tuner-string strong { font-size: 1.25rem; }
.tuner-string small { color: var(--muted); font-size: .72rem; }
.tuner-string.near { border-color: var(--primary); background: var(--primary-soft); }
.tuner-string.locked { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
.tuner-string.locked small { color: inherit; opacity: .85; }
.tuner-string.sounding { box-shadow: 0 0 0 3px var(--focus-ring); }

.tuner-note { transition: color .1s linear; }
.tuner-note[data-state="ok"] { color: var(--ok); }
.tuner-note[data-state="cerca"] { color: var(--warn); }
.tuner-note[data-state="lejos"] { color: var(--danger); }
.tuner-sub { margin-bottom: .5rem; }
.tuner-goal { min-height: 1.6em; margin-bottom: 1.1rem; font-size: 1.1rem; }
.tuner-goal strong { font-size: 1.3rem; }
.tuner-wrong { color: var(--danger); font-weight: 600; }
.tuner-level { height: 4px; max-width: 560px; margin: 1.2rem auto 0; border-radius: 2px; background: var(--border); overflow: hidden; }
.tuner-level span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .08s linear; }

.tuner-graph { display: block; width: 100%; max-width: 640px; height: 190px; margin: 0 auto; border-radius: var(--radius);
  background: var(--surface-2, var(--bg)); border: 1px solid var(--border); }
.tuner-status { margin-top: 1rem; }

/* Ícono del afinador en el menú */
.nav a.nav-icon { display: inline-flex; align-items: center; justify-content: center; padding: .3rem .55rem; flex: none; }
.nav a.nav-icon svg { display: block; }
