:root {
  --bg: #181818;
  --chrome: #141414;
  --text: #f0f0f0;
  --text-secondary: rgba(240, 240, 240, 0.74);
  --text-muted: rgba(240, 240, 240, 0.55);
  --placeholder: rgba(240, 240, 240, 0.6);
  --border: rgba(240, 240, 240, 0.12);
  --border-soft: rgba(240, 240, 240, 0.08);
  --human-bg: rgba(240, 240, 240, 0.08);
  --pill: rgba(240, 240, 240, 0.14);
  --code-bg: #111111;
  --added: rgba(63, 162, 102, 0.2);
  --removed: rgba(184, 0, 73, 0.2);
  --added-text: #70b489;
  --removed-text: #ffa198;
  --purple: #b180d7;
  --purple-bg: color-mix(in srgb, #b180d7 12%, transparent);
  --accent: #81a1c1;
  --accent-ink: #191c22;
  --danger: #f97066;
  --ok: #32d583;
  --warn: #fdb022;
  --radius: 12px;
  --app-height: 100dvh;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text-secondary);
  font: 14px/22px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  position: fixed;
  top: var(--vv-top, 0px);
  left: var(--vv-left, 0px);
  width: 100%;
  height: var(--app-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 8px 12px 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  padding-right: max(12px, env(safe-area-inset-right));
  padding-left: max(16px, env(safe-area-inset-left));
  background: var(--chrome);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.keyboard-open .top {
  padding-top: 8px;
}

.title-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  min-width: 0;
  padding: 0;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

h1 {
  margin: 1px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 58vw;
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.status-pill {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--pill);
  border-radius: 999px;
  padding: 4px 8px;
}

.status-pill[data-state="ok"] { color: var(--ok); }
.status-pill[data-state="generating"] { color: var(--warn); }
.status-pill[data-state="error"] { color: var(--danger); }

.icon-quiet {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  min-height: 32px;
  padding: 0 4px;
}

.transcript {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0;
}

.transcript-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 16px 10px;
  overflow-anchor: none;
}

.msg {
  max-width: 100%;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.msg.assistant {
  padding: 0 2px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg.assistant .md-p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
}

.msg.assistant hr {
  border: 0;
  border-top: 1px solid var(--border-soft);
  margin: 4px 0;
}

.msg.assistant .md-h {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.msg.assistant .md-list {
  margin: 0;
  padding: 0 0 0 1.2em;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg.assistant .md-quote {
  margin: 0;
  padding: 0 0 0 10px;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
}

.msg.assistant .md-table {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
}

.msg.assistant .md-table td {
  border: 1px solid var(--border-soft);
  padding: 4px 6px;
  vertical-align: top;
}

.md-inline-code {
  font: 12px/18px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(240, 240, 240, 0.08);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}

.md-link {
  color: var(--accent);
  text-decoration: none;
}

.msg.assistant strong { color: var(--text); font-weight: 600; }
.msg.assistant em { font-style: italic; }

.msg.human {
  background: var(--human-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.msg.human .body {
  white-space: pre-wrap;
}

.msg.activity, .tool-card {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 18px;
}

.activity-toggle,
.tool-head {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 2px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.chevron {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  opacity: 0.7;
  flex-shrink: 0;
}

.title-row .chevron { transform: rotate(45deg); margin-top: -3px; }

.activity-toggle[aria-expanded="true"] .chevron,
.tool-head[aria-expanded="true"] .chevron {
  transform: rotate(45deg);
  margin-top: -2px;
}

.activity-body { display: none; margin: 0 0 4px 14px; white-space: pre-wrap; }
.activity-toggle[aria-expanded="true"] + .activity-body { display: block; }

.clamp .body {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.show-more {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  padding: 4px 0 0;
}

.tool-card {
  background: rgba(240, 240, 240, 0.04);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
}

.tool-head { padding: 8px 10px; min-height: 36px; }
.tool-head .name {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-head .meta {
  margin-left: auto;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  flex-shrink: 0;
}
.tool-card.type-edit .meta { color: var(--added-text); }

.tool-body { display: block; border-top: 1px solid var(--border-soft); }
.tool-head[aria-expanded="false"] + .tool-body { display: none; }

.run-prompt {
  margin: 0;
  padding: 10px 12px;
  overflow: visible;
  background: var(--purple-bg);
  color: var(--purple);
  border-left: 3px solid var(--purple);
  font: 12px/18px ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff-block {
  margin: 0;
  padding: 4px 0 6px;
  overflow: visible;
  background: var(--code-bg);
  font: 12px/18px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.diff-line {
  display: flex;
  gap: 8px;
  padding: 0 10px 0 0;
  white-space: pre;
}

.diff-line .mark {
  flex: 0 0 18px;
  text-align: center;
  opacity: 0.85;
}

.diff-line .src {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.diff-line.added { background: var(--added); color: var(--added-text); }
.diff-line.removed { background: var(--removed); color: var(--removed-text); }
.diff-line.unchanged { color: var(--text-muted); }
.diff-line.hunk {
  color: var(--text-muted);
  justify-content: center;
  padding: 4px 0;
  letter-spacing: 2px;
}

.code-block {
  background: var(--code-bg);
  font: 12px/18px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-secondary);
  overflow: visible;
}

.code-block.inline-md {
  margin: 4px 0 8px;
  padding: 8px 0;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow-x: auto;
}

.code-line {
  padding: 0 10px;
  white-space: pre;
}

.code-line.added { background: var(--added); color: var(--added-text); }
.code-line.removed { background: var(--removed); color: var(--removed-text); }

.shell-output {
  margin: 0;
  padding: 8px 10px 10px;
  overflow: visible;
  background: var(--code-bg);
  color: var(--text-muted);
  font: 12px/18px ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

.dock {
  flex-shrink: 0;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  background: var(--bg);
}

.keyboard-open .dock {
  padding-bottom: 8px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 4px 8px;
}

.actions:empty { display: none; margin: 0; }

.pending-run {
  margin: 0 4px 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--purple-bg);
  border-left: 3px solid var(--purple);
  overflow: hidden;
}

.pending-run.hidden { display: none; }

.pending-run-title {
  color: var(--purple);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}

.pending-run .run-prompt {
  max-height: none;
  padding: 0;
  background: transparent;
  border: 0;
}

.review-label {
  margin: 0 0 4px;
  color: var(--purple);
  font-size: 14px;
  font-weight: 600;
}

.review-help {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
}

.attach-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 4px 8px;
  -webkit-overflow-scrolling: touch;
}

.attach-row.hidden { display: none; }

.attach-thumb {
  position: relative;
  flex: 0 0 auto;
}

.attach-thumb img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.attach-thumb button {
  appearance: none;
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: var(--chrome);
  color: var(--text);
  font-size: 14px;
  line-height: 22px;
}

.msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.msg-images img {
  max-width: min(100%, 240px);
  max-height: 180px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--code-bg);
}

.copy-img {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  padding: 0;
}

.attach-btn { flex-shrink: 0; }

button.action.action-review {
  background: #626262;
  border-color: #626262;
  color: var(--text);
}

button.action.action-review[aria-pressed="true"] {
  background: var(--purple);
  border-color: var(--purple);
  color: #191c22;
}

.composer-card {
  position: relative;
  background: rgba(240, 240, 240, 0.04);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px 10px 8px;
}

textarea, input[type="password"], .prompt {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(240, 240, 240, 0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 12px;
  font: 16px/22px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

textarea, .prompt {
  border: 0;
  background: transparent;
  padding: 2px 4px 8px;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  outline: none;
  overflow-y: auto;
}

.prompt:empty:before {
  content: attr(data-placeholder);
  color: var(--placeholder);
  pointer-events: none;
}

textarea::placeholder, input::placeholder { color: var(--placeholder); }

.composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.mode-pill {
  appearance: none;
  border: 0;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--pill);
  border-radius: 999px;
  padding: 6px 10px;
}

.mode-menu {
  position: absolute;
  left: 10px;
  bottom: 48px;
  min-width: 140px;
  max-width: min(92vw, 280px);
  max-height: 42vh;
  overflow: auto;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #1e1e1e;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 8;
}

.model-menu {
  left: auto;
  right: 48px;
  min-width: 200px;
}

.model-pill {
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-section {
  padding: 8px 10px 2px;
  color: var(--muted, #9a9a9a);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.mode-option {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 13px/18px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: 8px 10px;
  border-radius: 8px;
}

.mode-option[aria-selected="true"] {
  background: var(--pill);
}

.mode-menu.hidden { display: none; }

.hint {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}

.round-btn {
  appearance: none;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--text);
  color: var(--accent-ink);
}

.round-btn svg { width: 14px; height: 14px; }
.round-btn.hidden, button.hidden, .sheet.hidden { display: none; }
.round-btn:disabled, button:disabled { opacity: 0.45; }

button.action {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  min-height: 32px;
  padding: 0 10px;
  font: 12px/16px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sheet {
  position: fixed;
  top: var(--vv-top, 0px);
  left: var(--vv-left, 0px);
  width: 100%;
  height: var(--app-height, 100dvh);
  z-index: 20;
}

.sheet-backdrop {
  appearance: none;
  border: 0;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.sheet-card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 75%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--chrome);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.sheet-head.projects-head { margin-top: 18px; }

.new-project {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.new-project input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
}

.icon-quiet[aria-pressed="true"] { color: var(--purple); }

.sheet-list { display: flex; flex-direction: column; gap: 6px; }

.agent-item {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(240, 240, 240, 0.04);
  color: var(--text-secondary);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  min-height: 48px;
}

.agent-item[aria-current="true"] { border-color: var(--border); background: var(--human-bg); }
.agent-item .name { display: block; color: var(--text); }
.agent-item .sub { display: block; color: var(--text-muted); font-size: 12px; }

.login-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background: var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--chrome);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.login-card h1 { font-size: 18px; color: var(--text); }
.login-card p { color: var(--text-muted); }
.login-card label {
  display: block;
  margin: 16px 0 8px;
  font-size: 13px;
}

.login-card .primary {
  appearance: none;
  width: 100%;
  margin-top: 16px;
  border: 0;
  border-radius: 10px;
  min-height: 44px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 15px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.empty {
  color: var(--text-muted);
  text-align: center;
  margin: 32px 8px;
}

/* Tesla / large touchscreen (landscape Chromium, coarse pointer) */
.car-ui {
  font-size: 16px;
  touch-action: manipulation;
}

.car-ui .top {
  padding: 12px 20px;
}

.car-ui h1 {
  font-size: 18px;
  max-width: 46vw;
}

.car-ui .transcript-inner {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  gap: 16px;
  padding: 16px 24px 12px;
}

.car-ui .dock {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 20px 16px;
}

.car-ui .composer-card {
  padding: 14px 16px 12px;
}

.car-ui .prompt {
  min-height: 64px;
  max-height: 28vh;
  font-size: 20px;
  line-height: 28px;
}

.car-ui .round-btn {
  width: 56px;
  height: 56px;
}

.car-ui .round-btn svg {
  width: 20px;
  height: 20px;
}

.car-ui .mode-pill,
.car-ui .icon-quiet,
.car-ui button.action {
  min-height: 48px;
  font-size: 15px;
  padding: 8px 14px;
}

.car-ui .mode-option {
  min-height: 48px;
  font-size: 16px;
  padding: 12px 14px;
}

.car-ui .mode-menu {
  max-height: 50vh;
  min-width: 220px;
}

.car-ui #attach-btn {
  display: none;
}

.car-ui .msg.assistant {
  font-size: 16px;
  line-height: 1.5;
}

.car-ui .msg.human {
  font-size: 16px;
}

.car-ui .agent-item {
  min-height: 64px;
  font-size: 16px;
}

.car-ui .sheet-card {
  max-height: 85%;
  padding: 18px 20px 20px;
}

.car-ui .new-project input {
  min-height: 52px;
  font-size: 18px;
}

.car-ui.car-keyboard .app {
  height: 58vh !important;
  top: 0 !important;
}

.car-ui .login-card {
  width: min(640px, 92vw);
  padding: 32px;
}

.car-ui .login-card h1 {
  font-size: 28px;
}

.car-ui .login-card p,
.car-ui .login-card label {
  font-size: 18px;
}

.car-ui .login-card input,
.car-ui .login-card .primary {
  min-height: 56px;
  font-size: 20px;
}

.car-ui.car-keyboard .login-body {
  min-height: 58vh;
  align-items: start;
  padding-top: 6vh;
}
