/* Art direction: family gift wishlist -> warm, calm, minimal
   Palette: warm neutral beige/graphite, single teal accent
   Typography: 'General Sans' (display/headings) + 'Inter' (body)
   Density: balanced, generous spacing for readability on mobile */

:root, [data-theme="light"] {
  --color-bg: #f7f6f2;
  --color-surface: #ffffff;
  --color-surface-2: #fbfbf9;
  --color-surface-offset: #f0ede7;
  --color-divider: #e2ded7;
  --color-border: #d8d3c9;
  --color-text: #26241d;
  --color-text-muted: #6f6b62;
  --color-text-faint: #b3ada0;
  --color-text-inverse: #f9f8f4;
  --color-primary: #0f6e66;
  --color-primary-hover: #0a5650;
  --color-primary-active: #084440;
  --color-primary-highlight: #d7e6e3;
  --color-success: #3f7a2b;
  --color-success-highlight: #dbe8d2;
  --color-error: #a1372c;
  --color-error-highlight: #f1dcd8;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px oklch(0.2 0.01 80 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.2 0.01 80 / 0.08);
  --shadow-lg: 0 12px 32px oklch(0.2 0.01 80 / 0.12);
  --transition-interactive: 160ms cubic-bezier(0.16, 1, 0.3, 1);
  --font-display: 'General Sans', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
}

[data-theme="dark"] {
  --color-bg: #171613;
  --color-surface: #1e1c18;
  --color-surface-2: #221f1b;
  --color-surface-offset: #262319;
  --color-divider: #33302a;
  --color-border: #3c3830;
  --color-text: #e8e5de;
  --color-text-muted: #a6a096;
  --color-text-faint: #6c675d;
  --color-text-inverse: #1e1c18;
  --color-primary: #4bb3a8;
  --color-primary-hover: #6cc4ba;
  --color-primary-active: #2f8f85;
  --color-primary-highlight: #26372f;
  --color-success: #7bbf5c;
  --color-success-highlight: #2b3a24;
  --color-error: #dd7b6d;
  --color-error-highlight: #3d2823;
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.4);
  --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.5);
}

:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.2vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.85rem + 0.15vw, 0.9375rem);
  --text-base: clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.375rem);
  --text-xl: clamp(1.375rem, 1.2rem + 0.8vw, 1.875rem);
  --text-2xl: clamp(1.75rem, 1.3rem + 2vw, 2.75rem);
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem;
  --space-12: 3rem; --space-16: 4rem; --space-20: 5rem;
  --content-default: 960px;
  --content-narrow: 620px;
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: none; text-size-adjust: none; scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.55;
  transition: background var(--transition-interactive), color var(--transition-interactive);
}
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; line-height: 1.2; font-weight: 600; }
p, li { text-wrap: pretty; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: color-mix(in oklab, var(--color-primary) 30%, transparent); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: var(--radius-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.container { max-width: var(--content-default); margin-inline: auto; padding-inline: var(--space-4); }
.container-narrow { max-width: var(--content-narrow); margin-inline: auto; padding-inline: var(--space-4); }

/* Header */
.site-header {
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface);
  position: sticky; top: 0; z-index: 20;
}
.site-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding-block: var(--space-3); gap: var(--space-4);
}
.brand { display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); }
.brand svg { color: var(--color-primary); }
.nav-actions { display: flex; align-items: center; gap: var(--space-3); }

.theme-toggle {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full); border: 1px solid var(--color-border);
  background: var(--color-surface-2); color: var(--color-text-muted);
  transition: color var(--transition-interactive), border-color var(--transition-interactive), background var(--transition-interactive);
}
.theme-toggle:hover { color: var(--color-primary); border-color: var(--color-primary); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-5); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 600; border: 1px solid transparent;
  min-height: 44px; line-height: 1; white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:active { background: var(--color-primary-active); }
.btn-secondary { background: var(--color-surface-2); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { color: var(--color-text); }
.btn-danger { background: transparent; color: var(--color-error); border-color: color-mix(in oklab, var(--color-error) 40%, transparent); }
.btn-danger:hover { background: var(--color-error-highlight); }
.btn-sm { padding: var(--space-1) var(--space-3); min-height: 34px; font-size: var(--text-xs); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Forms */
.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.field label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }
.field input, .field textarea {
  padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); font-size: var(--text-base); min-height: 44px;
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--color-primary); }
.field-hint { font-size: var(--text-xs); color: var(--color-text-faint); }
.link-row { display: flex; gap: var(--space-2); margin-bottom: var(--space-2); }
.link-row input { flex: 1; }

.form-card {
  background: var(--color-surface); border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow-sm);
}

/* Flash messages */
.flash { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-4); font-size: var(--text-sm); }
.flash-success { background: var(--color-success-highlight); color: var(--color-success); }
.flash-error { background: var(--color-error-highlight); color: var(--color-error); }

