/* presently. — calm, premium, mobile-first */

:root {
  --cream: #f6f0e8;
  --beige: #e8dcd0;
  --blush: #e8cfcf;
  --charcoal: #35312f;
  --grey: #8b837d;
  --surface: #fffdfa;
  --line: #ece2d7;

  --under: #6f9070;
  --under-bg: #e4ede1;
  --at: #a98443;
  --at-bg: #f5ead2;
  --over: #b05a5a;
  --over-bg: #f5dcd8;

  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(53, 49, 47, 0.04), 0 8px 24px -12px rgba(53, 49, 47, 0.14);
  --shadow-lg: 0 2px 4px rgba(53, 49, 47, 0.05), 0 18px 40px -14px rgba(53, 49, 47, 0.22);
  --ease: cubic-bezier(0.22, 0.8, 0.3, 1);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  background-image: radial-gradient(900px 420px at 85% -80px, rgba(232, 207, 207, 0.55), transparent 70%);
  background-repeat: no-repeat;
  color: var(--charcoal);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.modal-open { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .brand, .title, .amount { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--charcoal); outline-offset: 2px; border-radius: 8px; }

.muted { color: var(--grey); }
.small { font-size: 0.85rem; }
.grow { flex: 1; min-width: 0; }
.over-text { color: var(--over); }

/* ---------- chrome ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
  background: rgba(246, 240, 232, 0.82);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.brand { font-size: 1.7rem; color: var(--charcoal); text-decoration: none; }
.brand span { color: #d3a5a5; }

.page {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 8px max(20px, env(safe-area-inset-right)) 40px max(20px, env(safe-area-inset-left));
}
.page.enter > * { animation: rise 0.45s var(--ease) both; }
.page.enter > *:nth-child(2) { animation-delay: 0.04s; }
.page.enter > *:nth-child(3) { animation-delay: 0.08s; }
.page.enter > *:nth-child(4) { animation-delay: 0.12s; }
.page.enter > *:nth-child(n+5) { animation-delay: 0.16s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.footer {
  text-align: center; color: var(--grey); font-family: var(--serif); font-style: italic; font-size: 0.9rem;
  padding: 8px 20px calc(env(safe-area-inset-bottom) + 28px);
}

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px; border-radius: 999px;
  font-weight: 600; font-size: 0.95rem; white-space: nowrap;
  transition: transform 0.15s var(--ease), box-shadow 0.2s, background 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--charcoal); color: var(--cream); box-shadow: 0 6px 16px -8px rgba(53, 49, 47, 0.6); }
.btn.primary:hover { background: #4a4542; }
.btn.ghost { background: var(--beige); color: var(--charcoal); }
.btn.ghost:hover { background: #e0d1c3; }
.btn.danger { background: var(--over); color: #fff; }
.btn.danger-text { color: var(--over); padding: 0 8px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  color: var(--grey); transition: background 0.2s, color 0.2s, transform 0.15s;
}
.icon-btn:hover { background: var(--beige); color: var(--charcoal); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 16px; height: 16px; }

.link-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--grey); font-size: 0.92rem; padding: 8px 0; transition: color 0.2s; }
.link-btn:hover { color: var(--charcoal); }

/* tap-to-edit values */
.editable {
  display: inline; text-align: left; border-radius: 10px; margin: 0 -6px; padding: 1px 6px;
  border-bottom: 1px dashed transparent; transition: background 0.2s;
}
.editable:hover { background: rgba(232, 220, 208, 0.7); }
.title { font-size: 1.35rem; line-height: 1.25; word-break: break-word; }
.title.xl { font-size: clamp(1.9rem, 6vw, 2.6rem); }
.amount { font-size: 1.9rem; line-height: 1.1; }
.amount.xl { font-size: clamp(2.4rem, 8vw, 3.2rem); display: block; margin-top: 2px; }
.inline-input {
  font-family: var(--serif); font-size: inherit; background: var(--surface); border: 1.5px solid var(--charcoal);
  border-radius: 12px; padding: 4px 10px; min-width: 7ch; max-width: 100%; outline: none;
  box-shadow: 0 0 0 4px rgba(232, 207, 207, 0.6);
}
.title + .inline-input, .inline-input { font-size: 1.3rem; }
.inline-input.xl { font-size: clamp(1.9rem, 6vw, 2.6rem); }
.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- dashboard ---------- */

.hero { padding: 14px 0 22px; }
.hero h1 { font-size: clamp(2.1rem, 7vw, 3rem); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.event-card { cursor: pointer; display: flex; flex-direction: column; gap: 14px; transition: transform 0.25s var(--ease), box-shadow 0.25s; }
.event-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.event-card:active { transform: scale(0.99); }
.card-top { display: flex; gap: 8px; align-items: flex-start; }
.card-tools { display: flex; margin: -6px -8px 0 0; opacity: 0.75; }
.budget-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--line); margin-top: 2px; padding-top: 14px; }

