/* Grouped-list UI after Apple's Human Interface Guidelines, with a warm holiday palette. */

:root {
  color-scheme: light dark;
  --bg: #f6f1e7;
  --cell: #fffdf8;
  --sheet: #f6f1e7;
  --label: #1f1c17;
  --secondary: rgba(64, 54, 40, 0.66);
  --tertiary: rgba(64, 54, 40, 0.32);
  --separator: rgba(64, 54, 40, 0.18);
  --fill: rgba(64, 54, 40, 0.08);
  --pressed: rgba(64, 54, 40, 0.07);
  --accent: #1f5c3f;          /* evergreen: actions */
  --accent-soft: rgba(31, 92, 63, 0.12);
  --on-accent: #ffffff;
  --berry: #a4161a;           /* cranberry: decoration only */
  --gold: #b88a2e;
  --destructive: #d70015;
  --kraft: #ecdcbc;
  --kraft-ink: #4a3a22;
  --bar: rgba(246, 241, 231, 0.82);
  --radius: 12px;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1712;
    --cell: #16241c;
    --sheet: #13201a;
    --label: #f3efe6;
    --secondary: rgba(235, 228, 214, 0.66);
    --tertiary: rgba(235, 228, 214, 0.32);
    --separator: rgba(235, 228, 214, 0.14);
    --fill: rgba(235, 228, 214, 0.1);
    --pressed: rgba(235, 228, 214, 0.08);
    --accent: #6ccf95;
    --accent-soft: rgba(108, 207, 149, 0.16);
    --on-accent: #0d1712;
    --berry: #e5484d;
    --gold: #d9b15e;
    --destructive: #ff6961;
    --kraft: #3b2f1e;
    --kraft-ink: #f0e2c4;
    --bar: rgba(13, 23, 18, 0.82);
  }
  dialog .group { background: #1d2e24; }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--label); }
body { font-size: 17px; line-height: 1.3; letter-spacing: -0.4px; min-height: 100vh; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent); text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.page { max-width: 680px; margin: 0 auto; padding: 0 0 56px; }

/* Navigation bar */
.navbar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 44px; padding: 0 8px;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.navbar.scrolled { box-shadow: 0 0.5px 0 var(--separator); }
.navbar .title { font-weight: 600; opacity: 0; transition: opacity 0.15s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navbar.scrolled .title { opacity: 1; }
.navbar .left { justify-self: start; }
.navbar .right { justify-self: end; }

.bar-button {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; padding: 0 8px; border: 0; background: none;
  color: var(--accent); cursor: pointer;
}
.bar-button.bold { font-weight: 600; }
.bar-button:disabled { color: var(--tertiary); cursor: default; }
.bar-button svg { width: 12px; height: 20px; }

/* Header */
.header { position: relative; padding: 6px 16px 0; }
.large-title {
  font-family: var(--serif); font-size: 34px; font-weight: 700; letter-spacing: 0;
  line-height: 40px; margin: 0; padding-right: 120px;
}
.header:has(.sprig) .subtitle { padding-right: 100px; }
.subtitle { margin: 4px 0 0; color: var(--secondary); font-size: 15px; letter-spacing: -0.2px; }
.sprig { position: absolute; top: -6px; right: 4px; width: 132px; height: 66px; pointer-events: none; }

/* Main pages (home, guest, admin): larger serif section headers in evergreen */
.page.main .section-header {
  margin: 0 20px 8px; font-family: var(--serif); font-size: 21px; line-height: 26px;
  font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--accent);
}

/* Inset grouped list */
.section { margin-top: 32px; }
.section-header {
  margin: 0 32px 7px; font-size: 13px; line-height: 18px; letter-spacing: -0.08px;
  text-transform: uppercase; color: var(--secondary);
}
.section-footer { margin: 7px 32px 0; font-size: 13px; line-height: 18px; letter-spacing: -0.08px; color: var(--secondary); }
.group { margin: 0 16px; background: var(--cell); border-radius: var(--radius); overflow: hidden; }

.row {
  position: relative; display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 44px; padding: 11px 16px;
  border: 0; background: none; text-align: left; color: var(--label);
}
.row + .row::before {
  content: ""; position: absolute; top: 0; right: 0; left: 16px;
  border-top: 0.5px solid var(--separator);
}
.row.has-leading + .row::before, .row + .row.has-leading::before { left: 54px; }
.row.has-avatar + .row::before, .row + .row.has-avatar::before { left: 60px; }
button.row, a.row { cursor: pointer; }
button.row:active, a.row:active { background: var(--pressed); }
.row.selected { background: var(--accent-soft); }
.row.selected + .row::before, .row.selected::before { border-color: transparent; }

.row .body { flex: 1; min-width: 0; }
.row .text { overflow-wrap: anywhere; }
.row .sub { margin-top: 2px; font-size: 15px; letter-spacing: -0.2px; color: var(--secondary); overflow-wrap: anywhere; }
.row .detail { color: var(--secondary); white-space: nowrap; }
.row .chevron { flex: none; width: 8px; height: 14px; color: var(--tertiary); }
.row.action { color: var(--accent); }
.row.action.destructive { color: var(--destructive); }
.row.centered { justify-content: center; }
.row.muted .text { color: var(--secondary); }
.row.bought .text { color: var(--secondary); text-decoration: line-through; text-decoration-color: var(--tertiary); }

.avatar {
  flex: none; width: 32px; height: 32px; margin: -2px 0; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-size: 15px; font-weight: 600; letter-spacing: 0;
}

.open { flex: none; display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-size: 15px; }
.open svg { width: 14px; height: 14px; }
.item-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: inherit; }

