:root {
  --bg: #0d1124;
  --bg2: #171c3a;
  --card: rgba(255, 255, 255, 0.06);
  --card-strong: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4f1fa;
  --muted: #a9a8c7;
  --rose: #ff8fab;
  --sky: #7cc4ff;
  --gold: #ffd59e;
  --ok: #8fe3b0;
  --danger: #ff7a7a;
  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: radial-gradient(ellipse at top, #232a5c 0%, var(--bg) 55%) fixed, var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
#sky, #fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#sky { z-index: 0; }
#fx { z-index: 50; }
#app, .gate { position: relative; z-index: 1; }
[hidden] { display: none !important; }
a { color: var(--sky); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.01em; margin: 0 0 .5rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* layout */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 20px 12px;
  background: linear-gradient(var(--bg) 60%, transparent);
}
.brand { color: var(--text); text-decoration: none; font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.icon-btn { text-decoration: none; font-size: 1.3rem; padding: 6px; border-radius: 10px; }
main { max-width: 860px; margin: 0 auto; padding: 4px 16px 120px; }
.view { display: none; animation: rise .35s ease; }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tabs {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 10px); z-index: 20;
  display: flex; gap: 2px; padding: 6px;
  background: rgba(23, 28, 58, 0.85); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 22px;
  max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none;
}
.tabs { width: min(640px, calc(100% - 16px)); }
.tabs a {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 2px; border-radius: 16px; overflow: hidden; text-overflow: ellipsis;
  color: var(--muted); text-decoration: none; font-size: .62rem; white-space: nowrap;
}
.tabs a span { font-size: 1.25rem; line-height: 1.2; }
.tabs a.active { background: var(--card-strong); color: var(--text); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--rose); }
textarea { min-height: 90px; resize: vertical; }
input[type="file"] { padding: 8px; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--rose); flex: none; }
button, .btn {
  font: inherit; cursor: pointer; border: 0; border-radius: 12px;
  padding: 10px 16px; font-weight: 600; color: #2a0d18;
  background: linear-gradient(135deg, var(--rose), var(--gold));
  text-decoration: none; display: inline-block;
}
button.ghost, .btn.ghost { background: var(--card-strong); color: var(--text); border: 1px solid var(--line); }
button.link { background: none; color: var(--muted); padding: 4px 6px; font-weight: 400; }
button:disabled { opacity: .5; cursor: default; }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; }

