:root {
  color-scheme: light dark;
  --bg: oklch(1 0 0);
  --side: oklch(0.975 0 0);
  --surface: oklch(0.955 0 0);
  --hover: oklch(0.925 0 0);
  --ink: oklch(0.22 0 0);
  --muted: oklch(0.48 0 0);
  --line: oklch(0.89 0 0);
  --error: oklch(0.48 0.17 27);
  --accent: oklch(0.2 0 0);
  --on-accent: oklch(1 0 0);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
* {
  box-sizing: border-box;
}
html {
  background: var(--bg);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  height: 100dvh;
  overflow: hidden;
}
button,
input,
textarea {
  font: inherit;
}
/* iOS Safari zooms focused text fields whose font is smaller than 16px. */
input,
textarea {
  font-size: 16px;
}
button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}
button:disabled {
  cursor: default;
  opacity: 0.4;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--muted);
  outline-offset: 3px;
}
button:hover:not(:disabled) {
  background: var(--hover);
}
[hidden] {
  display: none !important;
}
a {
  color: inherit;
}
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  font-size: 25px;
  line-height: 1;
}
.mobile {
  display: none;
}
#sidebar {
  width: 286px;
  flex: none;
  background: var(--side);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 0;
  min-height: 0;
}
.side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px 22px;
}
.brand {
  font-size: 23px;
  font-weight: 650;
  text-decoration: none;
  letter-spacing: -0.7px;
}
.brand span {
  display: block;
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--muted);
  margin-top: 4px;
}
.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-weight: 550;
  padding: 10px 12px;
  min-height: 46px;
  border-radius: 10px;
}
.new-chat span {
  font-size: 26px;
  font-weight: 350;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 12px 4px 20px;
  padding: 0 10px;
}
.search span {
  font-size: 25px;
}
.search input {
  width: 100%;
  min-width: 0;
  background: none;
  border: 0;
  padding: 12px 0;
  color: var(--ink);
  font-size: 16px;
  outline: none;
}
::placeholder {
  color: var(--muted);
  opacity: 1;
}
#thread-list {
  overflow-y: auto;
  flex: 1;
  padding-bottom: 24px;
  overscroll-behavior: contain;
}
.project-group {
  margin: 0 0 22px;
}
.project-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 12px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.thread {
  width: 100%;
  display: block;
  text-align: left;
  padding: 11px 12px;
  border-radius: 9px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
  min-height: 42px;
}
.thread.selected {
  background: var(--hover);
}
.side-footer {
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 4px max(18px, env(safe-area-inset-bottom));
}
.device-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--hover);
  display: grid;
  place-items: center;
  font-size: 20px;
}
.side-footer > div {
  flex: 1;
  min-width: 0;
}
.side-footer strong {
  font-size: 13px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-footer small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
}
main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.topbar {
  background: var(--bg);
  height: 78px;
  flex: none;
  display: flex;
  align-items: center;
  padding: 12px 26px;
  gap: 12px;
}
.heading {
  flex: 1;
  min-width: 0;
}
.heading strong {
  display: block;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  font-size: 17px;
  font-weight: 600;
}
.heading span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#conversation {
  flex: 1;
  overflow: auto;
  min-height: 0;
  overscroll-behavior: contain;
  scroll-padding-bottom: 20px;
}
.empty {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 70px;
  text-align: center;
}
.empty-mark {
  font-size: 37px;
  margin-bottom: 16px;
}
.empty h1 {
  font-size: 30px;
  letter-spacing: -0.7px;
  margin: 0 0 12px;
  font-weight: 600;
}
.empty p {
  color: var(--muted);
  margin: 0 0 20px;
}
.plain {
  padding: 10px 16px;
  border-radius: 8px;
  min-height: 44px;
}
.timeline {
  max-width: 800px;
  padding: 12px 32px 40px;
  margin: auto;
}
.older {
  display: block;
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 13px;
}
.message {
  margin: 20px 0 32px;
  line-height: 1.8;
  overflow-wrap: anywhere;
  min-width: 0;
}
.message.user {
  display: flex;
  justify-content: flex-end;
}
.message.user .content {
  background: var(--surface);
  border-radius: 20px;
  padding: 12px 18px;
  max-width: 85%;
  white-space: pre-wrap;
  line-height: 1.65;
}
.message.assistant .content {
  max-width: 75ch;
}
.message p {
  margin: 0 0 14px;
}
.message p:last-child {
  margin-bottom: 0;
}
.message h1,
.message h2,
.message h3 {
  font-size: 1.2em;
  margin: 24px 0 12px;
  font-weight: 650;
  line-height: 1.5;
}
.message ul,
.message ol {
  padding-left: 25px;
  margin: 12px 0;
}
.message li {
  margin: 6px 0;
}
.message pre {
  overflow: auto;
  background: var(--side);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 15px;
  font-size: 13px;
  line-height: 1.6;
  max-width: 100%;
  white-space: pre;
}
.message code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: var(--surface);
  border-radius: 4px;
  padding: 2px 4px;
}
.message pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}
.message a {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.message .phase {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}
.message time {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}
.composer-wrap {
  width: min(100%, 800px);
  margin: 0 auto;
  padding: 10px 24px max(12px, env(safe-area-inset-bottom));
  flex: none;
  background: var(--bg);
}
#composer {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 14px 14px 10px;
  background: var(--bg);
}
textarea {
  resize: none;
  width: 100%;
  max-height: 160px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 2px 4px 10px;
  line-height: 1.5;
  outline: none !important;
  font-size: 16px;
  display: block;
}
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.composer-actions > div {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.attach {
  cursor: pointer;
  font-size: 27px;
  min-width: 44px;
  min-height: 44px;
}
.model {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.send {
  height: 44px;
  width: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 25px;
  font-weight: 500;
}
.send:hover:not(:disabled) {
  background: var(--muted);
}
#stop {
  font-size: 15px;
}
.composer-note {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding-top: 10px;
}
.muted {
  color: var(--muted);
}
.pad {
  padding: 12px;
  font-size: 13px;
}
#notice {
  padding: 10px 20px;
  background: var(--surface);
  color: var(--error);
  font-size: 13px;
  line-height: 1.5;
}
.receipt {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 0;
}
.receipt.error {
  color: var(--error);
}
.receipt button {
  padding: 10px;
  text-decoration: underline;
}
.stream-status {
  font-size: 13px;
  color: var(--muted);
  padding: 10px 0;
}
.stream-status:before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--ink);
  border-radius: 50%;
  margin-right: 9px;
  animation: pulse 1.5s infinite;
}
.stream-status.awaiting-response:before {
  animation: none;
}
/* Questions and approvals stay in the conversation, including their outcome. */
.approval {
  border: 1px solid var(--line);
  padding: 20px;
  border-radius: 16px;
  margin: 20px 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.approval-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.approval h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.approval-status {
  color: var(--muted);
  font-size: 12px;
}
.approval fieldset {
  border: 0;
  margin: 0 0 22px;
  padding: 0;
  min-width: 0;
}
.approval legend {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 12px;
  padding: 0;
}
.answer-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  line-height: 1.5;
}
.answer-option:has(input:checked) {
  border-color: var(--ink);
  background: var(--surface);
}
.answer-option input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--ink);
}
.answer-option strong {
  display: block;
  font-size: 15px;
  font-weight: 550;
}
.option-description {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.approval .answer-text {
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  font-size: 16px;
  line-height: 1.5;
}
.approval .answer-text:focus-visible {
  outline: 2px solid var(--muted) !important;
  outline-offset: 2px;
}
.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.approval-actions button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 18px;
  min-height: 44px;
}
.approval-actions .approval-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.approval-actions .approval-primary:hover:not(:disabled) {
  background: var(--muted);
}
.approval p {
  white-space: pre-wrap;
  line-height: 1.6;
  margin: 12px 0;
}
.approval-explanation {
  font-size: 15px;
}
.approval-context {
  font-size: 12px;
  color: var(--muted);
}
.approval-command {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.6;
  background: var(--surface);
  border-radius: 8px;
  padding: 12px;
  max-height: 240px;
  overflow: auto;
}
.approval details summary {
  cursor: pointer;
  padding: 12px 0;
  font-size: 14px;
}
.approval-error {
  color: var(--error);
  font-size: 13px;
}
.approval-result {
  font-size: 15px;
}
.approval.resolved {
  border-color: transparent;
  background: var(--surface);
}
.approval.resolved .approval-header {
  margin-bottom: 0;
}
.approval.resolved .approval-result {
  margin-bottom: 0;
}
#attachments {
  display: flex;
  gap: 8px;
  overflow: auto;
}
#attachments > div {
  position: relative;
  margin-bottom: 10px;
  flex: none;
}
#attachments img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 10px;
}
#attachments button {
  position: absolute;
  right: 0;
  top: 0;
  background: var(--ink);
  color: var(--bg);
  border-radius: 50%;
  width: 26px;
  height: 26px;
}
dialog {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(480px, calc(100% - 32px));
  max-height: 80dvh;
  padding: 22px;
}
dialog::backdrop {
  background: oklch(0 0 0/0.35);
}
dialog h2 {
  font-size: 22px;
  margin: 0;
}
dialog p {
  font-size: 14px;
  line-height: 1.6;
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#project-options button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 10px;
  border-radius: 8px;
}
#project-options small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
  margin-top: 5px;
}
#access-key {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  margin: 10px 0;
}
.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 8px;
  padding: 12px 20px;
}
#project-options {
  max-height: 55dvh;
  overflow: auto;
}
@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.24 0 0);
    --side: oklch(0.2 0 0);
    --surface: oklch(0.3 0 0);
    --hover: oklch(0.34 0 0);
    --ink: oklch(0.95 0 0);
    --muted: oklch(0.72 0 0);
    --line: oklch(0.38 0 0);
    --error: oklch(0.78 0.13 27);
    --accent: oklch(0.95 0 0);
    --on-accent: oklch(0.2 0 0);
  }
}
@media (max-width: 760px) {
  /* Keep both iPhone safe areas independent of the drawer and its scrim. */
  body::before,
  body::after {
    content: "";
    position: fixed;
    left: 0;
    right: 0;
    background: var(--bg);
    pointer-events: none;
    z-index: 40;
  }
  body::before {
    top: 0;
    height: max(1px, env(safe-area-inset-top, 0px));
  }
  body::after {
    bottom: 0;
    height: max(1px, env(safe-area-inset-bottom, 0px));
  }
  .mobile {
    display: inline-flex;
  }
  #sidebar {
    position: fixed;
    background: var(--bg);
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 30;
    width: min(320px, 88vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    padding-top: max(16px, env(safe-area-inset-top));
  }
  body.menu-open #sidebar {
    transform: translateX(0);
  }
  .scrim {
    position: fixed;
    inset: 0;
    z-index: 20;
    border-radius: 0;
  }
  /* Safari can sample either edge of overlays for its browser chrome, even
     when safe-area insets are zero. Keep both bands the page color.
     Override button hover too: touch Safari can retain hover after a tap. */
  .scrim,
  .scrim:hover:not(:disabled) {
    background: linear-gradient(
      to bottom,
      var(--bg) 0 calc(66px + env(safe-area-inset-top, 0px)),
      oklch(0 0 0 / 0.3) calc(66px + env(safe-area-inset-top, 0px))
        calc(100% - 66px - env(safe-area-inset-bottom, 0px)),
      var(--bg) calc(100% - 66px - env(safe-area-inset-bottom, 0px)) 100%
    );
  }
  .topbar {
    height: auto;
    min-height: 66px;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
    gap: 6px;
  }
  .heading strong {
    font-size: 16px;
  }
  .heading span {
    font-size: 11px;
  }
  .timeline {
    padding: 8px 20px 20px;
  }
  .message {
    margin: 18px 0 28px;
  }
  .message.user .content {
    max-width: 90%;
    padding: 11px 16px;
  }
  .empty h1 {
    font-size: 27px;
  }
  .composer-wrap {
    padding: 8px 12px max(10px, env(safe-area-inset-bottom));
  }
  #composer {
    padding: 12px 10px 8px;
    border-radius: 22px;
  }
  .composer-note {
    font-size: 10px;
    padding-top: 8px;
  }
  .model {
    max-width: 180px;
  }
  .side-head {
    padding-bottom: 16px;
  }
  .empty {
    padding-bottom: 32px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

#attachments button:before {
  content: "";
  position: absolute;
  inset: -9px;
}

