/* Domovik — "lantern-lit night watch": warm near-black, one lantern-amber accent,
   teal for healthy/OK, coral only for hazards. Fonts are bundled (CSP is 'self'). */

@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/bricolage-latin.woff2") format("woff2"); font-weight: 200 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/bricolage-latin-ext.woff2") format("woff2"); font-weight: 200 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C4, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; src: url("fonts/inter-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; src: url("fonts/inter-latin-ext.woff2") format("woff2"); font-weight: 100 900; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C4, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-latin.woff2") format("woff2"); font-weight: 100 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-latin-ext.woff2") format("woff2"); font-weight: 100 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C4, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: #121110;
  --side: #171513;
  --surface: #1B1916;
  --surface-2: #221F1B;
  --raised: #2A251F;
  --line: #26221E;
  --line-2: #3A342D;
  --input: #121110;
  --text: #F1ECE4;
  --text-2: #D9D2C7;
  --muted: #B8AFA3;
  --faint: #A39B8F;
  --accent: #F2A541;
  --accent-ink: #1A1206;
  --accent-soft: #2A2219;
  --accent-line: #4A3A24;
  --chip-text: #E9C894;
  --ok: #7FC8A9;
  --ok-soft: #17241F;
  --ok-line: #2E4A3F;
  --danger: #E8735F;
  --danger-ink: #1A0B08;
  --danger-soft: #2A1A17;
  --danger-line: #6B3329;
  --display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --r-lg: 22px;
  --r: 18px;
  --r-sm: 12px;
}

* { box-sizing: border-box; }

