:root {
  --bg: #fbf6ec;
  --card: #fffdf8;
  --text: #1d2b22;
  --muted: #6b6f68;
  --border: #e8dfcf;
  --green: #1f5f3a;
  --green-dark: #143f27;
  --green-soft: #e3f1e6;
  --red: #b3261e;
  --red-dark: #8c1d17;
  --gold: #c9a227;
  --radius: 14px;
  --heading: Georgia, "Times New Roman", serif;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh; -webkit-text-size-adjust: 100%;
  /* Soft "snow": two offset layers of small dots over the cream background. */
  background:
    radial-gradient(circle, rgb(31 95 58 / 0.07) 2px, transparent 2.5px) 0 0 / 46px 46px,
    radial-gradient(circle, rgb(179 38 30 / 0.05) 1.5px, transparent 2px) 23px 23px / 46px 46px,
    var(--bg);
  background-attachment: fixed;
}
/* Candy-cane stripe along the top edge. */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 6px; z-index: 10;
  background: repeating-linear-gradient(-45deg, var(--red) 0 12px, #fff 12px 24px);
}
#app[inert] { opacity: 0.7; }

.screen { max-width: 560px; margin: 0 auto; padding: 22px 16px calc(32px + env(safe-area-inset-bottom)); }
.center { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
h1, h2 { font-family: var(--heading); }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 8px; color: var(--green); }
ul { list-style: none; margin: 0; padding: 0; }

button, input { font: inherit; }
button {
  min-height: 44px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer; color: var(--text);
}
button:disabled { opacity: 0.4; cursor: default; }
.primary { background: var(--red); color: #fff; font-weight: 600; box-shadow: 0 2px 0 var(--red-dark); }
.primary:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--red-dark); }
.secondary { background: var(--card); border-color: var(--border); }
.danger { background: var(--card); border-color: var(--red); color: var(--red); }
.small { padding: 0 12px; font-size: 0.9rem; }
.link { background: none; color: var(--green); padding: 0 8px; text-decoration: underline; }
.icon { width: 44px; padding: 0; background: var(--card); border-color: var(--border); }
input {
  width: 100%; min-height: 44px; padding: 0 12px; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
}

.card {
  display: flex; flex-direction: column; gap: 12px; padding: 20px;
  background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
}
.form-error { color: var(--red); margin: 0; min-height: 1.2em; }
input:focus-visible, button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Login */
.hero { text-align: center; }
.hero h1 { font-size: 2.2rem; color: var(--green); }
.hero .tree { font-size: 3.5rem; line-height: 1; }
.hero p { margin: 6px 0 0; color: var(--muted); font-style: italic; }
.center .card { border-top: 4px solid var(--red); }
.loading, .empty { color: var(--muted); text-align: center; }
.empty { padding: 24px 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  margin-bottom: 16px; padding: 10px 12px 10px 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--green), var(--green-dark)); color: #fff;
  box-shadow: 0 2px 8px rgb(20 63 39 / 0.25); border-bottom: 3px solid var(--gold);
}
.topbar .link { color: #fff; }
.actions { display: flex; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; margin-bottom: 16px; }
.toolbar > * { flex: 1; }
.back { margin-bottom: 12px; padding-left: 0; }

.stack, .items { display: flex; flex-direction: column; gap: 8px; }
.big { width: 100%; min-height: 56px; font-size: 1.1rem; background: var(--card); border-color: var(--border); }

.item {
  width: 100%; min-height: 56px; display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); text-align: left;
}
.item .name { flex: 1; overflow-wrap: anywhere; }
.item .who { color: var(--muted); font-size: 0.9rem; }
.box {
  width: 24px; height: 24px; flex: none; display: grid; place-items: center;
  border: 2px solid var(--border); border-radius: 6px; font-weight: 700;
}
.item.mine { background: var(--green-soft); border-color: var(--green); }
.item.mine .box { background: var(--green); border-color: var(--green); color: #fff; }
.item.mine .who { color: var(--green); font-weight: 600; }
.item.taken { opacity: 0.55; }
.item.taken .name { text-decoration: line-through; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 528px; margin: 0 auto; padding: 12px 16px; text-align: center;
  background: var(--text); color: #fff; border-radius: var(--radius); box-shadow: 0 4px 12px rgb(0 0 0 / 0.2);
}

.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 16px; background: var(--border); border-radius: var(--radius); }
.tab { flex: 1; background: none; }
.tab.active { background: var(--card); font-weight: 600; color: var(--red); }

.add { display: flex; gap: 8px; margin-bottom: 16px; }
.add input { flex: 1; }
.add button { flex: none; }

.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-item {
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.row, .admin-item.row { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
.row .name { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.who { color: var(--muted); font-size: 0.9rem; }
.who.free { color: var(--green); }
.buttons { justify-content: flex-end; }

.overview { display: flex; flex-direction: column; gap: 12px; }
.group { padding: 12px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.group ul { list-style: disc; padding-left: 20px; }
.muted { color: var(--muted); margin: 0; }
.danger-zone { display: flex; flex-direction: column; gap: 8px; margin-top: 32px; }
