/* assistant.css — assistant PWA. Phone-first.
 *
 * Identity: "Monolith" — pure monochrome, platinum on near-black, hairline
 * borders. Chosen by Aaron 2026-08-11 from three deployed variants.
 * Layout language replicates the Claude / ChatGPT mobile apps: plain
 * assistant text on the page, quiet gray user bubbles, pill composer with
 * attach + morphing send/stop circle, empty-state greeting, thinking dots. */

:root {
  --bg: #09090B;
  --bg-soft: #131316;
  --bg-softer: #1E1E23;
  --border: #26262C;
  --text: #F4F4F5;
  --text-dim: #86868F;
  --accent: #E8E8EA;
  --accent-contrast: #0E0E10;
  --accent-warm: #C9A227;
  --danger: #F87171;
  --ok: #4ADE80;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;  /* fallback */
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  position: relative;
}

.hidden { display: none !important; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(6px + var(--safe-top)) 8px 6px;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  border-radius: 12px;
  flex-shrink: 0;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { background: var(--bg-soft); color: var(--text); }

.topbar-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 0;
  padding: 2px 0;
}
.topbar-line { display: flex; align-items: center; gap: 4px; max-width: 100%; }
#title-text {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-line .chev { width: 14px; height: 14px; color: var(--text-dim); flex-shrink: 0; }
.topbar-sub { font-size: 11px; color: var(--text-dim); }

/* ── Messages ────────────────────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.msg { max-width: 86%; animation: rise 0.22s ease; }
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; width: 100%; max-width: 100%; }

.bubble { word-wrap: break-word; overflow-wrap: break-word; }
.msg.user .bubble {
  background: var(--bg-softer);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 22px;
  border-bottom-right-radius: 8px;
  white-space: pre-wrap;
}
.msg.assistant .bubble { padding: 0 2px; }
.msg.assistant .bubble.error-bubble { color: var(--danger); }

.msg-images { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; justify-content: flex-end; }
.msg-images img { max-width: 150px; max-height: 150px; border-radius: 14px; object-fit: cover; }

/* markdown inside assistant bubbles */
.bubble p { margin: 0 0 12px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 12px 22px; }
.bubble li { margin-bottom: 4px; }
.bubble h1, .bubble h2, .bubble h3 { margin: 16px 0 8px; font-size: 1.05em; }
.bubble a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.bubble strong { font-weight: 650; }
.bubble code {
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13.5px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}
.bubble pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  overflow-x: auto;
  margin: 0 0 12px;
}
.bubble pre code { background: none; padding: 0; font-size: 13px; }
.bubble table { border-collapse: collapse; margin: 0 0 12px; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 6px 10px; font-size: 14px; text-align: left; }
.bubble blockquote { border-left: 2px solid var(--border); padding-left: 12px; color: var(--text-dim); margin: 0 0 12px; }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

.cursor-blink {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--text);
  border-radius: 50%;
  margin-left: 3px;
  vertical-align: baseline;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.85); } }

/* thinking indicator (before first token) */
.thinking {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 8px 2px;
  animation: rise 0.22s ease;
}
.thinking span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: think 1.2s ease-in-out infinite;
}
.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes think { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* tool activity chips */
.tool-chip {
  display: block;
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
}
.tool-chip summary { padding: 9px 13px; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.tool-chip summary::-webkit-details-marker { display: none; }
.tool-chip .spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tool-chip .chip-status-ok { color: var(--ok); }
.tool-chip .chip-status-err { color: var(--danger); }
.tool-chip pre { margin: 0; padding: 9px 13px; border-top: 1px solid var(--border); font-size: 12px; overflow-x: auto; max-height: 220px; overflow-y: auto; font-family: ui-monospace, 'SF Mono', Menlo, monospace; }

/* delegation */
.delegation-chip {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  font-size: 13px;
  color: var(--text-dim);
  padding: 9px 13px;
  margin: 2px 0;
  animation: rise 0.22s ease;
  max-width: 100%;
}
.delegation-chip .dc-name { color: var(--text); font-weight: 550; white-space: nowrap; }
.delegation-chip .dc-task { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delegation-task {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  padding: 2px 2px;
}
.agent-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 4px;
  padding-left: 2px;
}

/* confirm card */
.confirm-card {
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-radius: var(--radius);
  background: rgba(201, 162, 39, 0.07);
  padding: 14px 16px;
  margin: 4px 0;
  animation: rise 0.22s ease;
}
.confirm-card .confirm-title { font-weight: 600; font-size: 12.5px; color: var(--accent-warm); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.confirm-card .confirm-desc { font-size: 15px; margin-bottom: 12px; white-space: pre-wrap; }
.confirm-card .confirm-actions { display: flex; gap: 10px; }
.confirm-card .confirm-actions button {
  flex: 1;
  padding: 11px 0;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
}
.confirm-card .approve { background: var(--accent); color: var(--accent-contrast); }
.confirm-card .decline { background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); }
.confirm-card.resolved { opacity: 0.6; }
.confirm-card .confirm-resolved-note { font-size: 13px; color: var(--text-dim); }

.latest-pill {
  position: absolute;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-softer);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  z-index: 15;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.latest-pill svg { width: 18px; height: 18px; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 28px calc(120px + var(--safe-bottom));
  pointer-events: none;
  z-index: 5;
}
.empty-mark { color: var(--text-dim); opacity: 0.5; }
.empty-mark svg { width: 40px; height: 40px; }
.empty-greeting { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.empty-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
  max-width: 340px;
  pointer-events: auto;
}
.empty-chips button {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 14px;
  text-align: left;
}
.empty-chips button:active { background: var(--bg-softer); color: var(--text); }

/* ── Composer ────────────────────────────────────────────────────────────── */
.composer {
  padding: 6px 12px calc(10px + var(--safe-bottom));
  background: var(--bg);
}

.composer-pill {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 5px;
}

.pill-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  border-radius: 50%;
  flex-shrink: 0;
}
.pill-btn svg { width: 20px; height: 20px; }
.pill-btn:active { background: var(--bg-softer); color: var(--text); }

#input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* <16px triggers iOS zoom-on-focus */
  line-height: 1.4;
  padding: 8px 4px;
  resize: none;
  max-height: 132px;
  outline: none;
}
#input::placeholder { color: var(--text-dim); }

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.send-btn svg { width: 19px; height: 19px; }
.send-btn .ic-stop { display: none; }
.send-btn:disabled { opacity: 0.35; }
.send-btn.stop { background: var(--bg-softer); color: var(--text); border: 1px solid var(--border); }
.send-btn.stop .ic-send { display: none; }
.send-btn.stop .ic-stop { display: block; }

