/* --- Typography (Bunny Fonts — GDPR-friendly, no Google dependency) --- */
@import url('https://fonts.bunny.net/css?family=inter:400,500,600,700|jetbrains-mono:400,500');

/* --- Tokens — OKLCH, warm neutral hue, equal-L status colors --- */
:root {
  color-scheme: dark light;

  /* Hue: 70 = warm neutral (Linear/Notion Calendar warm gray). */
  --h-surface: 70;

  /* Surfaces — dark-first */
  --surface-0: oklch(12% 0.008 var(--h-surface));
  --surface-1: oklch(17% 0.010 var(--h-surface));
  --surface-2: oklch(22% 0.012 var(--h-surface));
  --surface-3: oklch(28% 0.015 var(--h-surface));

  --border-subtle: oklch(100% 0 0 / 0.06);
  --border-card:   oklch(100% 0 0 / 0.10);

  /* Text — weight × opacity, not size, does the hierarchy */
  --text-primary:   oklch(95% 0.005 var(--h-surface));
  --text-secondary: oklch(72% 0.010 var(--h-surface));
  --text-muted:     oklch(52% 0.015 var(--h-surface));
  --text-dim:       oklch(36% 0.015 var(--h-surface));

  /* Status — hold L ≈ 70-76 so tiles don't compete for attention */
  --status-ok:    oklch(76% 0.170 150);
  --status-warn:  oklch(80% 0.150  85);
  --status-error: oklch(66% 0.220  25);
  --status-idle:  oklch(68% 0.150 265);

  --glow-ok:    oklch(76% 0.170 150 / 0.28);
  --glow-warn:  oklch(80% 0.150  85 / 0.32);
  --glow-error: oklch(66% 0.220  25 / 0.28);
  --glow-idle:  oklch(68% 0.150 265 / 0.18);

  /* 3-variable theme (Linear pattern) — downstream tokens derive from these */
  --base:     var(--surface-0);
  --accent:   var(--status-ok);
  --contrast: var(--text-primary);

  /* Concentric radii — inner = outer - 4px */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Typography stacks */
  --font-ui:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
}

/* Light mode — warm off-white surface; same hue axis, inverted L. */
@media (prefers-color-scheme: light) {
  :root {
    --surface-0: oklch(98% 0.005 var(--h-surface));
    --surface-1: oklch(96% 0.006 var(--h-surface));
    --surface-2: oklch(93% 0.008 var(--h-surface));
    --surface-3: oklch(89% 0.010 var(--h-surface));

    --border-subtle: oklch(0% 0 0 / 0.06);
    --border-card:   oklch(0% 0 0 / 0.10);

    --text-primary:   oklch(18% 0.010 var(--h-surface));
    --text-secondary: oklch(38% 0.010 var(--h-surface));
    --text-muted:     oklch(55% 0.012 var(--h-surface));
    --text-dim:       oklch(70% 0.010 var(--h-surface));
  }
}

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--base);
  color: var(--contrast);
  font-family: var(--font-ui);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 28px;
  min-height: 100vh;
}

/* Numeric cells default to mono for tabular alignment. */
.mono, .num, .oom-badge, .eval-big-num, .eval-counter-val, .eval-score-val,
.metric-label, .dl-date, .task-prio, .task-meta, .load-item {
  font-family: var(--font-mono);
}

/* --- Header — title left, view tabs center, hint + dot right --- */
.header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin: 0 auto 28px;
  max-width: 1400px;
}
.header h1 {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 6px;
  font-weight: 500;
  font-family: var(--font-mono);
  justify-self: start;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: end;
}

/* View tabs — shadcn-inspired pill row; active has accent line. */
.view-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border-subtle);
  border-radius: calc(var(--radius-md) + 2px);
  background: var(--surface-1);
}
.view-tab {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 150ms ease, color 150ms ease;
}
.view-tab:hover { color: var(--text-primary); background: var(--surface-2); }
.view-tab.active {
  color: var(--contrast);
  background: var(--surface-3);
  box-shadow: 0 0 0 1px var(--border-card) inset;
}
.kbd-chord {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 400;
}

