*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --papel: #faf6e8;
  --papel-oscuro: #f0e8d4;
  --tinta: #3a3228;
  --tinta-suave: #6b5d4f;
  --verde: #5a7a5a;
  --verde-claro: #7a9a6a;
  --naranja: #c87a4a;
  --rojo: #b85a4a;
  --raya: #e8dfc8;
  --sombra: rgba(58, 50, 40, 0.1);
  --espiral: #8a7a6a;
  --border-radius: 8px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--papel);
  background-image:
    linear-gradient(var(--raya) 1px, transparent 1px);
  background-size: 100% 1.8rem;
  color: var(--tinta);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.8rem;
  position: relative;
  overflow-x: hidden;
  padding-bottom: 4rem;
}

.espiral {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 8px;
  background: repeating-linear-gradient(
    90deg,
    var(--espiral) 0px,
    var(--espiral) 18px,
    transparent 18px,
    transparent 22px,
    var(--espiral) 22px,
    var(--espiral) 40px
  );
  z-index: 10;
  box-shadow: 0 2px 4px var(--sombra);
}

header {
  text-align: center;
  padding: 2rem 1rem 0.5rem;
  position: relative;
}

header::after {
  content: '';
  display: block;
  width: 80%;
  max-width: 400px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--verde-claro), transparent);
  margin: 0.5rem auto 0;
}

h1 {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 2rem;
  color: var(--verde);
  letter-spacing: 0.02em;
  text-shadow: 1px 1px 0 var(--papel-oscuro);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--tinta-suave);
  font-style: italic;
  margin-top: 0.25rem;
}

main {
  max-width: 640px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.nota-nueva {
  background: white;
  border-radius: var(--border-radius);
  padding: 1.25rem;
  box-shadow: 0 2px 8px var(--sombra);
  margin-bottom: 2rem;
  border-left: 4px solid var(--verde);
}

textarea {
  width: 100%;
  border: none;
  resize: vertical;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--tinta);
  background: transparent;
  outline: none;
  min-height: 4.5rem;
}

textarea::placeholder {
  color: var(--tinta-suave);
  opacity: 0.6;
  font-style: italic;
}

#btnAgregar {
  display: block;
  width: 100%;
  padding: 0.7rem;
  margin-top: 0.75rem;
  border: none;
  border-radius: var(--border-radius);
  background: var(--verde);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#btnAgregar:hover {
  background: var(--verde-claro);
}

#btnAgregar:active {
  transform: scale(0.98);
}

.notas-section {
  background: transparent;
}

.notas-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px dashed var(--raya);
}

.notas-header h2 {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 1.3rem;
  color: var(--tinta);
  font-weight: 600;
}

.contador {
  background: var(--verde);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  line-height: 1.4;
}

#listaNotas {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.nota {
  background: white;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  padding: 0.6rem 1rem 0.6rem 1.25rem;
  box-shadow: 0 1px 4px var(--sombra);
  position: relative;
  border-left: 4px solid var(--naranja);
  transition: transform 0.15s, box-shadow 0.15s;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.nota::before {
  content: '';
  position: absolute;
  top: 0;
  left: -4px;
  width: 4px;
  height: 100%;
  background: repeating-linear-gradient(
    180deg,
    var(--raya) 0px,
    var(--raya) 1.8rem,
    transparent 1.8rem,
    transparent 1.8rem
  );
}

.nota:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px var(--sombra);
}

.nota-texto {
  font-size: 0.95rem;
  line-height: 1.8rem;
  color: var(--tinta);
  word-wrap: break-word;
  white-space: pre-wrap;
  padding-right: 2rem;
}

.nota-fecha {
  font-size: 0.75rem;
  color: var(--tinta-suave);
  font-style: italic;
  margin-top: 0.15rem;
  opacity: 0.7;
}

.nota-borrar {
  position: absolute;
  top: 0.4rem;
  right: 0.6rem;
  width: 1.6rem;
  height: 1.6rem;
  border: none;
  background: transparent;
  color: var(--tinta-suave);
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  opacity: 0.5;
  line-height: 1;
}

.nota:hover .nota-borrar {
  opacity: 0.8;
}

.nota-borrar:hover {
  background: var(--rojo);
  color: white;
  opacity: 1;
}

.nota-vacia {
  text-align: center;
  color: var(--tinta-suave);
  font-style: italic;
  padding: 2rem 1rem;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: 0 1px 4px var(--sombra);
  opacity: 0.6;
}

.btn-borrar-todas {
  display: block;
  width: 100%;
  padding: 0.7rem;
  margin-top: 1.25rem;
  border: 2px solid var(--rojo);
  border-radius: var(--border-radius);
  background: transparent;
  color: var(--rojo);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-borrar-todas:hover {
  background: var(--rojo);
  color: white;
}

.btn-borrar-todas:active {
  transform: scale(0.98);
}

footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--tinta-suave);
  font-size: 0.75rem;
  opacity: 0.5;
}

@keyframes entrarNota {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nota {
  animation: entrarNota 0.25s ease-out;
}
