:root {
  --bg: #eef1ef;
  --bg-soft: #f7f9f7;
  --panel: #ffffff;
  --panel-strong: #fbfcfb;
  --border: #d9e0db;
  --border-strong: #c7d0ca;
  --text: #172019;
  --muted: #657168;
  --accent: #08794d;
  --accent-strong: #05623e;
  --accent-soft: #e6f3ec;
  --blue: #356d9b;
  --blue-soft: #edf4fa;
  --warning: #a46814;
  --warning-soft: #fff4dd;
  --danger: #b33a31;
  --danger-soft: #fbecea;
  --user: #e8f4ed;
  --assistant: #ffffff;
  --system: #f4f6f4;
  --shadow: 0 8px 28px rgba(23, 32, 25, 0.07);
  --radius-lg: 8px;
  --radius-md: 6px;
}

* {
  letter-spacing: 0 !important;
}

body {
  background: var(--bg);
}

.login-shell {
  background: var(--bg);
}

.login-card {
  width: min(420px, 100%);
  padding: 30px;
  border-top: 4px solid var(--accent);
}

.login-card h1 {
  margin-top: 7px;
  font-family: inherit;
  font-size: 25px;
}

.login-card .subhead {
  color: var(--muted);
  line-height: 1.65;
}

.app-shell {
  width: min(1680px, calc(100% - 24px));
  padding: 12px 0;
}

body:not(.activity-collapsed):not(.compact-mode) .app-shell {
  width: min(1680px, calc(100% - 382px));
  margin-left: 12px;
  margin-right: 370px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: none;
}

.topbar {
  min-height: 64px;
  padding: 10px 12px;
  grid-template-columns: minmax(190px, auto) minmax(0, 1fr) auto;
  gap: 12px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 7px;
  background: var(--text);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}

.topbar-brand strong {
  display: block;
  margin-top: 1px;
  font-size: 15px;
}

.eyebrow {
  color: var(--accent);
  font-size: 10px;
  line-height: 1.2;
  text-transform: uppercase;
}

.topbar-meta {
  justify-content: flex-start;
  gap: 7px;
  overflow: hidden;
}

.topbar-status,
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.topbar-status {
  color: var(--text);
  font-weight: 700;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ba59e;
}

body[data-connection="connected"] .connection-dot {
  background: #13a36a;
  box-shadow: 0 0 0 3px rgba(19, 163, 106, 0.12);
}

body[data-connection="reconnecting"] .connection-dot,
body[data-connection="connecting"] .connection-dot {
  background: #d18a22;
  animation: connection-pulse 1.2s ease-in-out infinite;
}

.topbar-pills {
  display: none;
}

.mode-pill,
.cwd-pill {
  display: none;
}

.mini-pill {
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid #e3e7e4;
  border-radius: 5px;
  background: #f5f7f5;
  font-size: 11px;
}

.mini-pill strong {
  color: var(--text);
}

.cwd-pill {
  max-width: 190px;
}

.cwd-pill strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  gap: 5px;
}

button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 650;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover {
  transform: none;
}

button.subtle,
.logout-button {
  border-color: var(--border);
  background: #fff;
  color: #4f5c53;
}

button.subtle:hover,
.logout-button:hover {
  border-color: var(--border-strong);
  background: #f4f6f4;
}

