:root {
  --bg: #101014;
  --bg2: #191921;
  --card: #1e1e28;
  --card2: #26263280;
  --line: #2e2e3c;
  --text: #ececf1;
  --muted: #9a9aad;
  --accent: #b48ce8;   /* soft lavender — Truffle */
  --accent2: #7ec8a9;  /* mossy green */
  --ok: #7ec8a9;
  --warn: #e8c56a;
  --bad: #e88a8a;
  --info: #8ab4e8;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
/* Installed-PWA safe area: viewport-fit=cover lets the web view run under the
   status bar / Dynamic Island, so the content must carry the top inset itself. */
main { padding: calc(16px + env(safe-area-inset-top)) 16px 8px; max-width: 560px; margin: 0 auto; }
/* The offline banner already clears the status bar — don't inset twice. */
.offline-banner:not(.hidden) ~ main { padding-top: 16px; }
h1 { font-size: 26px; margin: 8px 0 2px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

.offline-banner {
  background: #4a3b17; color: #f0d9a0; text-align: center;
  padding: 8px 12px; font-size: 13px;
  padding-top: calc(8px + env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 30;
}
.hidden { display: none !important; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.stat-value small { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.delta-up { color: var(--ok); }
.delta-down { color: var(--bad); }
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.pill.ok { background: #23392f; color: var(--ok); }
.pill.low, .pill.high { background: #402f2f; color: var(--bad); }
.pill.blue { background: #2a3446; color: var(--info); }

.env-row { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; }
.env-row + .env-row { border-top: 1px solid var(--line); }
.env-name { color: var(--muted); font-size: 14px; }
.env-val { font-size: 17px; font-weight: 600; }
.env-val.ok { color: var(--ok); }
.env-val.low, .env-val.high { color: var(--bad); }

/* Alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; }
.alert + .alert { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; }
.alert-dot.alert { background: var(--bad); }
.alert-dot.watch { background: var(--warn); }
.alert-dot.info { background: var(--info); }
.alert-title { font-weight: 600; font-size: 15px; }
.alert-detail { color: var(--muted); font-size: 13.5px; margin-top: 2px; line-height: 1.4; }

/* Chart */
.chart-wrap { margin-top: 8px; }
svg.chart { width: 100%; height: auto; display: block; }

/* Log type grid */
.logtype-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.logtype {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 12px; text-align: center; color: var(--text);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.logtype .lt-icon { display: block; font-size: 30px; margin-bottom: 8px; }
.logtype:active { background: var(--bg2); }

/* Wizard */
.wizard {
  position: fixed; inset: 0; background: var(--bg); z-index: 40;
  display: flex; flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
}
.wiz-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.wiz-cancel { background: none; border: none; color: var(--muted); font-size: 16px; padding: 8px; cursor: pointer; }
.wiz-progress { display: flex; gap: 6px; }
.wiz-progress i { width: 22px; height: 4px; border-radius: 2px; background: var(--line); }
.wiz-progress i.done { background: var(--accent); }
.wiz-q { font-size: 24px; font-weight: 700; margin: 20px 0 4px; }
.wiz-hint { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.wiz-body { flex: 1; overflow-y: auto; }
.choice-list { display: flex; flex-direction: column; gap: 10px; }
.choice, .tagchip {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  color: var(--text); padding: 16px; font-size: 17px; font-weight: 600;
  text-align: left; cursor: pointer; width: 100%;
}
.choice:active { background: var(--bg2); }
.choice .choice-sub { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.choice.selected, .tagchip.selected { border-color: var(--accent); background: #2a2337; }
.tag-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.tagchip { width: auto; padding: 10px 14px; font-size: 15px; border-radius: 999px; }
.wiz-input {
  width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; color: var(--text); font-size: 28px; font-weight: 700;
  padding: 14px 16px; outline: none;
}
.wiz-input:focus { border-color: var(--accent); }
textarea.wiz-input { font-size: 17px; font-weight: 400; min-height: 110px; resize: none; font-family: inherit; }
.wiz-unit { color: var(--muted); font-size: 15px; margin-top: 6px; }
.wiz-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1; border: none; border-radius: 14px; padding: 16px; font-size: 17px;
  font-weight: 700; cursor: pointer;
}
.btn-primary { background: var(--accent); color: #17111f; }
.btn-primary:disabled { opacity: .35; }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); flex: 0 0 auto; padding: 16px 18px; }

/* History */
.hist-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.hist-icon { font-size: 22px; flex: 0 0 auto; margin-top: 1px; }
.hist-main { flex: 1; min-width: 0; }
.hist-title { font-weight: 600; font-size: 15px; }
.hist-sub { color: var(--muted); font-size: 13px; margin-top: 1px; overflow-wrap: break-word; }
.hist-date { color: var(--muted); font-size: 12px; flex: 0 0 auto; text-align: right; }
.hist-del { background: none; border: none; color: var(--muted); font-size: 15px; padding: 4px 6px; cursor: pointer; }
.queued-badge { color: var(--warn); font-size: 11px; font-weight: 700; }

/* Settings */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); font-size: 16px; padding: 12px 14px; outline: none; font-family: inherit;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }
.btn.small { padding: 12px; font-size: 15px; }
.settings-status { font-size: 13.5px; margin-top: 10px; color: var(--muted); }
.settings-status.ok { color: var(--ok); }
.settings-status.bad { color: var(--bad); }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: rgba(20, 20, 28, .92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 11px; font-weight: 600; padding: 8px 0 10px; cursor: pointer;
}
.tab .tab-icon { display: block; font-size: 22px; margin-bottom: 2px; }
.tab.active { color: var(--accent); }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(86px + env(safe-area-inset-bottom));
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 10px 18px; font-size: 14.5px; font-weight: 600;
  z-index: 50; max-width: 88vw; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.empty { text-align: center; color: var(--muted); padding: 34px 20px; }
.empty .empty-icon { font-size: 40px; display: block; margin-bottom: 10px; }
