  :root {
    --fondo: #efe6d2;
    --panel: #e8ddc6;
    --linea: #d6cdb8;
    --texto: #123540;
    --tenue: #756e5d;
    --suave: #c6bda6;
    --punteo: #8a8069;

    --silencio: #978f7b;
    --andamio: #aba493;

    --grave: var(--texto);
    --agudo: #557884;

    --mal: #a3000e;
    --vivo: #f0dcab;
    --realce: #ded2b7;
    --sombra: #1235401f;

    --marca: var(--texto);
    --marca-fin: var(--texto);
    --marca-tinta: var(--texto);

    --ojo: var(--fondo);
    --marco: 65px;
    --sangria: 88px;
    --canal: 30px;

    --letra-logo: 30px;
    --letra-tema: 16px;
    --letra: 14px;
    --letra-chica: 11px;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --titular: 'Antonio', 'Arial Narrow', system-ui, sans-serif;
  }
  :root[data-luz="oscuro"] {
    --fondo: #141b1e;
    --panel: #1a2226;
    --linea: #263134;
    --texto: #e8e0cd;
    --tenue: #7c8a8e;
    --suave: #3f4c50;
    --punteo: #55646a;
    --silencio: #515e62;
    --andamio: #424d51;
    --agudo: #9f9886;
    --mal: #ff3f3b;
    --vivo: #40311c;
    --realce: #202a2e;
    --sombra: #0006;
    --ojo: var(--texto);
  }
  * { box-sizing: border-box; }

  [hidden] { display: none !important; }

  html, body { height: 100%; margin: 0; background: var(--fondo); }
  body { height: var(--alto, 100%); overflow: hidden; }
  body {
    background: var(--fondo); color: var(--texto);
    font: var(--letra)/1.55 var(--mono);
    display: flex; flex-direction: column;

    touch-action: manipulation;
  }
  #cinta { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

  #cinta .toque { fill: none; stroke: transparent; pointer-events: stroke; }

  @media (hover: none) { #cinta .toque { pointer-events: none; } }

  #cinta .franja { transition: opacity .12s; }
  #cinta.senalando .franja { opacity: .25; }
  #cinta.senalando .franja.sola { opacity: 1; }

  #cinta .tramo { fill: var(--fondo); fill-opacity: 0; transition: fill-opacity .12s; }
  #cinta.senalandoTramo .tramo { fill-opacity: .75; }
  #cinta.senalandoTramo .tramo.sola { fill-opacity: 0; }
  #cinta.senalandoTramo .rotulo.sola { fill: var(--texto); }

  #cinta .regla { stroke: var(--texto); stroke-width: 1.5; stroke-opacity: .5; }

  #cinta .corte { stroke: var(--texto); stroke-width: 1.5; }
  #cinta .rotulo {
    fill: var(--andamio); font-size: var(--letra-chica); letter-spacing: .04em;
    text-transform: lowercase; dominant-baseline: auto;
  }
  header, main, #errores { position: relative; z-index: 1; }

  header {
    display: flex; align-items: center; gap: 26px;
    padding: var(--sangria) 62px 26px var(--sangria);
    pointer-events: none;
  }
  header > * { pointer-events: auto; }
  #tocar {
    width: 64px; height: 64px; flex: none; padding: 0;
    border: 0; border-radius: 50%; background: var(--marca);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
  }
  #tocar svg { width: 22px; height: 22px; fill: var(--ojo); display: block; }
  #tocar:hover { filter: brightness(1.08); }

  body.cargando #tocar { background: var(--linea); cursor: progress; }
  body.cargando #tocar svg { fill: var(--tenue); }

  .marca { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; }

  .marca #enlace { margin-left: -9px; }

  body.soltando .wrap { box-shadow: inset 0 0 0 2px var(--marca); }
  body.soltando #src { cursor: copy; }

  h1 {
    font-family: var(--titular); font-size: var(--letra-logo); line-height: .8;
    text-box: trim-both cap alphabetic;
    margin: 0; font-weight: 600; letter-spacing: -.02em; color: var(--marca);
  }

  h1 span { display: block; color: var(--marca-fin); }

  .rayita { width: 1px; align-self: stretch; background: var(--linea); flex: none; }

  .nombre {
    display: inline-flex; align-items: baseline; gap: 7px; min-width: 0;
    border-bottom: 1px dotted var(--punteo); padding-bottom: 3px;
  }
  .nombre:focus-within { border-bottom-color: var(--marca-tinta); }
  #nombre {
    font: inherit; color: var(--texto); text-overflow: ellipsis;
    background: none; border: 0; padding: 0; outline: none; min-width: 0;
  }
  #nombre::placeholder { color: var(--suave); }

  #nombre.choca { color: var(--mal); text-decoration: underline wavy var(--mal); text-underline-offset: 4px; }
  button {
    font: inherit; color: var(--texto);
    background: var(--panel); border: 1px solid var(--linea);
    padding: 5px 13px; border-radius: 5px; cursor: pointer;
  }
  button:active { opacity: .6; }

  .i {
    width: 16px; height: 16px; flex: none; display: block;
    fill: none; stroke: currentColor; stroke-width: 2.25;
    stroke-linecap: round; stroke-linejoin: round;
  }
  .i.chica { width: 12px; height: 12px; stroke-width: 3; }
  .i.derecha { transform: rotate(-90deg); }

  .i.maciza { fill: currentColor; stroke: none; }
  button:hover { border-color: var(--tenue); }

  #abrir, #enlace, #archivo, #luz {
    flex: none; background: none; border: 0; border-radius: 4px;
    padding: 0 4px; min-height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--tenue);
  }
  #enlace:hover, #archivo:hover, #luz:hover { color: var(--texto); }
  #archivo { margin-left: -12px; }

  #luz { position: fixed; right: 44px; top: calc(var(--sangria) + 21px); z-index: 2; }

  #enlace.dicho {
    color: var(--marca-tinta); font-size: var(--letra-chica);
    letter-spacing: .1em; text-transform: uppercase;
  }
  main { flex: 1; display: flex; min-height: 0; }
  .editor { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  .wrap { position: relative; flex: 1; min-height: 0; }
  #hl, #src {
    position: absolute; inset: 0; margin: 0;
    padding: 0 20px 20px calc(var(--sangria) + var(--canal));
    border: 0; overflow: auto;
    font: inherit; font-size: var(--letra-tema); line-height: 1.75;
    white-space: pre-wrap; overflow-wrap: break-word;
    tab-size: 2;
  }
  #hl { pointer-events: none; color: var(--texto); }
  #src {
    background: transparent; color: transparent;
    caret-color: var(--parte, var(--texto)); resize: none; outline: none;
  }

  #src::selection { background: color-mix(in oklab, var(--parte, var(--texto)) 18%, transparent); }
  ::selection { background: color-mix(in oklab, var(--texto) 18%, transparent); }

  #hl, button, .panel { user-select: none; }

  .t-sujeto { color: var(--texto); }
  .t-articulo, .t-verbo, .t-estructura { color: var(--andamio); }
  .t-sonido, .t-nota { color: var(--texto); font-weight: 600; }
  .t-silencio { color: var(--silencio); }
  .t-mod { color: var(--tenue); }
  #hl [data-alto="1"] { color: var(--grave); }
  #hl [data-alto="2"] { color: color-mix(in oklab, var(--grave) 75%, var(--agudo)); }
  #hl [data-alto="3"] { color: color-mix(in oklab, var(--grave) 50%, var(--agudo)); }
  #hl [data-alto="4"] { color: color-mix(in oklab, var(--grave) 25%, var(--agudo)); }
  #hl [data-alto="5"] { color: var(--agudo); }

  .t-cola { font-weight: 400; color: color-mix(in oklab, currentColor 62%, var(--fondo)); }

  #hl span[data-tipo="tempo"] { color: var(--texto); font-weight: 600; }

  #hl span[data-tipo="seccion"] { font-weight: 600; }
  .t-mal { color: var(--mal); text-decoration: underline wavy var(--mal); text-underline-offset: 4px; }

  .t-enlace { color: var(--texto); text-decoration: underline dotted currentColor; text-underline-offset: 4px; }
  .t-comentario { color: var(--tenue); font-style: italic; }

  .t-editable.t-manija {
    text-decoration: underline dotted currentColor;
    text-underline-offset: 4px;
  }

  .panel {
    position: fixed; inset: auto; margin: 0; width: auto; height: auto; color: inherit;
    background: var(--panel); border: 1px solid var(--linea);
    border-radius: 6px; padding: 6px 0; min-width: 190px;
    max-height: 80vh; max-width: calc(100vw - 16px);
    overflow: auto; box-shadow: 0 8px 24px var(--sombra);
  }
  .panel .op.conSub { padding-right: 8px; }
  #sugerencias { max-height: 300px; }
  #sugerencias .op.elegido { background: var(--realce); color: var(--parte, var(--texto)); }

  #menu.columnas:popover-open { display: grid; gap: 1px; padding: 0; background: var(--linea); }
  #menu.columnas .sec { background: var(--panel); padding: 6px 0; min-width: 118px; }
  #menu.columnas .sec.detalle { min-width: 208px; }
  #menu.columnas .sec.pie { grid-column: 1 / -1; }

  #deshacer, #seleccion, #manija {
    position: fixed; z-index: 11; display: none;
    align-items: center; justify-content: center;
    height: 22px; line-height: 1; border-radius: 5px;
  }
  #deshacer.vivo, #seleccion.vivo, #manija.vivo { display: flex; }

  #deshacer.junta, #seleccion.junta, #manija.junta {
    border-top-right-radius: 0; border-bottom-right-radius: 0;
  }
  #deshacer.juntado, #seleccion.juntado, #manija.juntado {
    border-top-left-radius: 0; border-bottom-left-radius: 0;
  }

  #deshacer { padding: 0 5px; opacity: .7; }
  #seleccion {
    padding: 0 8px 0 5px; gap: 4px;
    border-color: var(--parte, var(--texto)); color: var(--parte, var(--texto));
  }
  #manija {
    padding: 0 5px;

    color: var(--parte, var(--texto)); opacity: .85;
  }
  #manija:hover, #manija.encendido { opacity: 1; border-color: var(--parte, var(--texto)); }
  #deshacer:hover { opacity: 1; border-color: var(--parte, var(--texto)); }
  .panel h3 {
    margin: 8px 14px 3px; font-size: var(--letra-chica); font-weight: 500;
    text-transform: uppercase; letter-spacing: .12em; color: var(--tenue);
  }
  .panel h3:first-child { margin-top: 0; }
  .panel .op {
    display: flex; gap: 10px; align-items: baseline;
    padding: 3px 14px; cursor: pointer; white-space: nowrap;
  }
  .panel .op:hover { background: var(--realce); }
  .panel .op .d { margin-left: auto; color: var(--tenue); font-size: var(--letra-chica); }

  .panel .op.puesto { color: var(--parte, var(--texto)); font-weight: 600; }

  .panel .op.noEntra { color: var(--tenue); pointer-events: none; }
  .t-activo {
    background: var(--vivo); border-radius: 3px;
    box-shadow: 0 0 0 2px var(--vivo);
  }
  #errores:not(:empty) {
    padding: 10px 20px calc(10px + env(safe-area-inset-bottom)) calc(var(--sangria) + var(--canal));
    border-top: 1px solid var(--linea);
  }
  #errores p { margin: 0 0 4px; color: var(--mal); }
  #errores b { color: var(--texto); font-weight: 600; }

  #errores .accion {
    background: none; border: 0; padding: 0; color: var(--texto);
    text-decoration: underline dotted currentColor; text-underline-offset: 4px;
  }
  #puntos { position: absolute; left: var(--sangria); top: 0; bottom: 0; width: var(--canal); pointer-events: none; z-index: 3; }

  .punto {
    position: absolute; left: 0; width: 22px; height: 22px; padding: 0;
    background: none; border: 0; cursor: pointer; pointer-events: auto;
    display: flex; align-items: center; justify-content: center;
  }
  .punto::before {
    content: ''; width: 13px; height: 13px; border-radius: 50%;
    background: currentColor;
  }
  .punto:hover::before { filter: brightness(1.15); }
  .punto.callado::before { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }

  .punto.senalado::before { box-shadow: 0 0 0 4px color-mix(in oklab, currentColor 28%, transparent); }
  .punto.callado.senalado::before {
    box-shadow: inset 0 0 0 1.5px currentColor,
                0 0 0 4px color-mix(in oklab, currentColor 28%, transparent);
  }

  #temas .op { align-items: center; }
  #temas .tira {
    flex: none; display: flex; flex-direction: column;
    width: 16px; height: 15px; border-radius: 1px; overflow: hidden;
  }
  #temas .tira span { flex: 1; min-height: 1px; }
  #temas .op.aparte { margin-top: 5px; padding-top: 7px; border-top: 1px solid var(--linea); }

  #temas .op .borrar { visibility: hidden; margin-left: 2px; color: var(--suave); }
  #temas .op:hover .borrar { visibility: visible; }
  #temas .op .borrar:hover { color: var(--mal); }
  #abrir:hover { color: var(--marca-tinta); }
  #temas .op.puesto { color: var(--marca-tinta); }
  @media (max-width: 720px) {
    :root { --sangria: 52px; --marco: 40px; --letra-logo: 24px; }

    #nombre { font-size: 16px; }
    header { gap: 10px; padding-right: var(--marco); }
    #tocar { width: 48px; height: 48px; }
    .marca { gap: 8px; }

    #luz {
      top: auto; bottom: calc(var(--marco) + 6px + env(safe-area-inset-bottom)); right: calc(var(--marco) + 6px);
      width: 34px; height: 34px; padding: 0; border-radius: 50%; background: var(--fondo);
    }
  }
