:root {
  --ground: #161826; --side: #1c1e2c; --surface: #232532; --code: #292b31;
  --text: #e9e9ed; --muted: #b2b6ca; --divider: rgb(233 233 237 / 16%);
  --accent: #9184d9; --accent-text: #b5abfc; --bubble: #423a6a; --bubble-text: #f5f4ff;
  --ok: #6cd092; --warn: #ebb25f; --err: #f98f87; --edge: #595d6c; --on-accent: #161826;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --ground: #f3f5fe; --side: #e9ecf8; --surface: #dde0f0; --code: #e4e7f5;
    --text: #161826; --muted: #595d6c; --divider: rgb(22 24 38 / 20%);
    --accent: #796cbf; --accent-text: #5d5294; --bubble: #e7e5fe; --bubble-text: #2b2741;
    --ok: #006b39; --warn: #915200; --err: #b02a2d; --edge: #cfd3e5; --on-accent: #ffffff;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ground); color: var(--text);
  font: 16px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
#app { height: 100dvh; display: flex; flex-direction: column; max-width: 820px; margin: 0 auto; }
button, input, textarea { font: inherit; color: inherit; }
button {
  min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--edge);
  background: transparent; cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.plain { border-color: transparent; padding: 0 10px; color: var(--accent-text); }
button.danger { color: var(--err); }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

header {
  display: flex; align-items: center; gap: 8px; min-height: 56px;
  padding: env(safe-area-inset-top) 12px 0 12px; border-bottom: 1px solid var(--divider);
}
header h1 { font-size: 17px; font-weight: 600; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header .meter { font-size: 13px; color: var(--muted); white-space: nowrap; }
.banner { padding: 8px 16px; font-size: 14px; background: var(--surface); color: var(--muted); }
.banner.err { color: var(--err); }

.center { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 24px; }
.center h1 { font-size: 24px; margin: 0; }
.center p { margin: 0; color: var(--muted); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, textarea {
  background: var(--side); border: 1px solid var(--edge); border-radius: 8px; padding: 10px 12px;
  font-size: 16px; /* smaller makes iOS zoom the page */
}
.error { color: var(--err); }

.list { flex: 1; overflow-y: auto; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); margin: 0; list-style: none; }
.list li button {
  width: 100%; min-height: 64px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 2px; text-align: left; border: 0; border-radius: 0; border-bottom: 1px solid var(--divider); padding: 10px 16px;
}
.list .name { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal { font-size: 14px; color: var(--muted); }
.signal.err { color: var(--err); } .signal.warn { color: var(--warn); }
.signal.working, .signal.new { color: var(--accent-text); }
.empty { padding: 32px 24px; color: var(--muted); text-align: center; }

.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; }
.msg { max-width: 100%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 88%; background: var(--bubble); color: var(--bubble-text); border-radius: 14px; padding: 8px 12px; }
.msg .from { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg.user .from { color: inherit; opacity: .75; }
.msg .note { font-size: 13px; color: var(--muted); margin-top: 4px; }
.msg.system { align-self: center; font-size: 13px; color: var(--muted); text-align: center; }
.msg.error { color: var(--err); border: 1px solid var(--err); border-radius: 8px; padding: 8px 12px; }
.msg p { margin: 0 0 8px; white-space: pre-wrap; }
.msg p:last-child { margin-bottom: 0; }
.msg pre { background: var(--code); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; margin: 0 0 8px; white-space: pre; }
.msg code { background: var(--code); border-radius: 4px; padding: 1px 4px; font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace; }
.msg pre code { background: none; padding: 0; font: inherit; }
.pictures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; }
.pictures.one { grid-template-columns: 1fr; }
.pictures img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--surface); display: block; cursor: zoom-in; }
.pictures.one img { aspect-ratio: auto; max-height: 260px; }
.shown { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 8px; }
.shown .pictures { margin-bottom: 0; width: 100%; }
.file { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.file .name { overflow-wrap: anywhere; }
.msg.question { align-self: stretch; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 8px; background: var(--surface); }
.msg.question .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.msg .table { overflow-x: auto; margin: 0 0 8px; }
.msg table { border-collapse: collapse; font-size: 14px; }
.msg th, .msg td { border: 1px solid var(--divider); padding: 6px 10px; vertical-align: top; max-width: 280px; }
.msg th { background: var(--code); font-weight: 600; }
.working { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; flex: none; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

.jobs { display: flex; gap: 8px; padding: 8px 16px; overflow-x: auto; border-top: 1px solid var(--divider); }
.job { display: flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; background: var(--surface); border-radius: 8px; padding: 0 4px 0 10px; }
.job button { min-height: 36px; }

.composer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--divider); }
.composer textarea { flex: 1; resize: none; max-height: 40dvh; min-height: 44px; }

/* A question card the agent asked for with `vw ask`. */
[hidden] { display: none !important; }
.msg.question.ask { gap: 10px; }
.ask-question { display: flex; flex-direction: column; gap: 2px; }
.ask-header { font-size: 11px; letter-spacing: 0.06em; color: var(--muted); }
.ask-text { font-weight: 600; }
.ask-option {
  display: flex; align-items: flex-start; gap: 8px; width: 100%; min-height: 0;
  text-align: left; background: none; border: 0; border-radius: 6px; padding: 6px 2px;
}
.ask-option .mark {
  flex: none; width: 16px; height: 16px; margin-top: 3px;
  border: 1.5px solid var(--muted); border-radius: 50%;
}
.ask-option .mark.box { border-radius: 4px; }
.ask-option.chosen .mark { background: var(--accent); border-color: var(--accent); }
.ask-option .ask-label { flex: 1; }
.ask-option .note { margin-top: 1px; }
.ask-custom-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.ask-custom { flex: 1; min-width: 0; }
.ask-send { align-self: flex-start; }
