:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-soft: #f1f4f2;
  --ink: #18211e;
  --muted: #68746f;
  --line: #dce2df;
  --accent: #0f766e;
  --accent-soft: #e8f5f1;
  --danger: #a33a2a;
  --shadow: 0 16px 42px rgba(20, 31, 28, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

button:hover,
button.active {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 25% 20%, rgba(15, 118, 110, 0.12), transparent 32%),
    var(--bg);
}

.auth-card {
  display: grid;
  width: min(420px, 100%);
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 4px;
  text-align: center;
}

.product-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 40px;
  font-size: 30px;
  line-height: 1;
}

.product-logo-large {
  width: 80px;
  height: 52px;
  font-size: 48px;
}

.auth-brand h1 {
  font-size: 24px;
}

.auth-brand p,
.auth-card label {
  color: var(--muted);
  font-size: 13px;
}

.auth-card label {
  display: grid;
  gap: 7px;
}

.auth-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  color: var(--ink);
  background: var(--surface);
}

.auth-card input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.auth-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-modes button:first-child {
  border-radius: 7px 0 0 7px;
}

.auth-modes button:last-child {
  border-left: 0;
  border-radius: 0 7px 7px 0;
}

.auth-modes button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.auth-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.auth-submit {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.auth-submit:hover {
  background: #0b655e;
  color: white;
}

.current-user {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-select {
  width: min(180px, 22vw);
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 28px 0 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
}

.project-select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.app-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  height: 100vh;
}

.app-shell.detail-open {
  grid-template-columns: 276px minmax(0, 1fr) minmax(340px, 410px);
}

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

.brand {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  padding: 0 4px 6px;
  color: inherit;
  text-decoration: none;
}

.brand h1 {
  font-size: 17px;
  line-height: 1.25;
}

.brand p,
.topbar p,
.hint,
.disclaimer,
.settings-header p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.new-chat-button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  border-color: #cfd9d5;
  padding: 8px 10px;
  background: var(--surface);
  text-align: left;
  font-weight: 650;
}

.new-chat-button span:first-child {
  color: var(--accent);
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  text-align: center;
}

.new-chat-button:hover {
  background: var(--accent-soft);
}

.sidebar-scroll {
  min-height: 0;
  overflow-y: auto;
  padding: 4px 2px 12px;
  scrollbar-width: thin;
}

.sidebar-section + .sidebar-section {
  margin-top: 20px;
}

.sidebar-section-heading {
  display: flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
}

.sidebar-section-heading h2 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.chat-history {
  display: grid;
  gap: 2px;
}

.chat-history-empty {
  padding: 7px 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.chat-history-item {
  display: block;
  width: 100%;
  min-height: 38px;
  overflow: hidden;
  border-color: transparent;
  padding: 7px 9px;
  background: transparent;
  text-align: left;
}

.chat-history-item:hover {
  background: var(--surface-soft);
}

.chat-history-item.active {
  border-color: #d1e2dc;
  background: var(--accent-soft);
  color: #0b5f58;
}

.chat-history-title,
.chat-history-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-history-title {
  font-size: 13px;
}

.chat-history-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.sidebar-account {
  position: relative;
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.account-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  border-color: transparent;
  padding: 6px 8px;
  background: transparent;
  text-align: left;
}

.account-button:hover,
.account-button[aria-expanded="true"] {
  border-color: transparent;
  background: var(--surface-soft);
  color: var(--ink);
}

.account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 750;
  text-transform: uppercase;
}

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

.account-copy strong {
  font-size: 12px;
}

.account-more {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
}

.account-menu {
  position: absolute;
  z-index: 20;
  right: 0;
  bottom: calc(100% + 8px);
  left: 0;
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(20, 31, 28, 0.16);
}

.account-menu[hidden] {
  display: none;
}

.account-menu button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 36px;
  border-color: transparent;
  padding: 6px 8px;
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.account-menu button:hover {
  background: var(--surface-soft);
}

.account-menu button span {
  color: var(--muted);
  text-align: center;
}

.account-menu-divider {
  height: 1px;
  margin: 4px 2px;
  background: var(--line);
}

.account-menu .account-logout {
  color: var(--danger);
}

.skill-list {
  display: grid;
  gap: 16px;
}

.function-group h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 8px 8px;
  color: #34413c;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.function-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.function-group-header h2 {
  margin-bottom: 0;
}

.manage-agents {
  min-height: 28px;
  border-color: transparent;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.manage-agents:hover {
  background: var(--surface-soft);
}

.standalone-function {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border-color: transparent;
  padding: 8px;
  background: transparent;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
}

.standalone-function:hover {
  background: var(--surface-soft);
}

.standalone-function.active {
  border-color: #cde1da;
  background: var(--accent-soft);
  color: #0b5f58;
}

.group-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid #d3ddd9;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--accent);
  font-family: "Segoe UI Symbol", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  font-weight: 600;
}

