:root {
  --fondo: #000000;
  --tinta: #ffffff;
  --letra: 20px;
  --panel: color-mix(in srgb, var(--tinta) 9%, var(--fondo));
  --raya: color-mix(in srgb, var(--tinta) 40%, var(--fondo));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--fondo);
  color: var(--tinta);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
}

/* ---------- Botones y campos ---------- */
.boton {
  font: inherit;
  font-weight: 600;
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid var(--raya);
  border-radius: 12px;
  background: var(--panel);
  color: var(--tinta);
  cursor: pointer;
  touch-action: manipulation;
}
.boton:hover { border-color: var(--tinta); }
.boton:disabled { opacity: .35; cursor: default; }
.boton.principal { background: var(--tinta); color: var(--fondo); border-color: var(--tinta); }
.boton.grande { width: 100%; min-height: 56px; font-size: 19px; }
.boton.gigante { min-width: 90px; min-height: 64px; font-size: 26px; }
.boton.peligro { background: #b3261e; border-color: #ff8a80; color: #fff; }

:focus-visible { outline: 3px solid #4da3ff; outline-offset: 2px; }

input[type="text"], input[type="search"], textarea, select {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--raya);
  border-radius: 12px;
  background: var(--fondo);
  color: var(--tinta);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--tinta) 65%, var(--fondo)); }
select option { background: var(--fondo); color: var(--tinta); }

/* ---------- Barra de arriba ---------- */
#barra {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 2px solid var(--raya);
}
#estado { flex: 1; min-width: 0; text-align: center; font-size: 16px; font-weight: 600; }
#estado.problema { background: #ffd60a; color: #000; border-radius: 8px; padding: 4px 8px; }

/* ---------- Dos columnas ---------- */
#cuerpo { flex: 1; display: flex; min-height: 0; position: relative; }

#lateral {
  width: clamp(260px, 30vw, 420px);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-right: 2px solid var(--raya);
  background: var(--fondo);
}
body.sin-lista #lateral { display: none; }

#buscador { flex: none; font-size: 18px; }

#filtros { display: flex; flex-wrap: wrap; gap: 8px; flex: none; max-height: 22vh; overflow: auto; }
#filtros:empty { display: none; }
#filtros .boton { min-height: 40px; padding: 6px 14px; font-size: 16px; border-radius: 999px; }
#filtros .boton[aria-pressed="true"] { background: var(--tinta); color: var(--fondo); border-color: var(--tinta); }

#lista { flex: 1; overflow: auto; min-height: 80px; }
.grupo { margin: 14px 4px 6px; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; }
.grupo:first-child { margin-top: 2px; }

.renglon {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: none;
  color: var(--tinta);
  font: inherit;
  font-size: clamp(17px, var(--letra), 23px);
  text-align: left;
  cursor: pointer;
}
.renglon:hover { background: var(--panel); }
.renglon[aria-current="true"] { background: var(--panel); border-color: var(--tinta); font-weight: 700; }
.renglon .nombre { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.renglon .tecla { font-size: 13px; border: 1px solid var(--raya); border-radius: 6px; padding: 2px 6px; white-space: nowrap; }
.punto { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--tinta); }
/* En pantallas angostas o táctiles no hay teclado: se quita la etiqueta Alt para dar espacio al nombre. */
@media (max-width: 1000px), (pointer: coarse) { .renglon .tecla { display: none; } }

#pie-lista { flex: none; display: flex; flex-direction: column; gap: 8px; }
.par { display: flex; gap: 8px; }
.par .boton { flex: 1; padding-inline: 8px; }

/* ---------- La nota ---------- */
#nota {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 24px max(24px, env(safe-area-inset-right)) calc(60px + env(safe-area-inset-bottom)) 24px;
  font-size: var(--letra);
}
#nota > * { max-width: 900px; margin-left: auto; margin-right: auto; }

.titulo-nota { margin-top: 0; margin-bottom: 6px; font-size: 1.7em; line-height: 1.2; overflow-wrap: anywhere; }
.datos { margin-top: 0; margin-bottom: 22px; font-size: 16px; font-weight: 600; }
.seccion { margin-bottom: 18px; padding: 4px 0 4px 16px; border-left: 6px solid var(--color-nota, var(--raya)); }
.seccion h2 { margin: 0 0 4px; font-size: .85em; text-transform: uppercase; letter-spacing: .04em; overflow-wrap: anywhere; }
.seccion p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.zona-liga { margin-top: 36px; }
.aviso { padding-top: 40px; text-align: center; }
.aviso .boton { margin-top: 12px; }

