/* Clase Dada · el cuaderno de clases.
   De día: hoja de carpeta rayada, margen rojo, agujeros, birome azul y corrección en rojo.
   De noche: pizarrón verde y tiza. Una columna para el pulgar, barra de pestañas abajo.
   Letras (autoalojadas, licencia OFL): Kalam para lo escrito a mano, Lexend para leer.
   Formas: papel con esquinas casi rectas (3 px); botones y campos 6 px. */
@font-face { font-family: "Kalam"; font-style: normal; font-weight: 400; font-display: swap; src: url("clase-kalam-400.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Kalam"; font-style: normal; font-weight: 700; font-display: swap; src: url("clase-kalam-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Lexend"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("clase-lexend-400-800.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --escritorio: #E4DCC6;
  --papel: #FBF7E8;
  --raya: #CBDDEA;
  --margen: #E49A9A;
  --agujero: #E4DCC6;
  --tarjeta: #FFFEF7;
  --postit: #FFF1A6;
  --tinta: #1D2433;
  --tinta2: #575F70;
  --linea: #DAD1B8;
  --linea-fuerte: #A99E80;
  --acento: #2A47C7;
  --acento-oscuro: #1B3199;
  --acento-tinta: #FFFFFF;
  --acento-suave: #E5EAFB;
  --marcador: #FFE97A;
  --rojo-birome: #C23B3B;
  --ok: #1B7447;
  --ok-fondo: #DDF1E5;
  --aviso: #8F5200;
  --aviso-fondo: #FCEBC8;
  --mal: #B42A2A;
  --mal-fondo: #FADCDC;
  --sombra-papel: 0 1px 0 rgba(90, 70, 20, .10), 0 3px 8px -2px rgba(90, 70, 20, .16);
  --fuente: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mano: "Kalam", "Segoe Print", "Bradley Hand", cursive;
  --radio: 6px;
  --radio-papel: 3px;
  --suave: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --escritorio: #0E1513;
    --papel: #1E2D29;
    --raya: rgba(255, 255, 255, .06);
    --margen: #B6787B;
    --agujero: #121B19;
    --tarjeta: #263733;
    --postit: #3F3C22;
    --tinta: #F3F0E4;
    --tinta2: #B2BFB8;
    --linea: #3B4E48;
    --linea-fuerte: #6E8580;
    --acento: #A9C8FF;
    --acento-oscuro: #7FA9EE;
    --acento-tinta: #0E1B33;
    --acento-suave: #2A3F5E;
    --marcador: rgba(255, 232, 130, .26);
    --rojo-birome: #FF9C9C;
    --ok: #82DBAA;
    --ok-fondo: #24503C;
    --aviso: #F2C56E;
    --aviso-fondo: #4F4020;
    --mal: #FF9C9C;
    --mal-fondo: #5A2A2C;
    --sombra-papel: 0 1px 0 rgba(0, 0, 0, .35), 0 3px 8px -2px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font: 16px/1.45 var(--fuente);
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 760px) { body { background: var(--escritorio); } }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--acento); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }

/* ---------- La hoja de carpeta: rayas, margen y agujeros ---------- */
.hoja-papel {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--papel);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--raya) 31px, var(--raya) 32px);
  background-position: 0 14px;
}
.hoja-papel::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 30px;
  width: 2px;
  background: var(--margen);
  opacity: .85;
  pointer-events: none;
}
.hoja-papel::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 30px;
  background: radial-gradient(circle at 15px 170px, var(--agujero) 0 5.5px, var(--linea) 6px, transparent 7px) 0 0 / 30px 290px repeat-y;
  pointer-events: none;
}
@media (min-width: 760px) {
  .hoja-papel { margin-top: 18px; min-height: calc(100vh - 18px); border-radius: var(--radio-papel) var(--radio-papel) 0 0; box-shadow: 0 10px 40px rgba(40, 30, 5, .25); }
}

