:root {
  color-scheme: light;
  --brand-ink: #111827;
  --brand-line: #d9e0ea;
  --brand-soft: #eef3f8;
  --accent: #0b6f69;
  --accent-strong: #095c57;
  --accent-soft: #dff4f0;
  --blue: #2563eb;
  --violet: #7c3aed;
  --warning: #b45309;
  --danger: #b42318;
  --success: #15803d;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #182230;
  --muted: #667085;
  --faint: #98a2b3;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --topbar-height: 72px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--brand-soft);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(120deg, rgba(11, 111, 105, 0.10), rgba(37, 99, 235, 0.06) 42%, rgba(248, 250, 252, 0) 64%),
    linear-gradient(180deg, #fdfefe 0%, #eef3f8 100%);
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 clamp(16px, 3vw, 34px);
  border-bottom: 1px solid rgba(217, 224, 234, 0.86);
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand-lockup,
.topbar-actions,
.account-shell,
.rail-header,
.rail-actions,
.conversation-header,
.conversation-actions,
.lifecycle-actions,
.pairing-actions,
.panel-heading,
.composer-dock,
.session-row,
.system-note,
.message-row {
  display: flex;
  align-items: center;
}

.brand-lockup {
  min-width: 0;
  gap: 12px;
  flex: 1 1 auto;
}

.brand-wordmark {
  width: 48px;
  height: 34px;
  object-fit: cover;
  object-position: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: #101828;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.10);
}

.brand-title,
.brand-subtitle,
.pane-kicker,
.pane-title,
.rail-note,
.field-feedback,
.summary-list,
.summary-list dd,
.summary-list dt,
.message-bubble p,
.system-note p,
.diagnostic-list,
.session-name,
.session-meta {
  margin: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 760;
  line-height: 1.1;
}

.brand-subtitle {
  max-width: min(58vw, 620px);
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}

.account-shell {
  min-width: 0;
  gap: 8px;
  padding: 4px;
  border: 1px solid rgba(215, 221, 232, 0.78);
  border-radius: var(--radius);
  background: rgba(248, 250, 252, 0.78);
}

.account-shell[data-status="signed-in"] {
  border-color: rgba(21, 128, 61, 0.24);
  background: rgba(21, 128, 61, 0.08);
}

.account-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 99px;
  background: var(--faint);
}

.account-shell[data-status="signed-in"] .account-status-dot {
  background: var(--success);
}

.account-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.account-label,
.account-detail {
  display: block;
  max-width: 132px;
  min-width: 0;
  overflow: hidden;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-label {
  color: var(--text);
  font-size: 12px;
  font-weight: 760;
}

.account-detail {
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
}

.topbar-state {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  gap: 8px;
  margin-left: auto;
}

.state-summary {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.account-link,
.primary-button,
.secondary-button,
.danger-button,
.composer-dock button {
  min-height: 38px;
  border-radius: var(--radius);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.icon-button {
  width: 38px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--brand-line);
  background: var(--surface);
}

.icon-button:not(:disabled):hover,
.account-link:hover,
.secondary-button:hover,
.danger-button:hover {
  border-color: #acb8c9;
  transform: translateY(-1px);
}

.account-link {
  display: inline-grid;
  place-items: center;
  padding: 0 14px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--brand-line);
  background: var(--surface);
}

.account-secondary {
  color: var(--muted);
  background: transparent;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(420px, 1fr) minmax(270px, 330px);
  gap: 18px;
  min-height: 0;
  padding: 16px clamp(18px, 3vw, 36px) 22px;
}

.session-rail,
.conversation-pane,
.side-panel {
  min-height: 0;
}

.session-rail {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 16px 14px 12px;
  border: 1px solid rgba(217, 224, 234, 0.78);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.70);
}

.rail-header,
.conversation-header,
.panel-heading {
  justify-content: space-between;
  gap: 12px;
}

.rail-actions,
.conversation-actions,
.lifecycle-actions {
  gap: 8px;
  flex: 0 0 auto;
}

.pane-kicker {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 780;
  line-height: 1.3;
  text-transform: none;
}

.pane-title {
  color: var(--text);
  font-size: 18px;
  line-height: 1.25;
}

.session-list {
  display: grid;
  align-content: start;
  gap: 4px;
  overflow: auto;
  min-height: 0;
}

.session-row {
  width: 100%;
  min-height: 58px;
  gap: 10px;
  padding: 9px;
  color: var(--text);
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
}

.session-row.selected {
  border-color: rgba(11, 111, 105, 0.18);
  background: rgba(11, 111, 105, 0.08);
}

.session-row:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.72);
  transform: translateY(-1px);
}