.function-list {
  display: grid;
  gap: 3px;
}

.function-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 36px;
  border-color: transparent;
  padding: 6px 9px;
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.function-item:hover {
  background: var(--surface-soft);
}

.function-item.active {
  border-color: #cde1da;
  background: var(--accent-soft);
  color: #0b5f58;
  font-weight: 650;
}

.function-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: #687a73;
  font-family: "Segoe UI Symbol", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.function-item:hover .function-icon,
.function-item.active .function-icon {
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent);
}

.function-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  border-bottom: 1px solid var(--line);
  padding: 12px 22px;
  background: rgba(255, 255, 255, 0.94);
}

.active-function {
  min-width: 0;
}

.active-function h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
}

.toolbar[hidden] {
  display: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

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

.conversation {
  overflow-y: auto;
  padding: 28px max(24px, calc((100% - 900px) / 2));
  scroll-behavior: smooth;
}

.empty-state {
  display: grid;
  min-height: 100%;
  place-content: center;
  justify-items: center;
  padding: 32px;
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 8px;
  font-size: 24px;
}

.empty-state p {
  max-width: 520px;
  color: var(--muted);
  line-height: 1.6;
}

.starter-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 760px);
  margin-top: 22px;
}

.starter-list button {
  min-height: 62px;
  padding: 10px 12px;
  background: var(--surface);
  color: #40504a;
  text-align: left;
  font-size: 13px;
  line-height: 1.4;
}

.starter-list button:hover {
  border-color: #b8d6cc;
  background: var(--accent-soft);
}

.message {
  width: min(100%, 820px);
  margin: 0 auto 22px;
}

.message-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.message pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.68;
}

.message.user {
  display: grid;
  justify-items: end;
}

.message.user .message-label {
  margin-right: 8px;
}

.message.user pre {
  max-width: min(78%, 680px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 13px;
  background: var(--surface);
}

.message.assistant pre {
  border-left: 3px solid #b9d9cf;
  padding-left: 14px;
}

.markdown-body {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.25em 0 0.55em;
  color: #17342d;
  line-height: 1.35;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body h1 {
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.35em;
  font-size: 22px;
}

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

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

.markdown-body h4 {
  font-size: 14px;
}

.markdown-body p {
  margin: 0.55em 0;
  white-space: pre-line;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.55em 0;
  padding-left: 1.7em;
}

.markdown-body li {
  margin: 0.25em 0;
}

.markdown-body code {
  border-radius: 4px;
  padding: 0.12em 0.35em;
  background: #edf2ef;
  color: #8b2e20;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}

.markdown-body pre {
  overflow-x: auto;
  margin: 0.85em 0;
  border: 1px solid #d3ddd8;
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  padding: 12px 14px;
  background: #f3f6f4;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
  color: #24322d;
  white-space: pre;
}

.markdown-body blockquote {
  margin: 0.75em 0;
  border-left: 3px solid #b8d8ce;
  padding: 0.35em 0.9em;
  background: var(--accent-soft);
  color: #40504a;
  white-space: pre-line;
}

.markdown-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  margin: 0.85em 0;
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
  min-width: 110px;
  border: 1px solid var(--line);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
}

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

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

.markdown-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.1em 0;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 7px;
}

.message-actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  border-color: transparent;
  padding: 0 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.message-actions button:hover {
  border-color: var(--line);
  background: var(--surface-soft);
}

.message-actions button.active {
  border-color: #b8d8ce;
  background: var(--accent-soft);
  color: var(--accent);
}

.message-actions button.feedback-dislike.active {
  border-color: #e3c7c1;
  background: #fbefec;
  color: var(--danger);
}

.message-action-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.detail-trigger {
  margin-left: 2px;
}

.detail-panel {
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -12px 0 30px rgba(20, 31, 28, 0.06);
}

.detail-panel[hidden] {
  display: none;
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
}

.detail-panel-header span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.detail-panel-header h2 {
  font-size: 17px;
}

.detail-panel-header button {
  width: 32px;
  min-height: 32px;
  border-color: transparent;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
}

.detail-panel-content {
  height: calc(100vh - 128px);
  overflow-y: auto;
  padding: 14px 16px 28px;
}

.detail-panel-note {
  min-height: 54px;
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.source-list,
.trace-list {
  display: grid;
  gap: 9px;
}

.source-card {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 8px;
  color: inherit;
  text-decoration: none;
}

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

.source-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
}

.source-card strong,
.source-card small {
  display: block;
}

.source-card strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.source-card small {
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.trace-step {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 9px;
  padding: 4px 0 12px;
}

.trace-step:not(:last-child)::after {
  position: absolute;
  top: 30px;
  bottom: -2px;
  left: 12px;
  width: 1px;
  background: var(--line);
  content: "";
}

.trace-marker {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  border: 1px solid #b8d8ce;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.trace-step.reasoning .trace-marker {
  border-color: #d8d8cb;
  background: #f5f4eb;
  color: #756f45;
}

.trace-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.trace-card h3 {
  font-size: 13px;
  line-height: 1.45;
}

.trace-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.confidence-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 7px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
}

.confidence-badge.high {
  background: var(--accent-soft);
  color: var(--accent);
}

.confidence-badge.medium {
  background: #f5f4eb;
  color: #756f45;
}

.detail-empty {
  padding: 32px 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.message.pending {
  color: var(--muted);
  font-size: 13px;
}

.pending-dots {
  display: inline-flex;
  align-items: baseline;
  margin-left: 1px;
}

.pending-dots span {
  display: inline-block;
  animation: pending-dot-bounce 1.05s ease-in-out infinite;
}

.pending-dots span:nth-child(2) {
  animation-delay: 0.14s;
}

.pending-dots span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes pending-dot-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pending-dots span {
    animation: none;
    opacity: 1;
  }
}

.composer-wrap {
  padding: 0 max(24px, calc((100% - 900px) / 2)) 18px;
}

.composer {
  overflow: hidden;
  border: 1px solid #cfd8d4;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 78px;
  max-height: 220px;
  resize: vertical;
  border: 0;
  padding: 14px 15px 8px;
  outline: none;
  background: transparent;
  color: var(--ink);
  line-height: 1.5;
}

.composer-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px 10px;
}