.add-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 160px; color: var(--grey); background: transparent; border: 1.5px dashed #d9c9b9; box-shadow: none; cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}
.add-card:hover { background: rgba(232, 207, 207, 0.35); color: var(--charcoal); border-color: #cfb3b3; }
.add-plus { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--blush); color: var(--charcoal); }

.empty { text-align: center; max-width: 440px; margin: 6vh auto 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty h2 { font-size: 1.7rem; }
.empty .btn { margin-top: 10px; }
.empty-art { width: 92px; height: 92px; display: grid; place-items: center; border-radius: 50%; background: var(--blush); color: var(--charcoal); margin-bottom: 8px; box-shadow: 0 0 0 12px rgba(232, 207, 207, 0.35); }
.empty-small { text-align: center; padding: 24px; }
.card.soft { background: rgba(255, 253, 250, 0.6); box-shadow: none; }

/* ---------- shared: pills, progress, stats ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 8px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; white-space: nowrap; letter-spacing: 0.01em;
}
.pill i { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-style: normal; font-size: 0.7rem; background: rgba(255, 255, 255, 0.75); }
.pill.under { background: var(--under-bg); color: #4d6f4e; }
.pill.at { background: var(--at-bg); color: #7f6128; }
.pill.over { background: var(--over-bg); color: #8e3f3f; }

.progress { height: 8px; border-radius: 999px; background: var(--beige); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; transition: width 0.6s var(--ease), background 0.3s; }
.progress .under { background: linear-gradient(90deg, #a9c3a6, var(--under)); }
.progress .at { background: linear-gradient(90deg, #dcc08a, var(--at)); }
.progress .over { background: linear-gradient(90deg, #dba0a0, var(--over)); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; margin: 0; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.stats dt, .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--grey); display: flex; align-items: center; gap: 6px; }
.stats dd { margin: 2px 0 0; font-weight: 600; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stats dd small { display: block; font-weight: 400; font-size: 0.74rem; color: var(--grey); }
.stats .editable { font-weight: 600; }
.tag { text-transform: none; letter-spacing: 0; font-size: 0.68rem; background: var(--beige); color: var(--grey); padding: 0 7px; border-radius: 999px; }

/* ---------- event page ---------- */

.crumbs { display: flex; justify-content: space-between; align-items: center; padding-top: 4px; }
.event-head { padding: 6px 0 20px; display: flex; flex-direction: column; gap: 2px; }

.summary { display: flex; flex-direction: column; gap: 18px; padding: 24px; background: linear-gradient(180deg, var(--surface), #fcf6f1); }
.summary-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.summary .stats { grid-template-columns: repeat(2, 1fr); gap: 16px; }
.summary .stats dd { font-size: 1.2rem; }
.notice { font-size: 0.88rem; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--beige); color: #5b534d; }
.notice.over { background: var(--over-bg); color: #8e3f3f; }

.allocation { display: flex; flex-direction: column; gap: 12px; margin: 22px 0 6px; }
.allocation h3, .section-head h3 { font-size: 1.15rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.overview .section-head { margin-top: 0; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--beige); border-radius: 16px; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 6px 12px; border-radius: 12px; color: var(--grey); transition: background 0.25s var(--ease), color 0.2s, box-shadow 0.25s; }
.segmented strong { font-weight: 600; font-size: 0.93rem; }
.segmented small { font-size: 0.72rem; opacity: 0.85; }
.segmented input:checked + span { background: var(--surface); color: var(--charcoal); box-shadow: 0 2px 8px -2px rgba(53, 49, 47, 0.2); }
.segmented input:focus-visible + span { outline: 2px solid var(--charcoal); outline-offset: 1px; }
.segmented.compact { align-self: flex-start; min-width: 230px; }

/* overview table */
.overview { margin-top: 22px; padding: 20px 16px; }
.overview .section-head { padding: 0 6px; }
.table { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)); gap: 8px; align-items: center; padding: 11px 6px; border-bottom: 1px solid var(--line); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.row > :not(:first-child) { text-align: right; }
.row.head { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--grey); padding-top: 0; }
.row.foot { border-bottom: 0; font-weight: 700; padding-bottom: 0; }
.row .name { color: var(--charcoal); font-weight: 500; padding: 0; min-width: 0; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; align-self: center; background: var(--under); }
.dot.at { background: var(--at); }
.dot.over { background: var(--over); }

/* recipients */
.recipients { display: flex; flex-direction: column; gap: 14px; }
.recipients .section-head { margin-bottom: 0; }
.recipient { display: flex; flex-direction: column; gap: 16px; scroll-margin-top: 80px; }
.recipient-head { display: flex; align-items: center; gap: 10px; }
.recipient-head .pill { flex: none; }
.recipient-head .icon-btn { margin-right: -8px; opacity: 0.7; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(232, 220, 208, 0.45); font-size: 0.92rem; color: #5b534d; transition: background 0.2s; }
.toggle:hover { background: rgba(232, 220, 208, 0.8); }
.chev { display: grid; transition: transform 0.3s var(--ease); }
.recipient.open .chev { transform: rotate(180deg); }
.bundle { display: flex; flex-direction: column; gap: 12px; animation: rise 0.3s var(--ease) both; }

.gifts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.gift { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); animation: rise 0.3s var(--ease) both; }
.gift:last-child { border-bottom: 0; }
.check { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid #cdbfb1; color: transparent; transition: all 0.2s var(--ease); }
.check svg { width: 16px; height: 16px; }
.check:hover { border-color: var(--charcoal); }
.check.on { background: var(--charcoal); border-color: var(--charcoal); color: var(--cream); }
.gift-main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 2px 0; }
.gift-name { font-weight: 500; overflow-wrap: anywhere; }
.gift-meta { font-size: 0.8rem; color: var(--grey); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gift.done .gift-name { color: var(--grey); text-decoration: line-through; text-decoration-color: #cdbfb1; }
.gift-price { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty-gifts { padding: 4px 2px; }

.add-gift, .add-recipient { display: flex; gap: 8px; }
.add-gift input, .add-recipient input {
  min-width: 0; height: 46px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--cream); outline: none; transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.add-gift input[name="name"], .add-recipient input { flex: 1; }
.add-gift input[name="price"] { width: 96px; flex: none; }
.add-gift .btn { width: 46px; padding: 0; flex: none; }
.add-recipient { margin-top: 4px; }
.add-recipient .btn { padding: 0 20px 0 16px; }
input:focus, select:focus, textarea:focus { border-color: var(--charcoal) !important; box-shadow: 0 0 0 4px rgba(232, 207, 207, 0.55); background: var(--surface) !important; }

/* ---------- modal ---------- */

.modal-layer { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; visibility: hidden; }
.modal-layer.open { visibility: visible; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(53, 49, 47, 0.35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; transition: opacity 0.25s; }
.modal-layer.open .modal-backdrop { opacity: 1; }
.modal {
  position: relative; width: 100%; max-width: 520px; max-height: 92dvh; overflow: auto;
  background: var(--surface); border-radius: 28px 28px 0 0; box-shadow: var(--shadow-lg);
  padding: 8px 22px calc(env(safe-area-inset-bottom) + 22px);
  transform: translateY(40px); opacity: 0; transition: transform 0.35s var(--ease), opacity 0.25s;
}
.modal-layer.open .modal { transform: none; opacity: 1; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 10px; }
.modal-head h2 { font-size: 1.5rem; }
.modal-head .icon-btn { margin-right: -8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.modal-actions.split { justify-content: space-between; align-items: center; }
.modal-actions.split span { display: flex; gap: 10px; }
@media (min-width: 640px) {
  .modal-layer { align-items: center; }
  .modal { border-radius: 28px; padding: 12px 28px 28px; }
}

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.8rem; font-weight: 600; color: #5b534d; letter-spacing: 0.02em; }
.field em { font-style: normal; font-weight: 400; color: var(--grey); margin-left: 4px; }
.field-row { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 520px) { .field-row { grid-template-columns: 1fr 1fr; } }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 12px 16px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--cream); outline: none; font-size: 16px; /* 16px stops iOS zooming in */
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.field select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%238b837d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; text-overflow: ellipsis; }
.field textarea { resize: vertical; }
.form-error { color: var(--over); font-size: 0.88rem; }

.settings { display: flex; flex-direction: column; gap: 16px; }
.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.settings hr { border: 0; border-top: 1px solid var(--line); margin: 0; width: 100%; }
.error { color: var(--over); }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 22px); z-index: 60;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 999px; background: var(--charcoal); color: var(--cream); font-size: 0.92rem;
  box-shadow: var(--shadow-lg); transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  transition: transform 0.35s var(--ease), opacity 0.25s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast button { font-weight: 700; color: var(--blush); }

/* ---------- larger screens ---------- */

@media (min-width: 720px) {
  .page { padding-top: 16px; }
  .summary .stats { grid-template-columns: repeat(5, 1fr); }
  .allocation { flex-direction: row; align-items: center; justify-content: space-between; }
  .row { font-size: 0.95rem; }
  .overview { padding: 24px 22px; }
}
@media (min-width: 960px) {
  .recipients { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .recipients .section-head, .add-recipient, .recipients > .empty-small { grid-column: 1 / -1; }
}
@media (max-width: 380px) {
  .add-gift input[name="price"] { width: 78px; }
  .stats dd { font-size: 0.98rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
