:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --pane: #ffffff;
  --sidebar: #fafafa;
  --ink: #111827;
  --muted: rgba(17, 24, 39, 0.56);
  --subtle: rgba(17, 24, 39, 0.38);
  --line: rgba(17, 24, 39, 0.09);
  --line-strong: rgba(22, 119, 255, 0.34);
  --accent: #1677ff;
  --accent-strong: #0958d9;
  --accent-soft: #f0f7ff;
  --danger: #b42318;
  --shadow: 0 18px 58px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.local-agent-shell {
  width: 100%;
  min-width: 0;
  height: 100vh;
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(248px, 288px) minmax(0, 1fr);
  overflow: hidden;
  background: var(--pane);
}

.local-agent-session-sidebar {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px 10px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  overflow: hidden;
}

.local-agent-session-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.local-agent-session-sidebar__heading {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
  color: rgba(17, 24, 39, 0.76);
}

.muted-count {
  color: var(--subtle);
  font-weight: 500;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.24);
}

.activity-dot--running {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(22, 119, 255, 0.12);
}

.local-agent-session-sidebar__tools,
.local-agent-actions,
.auth-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(17, 24, 39, 0.72);
  padding: 0;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(22, 119, 255, 0.28);
  background: rgba(22, 119, 255, 0.06);
  color: var(--accent-strong);
}

.text-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(22, 119, 255, 0.28);
  border-radius: 8px;
  background: rgba(22, 119, 255, 0.06);
  color: var(--accent-strong);
  padding: 7px 10px;
  text-decoration: none;
  font-size: 12px;
  line-height: 18px;
}

.text-button:hover,
.text-button:focus-visible {
  border-color: rgba(22, 119, 255, 0.46);
  background: var(--accent-soft);
}

.sidebar-search,
input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
button:focus-visible {
  border-color: rgba(22, 119, 255, 0.48);
  outline: 3px solid rgba(22, 119, 255, 0.14);
}

.local-agent-session-sidebar__list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
  padding-right: 2px;
}

.local-agent-session-tab {
  width: 100%;
  min-width: 0;
  position: relative;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(17, 24, 39, 0.78);
  padding: 8px 8px 8px 10px;
  text-align: left;
  outline: none;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.local-agent-session-tab:hover,
.local-agent-session-tab:focus-visible {
  border-color: rgba(22, 119, 255, 0.28);
  background: rgba(22, 119, 255, 0.06);
}

.local-agent-session-tab--active {
  border-color: rgba(22, 119, 255, 0.4);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.local-agent-session-tab__body {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 3px;
}

.local-agent-session-tab__title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.local-agent-session-tab__title,
.local-agent-session-tab__meta,
.local-agent-session-tab__time {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.local-agent-session-tab__title {
  font-size: 13px;
  font-weight: 650;
  line-height: 20px;
}

.local-agent-session-tab__meta,
.local-agent-session-tab__time {
  color: var(--subtle);
  font-size: 11px;
  line-height: 16px;
}

.local-agent-session-tab__activity {
  position: absolute;
  right: 10px;
  bottom: 9px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
  pointer-events: none;
}

.local-agent-session-tab__activity::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: inherit;
  border: 1px solid rgba(22, 119, 255, 0.36);
  animation: running-ripple 1.6s ease-out infinite;
}

@keyframes running-ripple {
  0% {
    opacity: 0.72;
    transform: scale(0.48);
  }

  70%,
  100% {
    opacity: 0;
    transform: scale(1);
  }
}

.local-agent-main-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--pane);
}