.attach-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--surface-soft);
  font-size: 13px;
  cursor: pointer;
  overflow: hidden;
}

.attach-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.attach-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

#sendButton,
.primary-button {
  min-width: 84px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.attachment-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(100%, 900px);
  margin: 0 auto 8px;
  border: 1px solid #cde1da;
  border-radius: 8px;
  padding: 9px 10px 9px 12px;
  background: var(--accent-soft);
}

.attachment-chip[hidden] {
  display: none;
}

.attachment-chip strong,
.attachment-chip span {
  display: block;
}

.attachment-chip strong {
  font-size: 13px;
}

.attachment-chip span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.attachment-chip button,
.settings-header button {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
}

.disclaimer {
  margin-top: 8px;
  text-align: center;
}

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

.settings-dialog {
  width: min(520px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(19, 28, 25, 0.42);
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.settings-header h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.settings-card label {
  display: grid;
  gap: 6px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 13px;
}

.settings-card input[type="text"],
.settings-card input[type="password"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  outline: none;
  background: #fbfcfb;
  color: var(--ink);
}

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

.temperature {
  grid-template-columns: auto minmax(0, 1fr) 30px;
  align-items: center;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.agent-dialog {
  width: min(640px, calc(100% - 32px));
}

.agent-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: min(58vh, 520px);
  overflow-y: auto;
}

.agent-choice {
  display: grid !important;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 9px !important;
  margin: 0 !important;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px;
  color: var(--ink) !important;
  cursor: pointer;
}

.agent-choice:has(input:checked) {
  border-color: #b8d8ce;
  background: var(--accent-soft);
}

.agent-choice input {
  margin-top: 3px;
}

.agent-choice strong,
.agent-choice small {
  display: block;
}

.agent-choice strong {
  margin-bottom: 4px;
  font-size: 13px;
}

.agent-choice small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.agent-dialog-actions {
  justify-content: space-between;
}

.project-dialog {
  width: min(760px, calc(100% - 32px));
}

.project-memory-editor {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
}

.project-memory-editor select,
.project-memory-editor textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.project-memory-editor textarea {
  resize: vertical;
}

.dialog-section-title {
  margin: 20px 0 8px;
  font-size: 14px;
}

.dialog-list {
  display: grid;
  gap: 7px;
  max-height: 190px;
  overflow-y: auto;
  color: var(--muted);
  font-size: 12px;
}

.dialog-list article {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: var(--surface-soft);
}

.dialog-list strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 12px;
}

.dialog-list p {
  white-space: pre-wrap;
  line-height: 1.5;
}

@media (max-width: 1180px) {
  .app-shell.detail-open {
    grid-template-columns: 276px minmax(0, 1fr);
  }

  .detail-panel {
    position: fixed;
    z-index: 40;
    top: 0;
    right: 0;
    width: min(410px, calc(100vw - 24px));
  }
}

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

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

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

  .chat-workspace {
    height: 100vh;
    min-height: 680px;
  }

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

  .toolbar {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .conversation,
  .composer-wrap {
    padding-left: 14px;
    padding-right: 14px;
  }

  .message.user pre {
    max-width: 90%;
  }

  .starter-list {
    grid-template-columns: 1fr;
  }

  .agent-choices {
    grid-template-columns: 1fr;
  }

  .project-memory-editor {
    grid-template-columns: 1fr;
  }

  .composer-actions {
    grid-template-columns: auto 1fr;
  }

  .composer-actions .hint {
    display: none;
  }
}
