/* Bloc · una hoja de libreta: renglones, margen rojo, se apunta hacia abajo y se tacha con un toque. */
:root {
  --papel: #FBF6E9;
  --tinta: #26231D;
  --tinta-suave: #8E8676;
  --renglon: #D8E1EE;
  --margen: rgba(214, 84, 74, .45);
  --boli: #2F64D8;
  --aviso-fondo: #26231D;
  --aviso-tinta: #FBF6E9;
  --aviso-boton: #F6C945;
  --fila: 52px;
  --margen-x: 46px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --papel: #1B1915;
    --tinta: #EDE6D6;
    --tinta-suave: #7F7767;
    --renglon: #2F2C26;
    --margen: rgba(214, 96, 86, .40);
    --boli: #86A6F2;
    --aviso-fondo: #EDE6D6;
    --aviso-tinta: #1B1915;
    --aviso-boton: #2F64D8;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--papel); }
body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font: 18px/1.45 ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.hoja {
  position: relative;
  max-width: 680px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
/* El margen rojo de la libreta, de arriba abajo. */
.hoja::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: calc(var(--margen-x) - 12px);
  width: 2px;
  background: var(--margen);
  pointer-events: none;
}

.cabecera {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 20px) 16px 6px var(--margen-x);
}
h1 { margin: 0; font-size: 30px; line-height: 1.1; font-weight: 800; letter-spacing: -.01em; }
.fecha { margin: 4px 0 0; font-size: 15px; color: var(--tinta-suave); }
.fecha::first-letter { text-transform: uppercase; }
.limpiar {
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--renglon);
  border-radius: 999px;
  background: transparent;
  color: var(--boli);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}
.limpiar:active { transform: scale(.97); }
.cuenta {
  margin: 0;
  min-height: 22px;
  padding: 0 16px 8px var(--margen-x);
  font-size: 14px;
  color: var(--tinta-suave);
  border-bottom: 1px solid var(--renglon);
}

.lista { list-style: none; margin: 0; padding: 0; }
.nota { border-bottom: 1px solid var(--renglon); }
.nota.entra { animation: entra .22s ease-out; }
@keyframes entra { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.linea {
  display: block;
  width: 100%;
  min-height: var(--fila);
  padding: 13px 16px 12px var(--margen-x);
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.linea:active { background: color-mix(in srgb, var(--renglon) 35%, transparent); }
/* El tachón es una raya de boli que se dibuja de izquierda a derecha, renglón a renglón. */
.texto {
  background-image: linear-gradient(var(--boli), var(--boli));
  background-repeat: no-repeat;
  background-position: 0 58%;
  background-size: 0% 2.5px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-size .28s ease-out, color .28s ease-out;
}
.tachada .texto { background-size: 100% 2.5px; color: var(--tinta-suave); }

.nueva { border-bottom: 1px solid var(--renglon); }
#campo {
  display: block;
  width: 100%;
  min-height: var(--fila);
  padding: 13px 16px 12px var(--margen-x);
  border: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--tinta);
  font: inherit;
  caret-color: var(--boli);
}
#campo::placeholder { color: var(--tinta-suave); opacity: .8; }

/* Renglones vacíos hasta el final de la hoja: tocar ahí es escribir. */
.relleno {
  flex: 1;
  min-height: calc(var(--fila) * 4);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--fila) - 1px), var(--renglon) calc(var(--fila) - 1px), var(--renglon) var(--fila));
  cursor: text;
}

.linea:focus-visible, .limpiar:focus-visible, .aviso button:focus-visible { outline: 2px solid var(--boli); outline-offset: -2px; }

.aviso {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 6px 6px 6px 18px;
  border-radius: 999px;
  background: var(--aviso-fondo);
  color: var(--aviso-tinta);
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  animation: sube .2s ease-out;
}
@keyframes sube { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.aviso[hidden] { display: none; }
.aviso button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--aviso-boton);
  color: var(--aviso-fondo);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
@media (prefers-color-scheme: dark) { .aviso button { color: #fff; } }

@media (prefers-reduced-motion: reduce) {
  .texto, .nota.entra, .aviso { transition: none; animation: none; }
}