/* Help button */
.kbd-hint {
  border: 1px solid var(--border-subtle);
  background: var(--surface-1);
  color: var(--text-secondary);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 11px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 150ms, border-color 150ms;
}
.kbd-hint:hover { color: var(--text-primary); border-color: var(--border-card); }

/* Conn dot — 8px per SOTA spec, 5 states */
.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s, box-shadow 0.3s;
}
.conn-dot.connected { background: var(--status-ok);    box-shadow: 0 0 6px var(--glow-ok); }
.conn-dot.stale     { background: var(--status-warn);  box-shadow: 0 0 6px var(--glow-warn); }
.conn-dot.error     { background: var(--status-error); box-shadow: 0 0 6px var(--glow-error); }

/* Views — hide inactive via [hidden] */
.view[hidden] { display: none; }
.tile-empty {
  color: var(--text-dim);
  font-size: 11px;
  padding: 12px 0;
  text-align: center;
}

/* --- Ask drawer (⌘/) — slides in from the right --- */
.ask-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 90vw);
  background: var(--surface-1);
  border-left: 1px solid var(--border-card);
  box-shadow: -20px 0 60px oklch(0% 0 0 / 0.4);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transform: translateX(0);
  transition: transform 220ms ease;
}
.ask-drawer[hidden] { display: flex; transform: translateX(100%); pointer-events: none; }
.ask-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.ask-title {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text-muted);
  font-weight: 600;
}
.ask-meta { flex: 1; font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }
.ask-close {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  width: 24px; height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.ask-close:hover { color: var(--text-primary); background: var(--surface-2); }
.ask-response {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ask-response.loading { color: var(--text-muted); font-style: normal; }
.ask-response.error   { color: var(--status-error); }
.ask-response.empty   { color: var(--text-dim); }

.ask-loading-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-primary);
}
.ask-loading-text { flex: 1; }
.ask-elapsed {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
}
.ask-loading-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.ask-cancel {
  margin-top: 14px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font: inherit;
  font-size: 11px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 150ms, border-color 150ms;
}
.ask-cancel:hover { color: var(--status-error); border-color: var(--status-error); }

.ask-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-card);
  border-top-color: var(--status-idle);
  border-radius: 50%;
  animation: ask-spin 0.9s linear infinite;
  flex-shrink: 0;
}
@keyframes ask-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .ask-spinner { animation: none; border-top-color: var(--border-card); }
}
.ask-form {
  border-top: 1px solid var(--border-subtle);
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ask-form textarea {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  resize: vertical;
  min-height: 54px;
  max-height: 200px;
  transition: border-color 150ms;
}
.ask-form textarea:focus { border-color: var(--status-idle); }
.ask-actions { display: flex; justify-content: space-between; align-items: center; }
.ask-hint { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); }
.ask-form button {
  background: var(--status-idle);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--contrast);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 16px;
  transition: background 150ms;
}
.ask-form button:hover { background: var(--status-ok); color: var(--surface-0); }
.ask-form button:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Command palette --- */
.palette {
  border: 1px solid var(--border-card);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 560px;
  width: calc(100% - 32px);
  margin-top: 12vh;
  box-shadow: 0 20px 60px oklch(0% 0 0 / 0.5);
}
.palette::backdrop {
  background: color-mix(in oklab, var(--surface-0) 70%, transparent);
  backdrop-filter: blur(6px);
}
.palette-body { display: flex; flex-direction: column; }
.palette-input {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  padding: 16px 20px;
  outline: none;
}
.palette-input::placeholder { color: var(--text-muted); }
.palette-list {
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px;
}
.palette-section {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 10px 14px 4px;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.palette-item:hover { background: var(--surface-2); color: var(--text-primary); }
.palette-item.focused {
  background: var(--surface-3);
  color: var(--contrast);
  box-shadow: 0 0 0 1px var(--border-card) inset;
}
.palette-item-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item-hint { color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; }
.palette-item-meta { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }
.palette-empty { padding: 24px; text-align: center; color: var(--text-dim); font-size: 11px; }
.palette-foot {
  border-top: 1px solid var(--border-subtle);
  padding: 10px 14px;
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  gap: 4px;
  align-items: center;
}

/* --- Shortcuts dialog --- */
.shortcuts {
  border: 1px solid var(--border-card);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
}
.shortcuts::backdrop {
  background: color-mix(in oklab, var(--surface-0) 80%, transparent);
  backdrop-filter: blur(4px);
}
.shortcuts-body { padding: 24px 28px; }
.shortcuts-body h2 {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.shortcuts-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 20px;
  font-size: 12px;
}
.shortcuts-list dt { text-align: right; color: var(--text-secondary); }
.shortcuts-list dd { color: var(--text-primary); }
.shortcuts-foot {
  margin-top: 16px;
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}
.dim { color: var(--text-dim); }
kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border: 1px solid var(--border-card);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-primary);
  box-shadow: 0 1px 0 oklch(0% 0 0 / 0.3);
  min-width: 16px;
  display: inline-block;
  text-align: center;
}

