
:root {
  --bg: #f6f5f2; --card: #ffffff; --text: #1d1d1b; --muted: #5d5d58;
  --line: #deddd7; --accent: #1f5fbf; --accent-text: #ffffff;
  --ok: #1e7a3c; --ok-bg: #e6f4ea; --warn: #8a5a00; --warn-bg: #fff4d6;
  --crit: #b3261e; --crit-bg: #fde8e6; --pause: #4a4a8a; --pause-bg: #ececf8;
  --logo-house: #1f5fbf; --logo-light: #f2b33d;
}
/* dark: follows the device unless the user chose "light"/"dark" (data-theme on <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161615; --card: #22221f; --text: #f0efe9; --muted: #b0afa8;
    --line: #3a3a36; --accent: #6ea2ff; --accent-text: #0b1a33;
    --ok: #7fd49a; --ok-bg: #18301f; --warn: #ffd27a; --warn-bg: #352a10;
    --crit: #ff9a90; --crit-bg: #3a1714; --pause: #b8b8ff; --pause-bg: #23233a;
    --logo-house: #6ea2ff;
  }
}
:root[data-theme="dark"] {
  --bg: #161615; --card: #22221f; --text: #f0efe9; --muted: #b0afa8;
  --line: #3a3a36; --accent: #6ea2ff; --accent-text: #0b1a33;
  --ok: #7fd49a; --ok-bg: #18301f; --warn: #ffd27a; --warn-bg: #352a10;
  --crit: #ff9a90; --crit-bg: #3a1714; --pause: #b8b8ff; --pause-bg: #23233a;
  --logo-house: #6ea2ff;
}
form.theme-toggle, form.lang-toggle { margin-top: .9rem; display: inline-block; }
form.lang-toggle button { background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: .3rem .8rem; font-size: .85rem; font-weight: 500; border-radius: 1rem; }
form.theme-toggle button { background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: .3rem .8rem; font-size: .85rem; font-weight: 500; border-radius: 1rem; }
form.theme-toggle button span { margin-left: .2rem; }
* { box-sizing: border-box; }
html { font-size: 19px; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.5; }
header { background: var(--card); border-bottom: 1px solid var(--line); }
header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
header a.brand { font-weight: 700; font-size: 1.2rem; color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; gap: .5rem; }
svg.logo { width: 1.9rem; height: 1.9rem; flex: none; }
svg.logo .house { fill: var(--logo-house); stroke: var(--logo-house); }
svg.logo .light { fill: var(--logo-light); }
.hero-logo { display: flex; justify-content: center; margin: 1.5rem 0 .25rem; }
.hero-logo svg.logo { width: 4.5rem; height: 4.5rem; }
nav { display: flex; flex-wrap: wrap; gap: .25rem; }
nav a { padding: .5rem .75rem; border-radius: .5rem; color: var(--text); text-decoration: none; }
nav a.active, nav a:hover { background: var(--bg); }
.wrap { max-width: 46rem; margin: 0 auto; padding: 1rem; }
main.wrap { padding-bottom: 4rem; }
h1 { font-size: 1.6rem; margin: 1rem 0 .5rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 .5rem; }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
details.fold > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between;
  align-items: center; gap: 1rem; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; }
details.fold > summary .fold-state { margin-left: auto; display: flex; flex-wrap: wrap; gap: .3rem;
  justify-content: flex-end; }
details.fold > summary::after { content: "▸"; color: var(--accent); font-size: 1.3rem; }
details.fold[open] > summary::after { content: "▾"; }
details.fold[open] > summary { margin-bottom: .8rem; }
details.sub { border-top: 1px solid var(--line); padding: .1rem 0; }
details.sub > summary { list-style: none; display: flex; align-items: center; gap: 1rem; margin: .5rem 0; }
details.sub > summary::-webkit-details-marker { display: none; }
details.sub > summary h3 { margin: 0; font-size: 1.05rem; }
details.sub > summary .fold-state { margin-left: auto; display: flex; flex-wrap: wrap; gap: .3rem;
  justify-content: flex-end; }
details.sub > summary::after { content: "▸"; color: var(--accent); }
details.sub[open] > summary::after { content: "▾"; }
.handout { font-size: 1.15rem; background: var(--bg); border: 1px dashed var(--line); border-radius: .6rem;
           padding: .8rem 1rem; margin: .5rem 0; }
.handout dt { font-size: .9rem; color: var(--muted); margin-top: .4rem; }
.handout dd { margin: 0 0 .4rem; }
.copy { user-select: all; -webkit-user-select: all; word-break: break-all; font-weight: 600; }
.handout .pin { font-size: 1.6rem; letter-spacing: .15em; font-variant-numeric: tabular-nums; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: .9rem;
  padding: 1rem 1.25rem; margin: .75rem 0; }
.status { border-radius: .9rem; padding: 1.25rem; margin: 1rem 0; font-size: 1.15rem; }
.status strong { display: block; font-size: 1.4rem; }
.ok { background: var(--ok-bg); color: var(--ok); }
.warn { background: var(--warn-bg); color: var(--warn); }
.crit { background: var(--crit-bg); color: var(--crit); }
.pause { background: var(--pause-bg); color: var(--pause); }
.status ul { margin: .5rem 0 0; padding-left: 1.2rem; }
.btn, button { display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
  padding: .8rem 1.3rem; border-radius: .7rem; border: 2px solid var(--accent);
  background: var(--accent); color: var(--accent-text); text-decoration: none; margin: .25rem .25rem .25rem 0; }
.btn.secondary, button.secondary { background: transparent; color: var(--accent); }
/* feedback when pressed: a short colour change (tap highlight for touch screens, where :active is unreliable) */
.btn, button { transition: background-color .15s, filter .15s, transform .05s;
  -webkit-tap-highlight-color: rgba(31, 95, 191, .35); }