#app {
  padding: calc(18px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(150px + env(safe-area-inset-bottom, 0px)) calc(46px + env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
}

/* ---------- Encabezado: título a mano, subrayado en rojo; la fecha arriba a la derecha, como en la carpeta ---------- */
.tope { display: flex; flex-direction: column; gap: 2px; }
.tope h1 {
  order: 2;
  align-self: flex-start;
  font-family: var(--mano);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  padding-bottom: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='8' viewBox='0 0 60 8'%3E%3Cpath d='M0 4 Q7.500 0 15 4 T30 4 T45 4 T60 4' fill='none' stroke='%23C23B3B' stroke-width='2.200' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x left bottom / 40px 6px;
}
.tope .fecha { order: 1; align-self: flex-end; text-align: right; font-family: var(--mano); color: var(--tinta2); font-size: 17px; line-height: 1.2; }
.bajada { color: var(--tinta2); font-size: 15px; }
.marcador { background: linear-gradient(transparent 52%, var(--marcador) 52%); padding: 0 2px; }

/* ---------- Campos ---------- */
.campo { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.campo > span { font-size: 14px; font-weight: 700; }
.campo small { color: var(--tinta2); font-size: 13px; line-height: 1.4; }
input[type="text"], input[type="search"], input[type="date"], input[type="month"], input[type="time"], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--linea-fuerte);
  border-radius: var(--radio);
  background: var(--tarjeta);
  color: var(--tinta);
  transition: border-color .15s, box-shadow .15s;
}
::placeholder { color: var(--tinta2); opacity: .85; }
textarea { line-height: 1.5; resize: vertical; min-height: 220px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-suave); }
input:disabled { opacity: .65; }
.con-signo { position: relative; display: block; }
.con-signo input { padding-left: 30px; font-variant-numeric: tabular-nums; }
.con-signo i { position: absolute; top: 50%; transform: translateY(-50%); left: 12px; font-style: normal; color: var(--tinta2); pointer-events: none; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Dos opciones para elegir una: la elegida queda encerrada con birome */
.opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opcion { position: relative; }
.opcion input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opcion span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: 8px 10px;
  border: 1.5px solid var(--linea-fuerte); border-radius: var(--radio); background: var(--tarjeta);
  font-weight: 700; font-size: 15px;
}
.opcion input:checked + span { border: 2px solid var(--acento); background: var(--acento-suave); color: var(--tinta); }
.opcion input:focus-visible + span { outline: 3px solid var(--acento); outline-offset: 2px; }