/* --- Email tile --- */
.email-top {
  display: flex;
  gap: 20px;
  align-items: baseline;
  margin-bottom: 12px;
}
.email-big {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-primary);
}
.email-big.warn { color: var(--status-warn); }
.email-big.crit { color: var(--status-error); }
.email-big-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.email-sub { font-size: 11px; color: var(--text-secondary); }
.email-accounts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  font-size: 11px;
}
.email-acc {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}
.email-acc-count {
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.email-acc-count.nr { color: var(--status-warn); }

/* --- Knowledge tile --- */
.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}
.kb-cell {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.kb-num {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}
.kb-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
.kb-recent {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-secondary);
}
.kb-recent-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}
.kb-recent-path { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.kb-recent-date { color: var(--text-dim); font-family: var(--font-mono); flex-shrink: 0; padding-left: 12px; }

/* --- Git tile --- */
.git-repos { display: flex; flex-direction: column; gap: 12px; }
.git-repo {
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--status-idle);
}
.git-repo-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 6px;
}
.git-repo-name { font-weight: 600; color: var(--text-primary); font-family: var(--font-mono); }
.git-repo-count { color: var(--text-secondary); font-family: var(--font-mono); }
.git-repo-count.zero { color: var(--text-dim); }
.git-recent {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.git-recent-row { display: flex; gap: 8px; }
.git-hash { color: var(--status-idle); font-family: var(--font-mono); width: 54px; }
.git-subj { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.git-date { color: var(--text-dim); font-family: var(--font-mono); flex-shrink: 0; }

/* --- Miniflux tile --- */
.feeds-big {
  font-family: var(--font-mono);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}
.feeds-big.warn { color: var(--status-warn); }
.feeds-big.crit { color: var(--status-error); }
.feeds-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 6px; }
.feeds-offline { color: var(--text-dim); font-size: 11px; }

/* --- Bento Grid --- */
.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(80px, auto);
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Tile sizing */
.tile-hero     { grid-column: span 8; }
.tile-side     { grid-column: span 4; }
.tile-half     { grid-column: span 6; }
.tile-full     { grid-column: span 12; }

/* --- Card (shared) --- */
.card {
  background:
    linear-gradient(var(--surface-1), var(--surface-1)) padding-box,
    linear-gradient(160deg, var(--border-card), var(--border-subtle)) border-box;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: transform 200ms ease, box-shadow 200ms ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px oklch(0% 0 0 / 0.35);
}

.card-title {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 16px;
  font-weight: 600;
  font-family: var(--font-mono);
}

/* --- Sessions panel --- */
.groups { display: flex; flex-wrap: wrap; gap: 20px; }
.group { flex: 1; min-width: 200px; }
.group-title {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 10px;
  font-weight: 400;
}

.agent {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  margin: 6px 0;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  transition: background 200ms ease, border-color 200ms ease;
}
.agent:hover {
  background: var(--surface-3);
  border-color: var(--border-card);
}

/* OOM score badge — shown next to the session name. */
.oom-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
  opacity: 0.85;
}
.oom-badge.oom-safe   { background: color-mix(in oklab, var(--status-ok)    18%, transparent); color: var(--status-ok); }
.oom-badge.oom-warn   { background: color-mix(in oklab, var(--status-warn)  18%, transparent); color: var(--status-warn); }
.oom-badge.oom-danger { background: color-mix(in oklab, var(--status-error) 22%, transparent); color: var(--status-error); }

