/* pocket — phone first. Everything is sized for a thumb and read in one hand. */

:root {
  --bg: #14161a;
  --surface: #1b1e24;
  --surface-2: #23272f;
  --line: #2e333c;
  --text: #e8eaed;
  --muted: #9aa2ae;
  --accent: #7aa2f7;
  --warn: #e0af68;
  --danger: #f7768e;
  --ok: #9ece6a;
  --radius: 14px;
  --tap: 46px;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; }

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

/* --- bars ---------------------------------------------------------------- */

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.wordmark {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0;
  flex: 1;
  padding-left: 6px;
}

.bar-title { flex: 1; min-width: 0; }
.bar-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status { font-size: 12.5px; color: var(--muted); }
.status.running { color: var(--accent); }
.status.waiting { color: var(--warn); }
.status.error   { color: var(--danger); }

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  flex: 0 0 var(--tap);
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}
.icon-btn:active { background: var(--surface-2); }

/* --- gate ---------------------------------------------------------------- */

.gate { justify-content: center; align-items: center; padding: 24px; }
.gate-inner { width: 100%; max-width: 340px; text-align: center; }
.gate .wordmark { font-size: 34px; margin-bottom: 6px; }
.gate form { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }

input[type=password], textarea, select {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}
input[type=password]:focus, textarea:focus { border-color: var(--accent); }

button.primary, button.ghost, button.wide {
  min-height: var(--tap);
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
button.primary { background: var(--accent); color: #0f1115; }
button.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
button.wide { width: 100%; margin-top: 8px; }
button:active { opacity: 0.75; }

/* --- conversation list --------------------------------------------------- */

.jobs { flex: 1; overflow-y: auto; padding: 10px; }

.job {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-bottom: 9px;
  color: var(--text);
  font: inherit;
}
.job-top { display: flex; align-items: baseline; gap: 8px; }
.job-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; background: var(--line); }
.dot.running { background: var(--accent); animation: pulse 1.4s infinite; }
.dot.waiting { background: var(--warn); animation: pulse 1s infinite; }
.dot.error { background: var(--danger); }
@keyframes pulse { 50% { opacity: 0.3; } }

.empty { text-align: center; color: var(--text); margin-top: 22vh; line-height: 1.8; }
.list-foot { padding: 12px 14px max(14px, env(safe-area-inset-bottom)); }

/* --- feed ---------------------------------------------------------------- */

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 6px;
  -webkit-overflow-scrolling: touch;
}

.msg { margin-bottom: 12px; max-width: 100%; }

.msg.you {
  margin-left: auto;
  width: fit-content;
  max-width: 85%;
  background: var(--accent);
  color: #0f1115;
  padding: 10px 14px;
  border-radius: 18px 18px 4px 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.claude { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.claude p { margin: 0 0 10px; }
.msg.claude code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 14px;
}
.msg.claude pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px;
  overflow-x: auto;
  font-size: 13px;
  white-space: pre;
}

/* Tool runs and thinking collapse away — the phone should show conclusions, not workings. */
details.tool, details.think {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  margin-bottom: 9px;
  overflow: hidden;
}
details.tool > summary, details.think > summary {
  padding: 10px 13px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  gap: 8px;
  align-items: center;
}
summary::-webkit-details-marker { display: none; }
.tool-verb { color: var(--text); font-weight: 550; flex: 0 0 auto; }
.tool-detail {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
details pre {
  margin: 0;
  padding: 11px 13px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  overflow-x: auto;
  color: var(--muted);
  white-space: pre;
}
details.tool.failed > summary .tool-verb { color: var(--danger); }

/* --- the approval card --------------------------------------------------- */

.ask {
  background: var(--surface-2);
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.ask h3 { margin: 0 0 4px; font-size: 15px; }
.ask pre {
  background: #0f1115;
  border-radius: 9px;
  padding: 11px;
  margin: 10px 0;
  font-size: 12.5px;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
  max-height: 40vh;
}
.ask-row { display: flex; gap: 9px; }
.ask-row button {
  flex: 1;
  min-height: var(--tap);
  border-radius: 11px;
  border: 0;
  font: inherit;
  font-weight: 650;
}
.allow { background: var(--ok); color: #0f1115; }
.deny  { background: var(--surface); color: var(--danger); border: 1px solid var(--line) !important; }
.always { background: transparent; color: var(--muted); border: 1px solid var(--line) !important; flex: 0 0 34% !important; font-weight: 500 !important; }
.ask.settled { border-color: var(--line); opacity: 0.55; }
.ask.settled .ask-row { display: none; }
.verdict { font-size: 13.5px; color: var(--muted); margin: 8px 0 0; }

.note { text-align: center; font-size: 13px; color: var(--muted); margin: 10px 0; }
.note.bad { color: var(--danger); }

/* --- composer ------------------------------------------------------------ */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px 10px max(9px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 34vh;
  border-radius: 20px;
  padding: 11px 15px;
}
.send {
  width: var(--tap);
  height: var(--tap);
  flex: 0 0 var(--tap);
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #0f1115;
  font-size: 21px;
  font-weight: 700;
}
.send:disabled { background: var(--surface-2); color: var(--muted); }
.stop {
  min-height: var(--tap);
  padding: 0 15px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--danger);
  font: inherit;
  font-weight: 600;
}

/* --- sheet --------------------------------------------------------------- */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}
.sheet-card {
  width: 100%;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 18px 16px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.sheet-card h3 { margin: 0 0 12px; font-size: 17px; }
.sheet-option {
  display: block;
  width: 100%;
  text-align: left;
  min-height: var(--tap);
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.sheet-option.destructive { color: var(--danger); }