.check {
  flex: none; width: 26px; height: 26px; margin: -4px 0; padding: 0;
  border: 1.5px solid var(--tertiary); border-radius: 50%;
  background: none; display: grid; place-items: center; cursor: pointer;
}
.check svg { width: 14px; height: 14px; color: var(--on-accent); opacity: 0; }
.check[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.check[aria-checked="true"] svg { opacity: 1; }
.check:disabled { cursor: default; opacity: 0.55; }

.small-button {
  flex: none; border: 0; border-radius: 999px; padding: 5px 12px;
  background: var(--fill); color: var(--accent); font-size: 15px; font-weight: 600; cursor: pointer;
}

.filled-button {
  display: block; width: calc(100% - 32px); margin: 16px 16px 0; min-height: 50px;
  border: 0; border-radius: 12px; background: var(--accent); color: var(--on-accent);
  font-weight: 600; cursor: pointer;
}
.filled-button:disabled { opacity: 0.4; cursor: default; }
.filled-button:active:not(:disabled) { filter: brightness(0.9); }
.plain-button { display: block; margin: 12px auto 0; min-height: 44px; padding: 0 16px; border: 0; background: none; color: var(--accent); cursor: pointer; }
.plain-button.destructive { color: var(--destructive); }

.empty { padding: 11px 16px; color: var(--secondary); }

/* Admin email */
.steps { margin: 0; padding-left: 20px; font-size: 15px; line-height: 1.4; letter-spacing: -0.2px; }
.steps li + li { margin-top: 6px; }
.row.failed .sub { color: var(--destructive); }

/* Help + welcome */
.help-button { gap: 5px; font-weight: 500; }
.help-button .help-icon { width: 20px !important; height: 20px !important; }
.how-button { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 7px 14px 7px 10px; }
.how-button .help-icon { width: 18px !important; height: 18px !important; }
.welcome .welcome-hint { margin-top: 10px; font-size: 13px; }
.help-icon { width: 22px !important; height: 22px !important; }
.row.faq { align-items: flex-start; padding-top: 13px; padding-bottom: 13px; }
.faq-q { font-weight: 600; }
.row.faq .sub { margin-top: 4px; line-height: 1.35; }
.welcome {
  margin: 20px 16px 0; padding: 16px 18px 18px; border-radius: var(--radius);
  background: var(--cell); box-shadow: inset 4px 0 0 var(--berry);
}
.welcome h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 21px; line-height: 26px; letter-spacing: 0; }
.welcome p, .welcome ul { margin: 0; font-size: 15px; line-height: 1.4; letter-spacing: -0.2px; color: var(--secondary); }
.welcome ul { padding-left: 18px; }
.welcome li + li { margin-top: 4px; }
.welcome .tag-button { margin-top: 14px; }