/* Avatar */
.avatar-wrap {
  width: 64px; height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}
.avatar-art { width: 44px; height: 34px; }
.avatar-art svg { width: 100%; height: 100%; }

.avatar-wrap.running { background: color-mix(in oklab, var(--status-ok) 10%, transparent); animation: breathe 3s ease-in-out infinite; }
.avatar-wrap.waiting { background: color-mix(in oklab, var(--status-warn) 10%, transparent); animation: sway 2s ease-in-out infinite; }
.avatar-wrap.idle    { background: color-mix(in oklab, var(--status-idle) 8%, transparent); animation: sleep-fade 4s ease-in-out infinite; }
.avatar-wrap.error   { background: color-mix(in oklab, var(--status-error) 10%, transparent); animation: error-pulse 2s ease-in-out infinite; }

.info { flex: 1; min-width: 0; }
.name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-line {
  font-size: 10px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Pulsing ring status dots --- */
.ring-dot {
  --dot-color: var(--status-idle);
  --dot-glow: var(--glow-idle);
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--dot-color);
  position: relative;
  flex-shrink: 0;
}
.ring-dot::before,
.ring-dot::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 100%; height: 100%;
  background: var(--dot-color);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
}

/* Running: expanding rings */
.ring-dot.running {
  --dot-color: var(--status-ok);
  --dot-glow: var(--glow-ok);
  box-shadow: 0 0 6px var(--dot-glow);
}
.ring-dot.running::before,
.ring-dot.running::after {
  animation: pulse-ring 2.5s ease-out infinite;
}
.ring-dot.running::after { animation-delay: 1.25s; }

/* Waiting: expanding rings (amber) */
.ring-dot.waiting {
  --dot-color: var(--status-warn);
  --dot-glow: var(--glow-warn);
  box-shadow: 0 0 8px var(--dot-glow);
}
.ring-dot.waiting::before,
.ring-dot.waiting::after {
  animation: pulse-ring 2s ease-out infinite;
}
.ring-dot.waiting::after { animation-delay: 1s; }

/* Error: steady slow pulse */
.ring-dot.error {
  --dot-color: var(--status-error);
  --dot-glow: var(--glow-error);
  box-shadow: 0 0 6px var(--dot-glow);
  animation: dot-pulse 1.5s ease-in-out infinite;
}

/* Idle: static dim */
.ring-dot.idle {
  --dot-color: var(--status-idle);
  opacity: 0.5;
}

.status-text { color: var(--text-muted); font-weight: 400; }
.status-text.running { color: var(--status-ok); }
.status-text.waiting { color: var(--status-warn); }
.status-text.error   { color: var(--status-error); }
.status-text.idle    { color: var(--status-idle); }

/* --- Health panel --- */
.metric { margin-bottom: 14px; }
.metric:last-child { margin-bottom: 0; }
.metric-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
}
.metric-label span:last-child { color: var(--text-secondary); }
.bar-bg {
  height: 5px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}
.bar-fill.ok   { background: var(--status-ok); }
.bar-fill.warn { background: var(--status-warn); }
.bar-fill.crit { background: var(--status-error); }

.load-row {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}
.load-item { font-size: 10px; color: var(--text-muted); }
.load-item span { color: var(--text-secondary); }

