:root {
  --bg: #f6f2ec;
  --card: #fbf9f6;
  --text: #1f1a17;
  --muted: #8a817a;
  --accent: #7a2e3a;
  --accent-soft: #efe3e1;
  --line: #e4ddd3;
  --gold: #c9a24a;
  --shadow: 0 1px 2px rgba(31, 26, 23, 0.04);
  --radius: 14px;
  --serif: 'Iowan Old Style', 'Palatino', 'Book Antiqua', Georgia, serif;
  --tabs-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; background: var(--bg); color: var(--text); }

body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 24px) 20px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 32px; line-height: 1.15; }
h2 { font-size: 22px; margin: 32px 0 12px; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

.i { display: block; flex: none; }

.muted { color: var(--muted); font-size: 14px; }
.eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.stack { display: grid; gap: 10px; }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card.link { display: flex; gap: 14px; align-items: center; transition: background .15s; }
.card.link:active { background: #f1ece5; }
.card .emoji {
  font-size: 22px; width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%; flex: none; color: var(--accent);
}
.card .title { font-weight: 600; }
.tile-icon { color: var(--accent); margin-bottom: 10px; }

.hero {
  background: var(--text);
  color: #f6f2ec;
  padding: 24px 22px;
  border-radius: 18px;
}
.hero .eyebrow { color: rgba(246, 242, 236, .55); }
.hero .big { font-family: var(--serif); font-size: 52px; line-height: 1; margin: 10px 0 8px; }
.hero .big span { font-size: 20px; color: rgba(246, 242, 236, .7); }
.hero .hero-sub { font-size: 14px; color: rgba(246, 242, 236, .7); }
.hero .muted { color: rgba(246, 242, 236, .6); }

.btn {
  appearance: none; border: 1px solid var(--accent); cursor: pointer;
  font: inherit; font-weight: 600; font-size: 15px; letter-spacing: .01em;
  padding: 14px 20px; border-radius: 12px;
  background: var(--accent); color: #fbf9f6;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity .12s, background .12s;
}
.btn:active { opacity: .85; }
.btn:disabled { opacity: .45; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.soft { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn.block { width: 100%; }
.btn.small { padding: 8px 14px; font-size: 14px; border-radius: 10px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; font: inherit; font-size: 14px; cursor: pointer;
  padding: 7px 14px; border-radius: 999px; background: transparent; color: var(--text);
  border: 1px solid var(--line);
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.gold { background: #efe8da; color: #7a6538; }
.badge.green { background: #e3eae2; color: #3f5e45; }

label { display: block; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; color: var(--muted); margin: 18px 0 6px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text);
  padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: #b3aaa2; }
textarea { min-height: 110px; resize: vertical; }
.emoji-input { width: 72px; text-align: center; font-size: 20px; padding: 9px; }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: rgba(246, 242, 236, .92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
#tabs[hidden] { display: none; }
#tabs a {
  flex: 1; max-width: 110px; text-align: center; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 0;
}
#tabs a svg { width: 22px; height: 22px; }
#tabs a.on { color: var(--accent); font-weight: 600; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px;
  font-size: 14px; max-width: calc(100% - 40px); text-align: center;
  animation: pop .25s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(31, 26, 23, .4);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 24px);
  animation: up .28s cubic-bezier(.2, .9, .3, 1);
}
.sheet .grabber { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 16px; }
.sheet h2 { margin-top: 4px; }
.sheet h2 + .muted { margin-top: -6px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }

.login { min-height: 80dvh; display: grid; place-content: center; gap: 16px; text-align: center; }
.login .monogram {
  width: 92px; height: 92px; margin: 0 auto 8px; border-radius: 50%; border: 1px solid var(--text);
  display: grid; grid-auto-flow: column; gap: 2px; place-content: center; align-items: center;
  font-family: var(--serif); font-size: 30px;
}
.login .monogram span { color: var(--accent); font-style: italic; font-size: 24px; }
.login h1 { font-size: 30px; }

.deck { position: relative; height: 420px; margin: 18px 0 22px; }
.idea-card {
  position: absolute; inset: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 10px 30px rgba(31, 26, 23, .06);
  padding: 32px 26px; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 14px;
  touch-action: none; user-select: none; cursor: grab;
  transition: transform .3s, opacity .3s;
}
.idea-card.behind { transform: scale(.95) translateY(14px); opacity: .6; pointer-events: none; }
.idea-card.dragging { transition: none; cursor: grabbing; }
.idea-card .emoji-big { font-size: 44px; line-height: 1.1; }
.idea-card h3 { font-size: 30px; line-height: 1.2; }
.idea-card .desc { color: var(--muted); font-size: 16px; }
.idea-card .stamp {
  position: absolute; top: 24px; font-weight: 600; font-size: 13px; letter-spacing: .16em; text-transform: uppercase;
  padding: 5px 10px; border: 1px solid; border-radius: 6px; opacity: 0;
}
.idea-card .stamp.yes { left: 22px; color: var(--accent); }
.idea-card .stamp.no { right: 22px; color: var(--muted); }
.idea-card.spin .emoji-big { animation: wobble .12s infinite alternate; }
@keyframes wobble { to { transform: scale(1.08); } }

.deck-actions { display: flex; justify-content: center; align-items: center; gap: 16px; }
.round {
  width: 60px; height: 60px; border-radius: 50%; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--text);
  display: grid; place-items: center; transition: background .12s;
}
.round:active { background: var(--accent-soft); }
.round.love { width: 72px; height: 72px; background: var(--accent); border-color: var(--accent); color: #fbf9f6; }
.round.mini { width: 48px; height: 48px; color: var(--muted); }

.plan-head { text-align: center; padding: 10px 0 4px; }
.plan-head .emoji-big { font-size: 48px; }
.plan-head h1 { margin-top: 8px; }
.countdown { font-family: var(--serif); font-size: 20px; color: var(--accent); }
.aside { margin-top: 14px; display: grid; gap: 2px; }

.stars { display: flex; gap: 8px; font-size: 28px; }
.stars button { border: 0; background: none; font-size: inherit; cursor: pointer; padding: 0; color: var(--line); }
.stars button.on { color: var(--accent); }

.memory { border-left: 2px solid var(--accent); }
.memory.sealed {
  text-align: center; border-left: 1px solid var(--line); color: var(--muted);
  display: grid; justify-items: center; gap: 6px;
}

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photos img, .photos .add {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; cursor: pointer; background: #ece6dd;
}
.photos .add { display: grid; place-items: center; color: var(--muted); border: 1px dashed #cfc6ba; background: transparent; }

.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(15, 12, 10, .94); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.viewer img { max-width: 100%; max-height: 82dvh; border-radius: 8px; }
.viewer .row { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 20px); }

.memories-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.memory-tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.memory-tile .cover { aspect-ratio: 1; background: #ece6dd; display: grid; place-items: center; font-size: 40px; }
.memory-tile .cover img { width: 100%; height: 100%; object-fit: cover; }
.memory-tile .meta { padding: 10px 12px 12px; }
.memory-tile .meta .title { font-family: var(--serif); font-size: 16px; line-height: 1.25; }

.flashback { background: #efe8de; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); padding: 3px; border-radius: 12px; margin: 16px 0 8px; }
.segmented button { border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600; padding: 9px; border-radius: 9px; color: var(--muted); cursor: pointer; }
.segmented button.on { background: var(--text); color: var(--bg); }
.segmented.who { margin: 0; }
.segmented.who label { margin: 0; letter-spacing: normal; text-transform: none; font-size: 14px; font-weight: 600; padding: 9px; border-radius: 9px; color: var(--muted); cursor: pointer; }
.segmented.who input { position: absolute; opacity: 0; pointer-events: none; }
.segmented.who label:has(input:checked) { background: var(--text); color: var(--bg); }

.envelope { display: flex; gap: 14px; align-items: center; cursor: pointer; }
.envelope .seal {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--muted); flex: none;
}
.envelope .seal.new { background: var(--accent); border-color: var(--accent); color: #fbf9f6; }
.envelope.locked { opacity: .6; }

.letter {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px;
  font-family: var(--serif); font-size: 19px; line-height: 1.6; white-space: pre-wrap;
}

.ticket {
  position: relative; display: flex; gap: 14px; align-items: center;
  background: var(--card);
  border-radius: 14px; padding: 16px 18px;
  border: 1px dashed #c9bfb2;
}
.ticket .emoji { font-size: 26px; }
.ticket.used { opacity: .45; }

.empty { text-align: center; padding: 34px 10px; color: var(--muted); display: grid; justify-items: center; gap: 10px; }
.empty .icon { color: #b3aaa2; }

.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.plan-head .manage { justify-content: center; margin-top: 14px; }
.ticket .icon-btn { padding: 8px; flex: none; }
label.check { display: flex; align-items: center; gap: 10px; }
label.check input { width: auto; }

.flashback .emoji { overflow: hidden; }
.flashback .emoji img { width: 100%; height: 100%; object-fit: cover; }
.flashback .eyebrow { margin-bottom: 2px; }

.miss { display: flex; gap: 16px; align-items: center; }
.miss .round.love { width: 56px; height: 56px; flex: none; }
.miss .round.beat { animation: beat .6s ease-in-out 2; }
@keyframes beat { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.18); } 60% { transform: scale(.95); } }

.question .q { font-family: var(--serif); font-size: 20px; line-height: 1.35; margin: 8px 0 12px; }
.question .answer { border-left: 2px solid var(--accent-soft); padding: 2px 0 2px 12px; margin-top: 10px; }
.question .answer p { margin: 2px 0 0; white-space: pre-wrap; }
.question a.muted { font-size: 14px; }
.sealed-line { display: flex; gap: 6px; align-items: center; margin: 0 0 10px; }


.want-add input[name=title] { flex: 1; min-width: 0; margin: 0; }
.want-add .btn { flex: none; padding: 0 14px; align-self: stretch; }
.want { display: flex; gap: 12px; align-items: flex-start; padding: 14px; }
.want .check {
  width: 26px; height: 26px; flex: none; border-radius: 50%; border: 1.5px solid var(--line);
  background: none; display: grid; place-items: center; cursor: pointer; color: #fbf9f6; padding: 0; margin-top: 1px;
}
.want.done .check { background: var(--accent); border-color: var(--accent); }
.want.done .title { text-decoration: line-through; color: var(--muted); }
.want .body { flex: 1; min-width: 0; }
.want .actions { margin-top: 8px; flex-wrap: wrap; gap: 8px; }
.want .actions:empty { display: none; }

h2.month { text-transform: capitalize; }
.photos.feed img { cursor: pointer; }

.place-row {
  display: inline-flex; gap: 6px; align-items: center; margin-top: 12px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: none; font: inherit; font-size: 14px;
  color: var(--accent); cursor: pointer; max-width: 100%;
}