button.subtle[aria-pressed="true"] {
  border-color: #b9d6c6;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

button.cut-in {
  border-color: #c8dceb;
  background: var(--blue-soft);
  color: #285e87;
}

button.danger {
  border-color: #eccdca;
  background: var(--danger-soft);
  color: var(--danger);
}

.app-layout {
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.control-panel {
  padding: 12px;
  align-self: stretch;
  height: 100%;
}

.control-group {
  margin-top: 10px;
  padding: 10px 0;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

.control-panel > .control-group:first-child,
.side-console .control-group:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.control-group summary::after {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

.workspace-section-head h2,
.workspace-section-head h3,
.panel-head h2,
.chat-head h2 {
  margin: 0;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.35;
}

.workspace-section-head h3 {
  font-size: 14px;
}

.thread-toolbar {
  gap: 5px;
}

.thread-toolbar button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

.thread-search,
textarea,
input,
.thread-card,
.request-card,
.workspace-empty,
.activity-entry,
.request-block,
.upload-dropzone,
.reasoning-switch button,
.chip {
  border-radius: 6px;
}

.thread-search {
  min-height: 38px;
  margin-top: 10px;
  background: #fafbfa;
}

.workspace-list {
  gap: 7px;
  margin-top: 10px;
}

.thread-card {
  padding: 10px;
  border-color: var(--border);
  box-shadow: none;
}

.thread-card.active {
  border-color: #8cb9a0;
  background: #eef7f2;
  box-shadow: inset 3px 0 0 var(--accent);
}

.thread-actions {
  gap: 5px;
  margin-top: 8px;
}

.thread-actions button {
  min-height: 27px;
  padding: 3px 7px;
  font-size: 11px;
}

.chat-panel {
  background: #fff;
}

.chat-head {
  flex: 0 0 auto;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfb;
}

.chat-meta {
  max-width: 70%;
  gap: 5px;
}

.chat-meta span {
  border-radius: 5px;
  background: #f3f5f3;
  font-size: 11px;
}

.messages {
  gap: 10px;
  padding: 18px max(20px, calc((100% - 980px) / 2)) 22px;
  background: #f7f9f7;
}

.message {
  position: relative;
  width: min(100%, 900px);
  max-width: min(100%, 900px);
  padding: 14px 48px 14px 16px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--assistant);
  box-shadow: 0 2px 8px rgba(23, 32, 25, 0.035);
}

.message.user {
  width: min(86%, 780px);
  margin-left: auto;
  border-color: #c6ddcf;
  background: var(--user);
}

.message.assistant {
  border-left: 3px solid #5b86a8;
}

.message.system {
  padding-right: 16px;
  border-style: dashed;
  background: var(--system);
  box-shadow: none;
}

.message-role {
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 750;
}

.message-body {
  color: #273129;
  font-size: 14px;
  line-height: 1.72;
}

.message.assistant .message-body {
  font-size: 15px;
}

.message-actions {
  top: 8px;
  right: 8px;
}

.message-copy {
  min-height: 26px;
  padding: 3px 7px;
  border-color: var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  opacity: 0;
}

.message:hover .message-copy,
.message-copy:focus-visible {
  opacity: 1;
}

.scroll-bottom {
  right: 20px;
  bottom: 162px;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 5px 16px rgba(23, 32, 25, 0.14);
  color: var(--accent);
  font-size: 19px;
}

.composer {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.composer textarea {
  min-height: 88px;
  border-color: var(--border-strong);
  border-radius: 7px;
  line-height: 1.58;
}

.composer textarea:focus {
  border-color: #6fa58a;
  box-shadow: 0 0 0 3px rgba(8, 121, 77, 0.08);
}

.composer-footer {
  gap: 10px;
}

.upload-panel-inline {
  min-width: 0;
}

.upload-dropzone {
  min-height: 36px;
  padding: 7px 10px;
  border-color: #b9cec1;
  background: #f6faf7;
}

.upload-dropzone strong,
.upload-dropzone span {
  font-size: 12px;
}

.queue-status,
.char-count {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.queue-status {
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--warning-soft);
  color: #805b12;
}

.char-count.near-limit {
  color: var(--danger);
  font-weight: 750;
}

.activity-panel {
  top: 86px;
  right: 12px;
  bottom: 12px;
  width: 348px;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-head {
  flex: 0 0 auto;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfb;
}

.activity-stream-section {
  flex: 1 1 auto;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  overflow: hidden;
}

.activity-stream-head {
  flex: 0 0 auto;
  align-items: center;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
}

.live-indicator > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a36b;
}

.compact-button {
  min-height: 27px;
  padding: 3px 8px;
  font-size: 11px;
}

.activity-log {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  margin-top: 9px;
  padding-right: 2px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.activity-entry {
  flex: 0 0 auto;
  border-color: var(--border);
  background: #fff;
}

.activity-entry summary {
  padding: 8px 10px;
  font-size: 11px;
}

.activity-entry pre {
  padding: 0 10px 10px;
  color: #526057;
  font-size: 11px;
  line-height: 1.52;
}

.activity-command {
  border-left: 3px solid #7d93a6;
}

.activity-file {
  border-left: 3px solid var(--accent);
}

.approvals-section {
  flex: 0 0 auto;
  max-height: 190px;
  margin: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  overflow-y: auto;
}

.approvals-section .workspace-list {
  margin-top: 8px;
}

.count-badge {
  min-width: 27px;
  height: 27px;
  padding: 0 8px;
  border-radius: 6px;
}

.side-console {
  flex: 0 0 auto;
  max-height: 300px;
  margin: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  border-bottom: 0;
  overflow-y: auto;
}

.side-console .control-group {
  margin-top: 8px;
}

.reasoning-switch {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.reasoning-switch button {
  min-height: 31px;
  padding: 5px 3px;
  font-size: 11px;
}

.field-block {
  margin-top: 12px;
}

.directory-row {
  grid-template-columns: minmax(0, 1fr) 62px;
  gap: 6px;
}

.hint,
.upload-meta {
  font-size: 11px;
}

.compact-strip {
  border-bottom: 1px solid var(--border);
  background: #fbfcfb;
}

body.compact-mode .compact-strip {
  display: flex;
  padding: 8px 10px;
}

@keyframes connection-pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

@media (max-width: 1380px) {
  body:not(.activity-collapsed):not(.compact-mode) .app-shell {
    width: calc(100% - 24px);
    margin: 0 auto;
  }

  .activity-panel {
    top: 82px;
    right: 12px;
    width: min(380px, calc(100% - 24px));
    box-shadow: 0 18px 54px rgba(23, 32, 25, 0.18);
  }

  .cwd-pill,
  .mode-pill {
    display: none;
  }
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: auto 1fr;
  }

  .topbar-meta {
    justify-content: flex-end;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .app-layout {
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .card,
  .chat-panel {
    border-radius: 0;
  }

  body:not(.compact-mode) .app-layout {
    display: block;
    height: calc(100dvh - 136px);
    margin-top: 0;
  }

  body:not(.compact-mode):not(.sidebar-collapsed) .control-panel {
    display: block;
    width: 100%;
    height: 100%;
    border-right: 0;
  }

  body:not(.compact-mode):not(.sidebar-collapsed) .chat-panel {
    display: none;
  }

  body:not(.compact-mode).sidebar-collapsed .chat-panel {
    display: flex;
    height: 100%;
  }

  body.compact-mode .chat-panel {
    border: 0;
  }

  .compact-strip {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .compact-strip button {
    flex: 1 1 96px;
  }

  .messages {
    padding: 12px;
  }

  .message,
  .message.user {
    width: 100%;
    padding: 12px 44px 12px 12px;
  }

  .message-copy {
    opacity: 1;
  }

  .composer {
    padding: 10px 12px 12px;
  }

  .upload-panel-inline {
    display: none;
  }

  .composer-actions {
    width: 100%;
    flex-direction: row;
    align-items: center;
  }

  .composer-actions button {
    width: auto;
    min-width: 76px;
  }

  .activity-panel {
    inset: 0;
    width: 100%;
    max-width: none;
    border: 0;
    border-radius: 0;
  }

  .control-panel {
    padding: 12px;
  }
}