/* Gift tag */
.tag-wrap { position: relative; margin: 24px 16px 0; filter: drop-shadow(0 1px 1px rgba(60, 40, 10, 0.18)) drop-shadow(0 4px 10px rgba(60, 40, 10, 0.08)); }
.tag, .tag-cover {
  --notch: 34px;
  clip-path: polygon(var(--notch) 0, 100% 0, 100% 100%, var(--notch) 100%, 0 50%);
  border-radius: 0;
}
.tag {
  display: grid; width: 100%; min-height: 128px; padding: 18px 20px 18px 62px;
  position: relative; border: 0; background: var(--kraft); color: var(--kraft-ink); text-align: left;
  align-content: center; gap: 2px;
}
.tag::after { /* stitched inner border */
  content: ""; position: absolute; inset: 7px 7px 7px 7px;
  clip-path: polygon(30px 0, 100% 0, 100% 100%, 30px 100%, 0 50%);
  border: 1px dashed rgba(74, 58, 34, 0.28); pointer-events: none;
}
.tag-hole {
  position: absolute; left: 22px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  border-radius: 50%; background: var(--bg); box-shadow: inset 0 0 0 2.5px var(--gold);
}
.tag-kicker { font-size: 13px; letter-spacing: 0.4px; text-transform: uppercase; opacity: 0.75; }
.tag-name { font-family: var(--serif); font-size: 32px; line-height: 38px; font-weight: 700; letter-spacing: 0; }
.tag-meta { font-size: 15px; opacity: 0.8; letter-spacing: -0.2px; }
.tag-button {
  position: relative; z-index: 1; justify-self: start; margin-top: 10px; min-height: 36px; padding: 0 16px;
  border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-size: 15px; font-weight: 600; letter-spacing: -0.2px; cursor: pointer;
}
.tag-button:active { filter: brightness(0.9); }

.tag-cover {
  position: absolute; inset: 0; display: grid; place-items: center;
  border: 0; background: var(--berry); color: #fff; cursor: pointer;
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.tag-cover::before, .tag-cover::after { content: ""; position: absolute; background: var(--gold); }
.tag-cover::before { top: 0; bottom: 0; left: 58%; width: 14px; }
.tag-cover::after { left: 0; right: 0; top: 50%; height: 14px; margin-top: -7px; }
.tag-cover span {
  position: relative; z-index: 1; padding: 6px 14px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.28); font-weight: 600; font-size: 15px; letter-spacing: -0.2px;
}
.tag-cover.opening { opacity: 0; transform: translateY(-10px) scale(1.03); }
@media (prefers-reduced-motion: reduce) { .tag-cover { transition: opacity 0.2s; } .tag-cover.opening { transform: none; } }

/* Form rows */
.field { display: flex; align-items: center; gap: 12px; }
.field label { flex: none; width: 72px; }
.field input, .field select, textarea.field-input {
  flex: 1; min-width: 0; padding: 0; border: 0; outline: none; background: none;
}
.field input::placeholder, textarea::placeholder { color: var(--tertiary); }
.field select { appearance: none; text-align: right; color: var(--secondary); cursor: pointer; }
textarea.field-input { width: 100%; min-height: 66px; resize: vertical; line-height: 1.35; }
textarea.mono { font: 13px/1.45 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0; min-height: 260px; }