/* Compact desktop-style execution rows; details stay closed until requested. */
.activity {
  margin: 4px 0;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}
.activity > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 0;
  cursor: pointer;
  list-style: none;
}
.activity > summary::-webkit-details-marker {
  display: none;
}
.activity > summary::after {
  content: "›";
  font-size: 20px;
  flex: none;
}
.activity[open] > summary::after {
  transform: rotate(90deg);
}
.activity > summary:focus-visible {
  outline: 2px solid var(--muted);
  outline-offset: 2px;
  border-radius: 6px;
}
.activity-icon {
  width: 20px;
  flex: none;
  text-align: center;
  font:
    15px ui-monospace,
    monospace;
}
.activity-label {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.activity-label strong {
  font-weight: 500;
  flex: none;
  color: var(--ink);
}
.activity-label > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-state {
  flex: none;
  font-size: 11px;
}
.activity-running .activity-state {
  color: var(--ink);
}
.activity-failed .activity-state,
.activity-interrupted .activity-state {
  color: var(--error);
}
.activity-body {
  margin: 0 0 12px;
  padding: 8px 14px 14px;
  background: var(--side);
  border-radius: 10px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.activity-body p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.activity-detail-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}
.activity-detail-heading strong {
  font-size: 12px;
  font-weight: 550;
  overflow-wrap: anywhere;
  min-width: 0;
}
.activity-detail-heading button {
  min-height: 44px;
  min-width: 44px;
  flex: none;
  color: var(--muted);
  font-size: 12px;
}
.activity-body pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font:
    12px/1.65 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  max-height: 280px;
  overflow: auto;
  margin: 0;
  tab-size: 2;
}
.activity-diff > span {
  display: block;
  white-space: pre-wrap;
}
.diff-add {
  color: oklch(0.38 0.09 150);
  background: oklch(0.96 0.025 150);
}
.diff-remove {
  color: oklch(0.43 0.13 25);
  background: oklch(0.96 0.025 25);
}
.activity-plan {
  padding-left: 20px;
  line-height: 1.8;
}
.activity + .message {
  margin-top: 22px;
}
@media (max-width: 760px) {
  .activity-label {
    display: block;
  }
  .activity-label > span {
    display: block;
    font-size: 12px;
    margin-top: 2px;
  }
}
@media (prefers-color-scheme: dark) {
  .diff-add {
    color: oklch(0.85 0.09 150);
    background: oklch(0.3 0.035 150);
  }
  .diff-remove {
    color: oklch(0.85 0.09 25);
    background: oklch(0.3 0.035 25);
  }
}
