:root {
  --bg: #101014;
  --panel: #1a1a20;
  --panel-2: #22222a;
  --text: #e8e4dc;
  --muted: #8b8b96;
  --accent: #e8b84b;
  --green: #5fb573;
  --red: #d96b6b;
  --border: #2c2c36;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: 640px;
  margin: 0 auto;
  /* Keep content out of the notch/rounded corners in landscape. */
  padding: 0 max(14px, env(safe-area-inset-right)) 32px max(14px, env(safe-area-inset-left));
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  /* Standalone PWA draws under the translucent status bar — pad past it. */
  padding: calc(10px + env(safe-area-inset-top)) 2px 10px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
header.topbar h1 {
  font-size: 18px;
  margin: 0;
  letter-spacing: 0.02em;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
header.topbar button { flex-shrink: 0; }

.status-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 6px;
  vertical-align: 1px;
}
.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--red); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin: 10px 0;
}
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card .meta { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.card p { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.section-title {
  margin: 22px 0 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
/* Share each row evenly — full-width tap targets instead of uneven slivers. */
.actions button { flex: 1 1 auto; }
.actions input[type="text"] { flex: 10 1 120px; width: auto; }

button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 44px; /* Apple HIG touch-target minimum */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(0.98); }
button.primary { background: var(--accent); border-color: var(--accent); color: #14130e; font-weight: 600; }
button.approve { background: var(--green); border-color: var(--green); color: #0e140f; font-weight: 600; }
button.danger { background: transparent; border-color: var(--red); color: var(--red); }
button:disabled { opacity: 0.5; cursor: default; }

input, textarea {
  font: inherit;
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { min-height: 72px; resize: vertical; }
input[type="checkbox"] {
  width: 20px;
  height: 20px;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}
label.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0; /* comfortable tap area for the checkbox row */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

summary {
  cursor: pointer;
  padding: 8px 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.field { margin: 10px 0; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.error-banner {
  background: rgba(217, 107, 107, 0.12);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 14px;
}
.notice {
  background: rgba(232, 184, 75, 0.1);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 14px;
}

.daemon-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.daemon-row .name { font-weight: 600; }
.daemon-row .sub { color: var(--muted); font-size: 13px; }

.badge {
  display: inline-block;
  font-size: 12px;
  border-radius: 999px;
  padding: 2px 9px;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-left: 8px;
}
.badge.count { background: var(--accent); border-color: var(--accent); color: #14130e; font-weight: 700; }

/* Code diff viewer — the evidence behind accept/merge/revert judgments. */
details.diff { margin: 10px 0; }
details.diff > summary .meta { font-size: 13px; }
details.diff-file {
  margin: 6px 0 6px 4px;
  border-left: 2px solid var(--border);
  padding-left: 8px;
}
.diff-path {
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}
.diff-stat { font-size: 12px; white-space: nowrap; margin-left: 6px; }
.diff-stat .plus { color: var(--green); }
.diff-stat .minus { color: var(--red); }
.diff-body {
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 6px 0;
  padding: 6px 0;
}
/* Wrap long lines — horizontal panning is miserable on a phone. */
.diff-body .ln { white-space: pre-wrap; overflow-wrap: anywhere; padding: 0 10px; min-height: 1.55em; }
.diff-body .ln.add { background: rgba(95, 181, 115, 0.13); color: #a9d8b5; }
.diff-body .ln.del { background: rgba(217, 107, 107, 0.13); color: #e3a3a3; }
.diff-body .ln.hunk { color: var(--accent); background: var(--panel-2); margin: 4px 0; }
