[hidden] { display: none !important; }
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1d2329;
  --muted: #5d6873;
  --line: #d8dde2;
  --accent: #b85c1e;
  --accent-text: #ffffff;
  --on: #e8a33d;
  --on-text: #2a1a00;
  --bad: #b3261e;
  --bad-bg: #fde7e5;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181c;
    --card: #1d2329;
    --text: #e8ebee;
    --muted: #9aa5b0;
    --line: #313a43;
    --accent: #e08a4c;
    --accent-text: #1a0d03;
    --on: #f0b354;
    --on-text: #2a1a00;
    --bad: #ff8a80;
    --bad-bg: #3b1714;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; max-width: 760px; margin: 0 auto;
}
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
main { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.narrow { max-width: 420px; margin: 40px auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.row:last-child { margin-bottom: 0; }
.row.end { justify-content: flex-end; }
button {
  font: inherit; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); padding: 12px 14px; cursor: pointer;
  min-height: 48px;
}
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: none; color: var(--accent); padding: 8px; min-height: 0; }
button.wide { width: 100%; }
.light { text-align: left; display: flex; flex-direction: column; gap: 2px; }
.light small { color: var(--muted); }
.light.on { background: var(--on); color: var(--on-text); border-color: var(--on); }
.light.on small { color: var(--on-text); opacity: .8; }
.groups { margin-bottom: 14px; }
.group { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: none; }
.group span { flex: 1; }
.group button { min-width: 64px; min-height: 40px; padding: 8px 12px; }
.status { margin: 0 0 12px; }
.device { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.device:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.device h3 { margin: 0 0 4px; font-size: 1rem; }
.sensors { list-style: none; margin: 0; padding: 0; }
.sensors li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sensors li:last-child { border-bottom: none; }
.pill { font-size: .85rem; padding: 2px 10px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); }
.pill.on { background: var(--on); color: var(--on-text); border-color: var(--on); }
.banner { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; font-weight: 600; }
.msg { color: var(--bad); min-height: 1.4em; margin: 12px 0 0; }
label { display: block; margin-bottom: 12px; color: var(--muted); }
input, select {
  display: block; width: 100%; margin-top: 4px; font: inherit; padding: 10px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.setpoint { display: flex; align-items: center; gap: 10px; }
.setpoint strong { font-size: 1.5rem; min-width: 4ch; text-align: center; }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); max-width: 360px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.muted { color: var(--muted); }
.people { list-style: none; margin: 0 0 8px; padding: 0; }
.people li { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.people li .row { margin: 4px 0 0; }
.invite h3 { margin: 8px 0 10px; font-size: 1rem; }
button.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
button.danger { color: var(--bad); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; margin: 0; }
.msg.ok { color: var(--muted); }
.linkbox { word-break: break-all; user-select: all; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: .85rem; }
.window { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.window[hidden] { display: none; }
.window input { width: 100%; min-width: 0; box-sizing: border-box; }
.table-wrap { overflow-x: auto; margin-bottom: 10px; }
table.log { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.log th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
table.log td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.log td:first-child { white-space: nowrap; color: var(--muted); }
table.log tr.bad td:last-child { color: var(--bad); }
.guest { color: var(--accent); }

/* header button: Settings / Done */
.nav { background: none; border: 1px solid var(--line); color: inherit; border-radius: 999px;
       padding: 6px 14px; font: inherit; font-size: .95rem; cursor: pointer; }
#settings #logout { margin-top: 4px; }
button.primary:disabled { background: var(--line); border-color: var(--line); color: var(--muted); }