.btn:active, button:active { filter: brightness(.8); transform: translateY(1px); }
.btn.secondary:active, button.secondary:active { background: var(--accent); color: var(--accent-text); filter: none; }
.busy { display: flex; align-items: center; gap: 1rem; }
.busy p { margin: 0; }
.spinner { flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%;
  border: .3rem solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.btn.danger, button.danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.big, button.big { font-size: 1.15rem; padding: 1rem 1.6rem; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .6rem; }
.choices button { width: 100%; margin: 0; padding: 1.1rem .5rem; font-size: 1.1rem; }
.choices-links { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
label { display: block; font-weight: 600; margin: .9rem 0 .25rem; }
label .hint { display: block; font-weight: 400; color: var(--muted); font-size: .9rem; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=datetime-local], input[type=time], select { width: 100%; font: inherit; padding: .7rem .8rem; border-radius: .6rem;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
form.inline { display: inline; }
form.inline p { display: inline; margin: 0; }
button.small, .btn.small, form.inline button { padding: .3rem .7rem; font-size: .9rem; }
ul.plain { list-style: none; padding: 0; }
/* the person form: role choice, and only the fields of the chosen role (plain CSS :has, no JavaScript) */
.role-choice { display: block; margin: .35rem 0; }
.history-filter { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0 1rem;
  align-items: end; }
.history-filter p { grid-column: 1 / -1; margin: .3rem 0 0; }
fieldset.night { border: 1px solid var(--line); border-radius: .7rem; padding: .6rem 1rem; margin: .8rem 0; }
.night-times { display: flex; gap: 1rem; flex-wrap: wrap; }
.night-times > * { flex: 1 1 8rem; }
h2.people-group { font-size: 1rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  margin: 1.4rem 0 .4rem; }
.card.person { padding: .7rem 1rem; margin: .5rem 0; }
.card.person .row { margin: 0; flex-wrap: nowrap; align-items: center; }
.card.person .row .btn { flex: none; margin: 0 0 0 .6rem; }
.card.person .note { font-size: .9rem; margin: .15rem 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.chip { font-size: .85rem; padding: .12rem .6rem; border-radius: 1rem; border: 1px solid var(--line); }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.pause { background: var(--pause-bg); color: var(--pause); border-color: transparent; }
.chip.none { color: var(--muted); }

fieldset.role-admin, fieldset.role-viewer, fieldset.roles { border: 1px solid var(--line); border-radius: .7rem;
  padding: .6rem 1rem; margin: .8rem 0; }
form:has(input[name=role][value=notify]:checked) fieldset.role-admin,
form:has(input[name=role][value=notify]:checked) fieldset.role-viewer,
form:has(input[name=role][value=viewer]:checked) fieldset.role-admin,
form:has(input[name=role][value=admin]:checked) fieldset.role-viewer { display: none; }
.way { margin-bottom: .6rem; }
.way-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; margin: -.4rem 0 .4rem;
  font-size: .9rem; }
.way-actions label.inline { margin: 0; color: var(--muted); }
.way-actions button { margin: 0; }
.routine { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .5rem 0; border-bottom: 1px solid var(--line); }
.routine:last-child { border-bottom: 0; }
.routine input[type=time] { width: auto; display: inline-block; margin: 0 .3rem; }
.routine select, .routine input[type=text] { width: auto; max-width: 100%; display: inline-block; margin: .2rem 0; }
ul.plain li { margin: .45rem 0; }
label.inline { display: inline-flex; gap: .3rem; align-items: center; font-weight: 400; margin: .2rem .8rem .2rem 0; }
.viewer-absence { text-align: left; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .2rem 1rem; margin: .5rem 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 1rem; font-size: .85rem; font-weight: 600; }
.steps { padding-left: 1.4rem; }
.steps li { margin: .4rem 0; }
.steps li.done { color: var(--ok); }
details summary { cursor: pointer; font-weight: 600; margin: 1rem 0 .5rem; }
.big-number { font-size: 2.6rem; font-weight: 700; }
button.logout { margin: 0; padding: .45rem .8rem; }
footer a { color: var(--muted); }
.viewer-status { display: grid; justify-items: center; text-align: center; gap: .25rem; margin: 2rem 0 1rem; }
.viewer-status h1 { margin: 1rem 0 .25rem; }
.viewer-status p { margin: .1rem 0; font-size: 1.1rem; }
.viewer-status .status-symbol { width: 12rem; height: 12rem; max-width: 62vw; max-height: 62vw; }
.symbol-choices { display: flex; flex-wrap: wrap; gap: .6rem; }
.symbol-choice { display: grid; justify-items: center; gap: .2rem; font-weight: 400; margin: 0; padding: .5rem;
  border: 2px solid var(--line); border-radius: .8rem; cursor: pointer; width: 7rem; text-align: center; font-size: .85rem; }
.symbol-choice:has(input:checked) { border-color: var(--accent); }
.symbol-choice input { margin: 0; }
.symbol-choice .status-symbol { width: 4rem; height: 4rem; }
fieldset.usecases, fieldset.usecase-symbols { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
fieldset.usecases legend, fieldset.usecase-symbols legend { font-weight: 600; padding: 0; margin-bottom: .4rem; }
.usecase-choice { display: grid; grid-template-columns: auto 3rem 1fr; align-items: center; gap: .6rem;
  font-weight: 400; margin: 0 0 .5rem; padding: .5rem .7rem; border: 2px solid var(--line); border-radius: .8rem;
  cursor: pointer; }
.usecase-choice:has(input:checked) { border-color: var(--accent); }
.usecase-choice input { margin: 0; }
.usecase-choice .status-symbol { width: 3rem; height: 3rem; }
.usecase-choice span { min-width: 0; overflow-wrap: anywhere; }
.usecase-choice small { display: block; color: var(--muted); }
@supports selector(:has(*)) {
  .usecase-symbols { display: none; }
  form:has(#uc-care:checked) .uc-care { display: block; }
  form:has(#uc-pet:checked) .uc-pet { display: block; }
  form:has(#uc-holiday_home:checked) .uc-holiday_home { display: block; }
  form:has(#uc-own_home:checked) .uc-own_home { display: block; }
  form:has(#uc-site:checked) .uc-site { display: block; }
}
.viewer-status [class^="light-"] { width: 11rem; height: 11rem; border-radius: 50%; max-width: 60vw; max-height: 60vw;
  box-shadow: 0 0 0 .6rem var(--card), 0 0 0 calc(.6rem + 1px) var(--line); }
.light-green { background: var(--ok); }
.light-yellow { background: #e0a800; }
.light-red { background: var(--crit); }
.light-grey { background: var(--muted); opacity: .55; }
form.viewer-logout { display: flex; justify-content: center; margin-top: 2rem; }
footer nav.legal { display: flex; justify-content: center; flex-wrap: wrap; gap: .4rem 1.2rem; margin-top: .4rem; }
table.devices { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.devices th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; letter-spacing: .04em;
  text-transform: uppercase; padding: .3rem .5rem .3rem 0; border-bottom: 1px solid var(--line); }
table.devices td { padding: .55rem .5rem .55rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.devices tr:last-child td { border-bottom: 0; }
table.devices code { font-size: .85rem; color: var(--muted); }
/* phones: brand on its own line, the menu as a compact row of chips below */
@media (max-width: 40rem) {
  header .wrap { flex-direction: column; align-items: stretch; gap: .35rem; padding-top: .6rem; padding-bottom: .6rem; }
  header a.brand span { white-space: nowrap; }
  header nav { gap: .2rem; }
  header nav a { padding: .35rem .6rem; font-size: .92rem; background: var(--bg); }
  header nav form.inline { margin-left: auto; }
  button.logout { padding: .3rem .6rem; font-size: .9rem; }
}
/* phones: every table row becomes a small card, each value with its label */
@media (max-width: 40rem) {
  table.devices thead { display: none; }
  table.devices tr { display: block; padding: .6rem 0; border-bottom: 1px solid var(--line); }
  table.devices tr:last-child { border-bottom: 0; }
  table.devices td { display: block; padding: .1rem 0; border: 0; }
  table.devices td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 600; }
  table.devices td:empty { display: none; }
}
.table-scroll { overflow-x: auto; }
.legal-text h2 { font-size: 1.15rem; }
.legal-text p, .legal-text li { max-width: 65ch; }
footer { color: var(--muted); font-size: .85rem; text-align: center; padding: 2rem 1rem; }
