:root {
  --bg: #fcf1f4; /* pale pink */
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #f1dce3;
  --accent: #0ea5e9;
  --on: #16a34a;
  --cool: #0ea5e9;
  --heat: #f97316;
  --danger: #dc2626;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1318; /* very dark pink, for the dark theme */
    --card: #2a1d24;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --line: #3a2a33;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  /* +28px at the top: the title clears the blurred band iOS draws under the status bar */
  padding: calc(env(safe-area-inset-top) + 28px) 16px calc(env(safe-area-inset-bottom) + 24px);
  max-width: 640px;
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
}
/* touch-action: no double-tap zoom on repeated taps (pinch zoom still works) */
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; }

.login { display: grid; place-items: center; align-content: center; min-height: 85vh; text-align: center; }

/* Animated login logo */
.brand { display: grid; justify-items: center; gap: 6px; }
.logo { width: 148px; height: 148px; margin-bottom: -10px; overflow: visible; filter: drop-shadow(0 10px 28px rgb(56 189 248 / .35)); }
.logo-halo { transform-origin: 80px 80px; animation: breathe 4s ease-in-out infinite; }
.logo-ring { transform-origin: 80px 80px; animation: spin 24s linear infinite reverse; }
.logo-vortex { transform-origin: 80px 80px; animation: spin 9s linear infinite reverse; }
.logo-core { transform-origin: 80px 80px; animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(.92); opacity: .7; } 50% { transform: scale(1.06); opacity: 1; } }
.wordmark { font-size: 2.2rem; letter-spacing: -.02em; margin-top: 4px; }
.wm-strong {
  font-weight: 800;
  background: linear-gradient(90deg, #0ea5e9, #6366f1, #a855f7, #ec4899, #f97316, #ec4899, #a855f7, #6366f1, #0ea5e9) 0 0 / 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 8s linear infinite;
}
.wm-light { font-weight: 300; }
.tagline { margin: 14px 0 0; font-size: 1.05rem; font-weight: 600; max-width: 320px; }
@keyframes shimmer { to { background-position: 300% 0; } }
@media (prefers-reduced-motion: reduce) {
  .logo *, .wm-strong { animation: none !important; }
}
.login form { display: grid; gap: 8px; width: min(320px, 100%); margin-top: 24px; text-align: left; }
.login label { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.login input, .login button {
  padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 1rem;
}
.login button { background: var(--accent); color: #fff; border: 0; font-weight: 600; margin-top: 12px; }

.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.top p { margin: 2px 0 0; font-size: .85rem; }
.top-actions { position: relative; }
.icon-btn { font-size: 1.4rem; width: 44px; height: 44px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Top-right menu */
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; min-width: 200px;
  display: grid; padding: 6px; border-radius: 14px; background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgb(15 23 42 / .18);
}
.menu button { text-align: left; padding: 12px 14px; border-radius: 10px; font-size: 1rem; }
.menu button:active { background: var(--bg); }
.menu button[aria-current="page"] { color: var(--accent); font-weight: 600; }
#logout { color: var(--danger); border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; margin-top: 4px; }

/* Schedules */
.sched-when { margin: 6px 0 0; }
.sched .zone-foot { align-items: center; }
.sched-actions { display: flex; gap: 18px; }
.sched-edit, .sched-del { font-size: .9rem; padding: 4px 0; }
.sched-edit { color: var(--accent); }
.sched-del { color: var(--danger); }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .2s;
}
.switch input:checked + span { background: var(--on); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sched-form { display: grid; gap: 8px; margin-top: 12px; }
.sched-form h3 { margin: 0 0 4px; }
.sched-form label, .sched-form .label { font-size: .85rem; color: var(--muted); margin-top: 4px; }
/* font-size 16px: below this, iOS Safari zooms in when the field is tapped */
.sched-form input:not([type="checkbox"]), .sched-form select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
.form-head { display: flex; justify-content: space-between; align-items: center; }
.close { width: 36px; height: 36px; border-radius: 50%; background: var(--bg); color: var(--muted); font-size: 1rem; }
.sched-form .row { display: flex; align-items: center; gap: 12px; }
.sched-form .row > input { flex: 1; min-width: 0; }
.sched-form .section-head { margin-top: 14px; }
.sched-form .row.section-head { justify-content: space-between; }
.sched-form .toggle-label { display: flex; align-items: center; gap: 8px; margin: 0; white-space: nowrap; }
.room-list { display: grid; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.room-list label {
  display: flex; justify-content: space-between; align-items: center; margin: 0;
  padding: 10px 14px; color: var(--text); font-size: 1rem; background: var(--bg);
}
.room-list label + label { border-top: 1px solid var(--line); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days .chip { padding: 10px 0; text-align: center; }
.time-row { margin-top: 4px; }
/* Safari ignores padding on native selects: custom look, same height as the other fields */
.sched-form select {
  -webkit-appearance: none; appearance: none; padding-right: 36px;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2364748b' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center;
}
.time-row label { flex: 1; display: grid; gap: 4px; }
.sched-form .setpoint { margin-top: 10px; }
.save { margin-top: 18px; font-size: 1.05rem; }
.primary { padding: 10px 18px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; }

.system { margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--line); font-size: .9rem;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.zones { display: grid; gap: 12px; }
.zone { background: var(--card); border-radius: 18px; padding: 16px; border: 1px solid var(--line); }
.zone.off .setpoint, .zone.off .room-temp { opacity: .45; }
.zone.offline { opacity: .5; }
.zone-head { display: flex; justify-content: space-between; align-items: center; }
.zone-name { margin: 0; font-size: 1.15rem; }
.power {
  min-width: 72px; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: .9rem;
  background: var(--line); color: var(--muted);
}
.zone.on .power { background: var(--on); color: #fff; }
.zone-room { margin: 6px 0 10px; display: flex; gap: 10px; align-items: baseline; }
.room-temp { font-size: 1rem; }
.setpoint { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sp-btn {
  width: 56px; height: 56px; border-radius: 50%; font-size: 1.8rem; line-height: 1;
  background: var(--bg); border: 1px solid var(--line);
}
.sp-btn:active { transform: scale(.94); }
.sp-value { text-align: center; }
.sp-value .sp { display: block; font-size: 2.6rem; font-weight: 300; font-variant-numeric: tabular-nums; }
.sp-value small { color: var(--muted); }
.sp.pending { color: var(--accent); }
.zone-foot { display: flex; justify-content: space-between; margin-top: 10px; font-size: .9rem; }
.fan { margin-top: 10px; }

.foot { display: flex; justify-content: center; margin-top: 24px; }
.ghost {
  padding: 10px 16px; border-radius: 12px; font-size: .95rem; font-weight: 500;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
}
.ghost:active { transform: scale(.97); }
.wide { width: 100%; padding: 14px 16px; font-weight: 600; }
#all-off { width: 100%; padding: 14px 16px; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; }
.alert {
  margin: 0 0 16px; padding: 10px 14px; border-radius: 12px; font-size: .9rem;
  background: var(--card); color: var(--text); border-left: 4px solid var(--danger);
}
.alert.warning { border-left-color: var(--heat); }
.empty-note {
  margin: 8px 0 16px; padding: 20px 16px; border-radius: 16px; text-align: center;
  background: var(--card); color: var(--text); font-size: 1rem; line-height: 1.5;
}
.install-link { text-align: center; margin: 22px 0 0; }
/* Same pill as the support button, light green */
.install-link a {
  display: inline-block; padding: 9px 20px; border-radius: 999px; background: #dcfce7;
  border: 1px solid #bbf7d0; color: #15803d; font-size: .88rem; font-weight: 500;
  text-decoration: none; line-height: 1.3;
}
.install-link a:active { transform: scale(.97); }
@media (prefers-color-scheme: dark) {
  .install-link a { background: #14532d; border-color: #166534; color: #bbf7d0; }
}
.support-link { text-align: center; margin: 24px 0 8px; }
.support-link a {
  display: inline-block; padding: 9px 20px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--line); color: var(--accent); font-size: .88rem; font-weight: 500;
  text-decoration: none; line-height: 1.3;
}
.danger-text { color: var(--danger); }
.support-note { max-width: 320px; margin: 8px auto 0; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.beta-note { max-width: 320px; margin: 18px auto 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.beta-note a { color: var(--muted); }
/* Footer on every page: who runs the site and the information pages */
.site-foot { margin-top: 36px; text-align: center; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.site-foot .support-link { margin: 0 0 16px; }
.site-foot .foot-links { padding-top: 14px; border-top: 1px solid var(--line); }
.site-foot nav a { color: var(--muted); }
.site-foot p { margin: 6px 0 0; }
.site-foot .support-note { margin: 8px auto 0; }
.support-link a:active { transform: scale(.97); }
