:root {
  --bg: #fbf6ef;
  --card: #ffffff;
  --ink: #2b1d1a;
  --muted: #7d6a63;
  --line: #eadfd3;
  --rose: #9f1239;
  --rose-soft: #fce7ec;
  --gold: #b08d57;
  --leaf: #4d7c3a;
  --leaf-soft: #e8f1e1;
  --danger: #b91c1c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #f8e1e7 0, transparent 40%),
    radial-gradient(circle at 90% 10%, #e6efd9 0, transparent 40%),
    var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

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

.hero { text-align: center; padding: 48px 16px 20px; }
.eyebrow { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); }

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: clamp(32px, 8.5vw, 52px);
  line-height: 1.1;
  color: var(--rose);
  text-wrap: balance;
}

.flourish { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 0; font-size: 16px; }
.flourish span { width: 48px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.lede { max-width: 34ch; margin: 0 auto; color: var(--muted); font-size: 15px; line-height: 1.6; }

.wrap { max-width: 640px; margin: 0 auto; padding: 8px 16px 48px; display: grid; gap: 16px; }
#app { display: grid; gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px 20px;
  box-shadow: 0 10px 30px rgba(107, 57, 44, 0.07);
}

h2 { margin: 0 0 14px; font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: 22px; }
label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }

input[type="text"], textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdfb;
  color: var(--ink);
  font-size: 16px;
  outline: none;
}

textarea { resize: vertical; min-height: 130px; font-family: Georgia, "Times New Roman", serif; line-height: 1.6; }
input:focus, textarea:focus { border-color: var(--rose); box-shadow: 0 0 0 3px var(--rose-soft); }
#joinCode { text-transform: uppercase; letter-spacing: 0.15em; font-family: "Courier New", monospace; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}

.btn.primary { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn.wide { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: 0.6; cursor: default; }

.error { color: var(--danger); font-size: 14px; }
.join .error { display: block; margin: 12px 0 0; min-height: 18px; }
.loading { text-align: center; color: var(--muted); }

.greeting-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.greeting { margin: 0; font-size: 17px; min-width: 0; overflow-wrap: anywhere; }
.greeting span { color: var(--rose); }

.logout {
  flex-shrink: 0;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.logout:hover { border-color: var(--rose); color: var(--rose); }

.wish-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; min-height: 18px; font-size: 13px; }
.count { color: var(--muted); font-size: 13px; margin-left: auto; font-variant-numeric: tabular-nums; }
.note { margin: 14px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

.leaf-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--leaf-soft);
  border-color: #cfe0c2;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.leaf-card p { margin: 0; line-height: 1.5; color: #2f4b24; }
.leaf-art { font-size: 34px; }

@keyframes popIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: none; }
}

.mine-head { display: flex; justify-content: space-between; align-items: baseline; }
.wish-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.wish-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 14px;
  background: #fffaf3;
  border-left: 3px solid var(--gold);
}

.wish-body { flex: 1; min-width: 0; }
.wish-body p { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 16px; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }
.wish-when { margin-top: 6px; font-size: 12px; color: var(--muted); }
.optional { font-weight: 400; color: var(--muted); }
#wishForm label:first-of-type { margin-top: 0; }

.wish-del {
  flex-shrink: 0;
  padding: 6px 10px;
  border: 1px solid #f5c2c2;
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.empty { margin: 4px 0 0; color: var(--muted); font-size: 14px; text-align: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 160%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  transition: transform 0.25s ease;
  z-index: 60;
}

.toast.show { transform: translate(-50%, 0); }

/* Fully hidden when not showing (an empty toast used to peek above the bottom edge) */
.toast { opacity: 0; transition: transform 0.25s ease, opacity 0.2s ease; }
.toast.show { opacity: 1; }
