:root {
  --paper: #F7F1E3;
  --card: #FFFFFF;
  --ink: #1F2A44;
  --muted: #5A5F6E;
  --line: #EDE5D3;
  --border: #CFC3A8;
  --accent: #A8431A;
  --accent-dark: #7E3012;
  --accent-soft: #FBE3D2;
  --teal: #2F6F6A;
  --teal-dark: #245753;
  --teal-soft: #D9ECE9;
  --slate-soft: #E1E4EE;
  --gold: #E9C77B;
  --photo: #D8CDB4;
  --display: Fraunces, Georgia, serif;
  --body: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tabbar-h: 70px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.4;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

main {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px 20px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}
main.bleed { padding-top: 0; }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }

h1, h2, .display { font-family: var(--display); font-weight: 700; margin: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 21px; }
.eyebrow svg { width: 18px; height: 18px; }
.eyebrow {
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex-grow: 1; min-width: 0; }

.card { background: var(--card); border-radius: 16px; padding: 16px; }
.card.list { padding: 4px 14px; }
.card.dark { background: var(--ink); color: var(--paper); }
.card.dark .eyebrow { color: var(--gold); }
.card.hero { background: var(--accent); color: #fff; border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card.hero .eyebrow { color: #fff; }
.card.notice { background: var(--teal-soft); color: var(--teal-dark); }
.quote { font-family: var(--display); font-size: 18px; line-height: 1.45; }

.list-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line); color: var(--ink);
}
.list-row:last-child { border-bottom: none; }
.list-row .title { font-weight: 700; font-size: 16px; }
.list-row .sub { font-size: 14px; color: var(--muted); }
.chev { width: 18px; height: 18px; stroke: #8A8E99; fill: none; stroke-width: 2; flex-shrink: 0; }

.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; background: var(--accent-soft); color: var(--accent-dark);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.t1 { background: var(--teal-soft); color: var(--teal-dark); }
.avatar.t2 { background: var(--slate-soft); color: var(--ink); }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; font-family: var(--display); }
.avatar.sm { width: 36px; height: 36px; font-size: 13px; }

