/* Cuaderno · celular primero. Barra arriba, contenido al medio, botón + abajo a la derecha.
   Identidad: cuaderno escolar — cursos como lomos de colores, tinta azul de lapicero. */
:root {
  --papel: #f5f6f8; --hoja: #ffffff; --tinta: #1b2433; --tenue: #5f6b7a; --raya: #dfe3ea;
  --lapicero: #2f5bd3; --lapicero-suave: #e7edfb; --peligro: #c8372d; --peligro-suave: #fbe9e7;
  --sombra: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 14px rgba(20, 30, 50, .07);
  --f: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --alto-barra: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --papel: #12161d; --hoja: #1a2029; --tinta: #e8ecf2; --tenue: #9aa6b5; --raya: #2b3340;
    --lapicero: #7ea2ff; --lapicero-suave: #1f2b45; --peligro: #ff7a6e; --peligro-suave: #3a1e1c;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { margin: 0; background: var(--papel); color: var(--tinta); font-family: var(--f); font-size: 16px; line-height: 1.5; overscroll-behavior-y: contain; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--lapicero); outline-offset: 2px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#app { display: flex; flex-direction: column; height: 100%; }
.barra {
  flex: none; display: flex; align-items: center; gap: 4px;
  padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px));
  min-height: calc(var(--alto-barra) + env(safe-area-inset-top, 0px));
  background: var(--hoja); border-bottom: 1px solid var(--raya); position: relative; z-index: 3;
}
.barra-titulo { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding-inline: 6px; }
.titulo { font-size: 21px; font-weight: 750; margin: 0; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titulo-nota { font: inherit; font-size: 19px; font-weight: 700; border: 0; background: transparent; color: var(--tinta); padding: 4px 0; width: 100%; outline: none; }
.titulo-nota::placeholder { color: var(--tenue); font-weight: 500; }
.estado { font-size: 12px; color: var(--tenue); min-height: 0; line-height: 1.1; }
.estado:empty { display: none; }
.icono-btn { width: 44px; height: 44px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex: none; }
.icono-btn:active { background: var(--lapicero-suave); }

.vista { flex: 1; min-height: 0; overflow-y: auto; padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(96px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.vista > * { max-width: 760px; margin-inline: auto; }
.seccion { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--tenue); margin: 18px auto 8px; font-weight: 700; }

/* Cursos como cuadernos */
.cursos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.curso { position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-height: 120px; padding: 14px 14px 12px 24px;
  background: var(--hoja); border-radius: 6px 12px 12px 6px; box-shadow: var(--sombra); overflow: hidden; }
.curso-lomo { position: absolute; left: 0; top: 0; bottom: 0; width: 12px; background: var(--c); }
.curso-lomo::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(180deg, transparent 0 14px, rgba(255,255,255,.35) 14px 16px); }
.curso::before { content: ""; position: absolute; inset: 0; left: 12px; background: repeating-linear-gradient(180deg, transparent 0 23px, var(--raya) 23px 24px); opacity: .35; pointer-events: none; }
.curso-nombre { position: relative; font-weight: 750; font-size: 17px; line-height: 1.2; overflow-wrap: anywhere; }
.curso-meta { position: relative; font-size: 13px; color: var(--tenue); }
.curso:active { transform: scale(.98); }

/* Listas de notas */
.lista { list-style: none; margin: 0 auto; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.nota-fila { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 12px; background: var(--hoja); border-radius: 12px; box-shadow: var(--sombra); min-height: 64px; }
.nota-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.nota-txt { min-width: 0; display: flex; flex-direction: column; }
.nota-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nota-txt small { color: var(--tenue); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nota-fecha { font-size: 12.5px; color: var(--tenue); white-space: nowrap; }

.vacio-grande { text-align: center; padding: 48px 8px; color: var(--tenue); }
.vacio-grande svg { width: 72px; height: 72px; stroke: var(--lapicero); stroke-width: 2.5; }
.vacio-grande h2 { color: var(--tinta); font-size: 20px; margin: 10px 0 4px; }
.vacio-grande p { max-width: 34ch; margin: 0 auto 18px; }
.vacio, .cargando { color: var(--tenue); text-align: center; padding: 30px 0; }

/* Botones */
.btn { border: 1px solid var(--raya); background: var(--hoja); border-radius: 12px; padding: 12px 18px; font-weight: 650; cursor: pointer; min-height: 48px; }
.btn.prim { background: var(--lapicero); border-color: var(--lapicero); color: #fff; }
.btn.peligro { background: var(--peligro); border-color: var(--peligro); color: #fff; }
.fila-botones { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.fila-botones .btn { flex: 1 1 140px; }
.fab { position: fixed; right: max(18px, env(safe-area-inset-right, 0px)); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); width: 60px; height: 60px; border-radius: 18px; border: 0;
  background: var(--lapicero); color: #fff; box-shadow: 0 6px 18px rgba(47, 91, 211, .35); display: grid; place-items: center; cursor: pointer; z-index: 4; }
.fab svg { width: 28px; height: 28px; stroke-width: 2.6; }
.fab:active { transform: scale(.94); }

/* Hoja inferior */
.velo { position: fixed; inset: 0; background: rgba(10, 15, 25, .45); z-index: 10; }
.hoja { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; background: var(--hoja); border-radius: 20px 20px 0 0; max-height: 85vh; overflow-y: auto;
  padding: 8px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); box-shadow: 0 -8px 30px rgba(0,0,0,.2);
  animation: subir .18s ease-out; }
@media (min-width: 700px) { .hoja { left: 50%; right: auto; width: 480px; transform: translateX(-50%); bottom: 24px; border-radius: 20px; animation: none; } }
@keyframes subir { from { transform: translateY(30px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .hoja { animation: none; } }
.hoja-asa { width: 40px; height: 5px; border-radius: 3px; background: var(--raya); margin: 4px auto 10px; }
.hoja h2 { font-size: 19px; margin: 0 0 12px; }
.hoja-texto { color: var(--tenue); margin: 0 0 16px; }
.opciones { display: flex; flex-direction: column; gap: 6px; }
.opcion { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center; text-align: left; border: 0; background: var(--papel); border-radius: 12px; padding: 12px; cursor: pointer; min-height: 56px; }
.opcion small { display: block; color: var(--tenue); font-size: 13.5px; }
.op-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--lapicero-suave); color: var(--lapicero); font-size: 18px; font-weight: 700; }
.opcion.peligro b { color: var(--peligro); } .opcion.peligro .op-ico { background: var(--peligro-suave); color: var(--peligro); }
.form { display: flex; flex-direction: column; gap: 8px; }
.form label, .form .etq { font-size: 14px; font-weight: 650; color: var(--tenue); }
.form input { font: inherit; font-size: 17px; padding: 12px 14px; border: 1px solid var(--raya); border-radius: 12px; background: var(--papel); color: var(--tinta); }
.form .btn { margin-top: 10px; }
.colores { display: flex; gap: 10px; flex-wrap: wrap; }
.color { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.color[aria-checked="true"] { border-color: var(--tinta); box-shadow: inset 0 0 0 3px var(--hoja); }
.ayuda { padding-left: 18px; margin: 0; display: flex; flex-direction: column; gap: 8px; }

.aviso { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom, 0px)); background: var(--tinta); color: var(--hoja);
  padding: 10px 16px; border-radius: 12px; z-index: 20; font-size: 14.5px; max-width: calc(100% - 32px); }

/* Nota de texto (Quill) */
body.modo-texto .vista { padding: 0; }
body.modo-texto .vista > * { max-width: none; }
.editor-caja { display: flex; flex-direction: column; min-height: 100%; background: var(--hoja); }
.editor-caja .ql-toolbar.ql-snow { position: sticky; top: 0; z-index: 2; background: var(--hoja); border: 0; border-bottom: 1px solid var(--raya);
  display: flex; flex-wrap: nowrap; overflow-x: auto; padding: 6px 8px; scrollbar-width: none; }
.editor-caja .ql-toolbar.ql-snow .ql-formats { display: flex; flex: none; margin-right: 8px; }
.editor-caja .ql-toolbar.ql-snow button { width: 40px; height: 40px; padding: 8px; }
.editor-caja .ql-container.ql-snow { border: 0; font-family: var(--f); font-size: 17px; flex: 1; }
.editor-caja .ql-editor { padding: 16px max(16px, env(safe-area-inset-right, 0px)) 120px max(16px, env(safe-area-inset-left, 0px)); max-width: 760px; margin: 0 auto; line-height: 1.6; color: var(--tinta); min-height: calc(100vh - 140px); outline: none; }
.editor-caja .ql-editor.ql-blank::before { color: var(--tenue); font-style: normal; left: 16px; }
.ql-snow .ql-stroke { stroke: var(--tinta); } .ql-snow .ql-fill { fill: var(--tinta); } .ql-snow .ql-picker { color: var(--tinta); }
.ql-snow .ql-picker-options { background: var(--hoja); }
.ql-snow .ql-tooltip { left: 8px !important; right: 8px; background: var(--hoja); color: var(--tinta); border-color: var(--raya); z-index: 5; }
.ql-snow .ql-tooltip input[type=text] { background: var(--papel); color: var(--tinta); border-color: var(--raya); max-width: 55vw; }

/* Pizarra (Excalidraw) a pantalla completa debajo de la barra */
body.modo-pizarra .vista { padding: 0; overflow: hidden; }
body.modo-pizarra .vista > * { max-width: none; }
.pizarra { height: 100%; width: 100%; }
.pizarra .excalidraw { --zIndex-layerUI: 2; }