.cli-pill {
  position: relative;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #ffffff;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 780;
}

.cli-pill.codex {
  background: var(--accent);
}

.cli-pill.claude {
  background: var(--violet);
}

.cli-pill.opencode {
  background: var(--blue);
}

.session-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
  flex: 1;
}

.session-name,
.session-meta {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-name {
  font-size: 13px;
  font-weight: 690;
}

.session-meta {
  color: var(--muted);
  font-size: 12px;
}

.session-status {
  width: 58px;
  flex: 0 0 auto;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  line-height: 1.25;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-status.ready {
  color: var(--success);
}

.session-status.idle {
  color: var(--warning);
}

.session-status.muted {
  color: var(--faint);
}

.session-status.error {
  color: var(--danger);
}

.state-dot,
.note-dot,
.dirty-dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  flex: 0 0 auto;
}

.state-dot.idle,
.note-dot {
  background: var(--warning);
}

.state-dot.muted {
  background: var(--faint);
}

.state-dot.ready {
  background: var(--success);
}

.state-dot.error {
  background: var(--danger);
}

.dirty-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  border: 2px solid var(--surface);
  background: var(--warning);
}

.rail-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.conversation-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 14px;
  padding: 18px 18px 16px;
  border: 1px solid rgba(215, 221, 232, 0.92);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.conversation-header h1 {
  margin: 3px 0 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.12;
  letter-spacing: 0;
}

.conversation-actions {
  align-self: flex-start;
}

.status-badge {
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0 10px;
  color: var(--warning);
  font-size: 12px;
  font-weight: 760;
  border: 1px solid rgba(180, 83, 9, 0.26);
  border-radius: 999px;
  background: rgba(180, 83, 9, 0.08);
  white-space: nowrap;
}

.status-badge.ready {
  color: var(--success);
  border-color: rgba(21, 128, 61, 0.30);
  background: rgba(21, 128, 61, 0.10);
}

.status-badge.error {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.30);
  background: rgba(180, 35, 24, 0.10);
}

.status-badge.neutral {
  color: var(--muted);
  border-color: var(--brand-line);
  background: var(--surface-alt);
}

.message-stream {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 250px;
  overflow: auto;
  padding: 2px;
}

.system-note {
  gap: 10px;
  padding: 10px 12px;
  color: #354052;
  border: 1px solid rgba(215, 221, 232, 0.82);
  border-radius: var(--radius);
  background: #f7fafc;
}

.system-note strong {
  display: block;
  font-size: 13px;
}

.system-note p,
.message-bubble p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.message-bubble {
  max-width: min(720px, 86%);
  padding: 12px 14px;
  border-radius: var(--radius);
}

.assistant .message-bubble {
  border: 1px solid var(--brand-line);
  background: #ffffff;
}

.user .message-bubble {
  color: #ffffff;
  background: #101828;
}

.user .message-bubble p {
  color: rgba(255, 255, 255, 0.84);
}

.message-speaker {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 780;
}

.code-block {
  max-width: 100%;
  overflow: auto;
  margin: 0;
  padding: 11px 12px;
  color: #263244;
  border: 1px solid rgba(215, 221, 232, 0.92);
  border-radius: var(--radius);
  background: var(--surface-alt);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.pairing-panel {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid rgba(11, 111, 105, 0.22);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(223, 244, 240, 0.78), rgba(255, 255, 255, 0.96));
}

.pairing-panel label {
  font-size: 13px;
  font-weight: 760;
}

.pairing-panel textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  color: var(--text);
  border: 1px solid #bcc9d8;
  border-radius: var(--radius);
  outline: 0;
  padding: 10px 12px;
  background: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.pairing-panel textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.pairing-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.danger-button {
  padding: 0 14px;
  font-weight: 730;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(180deg, #0b766f, var(--accent));
}

.primary-button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.secondary-button {
  color: var(--text);
  border: 1px solid var(--brand-line);
  background: var(--surface);
}

.danger-button {
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.28);
  background: rgba(180, 35, 24, 0.08);
}

.compact {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
}

.admin-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.admin-panel input,
.admin-panel select {
  min-width: 0;
  min-height: 34px;
  color: var(--text);
  border: 1px solid #c8d4e3;
  border-radius: var(--radius);
  outline: 0;
  background: #ffffff;
}

.admin-panel input {
  padding: 0 10px;
}

.admin-panel select {
  padding: 0 8px;
}

