:root {
  color-scheme: light;
  --cp-bg: #f7f4ef;
  --cp-bg-elevated: #fcfbf8;
  --cp-surface: #ffffff;
  --cp-surface-soft: #f5f5f5;
  --cp-border: #dedede;
  --cp-border-strong: #919191;
  --cp-text: #242424;
  --cp-text-muted: #5c5c5c;
  --cp-text-soft: #6f6f6f;
  --cp-accent: #12304f;
  --cp-accent-hover: #1d466d;
  --cp-accent-soft: rgba(18, 48, 79, 0.08);
  --cp-accent-fg: #ffffff;
  --cp-success: #16a34a;
  --cp-danger: #dc2626;
  --cp-warning: #f59e0b;
  --cp-link: #1d466d;
  --cp-shadow: 0 18px 48px rgba(0, 0, 0, 0.12);
  --cp-overlay: rgba(255, 255, 255, 0.8);
  --cp-panel: rgba(255, 255, 255, 0.86);
  --cp-panel-strong: rgba(255, 255, 255, 0.96);
  --cp-sheen: rgba(255, 255, 255, 0.55);
  --cp-highlight: rgba(18, 48, 79, 0.12);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --cp-bg: #3d3b3a;
  --cp-bg-elevated: #343231;
  --cp-surface: #292929;
  --cp-surface-soft: #2e2e2e;
  --cp-border: #474747;
  --cp-border-strong: #5f5f5f;
  --cp-text: #dedede;
  --cp-text-muted: #919191;
  --cp-text-soft: #b0b0b0;
  --cp-accent: #8fbce6;
  --cp-accent-hover: #a9ccef;
  --cp-accent-soft: rgba(143, 188, 230, 0.14);
  --cp-accent-fg: #12304f;
  --cp-success: #4ade80;
  --cp-danger: #f87171;
  --cp-warning: #fbbf24;
  --cp-link: #8fbce6;
  --cp-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  --cp-overlay: rgba(41, 41, 41, 0.88);
  --cp-panel: rgba(41, 41, 41, 0.72);
  --cp-panel-strong: rgba(41, 41, 41, 0.96);
  --cp-sheen: rgba(255, 255, 255, 0.04);
  --cp-highlight: rgba(143, 188, 230, 0.12);
}

body {
  padding: 24px;
  background: var(--cp-bg);
}

.login-screen {
  position: fixed;
  inset: 0;
}

.shell {
  grid-template-columns: 292px minmax(0, 1fr);
  width: calc(100vw - 48px);
  height: calc(100dvh - 48px);
  overflow: hidden;
  border: 1px solid var(--cp-border);
  border-radius: 16px;
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow);
}

.sidebar {
  gap: 8px;
  padding: 20px 16px 16px;
  border-right: 1px solid var(--cp-border);
  background: var(--cp-surface-soft);
}

.brand {
  min-height: 52px;
  margin-bottom: 12px;
  padding: 0 4px;
  border: 0;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 0.625rem;
  background: var(--cp-surface);
}

.brand h1 {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand p {
  display: none;
}

.workspace-nav {
  display: grid;
  gap: 2px;
  margin-bottom: 18px;
}

.workspace-nav-item {
  display: grid;
  width: 100%;
  min-height: 44px;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 0;
  border-radius: 0.625rem;
  color: var(--cp-text);
  background: transparent;
  font-size: 14px;
  text-align: left;
}

.workspace-nav-item:hover,
.workspace-nav-item.active {
  background: var(--cp-surface);
}

.workspace-nav-item:focus-visible {
  outline: 2px solid var(--cp-accent);
  outline-offset: 1px;
}

.workspace-nav-create {
  margin-bottom: 4px;
  font-weight: 600;
}

.workspace-nav-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--cp-text-muted);
  font-size: 20px;
}