.segmented {
  display: grid; grid-auto-columns: 1fr; grid-auto-flow: column;
  margin: 0 16px; padding: 2px; border-radius: 9px; background: var(--fill);
}
.segmented button {
  border: 0; border-radius: 7px; padding: 6px 4px; background: none;
  font-size: 13px; font-weight: 500; cursor: pointer; letter-spacing: -0.08px;
}
.segmented button[aria-pressed="true"] { background: var(--cell); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); font-weight: 600; }

.checkmark { flex: none; width: 16px; height: 16px; color: var(--accent); }

.email { margin: 0; padding: 11px 16px; white-space: pre-wrap; font-family: inherit; font-size: 15px; line-height: 1.4; letter-spacing: -0.2px; }

/* History grid */
.history { overflow-x: auto; }
.history table { border-collapse: collapse; font-size: 13px; letter-spacing: -0.08px; width: 100%; }
.history th, .history td { padding: 8px 10px; text-align: left; white-space: nowrap; border-bottom: 0.5px solid var(--separator); }
.history tr:last-child td { border-bottom: 0; }
.history th { color: var(--secondary); font-weight: 600; }
.history td:first-child, .history th:first-child { position: sticky; left: 0; background: var(--cell); font-weight: 600; }
.history .draft { color: var(--secondary); font-style: italic; }

/* Sheets and alerts */
dialog {
  width: 100%; max-width: 560px; max-height: calc(100vh - 40px);
  margin: auto auto 0; padding: 0 0 calc(24px + env(safe-area-inset-bottom));
  border: 0; border-radius: 14px 14px 0 0;
  background: var(--sheet); color: var(--label); overflow: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog .navbar { background: var(--sheet); backdrop-filter: none; -webkit-backdrop-filter: none; padding-top: 0; }
dialog .navbar .title { opacity: 1; }
dialog .section:first-of-type { margin-top: 12px; }
.error { margin: 12px 32px 0; color: var(--destructive); font-size: 13px; }

dialog.alert {
  width: 280px; margin: auto; padding: 0; border-radius: 14px; text-align: center;
  background: var(--cell);
}
.alert-body { padding: 20px 16px 16px; font-size: 15px; line-height: 1.35; letter-spacing: -0.2px; }
.alert-buttons { display: grid; grid-template-columns: 1fr 1fr; border-top: 0.5px solid var(--separator); }
.alert-buttons button { min-height: 44px; border: 0; background: none; color: var(--accent); cursor: pointer; }
.alert-buttons button + button { border-left: 0.5px solid var(--separator); }
.alert-buttons .bold { font-weight: 600; }
.alert-buttons .destructive { color: var(--destructive); font-weight: 600; }

.banner {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
  background: rgba(30, 30, 30, 0.92); color: #fff; font-size: 15px; z-index: 50;
}
.loading { padding: 80px 16px; text-align: center; color: var(--secondary); }

/* Laptops and desktops */
@media (min-width: 600px) {
  dialog { margin: auto; border-radius: 14px; padding-bottom: 24px; }
}
@media (hover: hover) {
  button.row:hover, a.row:hover { background: var(--pressed); }
  .row.selected:hover { background: var(--accent-soft); }
  .item-link:hover .text { text-decoration: underline; text-decoration-color: var(--tertiary); }
}
@media (min-width: 900px) {
  .section-footer, .row .sub, .subtitle { font-size: 15px; line-height: 20px; }
  .section-header { font-size: 14px; }
  .page.main .section-header { font-size: 22px; }
  .page.wide { max-width: 760px; }
  .split { display: grid; grid-template-columns: 400px 1fr; height: 100vh; }
  .split .sidebar .sprig { width: 100px; height: 50px; top: 0; }
  .split .sidebar .large-title { padding-right: 92px; font-size: 32px; }
  .split > .pane { overflow-y: auto; height: 100vh; }
  .split > .pane.sidebar { border-right: 0.5px solid var(--separator); }
  .split > .pane.detail { background: var(--bg); }
  .split .page { padding-top: 12px; }
  .split .detail .page { max-width: 720px; }
  .split .detail .large-title { font-size: 40px; line-height: 46px; }
}
