:root {
  --red: #b3192c;
  --red-dark: #8a1222;
  --green: #116b3e;
  --green-soft: #e7f3ec;
  --cream: #fbf7f0;
  --ink: #23201c;
  --muted: #6f675d;
  --line: #e7dfd2;
  --gold: #e3b23c;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: 'Inter', system-ui, sans-serif; color: var(--ink); background: var(--cream); line-height: 1.5; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
a { color: var(--green); }

.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 14px max(24px, env(safe-area-inset-left));
  background: #fff; border-bottom: 1px solid var(--line); border-top: 5px solid var(--red);
}
.brand { font-size: 22px; display: flex; align-items: center; gap: 8px; }
.brand-name { font-family: 'Mountains of Christmas', cursive; font-weight: 700; color: var(--red); font-size: 26px; }
.tag { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; background: var(--green-soft); color: var(--green); padding: 3px 8px; border-radius: 6px; }
.who { color: var(--muted); font-size: 14px; }

main { max-width: 1000px; margin: 0 auto; padding: 32px max(20px, env(safe-area-inset-right)) calc(64px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
h1 { font-size: 30px; margin: 0 0 6px; }
h2 { margin: 0 0 14px; font-size: 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.auth { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: start; }
.auth-intro p { font-size: 18px; color: var(--muted); }
.steps { padding-left: 20px; }
.steps li { margin: 8px 0; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 10px 30px rgba(60,40,10,.06); }

label { display: block; font-weight: 600; font-size: 14px; margin: 0 0 14px; }
label small { display: block; font-weight: 400; color: var(--muted); }
input[type=email], input[type=password], input:not([type]), input[inputmode] {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px; font: inherit; font-size: 16px;
  border: 1px solid #d6ccbc; border-radius: 10px; background: #fff;
}
input:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: transparent; }
label.check { display: flex; gap: 10px; font-weight: 400; align-items: flex-start; }
label.check input { margin-top: 4px; }

.btn {
  font: inherit; font-weight: 600; font-size: 15px; padding: 10px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid #d6ccbc; background: #fff; color: var(--ink);
}
.btn:hover { background: #f6f1e8; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .6; cursor: wait; }
form .btn.primary { width: 100%; }
.link-btn { border: 0; background: none; color: var(--green); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.err { color: var(--red); font-size: 14px; min-height: 1em; margin: 10px 0 0; }
.alt { font-size: 14px; margin: 14px 0 0; text-align: center; }

.banner { border-radius: 12px; padding: 14px 18px; margin-bottom: 24px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.warn { background: #fff6e0; border: 1px solid #f0d58a; }
.banner.ok { background: var(--green-soft); border: 1px solid #bfe0cc; }

.dash-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 16px; }

.add-kid {
  display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: end;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin-bottom: 24px;
}
.add-kid > * { min-width: 0; }
.add-kid label { margin: 0; }
.add-kid .btn.primary { width: auto; }
.add-kid .err { grid-column: 1 / -1; margin: 0; }
.avatars { border: 0; padding: 0; margin: 0; }
.avatars legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
#avatar-options { display: flex; flex-wrap: wrap; gap: 4px; }
#avatar-options label { margin: 0; }
#avatar-options input { position: absolute; opacity: 0; }
#avatar-options span { display: grid; place-items: center; width: 40px; height: 40px; font-size: 22px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; }
#avatar-options input:checked + span { border-color: var(--green); background: var(--green-soft); }
#avatar-options input:focus-visible + span { outline: 2px solid var(--green); }

.kids { display: grid; gap: 18px; }
.kid { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.kid-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.kid-name { font-size: 20px; font-weight: 700; }
.kid-user { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; color: var(--muted); }
.kid-actions { display: flex; gap: 8px; }
.wishes { list-style: none; padding: 0; margin: 14px 0 0; border-top: 1px solid var(--line); }
.wishes li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.wishes li:last-child { border-bottom: 0; }
.wish-gift { font-weight: 600; }
.wish-note { color: var(--muted); font-size: 14px; }
.wish-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.wishes .empty { color: var(--muted); justify-content: flex-start; }
.wishes [data-act="del-wish"] { min-width: 40px; min-height: 40px; font-size: 18px; text-decoration: none; border-radius: 50%; }
.wish-meta { display: flex; align-items: center; gap: 2px; flex: none; }

dialog { border: 0; border-radius: 18px; padding: 24px; max-width: 440px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(20,15,10,.5); }
.elf-pass { border: 4px dashed var(--green); border-radius: 16px; padding: 18px; background: #fffaf0; }
.ep-head { background: var(--red); color: #fff; text-align: center; font-weight: 700; letter-spacing: 3px; border-radius: 8px; padding: 6px; margin: -6px -6px 14px; }
.ep-name { font-family: 'Mountains of Christmas', cursive; font-size: 32px; text-align: center; margin-bottom: 10px; }
.ep-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.ep-row b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; word-break: break-all; text-align: right; }
.ep-foot { font-size: 12px; text-align: center; color: var(--muted); margin-top: 10px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
@media (pointer: coarse) { .btn.small { padding: 10px 14px; font-size: 14px; } .btn { min-height: 44px; } }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; gap: 20px; }
  .auth-intro h1 { font-size: 26px; }
  .auth-intro p { font-size: 16px; }
}
@media (max-width: 760px) {
  .add-kid { grid-template-columns: 1fr; }
  .add-kid .btn.primary { width: 100%; }
  .brand { font-size: 18px; gap: 6px; }
  .brand-name { font-size: 20px; white-space: nowrap; }
  .tag { display: none; }
  .who span { display: none; }
  main { padding-top: 20px; }
  h1 { font-size: 26px; }
  .panel { padding: 20px; }
  .kid { padding: 16px; }
  .kid-actions { width: 100%; }
  .kid-actions .btn { flex: 1; }
  .wishes li { align-items: flex-start; }
  .wish-date { font-size: 11px; }
  dialog { padding: 18px; }
}

@media print {
  body * { visibility: hidden; }
  #pass-card, #pass-card * { visibility: visible; }
  #pass-card { position: absolute; left: 0; top: 0; width: 380px; }
}

/* Sign in with Google */
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 44px;
  font: inherit; font-weight: 600; font-size: 15px; color: #1f1f1f; background: #fff;
  border: 1px solid #747775; border-radius: 10px; padding: 10px 16px; cursor: pointer;
}
.google-btn:hover { background: #f8f8f8; }
.google-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 16px 0; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