.image-previews { display: flex; gap: 8px; padding: 6px 4px 10px; overflow-x: auto; }
.image-previews .preview { position: relative; flex-shrink: 0; }
.image-previews img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
.image-previews .remove {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg-softer); color: var(--text);
  border: 1px solid var(--border);
  font-size: 11px; line-height: 1;
}
.image-previews .uploading { opacity: 0.4; }

/* ── Drawer ──────────────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideRight { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }

.backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
  animation: fadeIn 0.2s ease;
}
.drawer {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: min(84vw, 330px);
  background: var(--bg-soft);
  z-index: 31;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  animation: slideRight 0.24s cubic-bezier(0.32, 0.72, 0, 1);
}
.drawer-head { padding: 12px 12px 10px; }
.drawer-head input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 9px 14px;
  font: inherit;
  font-size: 15px;
  outline: none;
  -webkit-appearance: none;
}
.drawer-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 8px calc(12px + var(--safe-bottom)); }
.drawer-item { padding: 11px 12px; border-radius: 12px; cursor: pointer; }
.drawer-item.active { background: var(--bg-softer); }
.drawer-item:active { background: var(--bg-softer); }
.drawer-item .di-title { font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-item .di-meta { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; display: flex; gap: 8px; }
.drawer-empty { padding: 28px 14px; color: var(--text-dim); font-size: 14px; text-align: center; }

/* ── Bottom sheet ────────────────────────────────────────────────────────── */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--bg-soft);
  border-radius: 20px 20px 0 0;
  z-index: 31;
  padding: 8px 16px calc(24px + var(--safe-bottom));
  max-height: 72vh;
  overflow-y: auto;
  max-width: 760px;
  margin: 0 auto;
  animation: slideUp 0.26s cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet-grab { width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: 6px auto 14px; }
.sheet h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); margin: 16px 0 8px; font-weight: 600; }
.sheet-option {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  margin-bottom: 8px;
  text-align: left;
}
.sheet-option:disabled { opacity: 0.45; }
.sheet-option.selected { border-color: var(--text-dim); background: var(--bg-softer); }
.sheet-option .opt-sub { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.sheet-option .check { color: var(--text); font-weight: 700; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-mark { display: flex; justify-content: center; color: var(--text); margin-bottom: 4px; }
.login-mark svg { width: 44px; height: 44px; }
.login-card h2 { text-align: center; margin-bottom: 10px; font-weight: 600; letter-spacing: -0.01em; }
.login-card input[type="text"], .login-card input[type="password"] {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  padding: 13px 16px;
  font: inherit;
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
}
.login-card input:focus { border-color: var(--text-dim); }
.login-card button[type="submit"] {
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 14px;
  padding: 13px;
  font-size: 15px;
  font-weight: 650;
  margin-top: 4px;
}
.login-remember { font-size: 13.5px; color: var(--text-dim); display: flex; align-items: center; gap: 8px; padding-left: 2px; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; }

/* ── Install banner ──────────────────────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: calc(84px + var(--safe-bottom));
  left: 12px; right: 12px;
  background: var(--bg-softer);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 6px 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
  z-index: 25;
  max-width: 736px;
  margin: 0 auto;
  animation: rise 0.3s ease;
}