.admin-panel input:focus,
.admin-panel select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.admin-feedback {
  min-height: 17px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.admin-feedback.ready {
  color: var(--success);
  font-weight: 680;
}

.admin-feedback.error {
  color: var(--danger);
  font-weight: 680;
}

.field-feedback {
  min-height: 19px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.field-feedback.error {
  color: var(--danger);
  font-weight: 680;
}

.field-feedback.ready {
  color: var(--success);
  font-weight: 680;
}

.composer-dock {
  gap: 8px;
  min-height: 46px;
  padding: 7px;
  border: 1px solid var(--brand-line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
}

.composer-dock input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--muted);
  background: transparent;
}

.composer-dock button {
  width: 36px;
  color: #ffffff;
  background: #98a2b3;
}

.composer-dock button:not(:disabled) {
  background: var(--accent);
}

.composer-state {
  flex: 0 0 auto;
  max-width: 88px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  line-height: 1.25;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.summary-panel,
.base-list-panel,
.diagnostics-panel {
  padding: 15px;
  border: 1px solid rgba(217, 224, 234, 0.84);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
}

.summary-list {
  display: grid;
  gap: 12px;
  padding-top: 16px;
}

.summary-list div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.summary-list dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.summary-list dd {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.base-list {
  display: grid;
  gap: 8px;
  padding-top: 14px;
}

.base-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  color: var(--text);
  text-align: left;
  border: 1px solid var(--brand-line);
  border-radius: var(--radius);
  background: rgba(248, 250, 252, 0.86);
}

.base-row.selectable:not(:disabled):hover {
  border-color: #acb8c9;
  background: #ffffff;
  transform: translateY(-1px);
}

.base-row.ready {
  border-color: rgba(21, 128, 61, 0.24);
  background: rgba(21, 128, 61, 0.08);
}

.base-row.selected {
  border-color: rgba(15, 118, 110, 0.38);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.18);
}

.base-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.base-name,
.base-meta {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.base-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
}

.base-meta {
  color: var(--muted);
  font-size: 12px;
}

.mini-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  color: var(--muted);
  border-radius: 999px;
  background: var(--surface);
  font-size: 11px;
  font-weight: 760;
  line-height: 1;
  white-space: nowrap;
}

.mini-badge.ready {
  color: var(--success);
  background: rgba(21, 128, 61, 0.10);
}

.empty-block {
  display: grid;
  gap: 5px;
  min-height: 78px;
  align-content: center;
  padding: 12px;
  color: var(--muted);
  border: 1px dashed rgba(152, 162, 179, 0.54);
  border-radius: var(--radius);
  background: rgba(248, 250, 252, 0.74);
}

.empty-block strong {
  color: var(--text);
  font-size: 13px;
}

.empty-block span {
  font-size: 12px;
  line-height: 1.45;
}

.diagnostics-panel summary {
  color: var(--text);
  font-size: 13px;
  font-weight: 760;
  cursor: pointer;
}

.diagnostic-list {
  display: grid;
  gap: 7px;
  padding-left: 18px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 196px minmax(0, 1fr);
  }

  .side-panel {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 0.8fr) minmax(240px, 0.8fr);
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-height: auto;
  }

  .app-shell {
    display: block;
  }

  .topbar {
    align-items: flex-start;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .brand-subtitle {
    max-width: calc(100vw - 156px);
  }

  .topbar-state {
    align-self: center;
  }

  .account-copy {
    display: none;
  }

  .state-summary {
    display: none;
  }

  .workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .session-rail {
    order: 2;
    padding: 0;
  }

  .conversation-pane {
    order: 1;
    padding: 14px;
  }

  .conversation-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .conversation-actions {
    width: 100%;
    justify-content: space-between;
  }

  .lifecycle-actions {
    flex-wrap: wrap;
  }

  .conversation-header h1 {
    font-size: 30px;
  }

  .message-bubble {
    max-width: 94%;
  }

  .side-panel {
    order: 3;
    grid-template-columns: 1fr;
  }

  .session-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(186px, 1fr);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .session-row {
    min-height: 64px;
  }

  .empty-block {
    min-width: 186px;
  }
}

@media (max-width: 540px) {
  .topbar-state,
  .topbar-actions .icon-button,
  .account-secondary,
  .account-status-dot {
    display: none;
  }

  .brand-subtitle {
    display: none;
  }

  .topbar-actions {
    display: flex;
  }

  .account-shell {
    gap: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .account-link {
    min-height: 34px;
    padding: 0 10px;
  }
}

@media (max-width: 460px) {
  .topbar {
    gap: 10px;
  }

  .brand-title {
    font-size: 15px;
  }

  .pairing-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
