:root {
  color-scheme: light;
  --bg: #f1f1f1;
  --sidebar: #fafafa;
  --surface: #ffffff;
  --surface-soft: #f3f3f3;
  --text: #171717;
  --muted: #5f5f5f;
  --line: #d7d7d7;
  --line-strong: #8c8c8c;
  --accent: #202020;
  --accent-strong: #000000;
  --accent-soft: #eeeeee;
  --info-soft: #f2f2f2;
  --danger: #1f1f1f;
  --code: #eeeeee;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.58;
}

.workspace-shell {
  display: grid;
  grid-template-columns: 312px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  background: var(--surface);
}

.panel-sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 18px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  padding: 18px;
}

.panel-sidebar-header,
.panel-header,
.message-meta,
.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-sidebar-header {
  gap: 12px;
  min-height: 36px;
}

.panel-title,
.conversation-title {
  margin: 0;
  letter-spacing: 0;
}

.panel-sidebar .panel-title {
  font-size: 22px;
  line-height: 1.15;
}

.app-brand {
  display: flex;
  min-width: 0;
  height: 36px;
  align-items: center;
}

.app-brand-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-chat {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0;
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
}

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

.conversation-list {
  display: grid;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.conversation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 6px;
  align-items: stretch;
}

.conversation-open {
  display: grid;
  min-width: 0;
  gap: 5px;
  min-height: 66px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 11px 12px;
  text-align: left;
}

.conversation-open:hover {
  background: var(--surface-soft);
}

.conversation-row.active .conversation-open {
  border-color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 4px 0 0 var(--text);
}

.conversation-open span,
.conversation-open small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-open span {
  font-weight: 700;
}

.conversation-open small {
  color: var(--muted);
  font-size: 12px;
}

.conversation-rename-form {
  display: grid;
  min-width: 0;
  min-height: 66px;
}

.conversation-rename-input {
  width: 100%;
  min-width: 0;
  min-height: 66px;
  border: 1px solid var(--text);
  border-radius: 8px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
  font-weight: 700;
  box-shadow: inset 4px 0 0 var(--text);
}

