:root {
  --bg: #f6f1e7;
  --card: #fffdf8;
  --ink: #1f2a24;
  --muted: #66706a;
  --line: #e4dccb;
  --green: #1f5c3f;
  --green-soft: #e3efe7;
  --red: #b3262d;
  --header: #b3262d;
  --gold: #b88a2a;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121915;
    --card: #1a231e;
    --ink: #ecebe4;
    --muted: #9aa49e;
    --line: #2c3832;
    --green: #7cc59b;
    --green-soft: #213229;
    --red: #ef7b80;
    --header: #7d1d22;
    --gold: #d9b45d;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--header);
  color: #fff;
}

.brand {
  color: inherit;
  text-decoration: none;
  font: 600 1.15rem/1.2 Georgia, "Times New Roman", serif;
}

.brand::before {
  content: "🎄 ";
}

.me select {
  margin-left: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 0;
  background: #fff;
  color: #1f2a24;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: grid;
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  margin: 0;
}

h1 {
  font-size: 1.5rem;
  text-align: center;
}

h2 {
  font-size: 1.3rem;
  margin: 16px 0 4px;
}

.year-nav {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
}

.year-nav button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.year-nav button:hover {
  background: var(--green-soft);
}

.you {
  text-align: center;
  margin: 12px 0 0;
  font-weight: 500;
}

.pairs {
  list-style: none;
  margin: 16px auto 0;
  padding: 0;
  max-width: 320px;
}

.pairs li {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
}

.pairs li:nth-child(odd) {
  background: color-mix(in srgb, var(--line) 35%, transparent);
}

.pairs li.mine {
  background: var(--green-soft);
  font-weight: 600;
}

.giver {
  text-align: right;
}

.arrow {
  color: var(--gold);
}

.hint {
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
  margin: 12px 0 0;
}

.budget {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-left: 4px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 12%, transparent);
  border-radius: 8px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}

.tab:hover {
  border-color: var(--green);
}

.tab[aria-current="page"] {
  background: var(--green);
  border-color: var(--green);
  color: var(--card);
}

.status {
  color: var(--red);
  margin: 0;
  min-height: 0;
}

.status:empty {
  display: none;
}

.items {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.item {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.item .text {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.empty {
  padding: 20px 0;
  color: var(--muted);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* A dot after every item but the last. inline-block keeps the button hover
   underline off it, and the empty alt text hides it from screen readers. */
.meta > :not(:last-child)::after {
  content: "·";
  content: "·" / "";
  display: inline-block;
  margin: 0 0.6em;
  color: var(--muted);
}

button.link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--green);
  cursor: pointer;
  font-size: inherit;
}

button.link:hover {
  text-decoration: underline;
}

.comments {
  list-style: none;
  margin: 8px 0 0;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--line) 30%, transparent);
  border-radius: 10px;
  font-size: 0.925rem;
}

.comments li + li {
  margin-top: 4px;
}

.comments .when {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.comments .x {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}

form.add,
form.comment-form,
form.edit {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

form.edit {
  flex-direction: column;
  margin-top: 0;
}

form.edit .row {
  display: flex;
  gap: 8px;
}

textarea,
input[type="text"],
input[type="password"] {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  resize: vertical;
}

textarea:focus,
input:focus,
select:focus {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

form button[type="submit"],
form button.quiet {
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--green);
  background: var(--green);
  color: var(--card);
  cursor: pointer;
  align-self: flex-start;
}

form button.quiet {
  background: transparent;
  color: var(--green);
}

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  padding: 24px;
  max-width: min(360px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.5);
}

dialog form {
  display: grid;
  gap: 12px;
}

dialog h2 {
  margin: 0;
}

dialog p {
  margin: 0;
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.25rem;
  }

  form.add {
    flex-direction: column;
  }
}