/* --- Services panel — OpenStatus-style uptime bars per row --- */
.svc-list { display: flex; flex-direction: column; gap: 4px; }
.svc {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  padding: 3px 0;
}
.svc-name {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.svc-name.down { color: var(--status-error); }
.svc-bars {
  height: 14px;
  display: flex;
  gap: 1px;
  align-items: stretch;
}
.svc-bar {
  flex: 1 1 0;
  min-width: 1px;
  border-radius: 1px;
}
.svc-bar.up      { background: color-mix(in oklab, var(--status-ok) 90%, transparent); }
.svc-bar.down    { background: var(--status-error); }
.svc-bar.unknown { background: var(--surface-3); }
.svc-state {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.5px;
  min-width: 32px;
  text-align: right;
}
.svc-state.up   { color: var(--status-ok); }
.svc-state.down { color: var(--status-error); }

/* --- Sparkline-as-background --- */
.spark-host { position: relative; }
.spark-host > .spark-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  overflow: hidden;
  border-radius: inherit;
}
.spark-host > .spark-bg svg { width: 100%; height: 100%; display: block; }
.spark-host > * { position: relative; z-index: 1; }

.sparkline-inline {
  width: 80px;
  height: 22px;
  opacity: 0.6;
  vertical-align: middle;
}

/* --- Deadlines panel --- */
.dl-list { display: flex; flex-direction: column; gap: 8px; }
.dl {
  font-size: 11px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-subtle);
  transition: background 200ms ease;
}
.dl:hover { background: var(--surface-3); }
.dl.overdue { border-left-color: var(--status-error); }
.dl.soon    { border-left-color: var(--status-warn); }
.dl-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.dl-name {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.dl.overdue .dl-name { color: var(--status-error); }
.dl-type {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.dl-date { color: var(--text-muted); font-size: 10px; margin-top: 3px; }

/* --- Tasks panel --- */
.tasks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.tasks-head-stats { display: flex; gap: 12px; }
.tasks-head-spark {
  width: 160px;
  height: 28px;
  opacity: 0.55;
}
.tasks-head-spark svg { width: 100%; height: 100%; display: block; }
.tasks-head .tasks-badge {
  color: var(--status-error);
  font-weight: 500;
}
.task-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}
.task-list::-webkit-scrollbar       { width: 4px; }
.task-list::-webkit-scrollbar-thumb { background: var(--border-card); border-radius: 2px; }
.task {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-subtle);
  transition: background 200ms ease;
  cursor: default;
}
.task:hover { background: var(--surface-3); }
.task.p0 { border-left-color: var(--status-error); }
.task.p1 { border-left-color: var(--status-warn); }
.task.p2 { border-left-color: var(--status-idle); }
.task.p3 { border-left-color: var(--text-dim); }
.task.overdue { border-left-color: var(--status-error); }
.task.focused {
  background: var(--surface-3);
  box-shadow: 0 0 0 1px var(--border-card) inset;
}
.task.pending {
  opacity: 0.4;
  transition: opacity 200ms ease;
}
.task.pending .task-title { text-decoration: line-through; }
.task.pending .task-check { pointer-events: none; }
.task.ghost {
  border-left-color: var(--status-ok);
  opacity: 0.6;
  animation: task-ghost-pulse 1.4s ease-in-out infinite;
}
@keyframes task-ghost-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.8; }
}

