/* ---------- Theme tokens (light is the default) ---------- */

:root {
  --bg: #f7f3ee;
  --bg-accent: #fbe9e4;
  --card: #ffffff;
  --input: #fbf9f6;
  --text: #2a2622;
  --muted: #857d74;
  --border: #ebe4dc;
  --primary: #c8473a;
  --primary-hover: #b13b2f;
  --primary-soft: #fbeae7;
  --green: #2f8a57;
  --green-bg: #eaf6ef;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(60, 40, 20, 0.05);
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.04), 0 8px 24px -8px rgba(60, 40, 20, 0.1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #181715;
  --bg-accent: #2a1f1c;
  --card: #22201e;
  --input: #1c1b19;
  --text: #efebe5;
  --muted: #a09990;
  --border: #36332f;
  --primary: #e8685a;
  --primary-hover: #f07d70;
  --primary-soft: #3a2421;
  --green: #72d39c;
  --green-bg: #1c2e24;
  --shadow-sm: none;
  --shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  background:
    radial-gradient(1200px 400px at 50% -200px, var(--bg-accent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0 0 0.5em; line-height: 1.2; }
h1, h2 { font-family: "Fraunces", Georgia, serif; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; font-weight: 600; }

.muted { color: var(--muted); font-weight: normal; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ---------- Forms & buttons ---------- */

input, select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  margin-top: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; }
label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: 16px; }

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 20px;
  cursor: pointer;
  background: var(--border);
  color: var(--text);
  transition: background 0.15s, transform 0.05s, border-color 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--input); border-color: var(--muted); }
.btn.small { padding: 5px 12px; font-size: 0.85rem; border-radius: 8px; }
.btn:disabled { opacity: 0.6; cursor: wait; }

.link-btn {
  font: inherit;
  font-size: 0.9rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
}
.link-btn:hover { color: var(--primary); text-decoration-color: currentColor; }

.theme-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 5;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.theme-btn:hover { border-color: var(--muted); }

/* ---------- Login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 36px 28px; }
.login-card .logo {
  font-size: 2.6rem;
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
}
.login-card form { display: grid; gap: 12px; margin-top: 20px; }

/* ---------- App layout (single centered column) ---------- */

.content { max-width: 640px; margin: 0 auto; padding: 56px 16px 80px; }

.greeting { text-align: center; margin-bottom: 28px; }
.greeting h1 { margin-bottom: 6px; }
.greeting #current-user { color: var(--primary); }
.wave { display: inline-block; transform-origin: 70% 70%; animation: wave 1.6s ease-in-out 0.3s 1; }
@keyframes wave {
  0%, 60%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  40% { transform: rotate(-4deg); }
  50% { transform: rotate(10deg); }
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 auto 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.tab {
  flex: 1;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  background: none;
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--primary); color: #fff; }

.gift-form { margin-bottom: 28px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.hint {
  margin: 0 0 24px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--text);
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- Gift lists ---------- */

.gift-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }

.gift {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, background 0.2s;
}
.gift:hover { border-color: color-mix(in srgb, var(--muted) 40%, var(--border)); }
.gift-body { flex: 1; min-width: 0; }
.gift-name { font-weight: 600; overflow-wrap: anywhere; }
.gift-desc { margin: 4px 0 0; color: var(--muted); font-size: 0.92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.gift-link {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
}
.gift-link:hover { text-decoration: underline; }
.gift-actions { display: flex; gap: 6px; flex-shrink: 0; }

.gift.bought { background: var(--green-bg); border-color: transparent; }
.gift.bought .gift-name { text-decoration: line-through; text-decoration-color: var(--green); opacity: 0.8; }
.gift.taken { opacity: 0.6; }

.buy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 2px 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 64px;
  text-align: center;
  cursor: pointer;
}
.buy input { width: 22px; height: 22px; margin: 0; accent-color: var(--green); cursor: pointer; }
.buy input:disabled { cursor: not-allowed; }
.gift.bought .buy { color: var(--green); }

.person { margin-bottom: 32px; }
.person h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
}
.person h3 .count { font-size: 0.82rem; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 11px 20px;
  border-radius: 999px;
  max-width: calc(100% - 32px);
  font-weight: 500;
  font-size: 0.92rem;
  box-shadow: var(--shadow);
  z-index: 10;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
}

@media (max-width: 520px) {
  h1 { font-size: 1.6rem; }
  .content { padding-top: 64px; }
  .card { padding: 18px; }
  .gift { flex-wrap: wrap; }
  .tab { padding: 9px 8px; font-size: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
