:root {
  --bg: #121614;
  --bg-raise: #1a211d;
  --ink: #f4efe6;
  --muted: #a79d8e;
  --line: rgba(244, 239, 230, 0.1);
  --copper: #e39b5b;
  --sand: #e6d3a3;
  --leaf: #8fbf7f;
  --rose: #e07a6a;
  --sky: #7eb6c9;
  --paper: #f3ecdf;
  --paper-ink: #241c16;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Outfit", "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(227, 155, 91, 0.16), transparent 55%),
    radial-gradient(760px 420px at 100% 0%, rgba(126, 182, 201, 0.12), transparent 50%),
    var(--bg);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(244, 239, 230, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 239, 230, 0.035) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(circle at 50% 10%, #000 20%, transparent 78%);
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 3px; }
::selection { background: var(--copper); color: #241c16; }

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--paper);
  color: var(--paper-ink);
  padding: 0.5rem 0.8rem;
  z-index: 5;
}
.skip:focus { top: 0.6rem; }

.topbar, .wrap, .colophon, .login-shell { position: relative; z-index: 1; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 22, 20, 0.78);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 4;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  min-width: 10rem;
}
.brand strong { display: block; letter-spacing: 0.08em; font-size: 0.92rem; }
.brand small { display: block; color: var(--muted); font-size: 0.75rem; }
.mark { width: 34px; height: 34px; color: var(--copper); }
.nav { display: flex; gap: 0.25rem; flex: 1; }
.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
}
.nav a[aria-current="page"] { color: var(--paper-ink); background: var(--ink); }
.top-meta { display: flex; align-items: center; gap: 0.85rem; margin-left: auto; }
#clock { color: var(--sand); font-variant-numeric: tabular-nums; font-size: 0.86rem; }
.who { color: var(--muted); font-size: 0.88rem; }
.who em {
  font-style: normal;
  margin-left: 0.35rem;
  color: var(--sand);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
}
.signout { color: var(--muted); font-size: 0.86rem; }

.wrap { width: min(1360px, calc(100% - 2rem)); margin: 0 auto; padding: 1.6rem 0 3rem; }
.colophon {
  display: flex;
  justify-content: center;
  gap: 1.4rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 1rem 1.6rem;
}

.eyebrow, .kicker {
  margin: 0 0 0.35rem;
  color: var(--copper);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 520; letter-spacing: -0.03em; }
h1 { font-size: clamp(2.4rem, 4vw, 4rem); line-height: 0.95; margin: 0; }
h2 { margin: 0; font-size: 1.15rem; font-family: var(--sans); font-weight: 500; letter-spacing: 0; color: var(--muted); }
h3 { margin: 0; font-size: 1.45rem; }
.lede { max-width: 42rem; color: var(--muted); line-height: 1.5; margin: 0.7rem 0 0; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 1.4rem;
}