/* ---------- Botones: el principal en birome azul; los demás, lápiz ---------- */
.btn {
  min-height: 50px;
  padding: 12px 18px;
  border-radius: var(--radio);
  border: 1.5px solid var(--linea-fuerte);
  background: var(--tarjeta);
  font-weight: 700;
  text-align: center;
  transition: transform .12s var(--suave), box-shadow .12s var(--suave), background-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn.fuerte { background: var(--acento); color: var(--acento-tinta); border-color: var(--acento-oscuro); box-shadow: 0 3px 0 var(--acento-oscuro); }
.btn.fuerte:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--acento-oscuro); }
.btn.peligro { border-color: var(--mal); color: var(--mal); background: transparent; }
.btn.chico { min-height: 44px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.ancho { width: 100%; }
.link { background: none; border: 0; padding: 4px 0; min-height: 44px; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; font-weight: 700; color: var(--acento); text-align: left; }
.acciones { display: flex; flex-direction: column; gap: 10px; }
.fila-botones { display: flex; gap: 10px; flex-wrap: wrap; }
.fila-botones .btn { flex: 1 1 140px; }

/* ---------- Listas: fichas rayadas (cartulina con renglón rojo arriba) ---------- */
.lista {
  list-style: none; margin: 0; padding: 0;
  background: var(--tarjeta);
  border-radius: var(--radio-papel);
  border-top: 3px solid var(--margen);
  box-shadow: var(--sombra-papel);
  overflow: hidden;
}
.lista li + li { border-top: 1px solid var(--raya); }
@media (prefers-color-scheme: dark) { .lista li + li { border-top-color: rgba(255, 255, 255, .09); } }
.fila {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 64px;
  background: none; border: 0; text-align: left;
  transition: background-color .15s;
}
button.fila:active { background: var(--acento-suave); }
.fila .que { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fila .nombre { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.fila .datos { color: var(--tinta2); font-size: 14px; }
.fila .derecha { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.fila .derecha > .datos { font-family: var(--mano); font-weight: 700; font-size: 18px; color: var(--acento); }
.titulo-seccion { font-family: var(--mano); font-size: 23px; font-weight: 700; margin-top: 6px; line-height: 1.2; }

/* «Te toca hoy»: pasado con resaltador; deudas y al día: anotación en birome */
.etiqueta { display: inline-block; padding: 1px 6px; border-radius: 2px; font-size: 13px; font-weight: 700; white-space: nowrap; background: var(--acento-suave); color: var(--tinta); }
.etiqueta.hoy { background: linear-gradient(100deg, transparent 2%, var(--marcador) 4%, var(--marcador) 96%, transparent 98%); padding: 2px 8px; }
.etiqueta.debe { background: none; color: var(--mal); font-family: var(--mano); font-size: 18px; padding: 0; }
.etiqueta.aldia { background: none; color: var(--ok); font-family: var(--mano); font-size: 18px; padding: 0; }
.monto { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fila .monto.debe, .fila .monto.favor { font-family: var(--mano); font-weight: 700; font-size: 19px; line-height: 1.25; }
.monto.debe { color: var(--mal); }
.monto.favor { color: var(--ok); }

/* Los sellos de cada clase: tilde, aviso y falta, como en la libreta */
.sello {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  font-family: var(--mano); font-weight: 700; font-size: 16px; line-height: 1;
  border: 2px solid currentColor;
  transform: rotate(-8deg);
}
.sello.dada { color: var(--ok); background: var(--ok-fondo); }
.sello.avisó { color: var(--aviso); background: var(--aviso-fondo); transform: rotate(5deg); }
.sello.sinaviso { color: var(--mal); background: var(--mal-fondo); transform: rotate(-3deg); }
.sellos { display: flex; gap: 4px; align-items: center; }

/* ---------- Avisos: papelitos pegados en la hoja ---------- */
.aviso {
  background: var(--postit);
  border: 0;
  border-radius: 2px;
  padding: 14px 16px;
  font-size: 15px;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  box-shadow: 0 1px 1px rgba(90, 70, 20, .12), 0 10px 14px -10px rgba(90, 70, 20, .45);
  transform: rotate(-.6deg);
}
.aviso + .aviso { transform: rotate(.5deg); }
.aviso.hecho { background: var(--ok-fondo); }
.aviso.ojo { background: var(--aviso-fondo); }
@media (prefers-color-scheme: dark) { .aviso { box-shadow: 0 1px 1px rgba(0, 0, 0, .4), 0 10px 14px -10px rgba(0, 0, 0, .7); } }

.vacio { text-align: center; padding: 22px 18px; border: 1.5px dashed var(--linea-fuerte); border-radius: var(--radio-papel); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.vacio h2 { font-family: var(--mano); font-size: 24px; line-height: 1.2; }
.vacio p { color: var(--tinta2); max-width: 34ch; }

/* ---------- El mes: la cuenta en una sola ficha ---------- */
.mes-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mes-nav h2 { font-family: var(--mano); font-size: 25px; text-transform: capitalize; text-align: center; flex: 1; line-height: 1.2; }
.mes-nav button { width: 48px; height: 48px; flex: none; border-radius: var(--radio); border: 1.5px solid var(--linea-fuerte); background: var(--tarjeta); font-size: 24px; line-height: 1; }
.numeros {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--raya);
  border-top: 3px solid var(--margen);
  border-radius: var(--radio-papel);
  box-shadow: var(--sombra-papel);
  overflow: hidden;
}
@media (prefers-color-scheme: dark) { .numeros { background: rgba(255, 255, 255, .09); } }
.numero { background: var(--tarjeta); border-top: 3px solid var(--margen); border-radius: var(--radio-papel); padding: 12px 14px 12px; box-shadow: var(--sombra-papel); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.numeros .numero { border: 0; border-radius: 0; box-shadow: none; }
.numero small { color: var(--tinta2); font-size: 13px; font-weight: 700; }
.numero b { font-size: clamp(17px, 5.2vw, 23px); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; white-space: nowrap; }
.numero.debe b { color: var(--mal); }
.numero.fuerte b { color: var(--acento); }
.tabla-mes { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tabla-mes th { text-align: right; font-size: 12px; color: var(--tinta2); font-weight: 700; padding: 8px 6px; }
.tabla-mes th:first-child, .tabla-mes td:first-child { text-align: left; }
.tabla-mes td { padding: 10px 6px; text-align: right; border-top: 1px solid var(--raya); vertical-align: middle; }
.tabla-mes td:first-child { font-weight: 700; max-width: 120px; overflow-wrap: anywhere; }
.tabla-mes .tablita { background: var(--tarjeta); }
.tarjeta-tabla { background: var(--tarjeta); border-top: 3px solid var(--margen); border-radius: var(--radio-papel); box-shadow: var(--sombra-papel); padding: 4px 8px; overflow-x: auto; }

/* ---------- Ventanas: la ficha sube desde abajo ---------- */
dialog {
  border: 0; padding: 0;
  background: var(--tarjeta); color: var(--tinta);
  width: min(560px, 100%); max-width: 100%; max-height: 92vh;
  border-top: 3px solid var(--margen);
  border-radius: 10px 10px 0 0;
  margin: auto auto 0;
  overflow: auto;
}
dialog::backdrop { background: rgba(28, 22, 8, .5); }
@media (prefers-color-scheme: dark) { dialog::backdrop { background: rgba(0, 0, 0, .6); } }
@media (min-width: 620px) { dialog { border-radius: var(--radio-papel); margin: auto; } }
.hoja { padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 14px; }
.hoja h2 { font-family: var(--mano); font-size: 25px; line-height: 1.2; }
.hoja .cabeza { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.cerrar { background: none; border: 0; width: 44px; height: 44px; flex: none; font-size: 28px; line-height: 1; border-radius: var(--radio); color: var(--tinta2); }
.error { color: var(--mal); font-weight: 700; font-size: 14px; }
.nota { color: var(--tinta2); font-size: 13px; }
.quien { font-weight: 700; font-size: 17px; }

/* Anotar una clase: tres renglones grandes, el sello dice cuál es cuál */
.tres { display: flex; flex-direction: column; gap: 8px; }
.estado {
  display: flex; align-items: center; gap: 14px;
  min-height: 64px; padding: 10px 14px;
  border-radius: var(--radio); border: 1.5px solid var(--linea-fuerte); background: var(--tarjeta);
  text-align: left; width: 100%;
  transition: transform .12s var(--suave), background-color .15s;
}
.estado .sello { width: 40px; height: 40px; font-size: 22px; flex: none; }
.estado b { display: block; font-size: 17px; }
.estado small { color: var(--tinta2); font-size: 14px; }
.estado[aria-current="true"] { border: 2px solid var(--acento); background: var(--acento-suave); }
.estado:active { transform: scale(.985); background: var(--acento-suave); }

.sube-lista { display: flex; flex-direction: column; max-height: 240px; overflow: auto; border-top: 1px solid var(--raya); }
.sube-lista label { flex: none; display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 6px; border-bottom: 1px solid var(--raya); }
.sube-lista input { width: 22px; height: 22px; accent-color: var(--acento); flex: none; }
.sube-lista .que { flex: 1; min-width: 0; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 2px; }
.sube-lista .cambia { font-size: 13px; color: var(--tinta2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* El resumen para mandar: papel rayado, como una nota escrita */
.papelito {
  background-color: var(--tarjeta);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 23px, var(--raya) 23px, var(--raya) 24px);
  background-position: 0 10px;
  border-top: 3px solid var(--margen);
  border-radius: var(--radio-papel);
  box-shadow: var(--sombra-papel);
  padding: 10px 12px;
  white-space: pre-wrap; font-size: 15px; line-height: 24px; overflow-wrap: anywhere;
}

/* ---------- Barra de abajo: íconos a lápiz; la sección activa, pasada con resaltador ---------- */
.pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--papel);
  border-top: 2px solid var(--margen);
  padding: 6px max(6px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
}
.pestanas div { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; }
.pestanas button {
  position: relative; isolation: isolate; background: none; border: 0; min-height: 56px; border-radius: var(--radio);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12.5px; font-weight: 700; color: var(--tinta2);
}
.pestanas svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pestanas button[aria-current="page"] { color: var(--tinta); }
.pestanas button[aria-current="page"] svg { stroke-width: 2.2; }
.pestanas button[aria-current="page"]::after {
  content: ""; position: absolute; z-index: -1;
  left: 14%; right: 14%; bottom: 7px; height: 11px;
  background: var(--marcador); border-radius: 2px 5px 3px 6px;
  transform: rotate(-2deg);
}
.pestanas .globo { position: absolute; top: 2px; left: calc(50% + 8px); min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--mal); color: #fff; font-size: 11.5px; line-height: 19px; font-weight: 800; }
@media (prefers-color-scheme: dark) { .pestanas .globo { color: #2A0B0B; } }

/* ---------- Cartel de listo: un papelito que sube ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(88px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  background: var(--tinta); color: var(--papel);
  padding: 12px 16px; border-radius: var(--radio-papel); font-size: 15px; font-weight: 600;
  width: max-content; max-width: calc(100% - 32px); text-align: left;
  display: flex; gap: 14px; align-items: center;
  box-shadow: 0 8px 20px -6px rgba(20, 15, 5, .45);
}
.toast button { background: none; border: 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; font-weight: 800; padding: 0 4px; min-height: 44px; flex: none; }

@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: subir .28s var(--suave); }
  dialog[open]::backdrop { animation: aparecer .2s ease-out; }
  .toast:not([hidden]) { animation: papelito .26s var(--suave); }
  @keyframes subir { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
  @keyframes papelito { from { transform: translate(-50%, 14px) rotate(-1.5deg); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