/* Hero (index) */
.hero { padding-block: var(--space-20) var(--space-16); text-align: left; }
.hero h1 { font-size: var(--text-2xl); margin-bottom: var(--space-4); max-width: 20ch; }
.hero p { color: var(--color-text-muted); max-width: 52ch; margin-bottom: var(--space-8); font-size: var(--text-lg); }
.hero-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* Dashboard header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: var(--space-4); padding-block: var(--space-8) var(--space-6); }
.page-head h1 { font-size: var(--text-xl); }
.page-head .sub { color: var(--color-text-muted); font-size: var(--text-sm); margin-top: var(--space-1); }

.share-box {
  display: flex; align-items: center; gap: var(--space-2); background: var(--color-surface-2);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm); margin-bottom: var(--space-6); flex-wrap: wrap;
}
.share-box code { color: var(--color-primary); font-family: monospace; word-break: break-all; }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-divider); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-sm); }
table.wishlist-table { width: 100%; border-collapse: collapse; min-width: 640px; }
table.wishlist-table th {
  text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--color-text-faint); font-weight: 600; padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider); background: var(--color-surface-2);
}
table.wishlist-table td {
  padding: var(--space-4); border-bottom: 1px solid var(--color-divider); vertical-align: middle; font-size: var(--text-sm);
}
table.wishlist-table tr:last-child td { border-bottom: none; }
table.wishlist-table tr.is-booked { background: color-mix(in oklab, var(--color-success) 6%, transparent); }
.row-num { color: var(--color-text-faint); font-variant-numeric: tabular-nums; width: 2.5rem; }
.item-photo { width: 72px; height: 72px; border-radius: var(--radius-md); object-fit: cover; background: var(--color-surface-offset); }
.item-photo-placeholder {
  width: 72px; height: 72px; border-radius: var(--radius-md); background: var(--color-surface-offset);
  display: flex; align-items: center; justify-content: center; color: var(--color-text-faint);
}
.item-title { font-weight: 600; margin-bottom: var(--space-1); }
.item-comment { color: var(--color-text-muted); font-size: var(--text-xs); max-width: 28ch; }
.link-list { display: flex; flex-direction: column; gap: var(--space-1); }
.link-list a { color: var(--color-primary); font-size: var(--text-sm); }
.link-list a:hover { text-decoration: underline; }
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1); padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 600;
  background: var(--color-success-highlight); color: var(--color-success);
}
.booked-by { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: oklch(0.1 0 0 / 0.5); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: var(--space-4);
}
.modal-overlay.is-open { display: flex; }
.modal-box {
  background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-6);
  max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); border: 1px solid var(--color-divider);
}
.modal-box h3 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.modal-box p { color: var(--color-text-muted); font-size: var(--text-sm); margin-bottom: var(--space-4); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-5); }

/* Empty state */
.empty-state { text-align: center; padding: var(--space-16) var(--space-6); color: var(--color-text-muted); }
.empty-state h3 { color: var(--color-text); margin-bottom: var(--space-2); font-size: var(--text-lg); }
.empty-state p { max-width: 40ch; margin: 0 auto var(--space-6); }

/* Auth pages */
.auth-wrap { padding-block: var(--space-16); }
.auth-wrap h1 { font-size: var(--text-xl); margin-bottom: var(--space-6); }
.auth-switch { margin-top: var(--space-5); font-size: var(--text-sm); color: var(--color-text-muted); }
.auth-switch a { color: var(--color-primary); font-weight: 600; }

footer.site-footer { padding-block: var(--space-10); color: var(--color-text-faint); font-size: var(--text-xs); text-align: center; }

.item-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

@media (max-width: 640px) {
  .hero { padding-block: var(--space-12) var(--space-10); }
  table.wishlist-table { min-width: 560px; }
}

/* Photo lightbox */
.item-photo-btn {
  padding: 0; border: none; background: none; border-radius: var(--radius-md);
  cursor: zoom-in; display: block;
}
.item-photo-btn:hover .item-photo { opacity: 0.85; }
.item-photo-btn:focus-visible { outline-offset: 3px; }
.modal-box-photo {
  max-width: 560px; position: relative; padding: var(--space-4);
}
.modal-close-x {
  position: absolute; top: var(--space-3); right: var(--space-3);
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full); background: var(--color-surface-2); color: var(--color-text-muted);
  border: 1px solid var(--color-border); z-index: 1;
}
.modal-close-x:hover { color: var(--color-text); border-color: var(--color-primary); }
.modal-photo-full {
  width: 100%; max-height: 70vh; object-fit: contain; border-radius: var(--radius-md);
  background: var(--color-surface-offset);
}
.modal-photo-title { margin-top: var(--space-3); font-size: var(--text-sm); color: var(--color-text-muted); text-align: center; }

.item-actions-stack { align-items: flex-start; }
.item-move-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.item-main-cell { min-width: 340px; }
.item-comment { color: var(--color-text-muted); font-size: var(--text-sm); max-width: 60ch; margin-top: var(--space-1); }
.link-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); }
.link-list a { text-decoration: none; }