.flash, .note {
  border-radius: 14px;
  padding: 0.8rem 1rem;
  margin: 0 0 1rem;
  line-height: 1.45;
}
.flash-ok { background: rgba(143, 191, 127, 0.14); color: #d7efcf; }
.flash-bad { background: rgba(224, 122, 106, 0.16); color: #ffd2cb; }
.flash-info, .note { background: rgba(227, 155, 91, 0.12); color: #f3ddc2; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  background: var(--copper);
  color: #2a1c10;
  border-radius: 999px;
  padding: 0.75rem 1.15rem;
  font-weight: 600;
}
.button-dark { background: #241c16; color: var(--paper); width: 100%; }
.button-ghost, .button-quiet {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.button-quiet { color: var(--rose); }

.link-status {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  min-width: 16rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.03);
}
.link-status strong { display: block; }
.link-status p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.86rem; }
.lamp {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 5px rgba(167, 157, 142, 0.12);
  flex: none;
}
.is-online .lamp, .is-clear .lamp { background: var(--leaf); box-shadow: 0 0 0 5px rgba(143, 191, 127, 0.16); }
.is-occupied .lamp, .is-offline .lamp { background: var(--rose); box-shadow: 0 0 0 5px rgba(224, 122, 106, 0.16); }
.is-silent .lamp { background: var(--muted); }
.is-online .lamp { animation: pulse 1.8s ease-out infinite; }
.is-fresh { box-shadow: inset 0 0 0 1px rgba(227, 155, 91, 0.45); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(143, 191, 127, 0.45); }
  100% { box-shadow: 0 0 0 10px rgba(143, 191, 127, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .is-online .lamp { animation: none; }
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.stats article, .panel, .zone, .login-card, .setup-card {
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.045), rgba(255, 250, 242, 0.02));
  border: 1px solid var(--line);
  border-radius: 18px;
}
.stats article { padding: 0.95rem 1rem 1rem; }
.stats span, .zone-rule dt, label span, .panel-head p {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stats strong {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--serif);
  font-size: 2.3rem;
  font-weight: 520;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.stats strong sup { font-size: 1rem; margin-left: 0.1rem; }
.stats em { color: var(--muted); font-style: normal; font-size: 0.86rem; }

.zone-grid, .chart-grid, .threshold-grid, .people-layout {
  display: grid;
  gap: 0.8rem;
}
.zone-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 0.9rem; }
.chart-grid { grid-template-columns: 1.3fr 1fr; margin-bottom: 0.9rem; }
.zone {
  padding: 1rem 1rem 0.9rem;
  box-shadow: inset 0 3px 0 var(--zone, var(--copper));
  min-width: 0;
}
.zone header { display: flex; justify-content: space-between; gap: 0.5rem; align-items: flex-start; }
.presence {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.82rem;
}
.temp-read {
  font-family: var(--serif);
  font-size: clamp(3.2rem, 4vw, 4.4rem);
  line-height: 0.9;
  letter-spacing: -0.05em;
  margin: 0.85rem 0 0.7rem;
  font-variant-numeric: tabular-nums;
}
.temp-read sup { font-size: 1.1rem; letter-spacing: 0; margin-left: 0.15rem; color: var(--muted); }
.read-time { margin: -0.35rem 0 0.75rem; color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.hum-row { display: grid; grid-template-columns: auto auto 1fr; gap: 0.55rem; align-items: center; }
.hum-row strong { font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 99px; background: rgba(244, 239, 230, 0.08); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--sky); border-radius: inherit; }
.zone-rule { display: grid; gap: 0.45rem; margin: 0.9rem 0 0; }
.zone-rule div { display: flex; justify-content: space-between; gap: 0.6rem; }
.zone-rule dt { margin: 0; }
.zone-rule dd { margin: 0; text-align: right; font-size: 0.86rem; }
.is-silent { opacity: 0.72; }

.panel { padding: 1rem; }
.panel-head { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 0.8rem; }
.panel-head p { margin: 0.25rem 0 0; text-transform: none; letter-spacing: 0; font-size: 0.92rem; }
.chart-wrap { position: relative; height: 280px; }
.chart-empty:not([hidden]) {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 1rem;
  margin: 0;
}
.chart-empty[hidden], canvas[hidden] { display: none !important; }

.switch-panel { margin-top: 0.2rem; }
.switch-bay {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.45rem;
}
.sw-cell {
  border-radius: 12px;
  padding: 0.55rem 0.6rem;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid transparent;
  min-width: 0;
}
.sw-cell.is-on { border-color: rgba(143, 191, 127, 0.45); background: rgba(143, 191, 127, 0.1); }
.sw-id { display: block; font-family: var(--mono); font-size: 0.78rem; color: var(--sand); }
.sw-type, .sw-state { display: block; font-size: 0.78rem; color: var(--muted); }
.sw-cell.is-on .sw-state { color: var(--leaf); }

.tabs { display: flex; gap: 0.35rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.tabs a {
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
}
.tabs a[aria-current="page"] { background: var(--ink); color: var(--paper-ink); border-color: transparent; }

.filters, .set-all, .inline-form, .person {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: end;
}
.filters { margin-bottom: 0.7rem; }
label { display: grid; gap: 0.3rem; }
input, select {
  background: #101411;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  min-width: 0;
}
.quick-ranges { display: flex; gap: 0.8rem; margin: 0 0 1rem; }
.quick-ranges a { color: var(--sand); font-size: 0.88rem; }

.sheet-scroll {
  max-height: min(68vh, 760px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.18);
}
.sheet { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.82rem; }
.sheet th, .sheet td { padding: 0.62rem 0.75rem; border-bottom: 1px solid rgba(244, 239, 230, 0.06); text-align: left; white-space: nowrap; }
.sheet th {
  position: sticky;
  top: 0;
  background: #232a26;
  color: var(--sand);
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0.04em;
  z-index: 1;
}
.sheet td.num, .sheet th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet tbody tr:hover { background: rgba(227, 155, 91, 0.06); }
.sheet .pick { width: 2.6rem; text-align: center; }
.sheet .pick input { width: 1rem; height: 1rem; accent-color: var(--copper); }
.sheet tbody tr:has(input:checked) { background: rgba(224, 122, 106, 0.1); }
.delete-bar { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; margin: 0 0 1rem; }
.delete-bar .note { margin: 0; }
.empty-row { text-align: center; color: var(--muted); padding: 2rem 1rem !important; font-family: var(--sans); }
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-family: var(--sans);
  font-size: 0.75rem;
}
.pill-hot { background: rgba(224, 122, 106, 0.18); color: #ffc7be; }
.pill-calm { background: rgba(143, 191, 127, 0.16); color: #d5efcb; }
.pill-on { background: rgba(143, 191, 127, 0.16); color: #d5efcb; }
.pill-off { background: rgba(244, 239, 230, 0.06); color: var(--muted); }
.pager, .pager-note {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-top: 0.8rem;
  color: var(--muted);
}
.pager a { color: var(--sand); }

.rules-form, .stack-form { display: grid; gap: 0.9rem; }
.rule-block { margin-bottom: 0.2rem; }
.inline-field input { width: 8rem; }
.hint { color: var(--muted); margin: 0.7rem 0 0; }
.hint code { color: var(--sand); font-family: var(--mono); font-size: 0.82rem; }
.threshold-grid { grid-template-columns: repeat(4, 1fr); }
.threshold {
  position: relative;
  padding: 0.85rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}
.threshold small { color: var(--muted); }
.threshold input { width: 100%; margin-top: 0.45rem; padding-right: 2.4rem; }
.threshold em { position: absolute; right: 1.4rem; bottom: 1.35rem; font-style: normal; color: var(--muted); }
.people-layout { grid-template-columns: 1fr 1fr; margin-bottom: 0.9rem; }
.person-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.person {
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.person strong { display: block; }
.person small { color: var(--muted); }
.person select { min-width: 7rem; }

.login-body { min-height: 100vh; }
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
}
.login-story { padding: clamp(2rem, 6vw, 5rem); display: flex; flex-direction: column; justify-content: center; }
.login-story h1 { font-size: clamp(3.4rem, 7vw, 6.2rem); }
.story-points { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: 1rem; }
.story-points li { display: flex; gap: 0.9rem; align-items: flex-start; }
.story-points span { font-family: var(--serif); color: var(--copper); font-size: 1.3rem; }
.story-points p { margin: 0.15rem 0 0; color: var(--muted); }
.login-panel {
  background: var(--paper);
  color: var(--paper-ink);
  display: grid;
  place-items: center;
  padding: 2rem 1.2rem;
}
.login-card {
  width: min(420px, 100%);
  background: transparent;
  border: 0;
  box-shadow: none;
  display: grid;
  gap: 0.85rem;
}
.login-card h2 { font-family: var(--serif); font-size: 2rem; color: var(--paper-ink); margin: 0; }
.login-card label span { color: #7c6d5e; }
.login-card input {
  background: #fffaf3;
  color: var(--paper-ink);
  border-color: #e2d5c3;
}
.login-card .hint { color: #7c6d5e; }
.login-card .hint strong { color: var(--paper-ink); }
.login-card .flash-bad {
  background: #f6ddd6;
  color: #6b241c;
  border: 1px solid #d7a79c;
}

.setup-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.setup-card { max-width: 36rem; padding: 1.5rem; }
.setup-card code { font-family: var(--mono); color: var(--sand); }

.status-copy { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.86rem; }
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.7rem;
}
.week-day {
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  display: grid;
  gap: 0.45rem;
}
.week-day legend {
  padding: 0 0.2rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sand);
}
.week-day input[type="time"] { width: 100%; }
.checkline, .choice {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  font-size: 0.92rem;
}
.checkline span, .choice span { color: var(--ink); letter-spacing: 0; text-transform: none; font-size: 0.92rem; }
.cal-panel { margin-top: 1rem; }
.cal-nav, .cal-jumps { display: flex; justify-content: space-between; gap: 0.8rem; align-items: center; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0.2rem 0 0.9rem; color: var(--muted); font-size: 0.86rem; }
.cal-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch { width: 0.7rem; height: 0.7rem; border-radius: 3px; display: inline-block; }
.swatch-open { background: rgba(143, 191, 127, 0.55); }
.swatch-custom { background: rgba(227, 155, 91, 0.8); }
.swatch-closed { background: rgba(224, 122, 106, 0.75); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.4rem; }
.cal-dow { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 0 0.2rem 0.2rem; }
.cal-empty { min-height: 4.4rem; }
.cal-day {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 4.6rem;
  padding: 0.45rem 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(143, 191, 127, 0.08);
  color: inherit;
  text-decoration: none;
}
.cal-day:hover { border-color: rgba(230, 211, 163, 0.45); }
.cal-num { font-family: var(--serif); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.cal-tag { color: var(--muted); font-size: 0.68rem; line-height: 1.2; }
.cal-day.is-custom { background: rgba(227, 155, 91, 0.14); border-color: rgba(227, 155, 91, 0.45); }
.cal-day.is-closed { background: rgba(224, 122, 106, 0.14); border-color: rgba(224, 122, 106, 0.4); }
.cal-day.is-today .cal-num { color: var(--sand); }
.cal-day.is-selected { box-shadow: inset 0 0 0 2px var(--sand); }
.date-rule { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: 0.7rem; }
.date-rule h3 { margin: 0; font-family: var(--serif); font-weight: 520; }
.mode-row, .custom-hours { display: flex; flex-wrap: wrap; gap: 0.8rem 1.2rem; }
.custom-hours input[type="time"] { width: 8.5rem; }

@media (max-width: 1100px) {
  .zone-grid, .stats, .threshold-grid, .week-grid { grid-template-columns: 1fr 1fr; }
  .chart-grid, .people-layout, .login-shell { grid-template-columns: 1fr; }
  .switch-bay { grid-template-columns: repeat(4, 1fr); }
  .topbar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; }
}
@media (max-width: 680px) {
  .zone-grid, .stats, .threshold-grid, .switch-bay, .people-layout, .week-grid { grid-template-columns: 1fr; }
  .cal-nav { flex-direction: column; align-items: stretch; }
  .cal-tag { display: none; }
  .cal-empty, .cal-day { min-height: 2.7rem; }
  .cal-day { padding: 0.35rem; justify-content: center; }
  .page-head, .person, .filters { align-items: stretch; }
  .page-head { flex-direction: column; }
  .link-status { min-width: 0; }
  .top-meta { width: 100%; justify-content: space-between; }
  .login-story { padding: 2rem 1.2rem 1rem; }
  .login-story h1 { font-size: 3.1rem; }
  .hum-row { grid-template-columns: 1fr auto; }
  .meter { grid-column: 1 / -1; }
}
