:root {
  --red: #e63950;
  --red-dark: #c0203a;
  --pink: #ff6b81;
  --ink: #201a1d;
  --paper: #fff5f6;
  --card: #ffffff;
  --border: #f0d3d7;
  --muted: #8a6a70;
  --ok: #1f9d55;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f7ecee;
    --paper: #221417;
    --card: #2c1a1e;
    --border: #47262c;
    --muted: #c79aa1;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--red-dark); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  border: none;
  border-radius: 10px;
  padding: 0.7em 1.1em;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { background: transparent; color: #b5273e; border: 1px solid #b5273e33; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.4em 0.8em; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---- Auth pages (setup / login) ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.auth-shell { width: 100%; max-width: 380px; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { font-size: 1.8rem; margin: 0.3em 0 0; }
.auth-emoji { font-size: 3rem; }
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}
.auth-card h2 { margin-top: 0; }
.auth-sub { color: var(--muted); font-size: 0.9rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35em; }
.field input, .field select {
  width: 100%;
  padding: 0.65em 0.75em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
}
.error-box {
  background: #fbe4e7;
  color: #8f1f34;
  border: 1px solid #f0b7bf;
  border-radius: 8px;
  padding: 0.6em 0.9em;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
@media (prefers-color-scheme: dark) {
  .error-box { background: #3a1a20; color: #ff9db0; border-color: #5c2733; }
}

/* ---- Topbar (receiver pages) ---- */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.topbar-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.brand { display: flex; align-items: center; gap: 0.5em; text-decoration: none; color: var(--ink); font-weight: 700; }
.brand-emoji { font-size: 1.4rem; }
.nav { display: flex; gap: 1rem; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; font-size: 0.92rem; font-weight: 600; }
.nav a.active, .nav a:hover { color: var(--red-dark); }
.topbar-user { display: flex; align-items: center; gap: 0.75em; }
.user-chip { font-size: 0.85rem; color: var(--muted); }
.page { max-width: 900px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* ---- Page Pookie button page ---- */
.pookie-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  gap: 1.5rem;
}
.pookie-title {
  font-family: "Comic Sans MS", "Chalkboard SE", "Comic Neue", cursive;
  font-size: 2.4rem;
  color: var(--red-dark);
  margin: 0;
  transform: rotate(-2deg);
}
.pookie-sub { color: var(--muted); margin: 0; }
.pookie-btn {
  width: min(70vw, 280px);
  height: min(70vw, 280px);
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 30%, var(--pink), var(--red) 65%, var(--red-dark) 100%);
  color: #fff;
  font-family: "Comic Sans MS", "Chalkboard SE", "Comic Neue", cursive;
  font-size: 1.6rem;
  font-weight: 700;
  box-shadow: 0 12px 0 var(--red-dark), 0 20px 30px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  animation: pookie-wobble 2.6s ease-in-out infinite;
}
.pookie-btn:active {
  transform: translateY(10px);
  box-shadow: 0 2px 0 var(--red-dark), 0 6px 12px rgba(0,0,0,0.2);
}
.pookie-btn[disabled] {
  animation: none;
  background: radial-gradient(circle at 35% 30%, #c9a3a8, #a97e83 65%, #8a6367 100%);
  box-shadow: 0 12px 0 #8a6367;
  cursor: not-allowed;
}
@keyframes pookie-wobble {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}
.pookie-status {
  min-height: 1.6em;
  font-weight: 600;
  font-size: 1.1rem;
}
.pookie-status.ok { color: var(--ok); }
.pookie-status.err { color: #b5273e; }
.pookie-footer { margin-top: 1rem; }

/* ---- Dashboard (receiver) ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }
.push-status { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.status-dot { display: inline-block; width: 0.6em; height: 0.6em; border-radius: 50%; margin-right: 0.5em; }
.status-dot.on { background: var(--ok); }
.status-dot.off { background: var(--muted); }

.alert-banner {
  display: none;
  background: var(--red);
  color: #fff;
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  font-weight: 700;
  font-size: 1.15rem;
  animation: banner-pulse 1s ease-in-out infinite;
}
.alert-banner.show { display: block; }
@keyframes banner-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230,57,80,0.5); }
  50% { box-shadow: 0 0 0 14px rgba(230,57,80,0); }
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55em 0.4em; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.empty { color: var(--muted); font-size: 0.9rem; }

.no-margin { margin-bottom: 0 !important; }
.banner-actions { margin-top: 0.75rem; }
.btn-on-banner { color: #fff; border-color: rgba(255,255,255,0.5); }

form.inline { display: inline; }
.users-form { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 0.75rem; align-items: end; margin-bottom: 1.5rem; }
@media (max-width: 640px) {
  .users-form { grid-template-columns: 1fr; }
}