::selection { background: rgba(242, 165, 65, 0.35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2E2924; border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #3E3730; background-clip: content-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
/* The Android app (user agent "DomovikAndroid") gets a few different controls; see web/app.js. */
body:not(.in-app) .app-only,
body.in-app .web-only { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); }
.accent { color: var(--accent); }
.muted { color: var(--text-2); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- app shell ---------- */

.app { display: flex; height: 100vh; height: 100dvh; }

.sidebar {
  flex: 0 0 236px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 26px 16px 18px;
  background: var(--side);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px; }

.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-name { font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: -0.5px; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font: 500 14px var(--sans);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: #201D19; color: var(--text); }

.nav-item.active { background: var(--raised); color: var(--text); font-weight: 600; }

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item.active .nav-icon { stroke: var(--accent); }

.nav-label { flex-grow: 1; }

.badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.count { font-family: var(--mono); font-size: 12px; color: var(--faint); }

.side-status {
  margin-top: auto;
  padding: 14px 16px;
  border-radius: 16px;
  background: #1F1C18;
  border: 1px solid #2C2722;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-status-row { display: flex; align-items: center; gap: 10px; }
.side-state { font-weight: 600; }
.side-provider { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.side-quiet { font-size: 12px; color: var(--faint); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.ok { background: var(--ok); animation: pulse 2s ease-in-out infinite; }
.dot.error { background: var(--danger); box-shadow: 0 0 10px rgba(232, 115, 95, 0.6); }
.dot.idle { background: #6E665B; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(127, 200, 169, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(127, 200, 169, 0); }
}

.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; } /* min-height: lets main scroll in the stacked phone layout */

.topbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  padding: 28px 40px 20px;
}

.topbar-titles { flex-grow: 1; min-width: 0; }

.greet-line { color: var(--faint); font-size: 14px; }

.view-title {
  margin: 2px 0 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 38px;
  line-height: 1.1;
  letter-spacing: -1px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 999px;
  background: #1F1C18;
  border: 1px solid #2C2722;
}

#status-text {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.error-strip {
  flex-shrink: 0;
  margin: 0 40px 12px;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  color: #F3C9C0;
  font-size: 13px;
}

main { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }

.view { display: none; }

.view.active {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100%;
  padding: 4px 40px 36px;
  animation: rise 0.25s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.view-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.view-sub { color: var(--faint); margin-top: -8px; }

/* ---------- shared pieces ---------- */

.split { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.split-main { flex: 3 1 460px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.split-side { flex: 1 1 290px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.card {
  padding: 20px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-head { display: flex; align-items: center; gap: 8px; }
.card-head .card-label { flex-grow: 1; }

.card-label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--faint);
}

.card-title { margin: 0; font-family: var(--display); font-weight: 600; font-size: 20px; letter-spacing: -0.2px; }

.card-text { margin: 0; font-size: 15px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--raised);
  color: var(--chip-text);
  font-size: 12px;
}

.mini-list { display: flex; flex-direction: column; }

.mini-row { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.mini-row .mini-label { flex-grow: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .mini-age { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.mini-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); flex-shrink: 0; }
.mini-dot.critical { background: var(--danger); }
.mini-empty { color: var(--faint); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--text);
  font: 600 14px var(--sans);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, filter 0.15s;
}

.btn:hover { background: #241F1A; border-color: #4A433B; }

a.btn { text-decoration: none; }

.btn.primary { border: none; background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: default; }

.card > .btn { align-self: flex-start; }

.link-btn {
  min-height: 32px;
  padding: 0 4px;
  border: none;
  background: none;
  color: var(--accent);
  font: 500 13px var(--sans);
  cursor: pointer;
}

.link-btn:hover { text-decoration: underline; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}

.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ---------- setup checklist ---------- */

.setup-card { padding: 8px; gap: 0; }

.setup-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.setup-title { flex: 1; font-family: var(--display); font-weight: 600; font-size: 17px; }
.setup-count { font-family: var(--mono); font-size: 12px; color: var(--faint); }

.setup-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 2px; padding-top: 6px; }

.setup-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font: 500 14px var(--sans);
  text-align: left;
  cursor: pointer;
}

.setup-row:hover { background: var(--surface-2); }

.setup-check { width: 20px; height: 20px; border-radius: 50%; border: 1.8px solid #5A5148; flex-shrink: 0; position: relative; }
.setup-row.done .setup-check { background: var(--ok); border-color: transparent; }
.setup-row.done .setup-check::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2.6px;
  width: 5px;
  height: 9px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}
.setup-label { flex: 1; }
.setup-row.done .setup-label { color: var(--faint); text-decoration: line-through; }
.setup-chevron { color: var(--faint); font-size: 18px; line-height: 1; }

/* ---------- live ---------- */

.stream-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  max-height: calc(100vh - 210px);
  min-height: 220px;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: repeating-linear-gradient(135deg, #0D0C0B 0 14px, #100F0D 14px 28px);
  border: 1px solid #2A2520;
  display: flex;
  align-items: center;
  justify-content: center;
}

#stream-img { width: 100%; height: 100%; object-fit: contain; display: block; }

.stream-offline {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(13, 12, 11, 0.82);
  color: var(--faint);
  font-size: 14px;
}

.live-tag,
.live-task-badge {
  position: absolute;
  top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(18, 17, 16, 0.8);
  font-size: 12px;
}

.live-tag { left: 16px; font-weight: 600; letter-spacing: 1px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.live-task-badge { right: 16px; color: var(--text-2); }

.live-caption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(18, 17, 16, 0.86);
  font-size: 14px;
}

.live-caption .mono { font-size: 12px; flex-shrink: 0; }

/* ---------- chat ---------- */

.seg { display: flex; padding: 4px; gap: 4px; border-radius: 14px; background: #1F1C18; border: 1px solid #2C2722; }

.seg-btn {
  min-height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--faint);
  font: 600 13.5px var(--sans);
  cursor: pointer;
}

.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: #2F2923; color: var(--text); }

.chat-pane {
  padding: 18px;
  gap: 14px;
  background: var(--side);
  height: calc(100vh - 230px);
  min-height: 380px;
}

.chat-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px; }
.chat-log:empty { display: none; }

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 440px;
  margin: 0 auto;
  padding: 30px 20px;
  text-align: center;
  color: var(--muted);
}

.msg {
  max-width: 74%;
  padding: 11px 15px 8px;
  border-radius: 18px 18px 18px 6px;
  background: var(--surface-2);
  border: 1px solid transparent;
  animation: rise 0.2s ease both;
}

.msg-text { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-time { margin-top: 2px; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }

.msg-assistant { align-self: flex-start; }

.msg-user {
  align-self: flex-end;
  border-radius: 18px 18px 6px 18px;
  background: var(--accent);
  color: var(--accent-ink);
}

.msg-user .msg-time { color: rgba(26, 18, 6, 0.7); }

.msg-kind {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.msg-kind svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.msg-remark { background: var(--accent-soft); border-color: var(--accent-line); }
.msg-remark .msg-kind { color: var(--accent); }

.msg-health { background: var(--ok-soft); border-color: var(--ok-line); }
.msg-health .msg-kind { color: var(--ok); }

.msg-followup { border-color: var(--line-2); }

.msg-re {
  margin-bottom: 6px;
  padding-left: 10px;
  border-left: 2px solid #5A5148;
  font-size: 12px;
  color: var(--faint);
  overflow-wrap: anywhere;
}

.msg-system {
  align-self: center;
  max-width: 92%;
  border-radius: 14px;
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: #F3C9C0;
  font-size: 13px;
}

.msg-system .msg-text { font-size: 13px; }

.msg-typing .msg-text { color: var(--muted); font-style: italic; }

.chat-watch {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px dashed #4A433B;
  font-size: 13px;
  color: var(--muted);
}

.chat-watch svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chat-form { display: flex; gap: 10px; flex-shrink: 0; }
.chat-form input { flex: 1; min-width: 0; min-height: 48px; font-size: 15px; }
.chat-form .btn { min-height: 48px; padding: 0 22px; }

.memory-list { display: flex; flex-direction: column; gap: 12px; }
.memory-item-label { font-weight: 600; }
.memory-item-times { font-family: var(--mono); font-size: 12px; color: var(--faint); }

.reports-pane { display: flex; flex-direction: column; gap: 12px; }
.report-list { display: flex; flex-direction: column; gap: 10px; }

.report-card { padding: 14px 18px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.report-time { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.report-summary { margin-top: 2px; font-size: 15px; }
.report-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.report-chip { padding: 3px 10px; border-radius: 999px; background: var(--raised); color: var(--chip-text); font-size: 12px; }

/* ---------- tasks ---------- */

.task-list { display: flex; flex-direction: column; gap: 14px; max-width: 900px; }

.task-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 20px;
  padding: 20px 24px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.task-card.sev-critical { background: var(--danger-soft); border-color: var(--danger-line); }

.task-body { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.task-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.task-label { margin: 0; font-size: 18px; font-weight: 600; }

.sev-badge {
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--danger);
  color: var(--danger-ink);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
}

.task-detail { margin: 0; color: var(--muted); }
.task-card.sev-critical .task-detail { color: #E3C4BC; }
.task-meta { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.task-card.sev-critical .task-meta { color: #C9A69D; }

.nag { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.nag-label { font-size: 12px; color: var(--faint); }
.nag-meter { display: flex; gap: 4px; }
.nag-seg { width: 18px; height: 6px; border-radius: 3px; background: var(--line-2); }
.nag-seg.on { background: var(--accent); }

.done-btn svg { width: 16px; height: 16px; fill: none; stroke: var(--ok); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.task-card.sev-critical .done-btn { border: none; background: var(--danger); color: var(--danger-ink); }
.task-card.sev-critical .done-btn svg { stroke: var(--danger-ink); }

.completed { max-width: 900px; }

.completed summary {
  margin: 8px 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--faint);
  cursor: pointer;
}

.done-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-radius: 16px;
  background: #161412;
  border: 1px solid #221F1B;
}

.done-card svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: var(--ok); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.done-card .done-label { flex-grow: 1; color: var(--muted); text-decoration: line-through; }
.done-card .done-meta { font-family: var(--mono); font-size: 12px; color: var(--faint); }

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 60px 24px;
  text-align: center;
}

.empty-orb {
  width: 72px;
  height: 72px;
  margin-bottom: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ok-soft);
  border: 1px solid var(--ok-line);
}

.empty-orb svg { width: 32px; height: 32px; fill: none; stroke: var(--ok); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.empty-title { font-family: var(--display); font-weight: 700; font-size: 24px; }
.empty-sub { color: var(--muted); }

/* ---------- settings ---------- */

.settings-grid { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.settings-card { flex: 1 1 400px; min-width: 0; padding: 24px; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-weight: 500; }
.field.inline { flex-direction: row; align-items: center; gap: 14px; }
.field.inline > label { flex-grow: 1; }

.label-row { display: flex; align-items: baseline; }
.label-row label { flex-grow: 1; font-weight: 500; }

.hint { color: var(--faint); font-size: 12.5px; font-weight: 400; }
.hint.block { display: block; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row input[type="text"],
.row input[type="password"] { flex: 1; min-width: 0; }
.row.wrap { flex-wrap: wrap; }

.test-preview {
  display: block;
  width: 100%;
  max-width: 320px;
  margin-top: 4px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
}

select,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"] {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--input);
  color: var(--text);
  font: 14px var(--sans);
  color-scheme: dark;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input.mono { font-family: var(--mono); font-size: 13px; }

input[type="number"] { width: 84px; padding: 0 10px; flex-shrink: 0; }

select { cursor: pointer; }

select:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="time"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(242, 165, 65, 0.18);
}

input::placeholder { color: #7A7266; }

.switch-row { display: flex; align-items: center; gap: 14px; min-height: 44px; cursor: pointer; }
.switch-row > span:first-child { flex-grow: 1; }
.switch-title { display: block; font-weight: 500; }

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: 13px;
  background: var(--line-2);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}

input[type="checkbox"]:checked { background: var(--accent); }
input[type="checkbox"]:checked::before { transform: translateX(18px); background: var(--accent-ink); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
  --fill: 100%;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) 0 var(--fill), var(--line-2) var(--fill) 100%);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--accent);
}

.thresholds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.thresholds label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--faint); }
.thresholds input[type="number"] { width: 100%; }

.time-field { flex: 1 1 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--faint); }

.save-row { display: flex; align-items: center; gap: 14px; padding-bottom: 4px; }

/* ---------- notes (Chat side panel) ---------- */

.note-row { display: flex; align-items: flex-start; gap: 8px; }
.note-text { flex-grow: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.note-remove { flex-shrink: 0; }

/* ---------- devices & pairing ---------- */

.device-list { display: flex; flex-direction: column; }
.device-row { display: flex; align-items: center; gap: 12px; min-height: 56px; border-top: 1px solid var(--line); }
.device-row:first-child { border-top: none; }
.device-text { flex-grow: 1; min-width: 0; }
.device-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-meta { color: var(--faint); font-size: 12.5px; }

.pair-code {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}
.pair-code-value { font-size: 26px; font-weight: 600; letter-spacing: 3px; color: var(--accent); }

.pair-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: var(--bg);
  overflow-y: auto;
}
.pair-box { width: 100%; max-width: 420px; padding: 28px; gap: 16px; }
.pair-box .btn { align-self: stretch; text-align: center; }
.pair-mark { width: 44px; height: 44px; }
.pair-box code { font-family: var(--mono); font-size: 13px; color: var(--chip-text); }

/* ---------- narrow windows ---------- */

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { flex: 0 0 auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 14px; border-right: none; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand-name { display: none; }
  .nav { flex-direction: row; }
  .nav-item { padding: 0 10px; }
  .side-status { display: none; }
  .topbar { padding: 18px 20px 14px; }
  .view.active { padding: 4px 20px 24px; }
  .error-strip { margin: 0 20px 10px; }
  .view-title { font-size: 30px; }
  .chat-pane { height: calc(100vh - 260px); height: calc(100dvh - 260px); }
}

/* ---------- phones: bottom tab bar ---------- */

@media (max-width: 640px) {
  body { font-size: 15px; }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-bottom: none;
    border-top: 1px solid var(--line);
    background: rgba(23, 21, 19, 0.96);
    overflow: visible;
  }
  .brand { display: none; }
  .nav { flex: 1; justify-content: space-around; gap: 0; }
  .nav-item {
    position: relative;
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    padding: 4px 0;
    font-size: 11.5px;
    text-align: center;
  }
  .nav-item.active { background: transparent; color: var(--accent); }
  .nav-icon { width: 23px; height: 23px; }
  .nav-label { flex-grow: 0; }
  .nav-item .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; }
  .nav-item .count { position: absolute; top: 4px; left: calc(50% + 10px); font-size: 10.5px; }

  main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .topbar { padding: calc(14px + env(safe-area-inset-top)) 16px 10px; gap: 10px; }
  .view-title { font-size: 28px; }
  .status-pill { width: 100%; padding: 8px 14px; }
  .error-strip { margin: 0 16px 10px; }
  .view.active { padding: 2px 16px 20px; gap: 16px; }

  .split { gap: 16px; }
  .split-main, .split-side { flex-basis: 100%; }
  .stream-wrap { min-height: 0; max-height: none; border-radius: var(--r); }
  .live-tag, .live-task-badge { top: 10px; }
  .live-tag { left: 10px; }
  .live-task-badge { right: 10px; }
  .live-caption { left: 10px; right: 10px; bottom: 10px; padding: 9px 12px; font-size: 13px; }

  .chat-pane { padding: 12px; height: calc(100dvh - 300px - env(safe-area-inset-bottom)); min-height: 320px; }
  .msg { max-width: 86%; }
  .chat-form .btn { padding: 0 16px; }

  .task-card { padding: 16px 18px; gap: 12px 16px; }
  .task-body { flex-basis: 100%; }
  .nag { align-items: flex-start; }
  .done-card { padding: 12px 16px; }

  .settings-card { flex-basis: 100%; padding: 18px; }
  .setup-list { grid-template-columns: 1fr; }
}
