:root {
  --night: #1d1b3a; --night2: #3a2f5c; --paper: #fbf6ec; --ink: #1f2547; --line: #dcd6e6;
  --wax: #b3343b; --gold: #e2a66b; --text: #f3eefc; --muted: #c5bddb;
  --hand: "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
  --script: "Snell Roundhand", "Savoye LET", "Segoe Script", cursive;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--night); }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1.5px 1.5px at 12% 8%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 70% 14%, #fff9 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 32%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 40%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 62%, #fff5 50%, transparent 51%),
    linear-gradient(180deg, var(--night) 0%, var(--night2) 100%) fixed;
}
main { max-width: 720px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 16px 48px; }
h1, h2 { font-weight: 600; margin: 0 0 12px; }
h2 { font-size: 1.3rem; margin-top: 32px; }
a { color: var(--gold); }
.hand { font-family: var(--hand); }
.top { text-align: center; margin: 12px 0 8px; }
.top h1 { font-family: var(--script); font-size: 3rem; font-weight: 400; margin: 0; }
.top p { color: var(--muted); margin: 4px 0 0; }

.counters { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 20px 0 0; }
.counters div { background: #ffffff12; border: 1px solid #ffffff22; border-radius: 16px; padding: 12px 18px; text-align: center; min-width: 140px; }
.counters strong { display: block; font-size: 2rem; color: var(--gold); line-height: 1.1; }
.counters span { color: var(--muted); font-size: .9rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.env {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  aspect-ratio: 3 / 2; padding: 12px 14px; border-radius: 10px; text-decoration: none; color: var(--ink);
  background:
    linear-gradient(to bottom right, transparent 49.5%, #0000000f 50%, transparent 51%) top left / 50% 55% no-repeat,
    linear-gradient(to bottom left, transparent 49.5%, #0000000f 50%, transparent 51%) top right / 50% 55% no-repeat,
    var(--paper);
  box-shadow: 0 6px 18px #0006; transition: transform .2s ease;
}
.env:hover, .env:focus-visible { transform: translateY(-3px) rotate(-1deg); }
.env:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.env .small { font-family: var(--script); font-size: .85rem; color: #6b6f8f; }
.env .hand { font-size: 1.05rem; line-height: 1.25; }
.env.open { opacity: .85; }
.env.open .seal { opacity: .45; }
.new { position: absolute; top: 8px; right: 8px; background: var(--wax); color: #fff; font-size: .7rem; padding: 2px 8px; border-radius: 99px; }

.seal {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 35%, #d9555c, var(--wax) 60%, #7d1f25);
  color: #ffd9d9; font-size: 14px; box-shadow: 0 2px 4px #0005;
}
.seal.big { position: static; transform: none; width: 56px; height: 56px; font-size: 24px; margin: 0 auto 8px; }

.paper { background: var(--paper); color: var(--ink); border-radius: 6px; box-shadow: 0 10px 30px #0007; }
.letter { padding: 28px 22px 24px; }
.letter .dear { font-family: var(--script); font-size: 2rem; margin: 0 0 8px; }
.letter .body {
  font-size: 1.35rem; line-height: 2.2rem;
  background: repeating-linear-gradient(transparent 0 calc(2.2rem - 1px), var(--line) calc(2.2rem - 1px) 2.2rem);
}
.letter .body p { margin: 0 0 2.2rem; }
.letter .body p:last-child { margin-bottom: 0; }
.letter .sign { font-family: var(--script); font-size: 2rem; text-align: right; margin: 20px 0 0; }
.back { display: inline-block; margin: 8px 0 16px; text-decoration: none; }

.center { min-height: 80vh; display: grid; place-items: center; }
.login { width: 100%; max-width: 360px; padding: 28px 22px; text-align: center; }
.login h1 { font-family: var(--script); font-weight: 400; font-size: 2.4rem; }
label { display: block; text-align: left; margin: 14px 0 6px; font-size: .95rem; }
input, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff;
  border: 1px solid #c9c2d8; border-radius: 10px; padding: 12px;
}
textarea { font-family: var(--hand); font-size: 1.15rem; line-height: 1.6; resize: vertical; }
input:focus, textarea:focus { outline: 3px solid var(--gold); outline-offset: 1px; }
button {
  margin-top: 16px; font: inherit; font-weight: 600; color: #fff; background: var(--wax);
  border: 0; border-radius: 99px; padding: 12px 22px; min-height: 44px; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
button.ghost { background: transparent; color: var(--text); border: 1px solid #ffffff55; }
button.danger { background: transparent; color: #ff9aa0; border: 1px solid #ff9aa077; }
.hug { text-align: center; margin-top: 32px; }
.err { color: var(--wax); margin: 10px 0 0; }
.ok { color: #9be3b4; }
.note { color: var(--muted); }
.form { padding: 20px; margin-top: 20px; }
.form h2 { margin-top: 0; }
.form a { color: var(--ink); margin-left: 12px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #ffffff22; }
.list small { display: block; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .env { transition: none; } .env:hover { transform: none; } }