.conversation-delete {
  display: grid;
  place-items: center;
  align-self: stretch;
  width: 100%;
  min-height: 66px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.conversation-delete svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.conversation-delete:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.sidebar-settings-button {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  font-weight: 700;
  text-align: left;
}

.sidebar-settings-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.panel-main {
  display: grid;
  min-width: 0;
  min-height: 0;
  background: var(--surface-soft);
}

.chat {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.context-main {
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-header {
  min-width: 0;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 16px 22px;
}

.panel-actions,
.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.panel-header-title,
.title-block {
  min-width: 0;
}

.conversation-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.25;
}

.context-info {
  display: none;
}

.workflow-info {
  display: block;
  max-width: min(760px, 58vw);
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-info.error {
  color: var(--danger);
}

.model-picker {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 10px;
  font-size: 13px;
}

.model-picker select {
  max-width: 210px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-weight: 650;
}

.model-picker:focus-within,
textarea:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--line-strong);
}

.context-button,
.context-action,
.context-close {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  font-weight: 650;
}

.context-button:hover,
.context-action:hover,
.context-close:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.context-button:disabled {
  color: var(--muted);
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 24px 22px;
}

.message {
  display: grid;
  grid-template-columns: 36px minmax(0, 820px);
  gap: 12px;
  margin-bottom: 18px;
}

.message.user {
  justify-content: end;
  grid-template-columns: minmax(0, 720px) 36px;
}

.message.user .avatar {
  grid-column: 2;
  grid-row: 1;
}

.message.user .message-content {
  grid-column: 1;
  grid-row: 1;
  background: var(--info-soft);
  border-color: var(--line-strong);
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.assistant .avatar {
  border-color: var(--text);
  background: var(--text);
  color: var(--surface);
}

.message-content {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 13px 14px;
  line-height: 1.65;
}

.message-content.markdown-body {
  white-space: normal;
}

.reasoning-block {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.reasoning-block summary {
  min-height: 34px;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.reasoning-body {
  border-top: 1px solid var(--line);
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.reasoning-step-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: reasoning-step;
}

.reasoning-step-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.reasoning-step-list li::before {
  counter-increment: reasoning-step;
  content: counter(reasoning-step, decimal-leading-zero);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.9;
}

.error-message .message-content {
  border-color: var(--text);
  background: var(--surface);
  box-shadow: inset 4px 0 0 var(--text);
}

.workflow-history {
  display: grid;
  max-width: 868px;
  gap: 10px;
  margin: 4px 0 18px 48px;
}

.workflow-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.workflow-card.failed {
  border-color: var(--line-strong);
  box-shadow: inset 4px 0 0 var(--text);
}

.workflow-card summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.workflow-card summary small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.workflow-card-error,
.workflow-card-empty {
  margin: 0 12px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.workflow-card-error {
  color: var(--danger);
}

.workflow-tool-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0 12px 12px;
  list-style: none;
}

.workflow-tool-row {
  display: grid;
  grid-template-columns: 70px 132px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.workflow-tool-row.failed {
  color: var(--text);
}

.workflow-tool-status,
.workflow-tool-name,
.workflow-tool-input {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-tool-status,
.workflow-tool-name {
  font-weight: 700;
}

.workflow-tool-error {
  grid-column: 1 / -1;
  color: var(--danger);
}

.subagent-history {
  gap: 12px;
}

.message-subagents {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.subagent-group {
  display: grid;
  gap: 8px;
}

.subagent-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.subagent-group-title strong {
  color: var(--text);
  font-size: 13px;
}

.subagent-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.subagent-card.failed {
  border-color: var(--line-strong);
  box-shadow: inset 4px 0 0 var(--text);
}

.subagent-card summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.subagent-card summary span,
.subagent-card summary small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subagent-card summary small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.subagent-goal,
.subagent-error {
  margin: 0 12px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

.subagent-result {
  margin: 0 12px 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  font-size: 13px;
  line-height: 1.6;
}

.subagent-transcript {
  display: grid;
  gap: 0;
  margin: 0 12px 12px;
  border-top: 1px solid var(--line);
}

.subagent-message {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.subagent-message:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.subagent-message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.subagent-message-head strong {
  color: var(--text);
  font-size: 12px;
}

.subagent-message-body {
  font-size: 13px;
  line-height: 1.6;
}

.subagent-message.system .subagent-message-body,
.subagent-message.user .subagent-message-body {
  color: var(--muted);
}

.subagent-reasoning {
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.subagent-reasoning summary {
  min-height: 30px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.subagent-reasoning-body {
  border-top: 1px solid var(--line);
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.subagent-tool-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0 12px 12px;
  list-style: none;
}

.message-meta {
  gap: 12px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

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

.message-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body p {
  margin: 0 0 10px;
  overflow-wrap: anywhere;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 14px 0 8px;
  line-height: 1.3;
  letter-spacing: 0;
}

.markdown-body h1 {
  font-size: 22px;
}

.markdown-body h2 {
  font-size: 19px;
}

.markdown-body h3 {
  font-size: 17px;
}

.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-size: 15px;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 10px;
  padding-left: 24px;
}

.markdown-body li {
  margin: 3px 0;
}

.markdown-body blockquote {
  margin: 0 0 10px;
  padding: 2px 0 2px 12px;
  color: var(--muted);
  border-left: 3px solid var(--line);
}

.markdown-body pre {
  margin: 0 0 10px;
  padding: 11px 12px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--code);
  color: var(--text);
  line-height: 1.55;
}

.markdown-body code {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.92em;
}

.markdown-body :not(pre) > code {
  display: inline;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--code);
  color: var(--text);
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
}

.markdown-body pre code {
  font-size: 13px;
  white-space: pre;
}

.markdown-body a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.markdown-body table {
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 0 0 10px;
  overflow: auto;
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: top;
}

.markdown-body th {
  background: var(--surface-soft);
  font-weight: 650;
}

.markdown-body hr {
  height: 1px;
  border: 0;
  background: var(--line);
  margin: 12px 0;
}

.composer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 14px 22px 16px;
}

textarea {
  display: block;
  width: 100%;
  min-height: 76px;
  max-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  line-height: 1.55;
}

.message-queue[hidden] {
  display: none;
}

.message-queue {
  display: grid;
  gap: 8px;
  max-height: 210px;
  margin-top: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.message-queue-head,
.message-queue-meta,
.message-queue-actions {
  display: flex;
  align-items: center;
}

.message-queue-head {
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.message-queue-head strong {
  color: var(--text);
  font-size: 13px;
}

.message-queue-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.message-queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px;
}

.message-queue-main {
  min-width: 0;
}

.message-queue-meta {
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.message-queue-preview {
  min-width: 0;
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-queue-actions {
  gap: 6px;
  justify-content: flex-end;
}

.message-queue-action {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.message-queue-action:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.message-queue-action.danger {
  color: var(--danger);
}

.composer-footer {
  gap: 12px;
  justify-content: flex-end;
  margin-top: 10px;
}

.empty,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  text-align: center;
  padding: 42px 0;
}

.send-button {
  min-width: 82px;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  font-weight: 650;
}

.stop-button {
  min-width: 72px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--danger);
  padding: 0 14px;
  font-weight: 650;
}

.stop-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

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

.context-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--surface);
}

.context-overlay[hidden] {
  display: none;
}

.summary-top,
.context-source-head,
.context-message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.context-summary-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.summary-top span,
.context-source-meta,
.context-message-meta {
  color: var(--muted);
  font-size: 12px;
}

.summary-top strong {
  display: block;
  margin-top: 2px;
  font-size: 22px;
}

.context-source-list {
  display: grid;
  gap: 14px;
}

.context-source-group {
  display: grid;
  gap: 8px;
}

.context-source-group-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.context-preset-option {
  display: grid;
  width: 100%;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px;
  text-align: left;
}

.context-preset-option:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.context-preset-option:disabled {
  color: var(--muted);
}

.context-preset-option strong,
.context-preset-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.context-preset-option strong {
  font-size: 13px;
  white-space: nowrap;
}

.context-preset-option span {
  color: var(--muted);
  font-size: 12px;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.context-prompt-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.88);
  padding: 24px;
}

.context-prompt-dialog-backdrop[hidden] {
  display: none;
}

.context-prompt-dialog {
  display: grid;
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 2px solid var(--text);
  border-radius: 8px;
  background: var(--surface);
}

.context-prompt-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.context-prompt-dialog-header h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.context-prompt-dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.88);
  padding: 24px;
}

.settings-dialog-backdrop[hidden] {
  display: none;
}

.settings-dialog {
  display: grid;
  width: min(860px, 100%);
  max-height: calc(100vh - 48px);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 2px solid var(--text);
  border-radius: 8px;
  background: var(--surface);
}

.settings-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.settings-dialog-header h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.settings-dialog-body {
  display: grid;
  min-height: 0;
  gap: 14px;
  overflow: auto;
  padding: 14px;
}

.settings-section {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.settings-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.settings-section-header h4 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0;
}

.provider-profile-settings {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 14px;
}

.provider-profile-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.provider-profile-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px;
  text-align: left;
}

.provider-profile-row.active {
  border-color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 4px 0 0 var(--text);
}

.provider-profile-row strong,
.provider-profile-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-profile-row span {
  color: var(--muted);
  font-size: 12px;
}

.provider-profile-form {
  display: grid;
  gap: 10px;
}

.provider-profile-form label,
.subagent-settings-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.provider-profile-form input[type="text"],
.provider-profile-form input[type="password"],
.provider-profile-form textarea,
.subagent-settings-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
  font-size: 13px;
}

.provider-profile-form textarea {
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.subagent-settings-form {
  display: grid;
  gap: 10px;
}

.subagent-settings-form textarea {
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  line-height: 1.55;
}

.subagent-preset-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 12px;
}

.subagent-preset-column {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 8px;
}

.subagent-preset-title,
.subagent-preset-group-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.subagent-preset-list,
.subagent-preset-options,
.subagent-preset-group {
  display: grid;
  gap: 8px;
}

.subagent-preset-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.subagent-preset-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

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

.subagent-preset-main span {
  color: var(--muted);
  font-size: 12px;
}

.subagent-preset-option {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
  text-align: left;
}

.subagent-preset-option strong,
.subagent-preset-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subagent-preset-option span {
  color: var(--muted);
  font-size: 12px;
}

.subagent-preset-option:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.subagent-preset-option:disabled {
  cursor: default;
  opacity: 0.58;
}

.provider-profile-form input:disabled,
.provider-profile-form textarea:disabled {
  background: var(--surface-soft);
  color: var(--muted);
}

.provider-profile-enabled {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
}

.provider-profile-enabled input {
  width: 17px;
  height: 17px;
  accent-color: var(--text);
}

.provider-profile-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

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

.provider-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.provider-profile-actions button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  font-weight: 700;
}

.provider-profile-actions button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.settings-inline-action {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.settings-inline-action:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.archived-conversation-list {
  display: grid;
  gap: 8px;
}

.archived-conversation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
}

.archived-conversation-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

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

.archived-conversation-main span {
  color: var(--muted);
  font-size: 12px;
}

.context-record-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.context-selection-summary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.context-select-all {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.context-select-all input,
.context-record-checkbox {
  width: 17px;
  height: 17px;
  accent-color: var(--text);
}

.context-delete-records {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--danger);
  padding: 0 12px;
  font-weight: 650;
}

.context-delete-records:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.context-prompt-options {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding: 14px;
}

.context-preset-group {
  display: grid;
  gap: 8px;
}

.context-preset-group + .context-preset-group {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.context-preset-group-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.context-source-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  text-align: left;
}

.context-source-row.removable {
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 8px;
}

.context-source-select {
  display: flex;
  min-width: 0;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 10px;
  text-align: left;
}

.context-source-delete {
  width: 30px;
  height: 30px;
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.context-source-delete:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--text);
}

.context-source-row:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.context-source-row.included,
.context-source-row.locked {
  border-color: var(--line);
  background: var(--surface);
}

.context-source-row.locked {
  border-style: solid;
}

.context-source-row.cropped {
  border-color: var(--line-strong);
  border-style: dashed;
  background: var(--surface);
}

.context-source-row.excluded {
  border-color: var(--line-strong);
  border-style: dotted;
  background: var(--surface);
  color: var(--muted);
}

.context-source-row.selected {
  border-color: var(--text);
  background: var(--surface-soft);
  box-shadow: inset 4px 0 0 var(--text);
}

.context-source-row.selected .context-source-main strong {
  font-weight: 850;
}

.context-source-main {
  min-width: 0;
}

.context-source-main strong,
.context-source-main span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-source-main strong {
  font-size: 14px;
}

.context-source-main span {
  margin-top: 4px;
}

.context-message-list {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding: 22px;
}

.context-message-card {
  max-width: 980px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.context-message-card.selectable {
  display: flex;
  align-items: stretch;
}

.context-message-card.selected {
  border-color: var(--text);
  background: var(--surface-soft);
}

.context-message-select {
  display: flex;
  width: 36px;
  flex: 0 0 36px;
  justify-content: center;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
  padding-top: 12px;
}

.context-message-body {
  min-width: 0;
  flex: 1 1 auto;
}

.context-message-head {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding: 11px 13px;
}

.context-message-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.context-message-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-message-content {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 0 0 8px 8px;
  background: var(--surface);
  color: var(--text);
  padding: 13px;
  font: inherit;
  line-height: 1.65;
}

.context-loading,
.context-error {
  max-width: 980px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 16px;
}

.context-error {
  border-color: var(--text);
  background: var(--surface);
  color: var(--danger);
  box-shadow: inset 4px 0 0 var(--text);
}

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

  .workspace-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .panel-sidebar {
    max-height: 320px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .panel-main {
    min-height: 0;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .panel-actions,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .model-picker {
    justify-content: space-between;
  }

  .model-picker select {
    max-width: none;
  }

  .messages {
    overflow: visible;
    padding: 16px;
  }

  .message,
  .message.user {
    grid-template-columns: 34px minmax(0, 1fr);
    justify-content: stretch;
  }

  .message.user .avatar,
  .message.user .message-content {
    grid-column: auto;
    grid-row: auto;
  }

  .composer {
    padding: 14px 16px 16px;
  }

  .context-overlay {
    overflow: auto;
  }

  .context-action {
    width: 100%;
  }

  .context-message-list {
    overflow: visible;
    padding: 16px;
  }

  .settings-dialog-backdrop {
    align-items: start;
    overflow: auto;
    padding: 14px;
  }

  .settings-dialog-body {
    grid-template-columns: 1fr;
  }

  .subagent-preset-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .panel-sidebar {
    padding: 14px 12px;
  }

  .conversation-title {
    font-size: 18px;
  }

  .message {
    gap: 9px;
  }

  .avatar {
    width: 34px;
    height: 34px;
  }

  .message-content {
    padding: 12px;
  }

  .message-queue-item {
    grid-template-columns: minmax(0, 1fr);
  }

  .message-queue-actions {
    justify-content: stretch;
  }

  .message-queue-action {
    flex: 1 1 auto;
  }

  .message-meta,
  .composer-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .send-button {
    width: 100%;
  }

  .context-mode .panel-sidebar,
  .context-mode .panel-header,
  .context-message-list {
    padding-left: 12px;
    padding-right: 12px;
  }

  .context-mode .panel-sidebar-header,
  .context-source-head,
  .context-message-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .context-record-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .context-select-all {
    min-height: 34px;
  }

  .context-close,
  .context-delete-records,
  .context-button {
    width: 100%;
  }

}