.date-chip {
  width: 50px; height: 54px; border-radius: 12px; background: var(--paper); flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.date-chip .m { font-size: 11px; font-weight: 800; color: var(--muted); }
.date-chip .d { font-size: 20px; font-weight: 800; }
.tag { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 12px; white-space: nowrap; }
.tag.bday { color: var(--accent); background: var(--accent-soft); }
.tag.ann { color: var(--teal-dark); background: var(--teal-soft); }

.btn {
  min-height: 48px; padding: 0 20px; border-radius: 24px; border: 2px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; font-size: 15px; cursor: pointer; text-align: center; white-space: nowrap;
  background: var(--accent); color: #fff;
}
.btn-row .btn { padding: 0 12px; }
.btn:hover { color: #fff; background: var(--accent-dark); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 17px; border-radius: 28px; }
.btn.dark { background: var(--ink); }
.btn.dark:hover { background: #111827; }
.btn.outline { background: var(--card); color: var(--ink); border-color: var(--ink); }
.btn.outline:hover { background: var(--paper); color: var(--ink); }
.btn.light { background: #fff; color: var(--accent-dark); }
.btn.ghost-light { background: transparent; color: #fff; border-color: #fff; }
.btn.soft { background: var(--teal-soft); color: var(--teal-dark); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn[disabled] { opacity: .6; cursor: default; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }
.link-btn { background: none; border: none; padding: 10px 0; color: var(--accent); font-weight: 800; cursor: pointer; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; background: var(--card); color: var(--ink); border: none;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.search {
  display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 16px;
  background: var(--card); border: 1px solid #E4DAC4; border-radius: 25px; color: var(--muted);
}
.search svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.search input { border: none; outline: none; background: transparent; font-size: 16px; flex-grow: 1; color: var(--ink); min-width: 0; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 40px; padding: 0 16px; border-radius: 20px; font-size: 14px; font-weight: 700; cursor: pointer;
  background: var(--card); color: var(--ink); border: 1px solid #E4DAC4;
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.segmented { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 4px; padding: 4px; background: #E4DAC4; border-radius: 24px; }
.segmented button { min-height: 44px; padding: 0 6px; white-space: nowrap; border-radius: 20px; border: none; background: transparent; font-weight: 700; font-size: 14px; color: #3D4252; cursor: pointer; }
.segmented button[aria-selected="true"] { background: var(--card); color: var(--ink); font-weight: 800; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label, legend { font-weight: 800; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); font-size: 16px; color: var(--ink);
}
textarea.input { padding: 12px 14px; line-height: 1.45; resize: vertical; min-height: 110px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--teal); }
fieldset { margin: 0; padding: 0; border: none; display: flex; flex-direction: column; gap: 8px; }
legend { padding: 0 0 8px; }
.radio-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border);
}
.radio-card:has(input:checked) { border: 2px solid var(--teal); padding: 11px 13px; }
.radio-card input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--teal); flex-shrink: 0; }
.radio-card strong { display: block; font-size: 15px; }
.toggle-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.toggle-pair label { min-height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); display: flex; align-items: center; justify-content: center; font-weight: 800; cursor: pointer; }
.toggle-pair input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-pair label:has(input:checked) { background: var(--teal); border-color: var(--teal); color: #fff; }
.toggle-pair label:has(input:focus-visible) { outline: 3px solid var(--teal); outline-offset: 2px; }
.divider { height: 1px; background: #E4DAC4; }

.photo-picker { display: flex; align-items: center; gap: 16px; }
.photo-picker .avatar { width: 96px; height: 96px; background: var(--photo); color: var(--muted); }
.photo-picker .avatar svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.file-btn input { display: none; }

/* Profile */
.profile-photo {
  position: relative; margin: 0 -20px; height: 380px; background: var(--photo);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.profile-photo .initials { font-family: var(--display); font-size: 72px; font-weight: 700; color: var(--muted); }
.profile-photo .icon-btn { position: absolute; top: 20px; left: 16px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.tile .val { font-family: var(--display); font-size: 22px; font-weight: 700; }
.tile.bday { background: var(--accent-soft); color: var(--accent-dark); }
.tile.ann { background: var(--teal-soft); color: var(--teal-dark); }
.tile.none { background: var(--card); color: var(--muted); }
.tile .val { color: var(--ink); }
.phone-mask { font-weight: 800; font-size: 16px; letter-spacing: .04em; }
.round-icon {
  width: 40px; height: 40px; border-radius: 50%; background: var(--slate-soft); color: var(--ink);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.round-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wish { display: flex; gap: 10px; align-items: flex-start; }
.wish .bubble { background: var(--card); border-radius: 14px; padding: 10px 12px; font-size: 15px; }
.wish .who { font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 2px; }
.compose { display: flex; align-items: center; gap: 8px; padding: 5px 5px 5px 16px; background: var(--card); border: 1px solid #E4DAC4; border-radius: 26px; }
.compose input { border: none; outline: none; background: transparent; font-size: 16px; flex-grow: 1; min-width: 0; }

.bar { height: 8px; border-radius: 4px; background: var(--line); }
.bar > div { height: 8px; border-radius: 4px; background: var(--teal); }

/* Login */
.login { min-height: calc(100vh - 60px); justify-content: center; gap: 22px; }
.login .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 26px; font-weight: 700; letter-spacing: .12em;
  background: var(--card); border: 2px dashed var(--border); border-radius: 12px; padding: 10px; text-align: center;
}
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--teal-soft); border-top-color: var(--teal); animation: spin 0.9s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 24px; font-weight: 700; font-size: 15px;
  max-width: calc(100% - 32px); z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.error-text { color: #9B1C1C; font-weight: 700; font-size: 14px; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--card); border-top: 1px solid #E4DAC4;
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
}
.tabbar a {
  height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 800; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 520px) {
  .tabbar { left: 50%; right: auto; width: 480px; transform: translateX(-50%); border-left: 1px solid #E4DAC4; border-right: 1px solid #E4DAC4; }
}
