:root {
  --paper: #f9f7f2;
  --ink: #283c34;
  --muted: #72786e;
  --terracotta: #b76048;
  --line: #e2e4db;
  --sage: #e9ece1;
  --person-color: #657b62;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a { touch-action: manipulation; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
button, a, input, select, textarea { outline-offset: 4px; }
:focus-visible { outline: 3px solid var(--terracotta); }
[hidden] { display: none !important; }
.wrap { width: calc(100% - 48px); max-width: 820px; margin-inline: auto; }
.svg-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { display: block; width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 100; border-radius: 6px; padding: 12px 16px; background: var(--ink); color: white; }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* A short title, then an always-reachable row of person anchors. */
.list-header { padding-block: 44px 22px; }
h1 { font-size: 38px; line-height: 1.2; font-weight: 750; letter-spacing: -1.3px; overflow-wrap: anywhere; }
.people-nav { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line); background: var(--paper); }
.people-tabs { display: flex; gap: 10px; padding-block: 12px 18px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #d0d6c8 transparent; }
.person-pill { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; gap: 10px; min-height: 46px; padding: 8px 17px; border: 1px solid #dcded6; border-radius: 999px; background: white; font-weight: 650; white-space: nowrap; }
.person-dot { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; background: var(--person-color); }
.person-pill:hover, .person-pill[aria-current], .person-pill.active { border-color: var(--person-color); background: color-mix(in srgb, var(--person-color) 5%, white); }
.person-pill:focus-visible { outline-offset: -4px; }
.person-count { color: var(--muted); font-size: .95em; font-weight: 400; }
.list-content { padding-top: 30px; }

/* Every person stays on the page; gift cards are large, simple links. */
.gift-grid { display: flex; flex-direction: column; gap: 46px; }
.person-section { min-width: 0; scroll-margin-top: 94px; }
.person-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.person-tag { display: inline-block; position: relative; min-width: 0; max-width: 100%; padding: 10px 20px 10px 40px; border-radius: 0 10px 10px 0; background: var(--person-color); color: white; clip-path: polygon(16px 0, 100% 0, 100% 100%, 16px 100%, 0 50%); font-size: 26px; line-height: 1.3; font-weight: 700; overflow-wrap: anywhere; }
.person-tag::before { content: ""; position: absolute; left: 18px; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--paper); transform: translateY(-50%); }
.person-tag h2 { font: inherit; }
.person-actions { display: flex; flex-shrink: 0; align-items: center; gap: 5px; margin-left: auto; }
.person-actions button { min-height: 44px; min-width: 44px; }
.gift-list { display: flex; flex-direction: column; gap: 12px; }
.gift-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: white; }
.gift-card:hover { border-color: #bdc9b7; }
.gift-link { display: flex; align-items: flex-start; gap: 20px; min-height: 140px; padding: 14px; border-radius: inherit; }
.gift-link:focus-visible { outline-offset: -4px; }
.gift-photo { display: flex; align-items: center; justify-content: center; flex: 0 0 110px; width: 110px; height: 110px; overflow: hidden; border-radius: 10px; background: var(--person-tint, color-mix(in srgb, var(--person-color) 13%, white)); color: var(--person-color); }
.gift-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gift-initial { display: none; width: 100%; height: 100%; align-items: center; justify-content: center; color: var(--person-color); font-size: 44px; line-height: 1; font-weight: 750; }
.gift-photo.no-image .gift-initial { display: flex; }
.gift-photo.no-image img { display: none; }
.gift-details { flex: 1; min-width: 0; padding-top: 3px; }
.gift-title { font-size: 20px; line-height: 1.35; font-weight: 700; letter-spacing: -.3px; overflow-wrap: anywhere; }
.gift-note { display: block; margin-top: 7px; color: var(--muted); font-size: 16px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.gift-arrow { flex-shrink: 0; width: 16px; height: 16px; margin-top: 8px; color: #8d9789; }
.gift-admin-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 4px; padding: 2px 10px 7px; border-top: 1px solid #eff0eb; }
.gift-admin-actions button, .person-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 10px; border: 0; border-radius: 6px; background: transparent; font-size: 13px; }
.gift-admin-actions button { min-height: 44px; }
.gift-admin-actions button:hover, .person-actions button:hover { background: var(--sage); }
.gift-admin-actions .icon, .person-actions .icon { width: 16px; height: 16px; }
.gift-admin-actions .delete, .gift-admin-actions .remove, .gift-admin-actions .delete-button { color: #a44836; }
.section-empty, .empty-state { border: 1px dashed #d6dccf; border-radius: 12px; padding: 24px; color: var(--muted); background: #ffffff70; }
.section-empty p + button, .empty-state p + button { margin-top: 14px; }
.empty-state h2, .empty-state h3 { margin-bottom: 8px; font-size: 22px; color: var(--ink); }
.loading-message { padding-block: 14px; color: var(--muted); }
.sample-item { display: inline-block; margin-top: 8px; color: var(--muted); font-size: 11px; }

/* Editing tools are secondary to the list, and hidden for visitors. */
.admin-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; margin-bottom: 20px; border: 1px solid #dbe0d1; border-radius: 10px; background: var(--sage); font-size: 14px; }
.admin-banner strong { margin-right: auto; font-weight: 600; }
.sample-notice { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.sample-notice .text-button { color: var(--terracotta); text-decoration: underline; text-underline-offset: 3px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border: 1px solid transparent; border-radius: 7px; font-size: 14px; line-height: 1.4; font-weight: 600; }
.button .icon { width: 17px; height: 17px; }
.button-primary { background: var(--ink); color: white; }
.button-primary:hover { background: #3d5548; }
.button-secondary { border-color: #cfd5c7; background: white; }
.button-secondary:hover, .button-plain:hover { background: var(--sage); }
.button-plain { background: transparent; color: var(--muted); }
.button-danger { background: #a64c3a; color: white; }
.button-remove { margin-right: auto; padding-inline: 0; color: #a44836; }
.button-remove:hover { text-decoration: underline; }
.button-danger:hover { background: #8a3b2d; }
.icon-button { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 10px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.icon-button:hover { background: var(--sage); color: var(--ink); }
.text-button { min-height: 44px; padding: 8px 0; border: 0; background: transparent; font-size: inherit; }
.manage-link:hover, .text-button:hover { color: var(--terracotta); }
.site-footer { display: flex; gap: 20px; padding-block: 38px 28px; color: var(--muted); font-size: 12px; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; }

/* Native dialogs keep keyboard focus and work on small screens. */
.modal { width: 540px; max-width: calc(100% - 32px); max-height: calc(100dvh - 32px); padding: 0; overflow-y: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: 0 20px 90px #20352d30; }
.modal::backdrop { background: #23382f75; }
.modal-small { width: 440px; }
.dialog-form { padding: 26px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.dialog-header h2 { font-size: 25px; line-height: 1.25; letter-spacing: -.6px; overflow-wrap: anywhere; }
.dialog-header .icon-button { margin: -7px -9px -7px 0; }
.dialog-form label, .login-card label { display: block; margin: 17px 0 7px; font-size: 14px; font-weight: 600; }
.dialog-form input:not([type="hidden"]), .dialog-form select, .dialog-form textarea, .login-card input { display: block; width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px; border: 1px solid #ccd2c5; border-radius: 7px; background: white; color: var(--ink); font-size: 16px; }
.dialog-form input:focus, .dialog-form select:focus, .dialog-form textarea:focus, .login-card input:focus { outline: 2px solid var(--terracotta); outline-offset: 1px; }
input::placeholder, textarea::placeholder { color: #8a9085; }
.dialog-form textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.optional { margin-left: 4px; color: var(--muted); font-size: 12px; font-weight: 400; }
.color-fieldset { min-width: 0; margin: 20px 0 0; padding: 0; border: 0; }
.color-fieldset legend { margin-bottom: 10px; padding: 0; font-size: 14px; font-weight: 600; }
.color-palette { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.dialog-form .color-option { position: relative; margin: 0; cursor: pointer; font-size: 11px; font-weight: 500; }
.dialog-form .color-option input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; }
.color-choice { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 2px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.color-swatch { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: transparent; font-size: 21px; }
.color-option input:checked + .color-choice { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.color-option input:checked + .color-choice .color-swatch { color: white; }
.color-option input:focus-visible + .color-choice { outline: 3px solid var(--terracotta); outline-offset: 2px; }
.tag-preview { margin-top: 20px; }
.tag-preview .person-tag { font-size: 23px; }
.input-with-button { display: flex; gap: 8px; }
.input-with-button input { flex: 1; }
.input-with-button .button { flex-shrink: 0; padding-inline: 12px; font-size: 13px; }
.field-hint { margin-top: 7px; color: var(--muted); font-size: 12px; }
.gift-photo-preview { display: block; max-width: 120px; max-height: 140px; margin-top: 10px; border-radius: 7px; object-fit: contain; }
.field-hint.error, .form-error { color: #a0402f; }
.form-error { margin-top: 12px; font-size: 13px; overflow-wrap: anywhere; }
.form-error:empty { display: none; }
.dialog-footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.confirm-message { color: var(--muted); overflow-wrap: anywhere; }
.toast { position: fixed; bottom: 20px; left: 50%; z-index: 50; display: flex; align-items: center; gap: 9px; width: max-content; max-width: calc(100% - 32px); padding: 12px 17px; border-radius: 9px; background: var(--ink); color: white; font-size: 14px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .15s, transform .15s; }
.toast span { min-width: 0; overflow-wrap: anywhere; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast .icon { width: 17px; height: 17px; color: #d2dec1; }

.login-main { display: flex; align-items: center; justify-content: center; min-height: calc(100dvh - 110px); padding-block: 36px; }
.login-card { width: 410px; max-width: 100%; padding: 30px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.login-icon { width: 26px; height: 26px; margin-bottom: 18px; color: var(--terracotta); }
.login-card h1 { font-size: 29px; letter-spacing: -.7px; }
.login-intro { margin-top: 12px; color: var(--muted); font-size: 14px; }
.login-card form .button { width: 100%; margin-top: 20px; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 14px; color: var(--muted); font-size: 13px; }

/* More ideas in view on desktop, still grouped in reading order by person. */
@media (min-width: 960px) {
  .wrap { max-width: 1160px; }
  .gift-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .gift-card { display: flex; flex-direction: column; }
  .gift-link { flex: 1; gap: 16px; }
  .gift-admin-actions { margin-top: auto; }
  .section-empty { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .wrap { width: calc(100% - 32px); }
  .list-header { padding-block: 28px 18px; }
  h1 { font-size: 30px; letter-spacing: -1px; }
  .people-tabs { width: 100%; max-width: none; padding: 10px 16px 14px; gap: 8px; }
  .person-pill { min-height: 44px; gap: 8px; padding: 8px 14px; font-size: 15px; }
  .person-dot { width: 9px; height: 9px; }
  .list-content { padding-top: 25px; }
  .gift-grid { gap: 36px; }
  .person-heading { gap: 8px; margin-bottom: 14px; }
  .person-tag { padding: 10px 17px 10px 35px; font-size: 23px; clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 50%); }
  .person-tag::before { left: 16px; width: 7px; height: 7px; }
  .person-actions { gap: 0; }
  .person-actions button { padding-inline: 7px; }
  .gift-list { gap: 10px; }
  .gift-link { min-height: 120px; padding: 12px; gap: 14px; }
  .gift-photo { flex-basis: 88px; width: 88px; height: 88px; border-radius: 9px; }
  .gift-initial { font-size: 37px; }
  .gift-details { padding-top: 1px; }
  .gift-title { font-size: 17px; line-height: 1.35; letter-spacing: -.15px; }
  .gift-note { margin-top: 6px; font-size: 14px; line-height: 1.5; }
  .gift-arrow { display: none; }
  .admin-banner { padding: 10px 12px; font-size: 13px; }
  .admin-banner .button { padding-inline: 12px; font-size: 13px; }
  .sample-notice { font-size: 12px; margin-bottom: 20px; }
  .dialog-form { padding: 20px; }
  .dialog-header h2 { font-size: 23px; }
  .login-card { padding: 24px; }
  .site-footer { padding-top: 26px; }
}

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