/* ---------- Editar ---------- */
.campo { display: block; margin-bottom: 18px; font-size: 17px; font-weight: 700; }
.campo > input, .campo > select, .campo > textarea { margin-top: 6px; font-weight: 400; }
#nota .campo-titulo { font-size: var(--letra); font-weight: 700; }

.bloque { margin-bottom: 18px; padding: 14px; border: 2px solid var(--raya); border-radius: 14px; }
.bloque input, .bloque textarea { font-size: var(--letra); }
.bloque input { font-weight: 700; margin-bottom: 8px; }
.bloque textarea { resize: vertical; line-height: 1.4; min-height: 3.6em; display: block; }

.botones { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; font-size: 17px; }
.bloque .botones { margin: 10px 0 0; }

.paleta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; align-items: center; }
.muestra-color {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid var(--raya);
  cursor: pointer;
}
.muestra-color[aria-pressed="true"] { border-color: var(--tinta); box-shadow: 0 0 0 4px var(--fondo), 0 0 0 7px var(--tinta); }
.otro-color { display: flex; align-items: center; gap: 8px; margin-left: 8px; }
input[type="color"] { width: 64px; height: 48px; padding: 2px; border: 2px solid var(--raya); border-radius: 10px; background: none; cursor: pointer; }

.zona-borrar { margin-top: 44px; padding-top: 20px; border-top: 2px solid var(--raya); }

/* ---------- Ventanas (siempre en alto contraste, para no quedarse sin poder leer) ---------- */
.ventana {
  --fondo: #111114;
  --tinta: #ffffff;
  --panel: #232328;
  --raya: #77777f;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 22px;
  border: 2px solid #fff;
  border-radius: 18px;
  background: var(--fondo);
  color: var(--tinta);
  font-size: 18px;
}
.ventana::backdrop { background: rgb(0 0 0 / .7); }
.ventana h2 { margin: 0 0 8px; }
.ventana h3 { margin: 20px 0 10px; font-size: 18px; }
.ventana .grande { margin-bottom: 10px; }
.fila { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.al-final { justify-content: flex-end; margin-top: 22px; }
#letra-numero { min-width: 90px; text-align: center; font-weight: 700; }
#muestra { margin-top: 12px; padding: 14px; border: 2px solid var(--raya); border-radius: 12px; font-size: var(--letra); }
#temas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tema { min-height: 62px; border-width: 3px; }
.tema[aria-pressed="true"] { border-color: #4da3ff; box-shadow: 0 0 0 3px #4da3ff; }
.color-propio { display: flex; align-items: center; gap: 10px; }
#poco-contraste { background: #ffd60a; color: #000; padding: 10px; border-radius: 10px; font-weight: 700; }
.de-papelera { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--raya); }
.de-papelera span { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* Pantalla de contraseña: tapa todo lo demás. */
#d-entrada::backdrop { background: #000; }
#d-entrada input {
  font: inherit;
  font-size: 22px;
  width: 100%;
  padding: 14px;
  border: 2px solid var(--raya);
  border-radius: 12px;
  background: var(--fondo);
  color: var(--tinta);
}
#entrada-error { background: #ffd60a; color: #000; padding: 10px; border-radius: 10px; font-weight: 700; }

#globo {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 14px 20px;
  border-radius: 14px;
  background: #fff;
  color: #000;
  border: 3px solid #000;
  font-weight: 700;
  text-align: center;
  z-index: 20;
}

#otra-pestana {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  background: var(--fondo);
  font-size: 24px;
  text-align: center;
}

/* ---------- Celular ---------- */
#sombra { display: none; }

@media (max-width: 699px) {
  #barra { gap: 6px; flex-wrap: wrap; }
  #barra .boton { padding-inline: 12px; font-size: 16px; }
  #estado { order: 5; flex-basis: 100%; font-size: 14px; }
  #estado:empty { display: none; }
  #boton-editar { margin-left: auto; }

  #lateral, body.sin-lista #lateral {
    display: flex;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    width: min(88vw, 380px);
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform .18s ease, visibility .18s;
  }
  body.panel-abierto #lateral { transform: none; visibility: visible; }
  body.panel-abierto #sombra { display: block; position: absolute; inset: 0; z-index: 9; background: rgb(0 0 0 / .65); }

  #nota { padding: 18px 16px calc(60px + env(safe-area-inset-bottom)); }
  #temas { grid-template-columns: 1fr; }
}