/* Inline edit panel — slides in below a task row. */
.task-edit {
  background: var(--surface-2);
  border-left: 3px solid var(--status-idle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: -4px 0 6px 0;
  display: grid;
  grid-template-columns: auto 100px 110px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}
.task-edit label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.task-edit input, .task-edit select, .task-edit textarea {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font: inherit;
  font-size: 11px;
  padding: 5px 8px;
  outline: none;
  transition: border-color 150ms;
}
.task-edit input:focus, .task-edit select:focus, .task-edit textarea:focus {
  border-color: var(--status-idle);
}
.task-edit textarea { grid-column: 1 / -1; min-height: 50px; resize: vertical; }
.task-edit-actions { display: flex; gap: 6px; }
.task-edit button {
  background: var(--surface-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  padding: 5px 10px;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.task-edit button:hover { background: var(--surface-2); border-color: var(--border-card); }
.task-edit button.primary {
  background: var(--status-idle);
  border-color: var(--status-idle);
  color: var(--contrast);
}
.task-edit button.primary:hover { background: var(--status-ok); color: var(--surface-0); }
.task-edit button.danger {
  color: var(--status-error);
  border-color: color-mix(in oklab, var(--status-error) 30%, transparent);
}
.task-edit button.danger:hover {
  background: color-mix(in oklab, var(--status-error) 15%, transparent);
}
.task-check {
  width: 14px; height: 14px;
  margin-top: 1px;
  border: 1px solid var(--border-card);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 150ms, border-color 150ms;
}
.task-check:hover { border-color: var(--status-ok); background: var(--glow-ok); }
.task-body { flex: 1; min-width: 0; }
.task-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.task-title {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.task.overdue .task-title { color: var(--status-error); }
.task-prio {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
  flex-shrink: 0;
}
.task.p0 .task-prio { color: var(--status-error); }
.task.p1 .task-prio { color: var(--status-warn); }
.task.p2 .task-prio { color: var(--status-idle); }
.task-meta {
  color: var(--text-muted);
  font-size: 10px;
  margin-top: 2px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.task-meta .overdue-badge {
  color: var(--status-error);
  font-weight: 600;
}
.task-project { color: var(--text-dim); font-size: 9px; text-transform: uppercase; letter-spacing: 1px; }
.task-add {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}
.task-add input, .task-add select {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 150ms;
}
.task-add input:focus, .task-add select:focus { border-color: var(--status-idle); }
.task-add input[type="text"] { flex: 1; min-width: 0; }
.task-add input[type="date"] { width: 125px; }
.task-add select { width: 55px; }
.task-add button {
  background: var(--status-idle);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 14px;
  transition: background 150ms;
}
.task-add button:hover { background: var(--status-ok); color: var(--surface-0); }
.task-add button:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Eval panel --- */
.eval-row {
  display: flex;
  align-items: stretch;
  gap: 20px;
  flex-wrap: wrap;
}
.eval-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.eval-block-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.eval-stage {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.eval-stage.verify     { background: color-mix(in oklab, var(--status-idle)  12%, transparent); color: var(--status-idle);  border: 1px solid color-mix(in oklab, var(--status-idle)  25%, transparent); }
.eval-stage.endure     { background: color-mix(in oklab, var(--status-warn)  10%, transparent); color: var(--status-warn);  border: 1px solid color-mix(in oklab, var(--status-warn)  25%, transparent); }
.eval-stage.production { background: color-mix(in oklab, var(--status-ok)    10%, transparent); color: var(--status-ok);    border: 1px solid color-mix(in oklab, var(--status-ok)    25%, transparent); }

.eval-big-num {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}
.eval-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.eval-progress {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.eval-progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
}
.eval-progress-header span:last-child { color: var(--text-secondary); }
.eval-bar-bg {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.eval-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.eval-scores {
  display: flex;
  gap: 16px;
}
.eval-score {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 100px;
}
.eval-score-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.eval-score-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.eval-score-bar .eval-bar-bg { flex: 1; }
.eval-score-val {
  font-size: 11px;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}

.eval-gate {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}
.eval-gate-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.eval-gate-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
}
.eval-gate-dot.met { background: var(--status-ok); box-shadow: 0 0 4px var(--glow-ok); }
.eval-gate-dot.not-met { background: var(--status-error); box-shadow: 0 0 4px var(--glow-error); }

.eval-counters {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}
.eval-counter {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}
.eval-counter-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.eval-counter-label {
  font-size: 8px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.eval-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}
.eval-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.eval-badge.failures {
  background: color-mix(in oklab, var(--status-error) 10%, transparent);
  color: var(--status-error);
  border: 1px solid color-mix(in oklab, var(--status-error) 22%, transparent);
}
.eval-badge.trends {
  background: color-mix(in oklab, var(--status-warn) 10%, transparent);
  color: var(--status-warn);
  border: 1px solid color-mix(in oklab, var(--status-warn) 22%, transparent);
}
.eval-badge.zero {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.eval-sep {
  width: 1px;
  background: var(--border-subtle);
  align-self: stretch;
  margin: 4px 4px;
}

.eval-offline {
  color: var(--text-dim);
  font-size: 11px;
  padding: 8px 0;
}

/* --- Footer --- */
.updated {
  text-align: center;
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 24px;
}

/* --- Keyframes --- */
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
@keyframes sway {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(1.5px); }
}
@keyframes sleep-fade {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.25; }
}
@keyframes error-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
@keyframes pulse-ring {
  0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.5; }
  100% { transform: translate(-50%, -50%) scale(3);    opacity: 0; }
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--glow-error); }
  50%      { opacity: 0.5; box-shadow: 0 0 12px var(--glow-error); }
}

/* --- View transitions (scoped; respects prefers-reduced-motion) --- */
@supports (view-transition-name: foo) {
  main.view { view-transition-name: view-content; }
  ::view-transition-old(view-content),
  ::view-transition-new(view-content) {
    animation-duration: 220ms;
    animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  ::view-transition-old(view-content) {
    animation-name: qai-fade-out;
  }
  ::view-transition-new(view-content) {
    animation-name: qai-fade-in;
  }
}
@keyframes qai-fade-out {
  to { opacity: 0; transform: translateY(-4px); }
}
@keyframes qai-fade-in {
  from { opacity: 0; transform: translateY(4px); }
}

/* --- Reduced motion — global kill switch + View Transition skip --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  ::view-transition-old(view-content),
  ::view-transition-new(view-content) {
    animation: none !important;
  }
}

/* --- Slack drafts bento --- */
.slack-draft {
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin-bottom: 10px;
}
.slack-draft + .slack-draft { margin-top: 0; }
.slack-draft-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 6px;
  color: var(--text-secondary, var(--text-primary));
}
.slack-draft-head .badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
}
.slack-draft-head .prio-P0 { color: var(--status-error); border-color: color-mix(in oklab, var(--status-error) 40%, transparent); }
.slack-draft-head .prio-P1 { color: var(--status-warn);  border-color: color-mix(in oklab, var(--status-warn) 40%, transparent); }
.slack-draft-head .prio-P2 { color: var(--status-idle);  border-color: color-mix(in oklab, var(--status-idle) 40%, transparent); }
.slack-draft-head .prio-P3 { color: var(--text-primary); opacity: 0.7; }
.slack-draft-head .slack-ch { font-weight: 600; }
.slack-draft-head .slack-who { opacity: 0.7; }
.slack-draft-head .slack-state.approved {
  margin-left: auto;
  color: var(--status-warn);
  font-style: italic;
}
.slack-trigger {
  font-size: 11px;
  color: var(--text-secondary, var(--text-primary));
  opacity: 0.75;
  border-left: 2px solid var(--border-subtle);
  padding-left: 8px;
  margin-bottom: 8px;
  max-height: 3em;
  overflow: hidden;
}
.slack-draft-body {
  width: 100%;
  min-height: 80px;
  background: var(--surface-3);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px;
  font: inherit;
  font-size: 12px;
  resize: vertical;
  margin-bottom: 8px;
}
.slack-draft-body:focus { outline: none; border-color: var(--status-idle); }
.slack-draft-body:disabled { opacity: 0.6; cursor: not-allowed; }
.slack-actions { display: flex; gap: 6px; }
.slack-actions .btn {
  background: var(--surface-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  padding: 5px 10px;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.slack-actions .btn:hover { background: var(--surface-2); border-color: var(--border-card); }
.slack-actions .btn.primary {
  background: var(--status-idle);
  border-color: var(--status-idle);
  color: var(--contrast);
}
.slack-actions .btn.primary:hover { background: var(--status-ok); color: var(--surface-0); }
.slack-actions .btn.danger {
  color: var(--status-error);
  border-color: color-mix(in oklab, var(--status-error) 30%, transparent);
}
.slack-actions .btn.danger:hover { background: color-mix(in oklab, var(--status-error) 15%, transparent); }
.slack-actions .btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .tile-hero { grid-column: span 12; }
  .tile-side { grid-column: span 6; }
}
@media (max-width: 640px) {
  body { padding: 14px; }
  .bento { grid-template-columns: 1fr; gap: 12px; }
  .tile-hero, .tile-side, .tile-half, .tile-full { grid-column: span 1; }
  .groups { flex-direction: column; }
  .card { padding: 16px; }
  .eval-row { gap: 12px; }
  .eval-scores { flex-direction: column; gap: 8px; }
}