/* gate */
.gate { max-width: 440px; margin: 0 auto; padding: 12vh 20px 40px; }
.gate h1 { font-size: 2rem; text-align: center; }
.gate .sub { text-align: center; color: var(--muted); margin-bottom: 24px; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.who button { background: var(--card-strong); color: var(--text); border: 1px solid var(--line); padding: 16px; }
.who button.sel { border-color: var(--rose); background: rgba(255, 143, 171, .15); }

/* home */
.hero { text-align: center; padding: 26px 10px 10px; }
.hero .eyebrow { color: var(--muted); font-size: .95rem; }
.hero h1 { font-size: clamp(1.5rem, 5vw, 2.2rem); margin: 4px 0 18px; }
.count { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 560px; margin: 0 auto; }
.count div { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 4px; }
.count b { display: block; font-family: var(--serif); font-size: clamp(2rem, 9vw, 3.4rem); line-height: 1.05; font-variant-numeric: tabular-nums; }
.count span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.when { color: var(--muted); margin-top: 14px; font-size: .95rem; }

.route svg { width: 100%; height: auto; display: block; }
.route .pct { text-align: center; color: var(--muted); font-size: .9rem; margin-top: -4px; }
.clocks { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.clock { text-align: center; padding: 14px 8px; }
.clock .t { font-family: var(--serif); font-size: clamp(1.6rem, 7vw, 2rem); font-variant-numeric: tabular-nums; }
.clock .who-l { color: var(--muted); font-size: .9rem; }
.clock .hint { font-size: .85rem; color: var(--gold); min-height: 1.3em; }

.miss { text-align: center; }
.heart-btn {
  font-size: 2.4rem; width: 92px; height: 92px; border-radius: 50%; padding: 0;
  background: radial-gradient(circle at 35% 30%, #ffb3c6, var(--rose) 60%, #d6587a);
  box-shadow: 0 8px 30px rgba(255, 143, 171, .35); transition: transform .12s;
  color: #fff; line-height: 1;
}
.heart-btn:active { transform: scale(.9); }
.heart-btn.pop { animation: pop .4s ease; }
@keyframes pop { 50% { transform: scale(1.18); } }
.stat b { font-family: var(--serif); font-size: 1.8rem; display: block; }
.flight { border-color: rgba(124, 196, 255, .45); }
.embed iframe { width: 100%; border: 0; border-radius: 12px; }

.landed h1 { font-size: clamp(2rem, 8vw, 3.4rem); }

/* notes */
.notes-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-top: 8px; }
.sticky {
  color: #2b2230; padding: 16px 14px 12px; border-radius: 4px 4px 16px 4px; min-height: 150px;
  display: flex; flex-direction: column; box-shadow: 0 10px 24px rgba(0,0,0,.35);
  transform: rotate(var(--r, 0deg)); white-space: pre-wrap; word-break: break-word;
}
.sticky .meta { margin-top: auto; padding-top: 10px; font-size: .78rem; opacity: .7; display: flex; justify-content: space-between; align-items: center; }
.sticky button.link { color: #2b2230; }
.c-yellow { background: #ffe9a3; } .c-pink { background: #ffc4d4; } .c-blue { background: #bfe3ff; }
.c-green { background: #c8f2d2; } .c-lilac { background: #dcccff; } .c-peach { background: #ffd2b3; }
.colors { display: flex; gap: 8px; }
.colors button { width: 28px; height: 28px; border-radius: 50%; padding: 0; border: 2px solid transparent; }
.colors button.sel { border-color: var(--text); }

/* letters */
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.envelope {
  position: relative; cursor: pointer; text-align: left; color: var(--text);
  background: linear-gradient(160deg, #2b3266, #1c2149); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 16px 16px; min-height: 140px; overflow: hidden; font-weight: 400;
}
.envelope::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 56px;
  background: linear-gradient(to bottom right, transparent 49.5%, rgba(255,255,255,.06) 50%) left/50% 100% no-repeat,
              linear-gradient(to bottom left, transparent 49.5%, rgba(255,255,255,.06) 50%) right/50% 100% no-repeat;
}
.envelope .seal {
  position: absolute; right: 14px; top: 34px; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.2rem;
  background: radial-gradient(circle at 35% 30%, #ff9db5, #c2365b); box-shadow: 0 4px 10px rgba(0,0,0,.4);
}
.envelope.open .seal { background: radial-gradient(circle at 35% 30%, #fff1c9, #e3a94c); }
.envelope h3 { margin-top: 58px; padding-right: 50px; }
.letter-paper {
  background: #fbf6ec; color: #2b2230; border-radius: 10px; padding: 26px 22px;
  font-family: var(--serif); font-size: 1.08rem; white-space: pre-wrap; line-height: 1.7;
}

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { text-align: center; color: var(--muted); font-size: .75rem; }
.door {
  aspect-ratio: 1; min-width: 0; border-radius: 10px; padding: 0; position: relative; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.door .n { font-family: var(--serif); font-size: clamp(.9rem, 3.6vw, 1.15rem); line-height: 1.1; }
.door .b { font-size: .8rem; min-height: 1.1em; }
.door.today { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 213, 158, .35), 0 0 22px rgba(255, 213, 158, .25); }
.door.past { opacity: .75; }
.door.land { background: linear-gradient(135deg, rgba(255,143,171,.35), rgba(255,213,158,.35)); }
.door.has.unopened { animation: glow 2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 18px rgba(255, 143, 171, .55); } }
.surprise { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; white-space: pre-wrap; }
.surprise img { width: 100%; border-radius: 12px; margin-top: 8px; }
.flip { animation: flip .6s ease; }
@keyframes flip { from { transform: perspective(600px) rotateY(90deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* question */
.q { font-family: var(--serif); font-size: 1.4rem; line-height: 1.35; margin: 6px 0 14px; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .answers { grid-template-columns: 1fr; } }
.answer { background: rgba(0,0,0,.2); border-radius: 12px; padding: 12px; white-space: pre-wrap; }
.answer .by { font-size: .8rem; color: var(--muted); display: block; margin-bottom: 4px; }
.blur { filter: blur(6px); user-select: none; }

/* lists */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chips button { background: var(--card); color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.chips button.sel { background: rgba(255,143,171,.15); color: var(--text); border-color: var(--rose); }
.items { list-style: none; margin: 12px 0 0; padding: 0; }
.items li { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.items li.done .txt { text-decoration: line-through; color: var(--muted); }
.items .txt { flex: 1; word-break: break-word; }
.items .by { font-size: .75rem; color: var(--muted); }

/* memories */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--rose), var(--sky)); }
.mem { position: relative; margin-bottom: 18px; }
.mem::before { content: ""; position: absolute; left: -21px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 0 4px var(--bg); }
.mem img { width: 100%; max-height: 420px; object-fit: cover; border-radius: 12px; cursor: zoom-in; display: block; margin: 8px 0; }
.mem .date { color: var(--gold); font-size: .85rem; }

/* modal / toast */
dialog {
  width: min(560px, calc(100% - 24px)); max-height: 88vh; overflow: auto;
  background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 20px; padding: 20px;
}
dialog::backdrop { background: rgba(5, 6, 18, .7); backdrop-filter: blur(3px); }
dialog img.full { width: 100%; border-radius: 12px; }
#toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px);
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 18px;
  opacity: 0; transition: .3s; z-index: 60; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
