/* hrdr — phone-first, dark-only: agent output is dark-authored, so the whole
   page keeps a terminal ground (same reasoning collie documents in ADR 0002).
   Touch targets ≥ 44px, safe-area insets for notched phones, horizontal chip
   rows instead of any desktop layout assumptions. */

:root {
  --bg: #0b0e14;
  --card: #151a23;
  --card-edge: #232a36;
  --text: #e6e9ef;
  --dim: #8b93a3;
  --accent: #88c0d0;
  --blocked: #bf616a;
  --working: #ebcb8b;
  --done: #a3be8c;
  --idle: #4c566a;
  --radius: 14px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", system-ui, Roboto, sans-serif;
  font-size: 16px;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.hidden { display: none !important; }

/* ── top bar ─────────────────────────────────────────────────────────────── */

#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--sat) + 10px) 14px 10px;
  border-bottom: 1px solid var(--card-edge);
  flex-shrink: 0;
}

#titleblock { min-width: 0; flex: 1; display: flex; align-items: baseline; gap: 10px; }

#apptitle { font-size: 20px; margin: 0; letter-spacing: .5px; }

#pane-title {
  color: var(--dim);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#topright { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

#livedot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--done);
  box-shadow: 0 0 6px var(--done);
}
#livedot.stale { background: var(--blocked); box-shadow: 0 0 6px var(--blocked); }

.iconbtn {
  appearance: none; border: 1px solid var(--card-edge); background: var(--card);
  color: var(--text); border-radius: 10px; min-width: 38px; height: 38px;
  font-size: 20px; line-height: 1; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn:active { transform: scale(.94); }

#focusbtn {
  appearance: none; border: 1px solid var(--card-edge); background: var(--card);
  color: var(--accent); border-radius: 10px; height: 38px; padding: 0 12px;
  font-size: 14px;
}
#focusbtn:active { transform: scale(.94); }

/* ── dashboard ───────────────────────────────────────────────────────────── */

#view { flex: 1; overflow-y: auto; padding: 12px 14px calc(var(--sab) + 16px); }

.section-label {
  color: var(--dim); font-size: 12px; text-transform: uppercase;
  letter-spacing: 1.2px; margin: 18px 2px 8px;
}
.section-label:first-child { margin-top: 4px; }
.section-label.empty { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  padding: 13px 15px;
  margin-bottom: 9px;
  display: block; width: 100%; text-align: left;
  appearance: none; color: var(--text);
  font-family: inherit; font-size: inherit;
}
.card:active { transform: scale(.985); border-color: var(--accent); }

.card .row1 { display: flex; align-items: center; gap: 9px; min-width: 0; }
.card .st { flex-shrink: 0; font-size: 13px; }
.card .name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
  font-weight: 560; font-size: 15.5px;
}
.card .row2 {
  display: flex; gap: 7px; margin-top: 8px; overflow-x: auto;
  scrollbar-width: none;
}
.card .row2::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0; color: var(--dim); background: rgba(255,255,255,.05);
  border-radius: 7px; padding: 3px 8px; font-size: 12px;
  max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.accent { color: var(--accent); }
.chip.syncok { color: var(--done); }
.chip.syncwarn { color: var(--working); }

.st.blocked { color: var(--blocked); }
.st.working { color: var(--working); animation: pulse 1.4s ease-in-out infinite; }
.st.done    { color: var(--done); }
.st.idle    { color: var(--dim); }
.st.unknown { color: var(--idle); }

@keyframes pulse { 50% { opacity: .35; } }

/* ── pane view ───────────────────────────────────────────────────────────── */

.pane-wrap { display: flex; flex-direction: column; height: 100%; padding: 0; }

#output {
  flex: 1; overflow: auto; -webkit-overflow-scrolling: touch;
  margin: 10px 0 8px;
  padding: 12px;
  background: #080a0f;
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
}

.chiprow {
  display: flex; gap: 7px; overflow-x: auto; padding: 2px;
  margin-bottom: 6px;
  scrollbar-width: none; flex-shrink: 0;
  scroll-snap-type: x proximity;
}
.chiprow::-webkit-scrollbar { display: none; }

.qbtn, .kbtn {
  flex-shrink: 0; scroll-snap-align: start;
  appearance: none; border: 1px solid var(--card-edge); background: var(--card);
  color: var(--text); border-radius: 10px; padding: 11px 14px;
  font-size: 14px; font-family: inherit; max-width: 78vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kbtn { min-height: 42px; padding: 8px 13px; }
.qbtn { border-color: var(--working); color: var(--working); font-size: 15px; }
.qbtn:active, .kbtn:active { transform: scale(.94); border-color: var(--accent); }

.qrow .qbtn { animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

#keyshandle {
  appearance: none; border: none; background: transparent; color: var(--dim);
  width: 100%; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1; padding: 0; margin: -2px 0 0;
}
#keyshandle.active { color: var(--accent); }
#keyshandle:active { opacity: .6; }

#inputrow {
  display: flex; gap: 8px; margin-top: 4px; flex-shrink: 0;
  padding-bottom: var(--sab);
}
#reply {
  flex: 1; height: 46px;
  appearance: none; background: var(--card); border: 1px solid var(--card-edge);
  color: var(--text); border-radius: 12px; padding: 0 14px; font-size: 16px;
  font-family: inherit;
}
#reply:focus { outline: none; border-color: var(--accent); }
#send {
  appearance: none; border: none; background: var(--accent); color: #0b0e14;
  border-radius: 12px; width: 56px; height: 46px; font-size: 15px; font-weight: 600;
  font-family: inherit; flex-shrink: 0;
}
#send:active { transform: scale(.94); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 86px);
  transform: translateX(-50%);
  background: #1c2330; color: var(--text); border: 1px solid var(--card-edge);
  border-radius: 10px; padding: 10px 16px; font-size: 14px;
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 9;
  max-width: 85vw;
}
#toast.show { opacity: 1; }

.offline-note { color: var(--blocked); font-size: 13px; padding: 6px 2px; }
