/* Watchdog PWA. Calm guardian, not a dashboard. Light tokens on :root, dark
   overrides only in the media query. */
:root {
  --bg: #FAF9F6;
  --surface: #FFFFFF;
  --surface-2: #F1F0EA;
  --text: #1F241F;
  --muted: #6B7265;
  --border: #E3E1D8;
  --accent: #33604A;
  --accent-contrast: #FFFFFF;
  --ok: #2E7D4F;
  --ok-bg: #E4F0E7;
  --warn: #8F6410;
  --warn-bg: #F5EBD3;
  --down: #A93B31;
  --down-bg: #F6E2DF;
  --shadow: 0 1px 3px rgba(31, 36, 31, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10130F;
    --surface: #1A1F19;
    --surface-2: #232922;
    --text: #E8E9E2;
    --muted: #969D91;
    --border: #2E352D;
    --accent: #8FBF9F;
    --accent-contrast: #10130F;
    --ok: #7CC79A;
    --ok-bg: #1D3226;
    --warn: #D9B25E;
    --warn-bg: #35301C;
    --down: #E08A7F;
    --down-bg: #3A231F;
    --shadow: none;
  }
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 20px 14px;
}
.topbar .mark { width: 26px; height: 26px; color: var(--accent); }
.topbar h1 { font-size: 20px; font-weight: 600; letter-spacing: 0.01em; flex: 1; }
.iconbtn { padding: 8px; border-radius: 10px; color: var(--muted); }
.iconbtn svg { width: 22px; height: 22px; display: block; }
.iconbtn:active { background: var(--surface-2); }
.iconbtn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  display: flex; align-items: center; gap: 12px;
  margin: 0 16px 12px; padding: 12px 16px;
  background: var(--down-bg); color: var(--down);
  border-radius: 12px; font-size: 15px;
}
.banner span { flex: 1; }
.banner button { font-weight: 600; color: var(--down); text-decoration: underline; }
.banner[hidden] { display: none; }

main { padding: 0 16px; }
.tab[hidden] { display: none; }

.cards { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px 18px; box-shadow: var(--shadow);
}
.card.tappable { cursor: pointer; }
.card .row { display: flex; align-items: center; gap: 10px; }
.card h3 { font-size: 19px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.card .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--muted); opacity: 0.5; }

.badge {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); flex: none;
}
.pill {
  display: inline-block; font-size: 13px; font-weight: 600;
  padding: 4px 12px; border-radius: 999px;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.degraded { background: var(--warn-bg); color: var(--warn); }
.pill.down { background: var(--down-bg); color: var(--down); }

.detail { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.detail .facts { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.detail .facts .muted { font-size: 14px; }
.alertrow { display: flex; gap: 8px; align-items: baseline; padding: 7px 0; font-size: 14px; }
.alertrow + .alertrow { border-top: 1px solid var(--border); }
.alertrow .badge { text-transform: none; letter-spacing: 0; }
.alertrow .sum { flex: 1; min-width: 0; }
.alertrow .age { color: var(--muted); flex: none; font-size: 13px; }

.empty { text-align: center; color: var(--muted); padding: 56px 20px; }
.empty .big { font-size: 22px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

.thread { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.msg { max-width: 88%; border-radius: 16px; padding: 10px 14px; font-size: 15px; }
.msg.q { align-self: flex-end; background: var(--accent); color: var(--accent-contrast); border-bottom-right-radius: 4px; }
.msg.a { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.a p { margin: 0 0 8px; }
.msg.a p:last-child { margin-bottom: 0; }
.msg.a pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; background: var(--surface-2); border-radius: 8px;
  padding: 8px 10px; margin: 0 0 8px; overflow-x: auto;
}
.msg.a pre:last-child { margin-bottom: 0; }
.pending { display: inline-flex; gap: 5px; padding: 4px 0; }
.pending i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: pulse 1.2s ease-in-out infinite;
}
.pending i:nth-child(2) { animation-delay: 0.2s; }
.pending i:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

.hint { color: var(--muted); font-size: 13px; margin: 10px 2px 12px; }
.composer {
  position: fixed; bottom: calc(64px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; padding: 10px 16px;
  display: flex; gap: 10px; background: var(--bg);
}
.composer button {
  flex: none; width: 48px; border-radius: 12px;
  background: var(--accent); color: var(--accent-contrast);
}
.composer button svg { width: 20px; height: 20px; display: block; margin: 0 auto; }
#tab-ask { padding-bottom: 78px; }

.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbtn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 0 8px; color: var(--muted); font-size: 12px; font-weight: 500;
}
.tabbtn svg { width: 24px; height: 24px; }
.tabbtn.active { color: var(--accent); }

.scrim {
  position: fixed; inset: 0; background: rgba(16, 19, 15, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.scrim[hidden] { display: none; }
.sheet {
  background: var(--surface); width: 100%; max-width: 520px;
  border-radius: 20px 20px 0 0; padding: 24px 20px calc(28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}
.sheet h2 { font-size: 22px; font-weight: 600; }
.sheet label { font-size: 14px; font-weight: 600; margin-top: 6px; }
.sheet .primary {
  margin-top: 10px; background: var(--accent); color: var(--accent-contrast);
  border-radius: 12px; padding: 14px; font-weight: 600; font-size: 16px;
}
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--down); font-size: 14px; }
