:root {
  --bg: #fbf7f1;
  --card: #ffffff;
  --ink: #2d2a26;
  --muted: #7a726a;
  --line: #ece4d9;
  --red: #c4423a;
  --red-soft: #fbe9e6;
  --green: #2f7a5b;
  --green-soft: #e5f3ec;
  --gold: #e3a83b;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(60 40 20 / 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; line-height: 1.2; }

a { color: var(--green); }

button, input, textarea {
  font: inherit;
  color: inherit;
}

input[type="text"], input[type="password"], input[type="url"] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

input:focus-visible, button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: 0.55rem 1rem;
  background: var(--red);
  color: #fff;
  font-weight: 600;
}

button:hover { filter: brightness(1.05); }
button:disabled { opacity: 0.6; cursor: default; }

button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.small {
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
}

button.link {
  background: none;
  color: var(--muted);
  padding: 0.25rem 0.4rem;
  font-weight: 500;
  font-size: 0.85rem;
}

button.link:hover { color: var(--red); }

.error {
  color: var(--red);
  font-size: 0.9rem;
  min-height: 1.3em;
  margin: 0.4rem 0 0;
}

.muted { color: var(--muted); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* Gate and admin login */

.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.gate {
  width: min(380px, 100%);
  text-align: center;
  padding: 2rem;
}

.gate .emoji { font-size: 3rem; }
.gate h1 { margin: 0.5rem 0 0.25rem; }
.gate p { margin: 0 0 1.25rem; }
.gate form { display: grid; gap: 0.75rem; }

.password-field { position: relative; }
.password-field input { padding-right: 4rem; }

.password-field button {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
}

/* Header */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

header h1 { font-size: 1.4rem; }

.who {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

/* Main layout */

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  align-items: start;
}

.people h2, .wishlists > h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.people ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.people li button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  text-align: left;
}

.people li button:hover { background: var(--bg); }
.people li button.me { background: var(--green-soft); color: var(--green); }
.people .hint { font-size: 0.85rem; margin: 0.75rem 0 0; }

.giftee {
  background: linear-gradient(135deg, var(--red-soft), #fff6e5);
  border: 1px solid #f3d6cf;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.giftee .emoji { font-size: 2.2rem; }
.giftee strong { font-size: 1.25rem; color: var(--red); }

.wishlists { display: grid; gap: 1rem; }

.list h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.list.mine { outline: 2px solid var(--green-soft); }

.tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
}

.tag.gold { background: #fdf1d8; color: #9a6a12; }

.list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}

.list li:first-child { border-top: 0; }

.item-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item-text a { font-size: 0.85rem; margin-left: 0.4rem; }
.item-actions { display: flex; gap: 0.25rem; flex-shrink: 0; align-items: center; }

.list li.bought .item-text { color: var(--muted); text-decoration: line-through; }

.empty { color: var(--muted); font-size: 0.95rem; padding: 0.25rem 0; }

.item-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  margin-top: 0.75rem;
  width: 100%;
}

.list li .item-form { margin-top: 0; }
.list .error:empty { display: none; }

/* Dialog */

dialog {
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  width: min(360px, calc(100% - 2rem));
}

dialog::backdrop { background: rgb(45 42 38 / 0.35); }
dialog h3 { margin-bottom: 0.25rem; }
dialog p { margin: 0 0 1rem; }
dialog form { display: grid; gap: 0.6rem; }

.buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

/* Admin setup */

.setup {
  width: min(560px, 100%);
  display: grid;
  gap: 1rem;
}

.name-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.admin-people {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}

.admin-people li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
}

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; padding: 0 1rem 2rem; }
  header { padding: 1rem; flex-wrap: wrap; gap: 0.5rem; }
  header h1 { font-size: 1.15rem; }
  .item-form { grid-template-columns: 1fr; }
}