.local-agent-main-pane__header {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.local-agent-main-pane__title {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.local-agent-main-pane__title strong,
.local-agent-main-pane__title span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.local-agent-main-pane__title strong {
  font-size: 14px;
}

.local-agent-main-pane__title span {
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  min-width: 116px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}

.status-pill.connected {
  border-color: rgba(22, 119, 255, 0.32);
  color: var(--accent-strong);
}

.status-pill.error {
  border-color: rgba(180, 35, 24, 0.36);
  color: var(--danger);
}

.local-agent-chat-region {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.local-agent-transcript-shell {
  width: 100%;
  max-width: 68rem;
  min-height: 0;
  margin: 0 auto;
  padding: 16px 8px;
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.agent-transcript-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  padding: 6px 4px 14px;
}

.transcript-empty {
  height: 100%;
  min-height: 320px;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.transcript-empty strong {
  color: var(--ink);
  font-size: 18px;
}

.transcript-empty span {
  font-size: 13px;
}

.agent-chat-row {
  min-width: 0;
  max-width: 100%;
  display: grid;
  gap: 3px;
}

.agent-chat-row--user {
  justify-items: end;
}

.agent-chat-row--assistant,
.agent-chat-row--system {
  justify-items: start;
}

.agent-chat-meta-row {
  max-width: min(44rem, 92%);
  margin: 0 6px;
  color: rgba(15, 23, 42, 0.48);
  font-size: 11px;
  line-height: 16px;
}

.agent-chat-row--user .agent-chat-meta-row {
  text-align: right;
}

.agent-chat-bubble {
  max-width: min(44rem, 92%);
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  padding: 10px 12px;
}

.agent-chat-row--user .agent-chat-bubble {
  border-color: rgba(22, 119, 255, 0.26);
  background: var(--accent-soft);
}

.agent-chat-row--system .agent-chat-bubble {
  border-style: dashed;
  color: var(--muted);
  background: #fbfcfd;
}

.agent-chat-row--running .agent-chat-bubble {
  border-color: rgba(22, 119, 255, 0.3);
}

.agent-chat-row--error .agent-chat-bubble {
  border-color: rgba(180, 35, 24, 0.28);
  color: var(--danger);
  background: #fff7f6;
}

.agent-chat-content {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.62;
}

pre.agent-chat-content {
  max-height: 320px;
  overflow: auto;
  border-radius: 10px;
  background: #111827;
  color: #f9fafb;
  padding: 10px;
  font-size: 12px;
}

.agent-live-region,
.agent-event-journal {
  width: min(44rem, 92%);
  min-width: 0;
  display: grid;
  gap: 6px;
  justify-self: start;
}

.agent-region-label {
  margin-left: 6px;
  color: rgba(15, 23, 42, 0.48);
  font-size: 11px;
  line-height: 16px;
}

.agent-working-bubble {
  min-width: 0;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(22, 119, 255, 0.32);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  padding: 10px 12px;
}

.agent-live-region--error .agent-working-bubble {
  border-color: rgba(180, 35, 24, 0.28);
  color: var(--danger);
  background: #fff7f6;
}

.agent-working-bubble strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.5;
}

.agent-working-bubble__partial {
  max-height: 240px;
  overflow: auto;
  margin: 0;
  border-radius: 10px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 9px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.55;
}

.agent-working-bubble__detail {
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.45;
}

.agent-working-bubble__stop {
  width: max-content;
  min-height: 30px;
  border: 1px solid rgba(180, 35, 24, 0.28);
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  padding: 5px 10px;
  font-size: 12px;
}

.agent-event-journal {
  border-left: 2px solid rgba(22, 119, 255, 0.18);
  padding-left: 10px;
}

.agent-event-journal__list {
  display: grid;
  gap: 4px;
}

.agent-event-journal__item {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  padding: 6px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.local-agent-composer-shell {
  flex: 0 0 auto;
  width: min(90%, 58rem);
  align-self: center;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.local-agent-composer-input {
  display: grid;
  gap: 8px;
}

#promptInput {
  min-height: 92px;
  max-height: 220px;
  border: 0;
  border-radius: 14px;
  background: #fbfcfd;
  resize: vertical;
}

.local-agent-composer-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
  align-items: center;
}

#workspaceInput {
  height: 38px;
}

.send-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
}

.send-button:hover,
.send-button:focus-visible {
  background: var(--accent-strong);
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.18);
}

.settings-drawer {
  position: fixed;
  z-index: 40;
  top: 0;
  right: 0;
  width: min(440px, 100vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, auto) minmax(0, auto) minmax(0, 1fr);
  gap: 14px;
  overflow: auto;
  padding: 16px;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform 180ms ease;
}

.settings-drawer--open {
  transform: translateX(0);
}

.settings-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-section {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.auth-session-panel {
  min-width: 0;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}

.auth-session-panel__tools {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

#codexAuthInput {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

#chatGptSessionInput {
  min-height: 118px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.auth-actions {
  min-width: 0;
}

.auth-actions span:last-child {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metrics div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 9px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metrics strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#output {
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #f9fafb;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
}

@media (prefers-reduced-motion: reduce) {
  .local-agent-session-tab__activity::after {
    animation: none;
    opacity: 0;
  }

  .settings-drawer {
    transition: none;
  }
}

@media (max-width: 820px) {
  .local-agent-shell {
    height: 100dvh;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .local-agent-session-sidebar {
    grid-template-rows: auto auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .local-agent-session-sidebar__list {
    display: none;
  }

  .local-agent-main-pane__header {
    padding: 10px 12px;
    gap: 10px;
  }

  .local-agent-actions {
    gap: 4px;
  }

  .status-pill {
    min-width: 92px;
    padding-inline: 8px;
  }

  .local-agent-transcript-shell {
    padding: 10px 8px;
  }

  .local-agent-composer-shell {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border-radius: 16px;
  }

  #promptInput {
    min-height: 64px;
    max-height: 140px;
  }

  .local-agent-composer-footer {
    grid-template-columns: minmax(0, 1fr) 38px;
  }

  .send-button {
    width: 38px;
    height: 38px;
  }
}