.sessions-header {
  padding: 0 12px 8px;
  border: 0;
  color: var(--cp-text-soft);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

.sessions-list {
  margin: 0;
  padding: 0;
}

.session-row {
  min-height: 44px;
  margin: 0 0 2px;
  padding: 8px 10px;
  border: 0;
  border-radius: 0.625rem;
}

.session-row:hover,
.session-row.active {
  border: 0;
  background: var(--cp-border);
  box-shadow: none;
}

.session-avatar,
.session-row.active .session-avatar {
  width: 20px;
  height: 20px;
  border: 0;
  color: var(--cp-text-muted);
  background: transparent;
  font-size: 13px;
}

.session-title {
  font-size: 13px;
  font-weight: 500;
}

.session-meta {
  display: none;
}

.session-delete {
  width: 28px;
  overflow: hidden;
  opacity: 0;
  white-space: nowrap;
}

.session-row:hover .session-delete,
.session-row:focus-within .session-delete {
  opacity: 1;
}

.sidebar-footer {
  padding: 12px 4px 0;
  border-top: 1px solid var(--cp-border);
}

.workspace,
.chat-view,
.messages {
  background: var(--cp-surface);
}

.topbar {
  min-height: 68px;
  padding: 10px 18px;
  border: 0;
  border-bottom: 1px solid var(--cp-border);
  color: var(--cp-text);
  background: var(--cp-surface);
}

.topbar h2 {
  color: var(--cp-text);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.topbar p,
.topbar .github-user {
  color: var(--cp-text-muted);
  opacity: 1;
}

.topbar .ghost-button,
.topbar .danger-button {
  min-height: 36px;
  padding: 7px 12px;
  border-color: var(--cp-border);
  color: var(--cp-text-muted);
  background: transparent;
}

.messages {
  gap: 22px;
  padding: 28px max(28px, calc((100% - 1040px) / 2)) 20px;
}

.message,
.message.user {
  width: 100%;
  max-width: 1040px;
}

.message.assistant .message-content {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.message.user .message-body {
  max-width: min(760px, 82%);
  padding: 11px 15px;
  border: 1px solid var(--cp-border);
  border-radius: 16px 16px 4px 16px;
  background: var(--cp-surface-soft);
  box-shadow: none;
}

.message-body {
  padding: 0;
  color: var(--cp-text);
  font-size: 15px;
  line-height: 1.75;
  white-space: normal;
}

.message-body p {
  margin: 0 0 12px;
}

.message-body p:last-child {
  margin-bottom: 0;
}

.message-body h2,
.message-body h3,
.message-body h4 {
  margin: 18px 0 10px;
  line-height: 1.35;
}

.message-body h2:first-child,
.message-body h3:first-child,
.message-body h4:first-child {
  margin-top: 0;
}

.message-body ul,
.message-body ol {
  display: grid;
  gap: 8px;
  margin: 10px 0 16px;
  padding-left: 26px;
}

.message-body code,
.message-body pre {
  background: var(--cp-surface-soft);
  font-family: Consolas, "Courier New", Courier, monospace;
}

.message-body code {
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

.message-body pre {
  overflow-x: auto;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  white-space: pre;
}

.message-body a {
  color: var(--cp-link);
}

.message-time {
  margin: 0 0 8px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.message:hover .message-time {
  opacity: 1;
}

.message-progress,
.activity-card,
.message-interaction {
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface-soft);
  box-shadow: none;
}

.message-artifacts {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.artifact-section-title {
  display: flex;
  grid-column: 1 / -1;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 2px;
}

.artifact-section-title strong {
  font-size: 16px;
}

.artifact-section-title span {
  color: var(--cp-text-muted);
  font-size: 14px;
}

.artifact-card {
  min-width: 0;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface);
  box-shadow: none;
}

.artifact-header {
  min-height: 54px;
  justify-content: flex-start;
  padding: 8px 10px;
  border: 0;
}

.artifact-kind-icon {
  display: grid;
  width: 32px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--cp-accent);
}

.artifact-kind-icon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.artifact-kind-icon path {
  fill: var(--cp-accent-soft);
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.artifact-kind-icon text {
  fill: currentColor;
  font-family: Consolas, "Courier New", Courier, monospace;
  font-size: 6px;
  font-weight: 700;
}

.artifact-header > div {
  flex: 1;
}

.artifact-header strong {
  font-size: 13px;
  font-weight: 600;
}

.artifact-header span:not(.artifact-kind-icon) {
  display: none;
}

.artifact-actions {
  gap: 4px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.artifact-card:hover .artifact-actions,
.artifact-card:focus-within .artifact-actions {
  opacity: 1;
}

.artifact-preview-action,
.artifact-download {
  min-height: 28px;
  padding: 0 7px;
  border-color: var(--cp-border);
  color: var(--cp-text-muted);
  background: var(--cp-surface);
  font-size: 11px;
}

.composer {
  position: relative;
  display: block;
  padding: 12px max(28px, calc((100% - 1040px) / 2)) 0;
  border: 0;
  background: var(--cp-surface);
}

.composer-input-wrap {
  min-height: 156px;
  padding: 12px 14px 10px;
  border: 1px solid var(--cp-border);
  border-radius: 24px;
  background: var(--cp-surface);
  box-shadow: 0 0 2px var(--cp-border);
}

.composer-input-wrap.attachment-drag-active {
  border-color: var(--cp-accent);
  background: var(--cp-accent-soft);
  box-shadow: 0 0 0 3px var(--cp-accent-soft);
}

.composer textarea {
  min-height: 88px;
  max-height: 220px;
  padding: 8px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 15px;
}

.composer-tools {
  gap: 6px;
  padding: 4px 54px 0 4px;
}

.attach-button,
.composer-mode {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 5px 8px;
  border: 0;
  border-radius: 0.625rem;
  color: var(--cp-text-muted);
  background: transparent;
  font-size: 12px;
}

.attach-button:hover,
.composer-mode:hover {
  background: var(--cp-surface-soft);
}

.composer-webiq {
  color: var(--cp-success);
}

.attachment-hint {
  margin-left: auto;
}

.composer #send-message {
  position: absolute;
  right: 14px;
  bottom: 10px;
  display: grid;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  box-shadow: none;
}

.composer #send-message:not(.stop-mode) {
  font-size: 0;
}

.composer #send-message:not(.stop-mode)::before {
  content: "↑";
  font-size: 18px;
}

.composer #send-message.stop-mode {
  right: 10px;
  bottom: 8px;
  width: auto;
  min-width: 52px;
  min-height: 40px;
}

.composer-disclaimer {
  margin: 10px 0 12px;
  color: var(--cp-text-soft);
  font-size: 11px;
  text-align: center;
}

.empty-state {
  background: var(--cp-surface);
}

.empty-card {
  border: 1px solid var(--cp-border);
  border-radius: 16px;
  box-shadow: 0 0 2px var(--cp-border);
}

.empty-card::after {
  display: none;
}

.shell.sidebar-collapsed .workspace-nav-item {
  grid-template-columns: 1fr;
  justify-items: center;
  padding-inline: 4px;
}

.shell.sidebar-collapsed .workspace-nav-item > span:last-child {
  display: none;
}

.shell.sidebar-collapsed .workspace-nav {
  width: 100%;
}

@media (max-width: 1100px) {
  body {
    padding: 0;
  }

  .shell {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .message-artifacts {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
  }

  .sidebar,
  .shell.sidebar-collapsed .sidebar {
    display: flex;
    width: min(86vw, 320px);
    height: 100dvh;
    padding: 16px 14px;
    background: var(--cp-surface-soft);
  }

  .shell.sidebar-collapsed .workspace-nav-item {
    grid-template-columns: 28px minmax(0, 1fr);
    justify-items: stretch;
    padding-inline: 12px;
  }

  .shell.sidebar-collapsed .workspace-nav-item > span:last-child {
    display: initial;
  }

  .messages {
    padding: 22px 18px;
  }

  .composer {
    padding: 10px 16px 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    min-height: 64px;
    padding: 10px 12px;
  }

  .topbar-actions {
    overflow-x: auto;
  }

  .message-artifacts {
    grid-template-columns: 1fr;
  }

  .composer-input-wrap {
    min-height: 132px;
    border-radius: 18px;
  }

  .composer textarea {
    min-height: 72px;
  }

  .composer-mode,
  .attachment-hint {
    display: none;
  }

  .artifact-actions {
    width: auto;
    opacity: 1;
  }
}
