:root {
  --bg: #eef3fb;
  --sidebar-bg: linear-gradient(180deg, #0e1a33 0%, #101f46 100%);
  --sidebar-text: #cad6ef;
  --sidebar-muted: #8da2c6;
  --panel-bg: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --line: #dbe5f3;
  --line-strong: #bfd0ea;
  --text: #14213d;
  --muted: #6a7792;
  --primary: #2153d4;
  --primary-strong: #123fb2;
  --assistant-bg: #eef5ff;
  --user-bg: #1748c1;
  --user-text: #f7fbff;
  --warning: #8a5a00;
  --warning-bg: #fff6de;
  --danger: #a63228;
  --danger-bg: #fff1ef;
  --info: #1f4b91;
  --info-bg: #edf4ff;
  --shadow: 0 16px 48px rgba(14, 24, 49, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1000px 480px at 100% -5%, rgba(33, 83, 212, 0.18), transparent 55%),
    radial-gradient(820px 420px at -5% 0%, rgba(14, 26, 51, 0.14), transparent 52%),
    var(--bg);
  color: var(--text);
}

#root {
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 18px;
  color: var(--sidebar-text);
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-block {
  display: grid;
  gap: 8px;
}

.brand-kicker {
  margin: 0;
  color: #8fb4ff;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.brand-block h1 {
  margin: 0;
  font-size: 2.2rem;
  line-height: 1.02;
}

.brand-desc {
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.sidebar-group {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  padding: 14px;
  backdrop-filter: blur(12px);
}

.group-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.sidebar-group h2 {
  margin: 0;
  font-size: 0.96rem;
  color: #eef3ff;
}

.group-title-row span {
  color: var(--sidebar-muted);
  font-size: 0.78rem;
}

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

.mode-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #dce7ff;
  font-weight: 700;
}

.mode-btn.active {
  border-color: rgba(143, 180, 255, 0.52);
  background: rgba(33, 83, 212, 0.34);
  color: #ffffff;
}

.mode-tip {
  margin: 10px 0 0;
  color: var(--sidebar-muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.new-chat-btn {
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #4a8cff 0%, #2050d2 100%);
  color: #f7fbff;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(17, 48, 125, 0.28);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.history-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.history-search,
.token-panel input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
  padding: 10px 11px;
}

.history-search::placeholder,
.token-panel input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.history-search:focus,
.token-panel input:focus {
  outline: none;
  border-color: rgba(143, 180, 255, 0.6);
}

.clear-search-btn,
.token-action-btn,
.history-actions button,
.message-actions button,
.ghost-btn,
.primary-btn,
.toolbar-btn,
.mini-tab {
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.clear-search-btn,
.mini-tab {
  background: rgba(255, 255, 255, 0.08);
  color: #d7e3fd;
  border-color: rgba(255, 255, 255, 0.1);
  padding: 8px 10px;
}

.history-sort-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.mini-tab.active {
  border-color: rgba(143, 180, 255, 0.5);
  background: rgba(33, 83, 212, 0.34);
  color: #ffffff;
}

.history-list {
  margin-top: 12px;
  max-height: 46vh;
  overflow-y: auto;
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  gap: 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
}

.history-item.active {
  border-color: rgba(143, 180, 255, 0.52);
  background: rgba(33, 83, 212, 0.26);
}

.history-main {
  border: none;
  padding: 0;
  background: transparent;
  text-align: left;
  color: inherit;
  display: grid;
  gap: 4px;
}

.history-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #eef4ff;
}

.history-pin {
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #bed2ff;
  font-size: 0.7rem;
}

.history-time,
.history-snippet {
  color: var(--sidebar-muted);
}

.history-time {
  font-size: 0.74rem;
}

.history-snippet {
  font-size: 0.78rem;
  line-height: 1.4;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-actions button {
  padding: 5px 8px;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
  color: #dbe7ff;
}

.token-panel {
  margin-top: auto;
}

.token-tip {
  margin: 8px 0 0;
  color: var(--sidebar-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.token-action-btn {
  margin-top: 12px;
  width: 100%;
  padding: 10px 12px;
  border-color: rgba(143, 180, 255, 0.5);
  background: rgba(33, 83, 212, 0.3);
  color: #edf3ff;
}

.chat-main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 14px;
  padding: 20px 22px;
}

.chat-header,
.message-panel,
.composer,
.banner {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.header-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-header h2 {
  margin: 6px 0 0;
  font-size: 1.2rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: #eaf1ff;
  border: 1px solid #c4d6f6;
  color: var(--info);
  font-size: 0.82rem;
  font-weight: 700;
}

.ghost-btn,
.primary-btn,
.toolbar-btn,
.message-actions button {
  padding: 8px 12px;
}

.ghost-btn,
.message-actions button,
.toolbar-btn {
  background: #f6f9ff;
  border-color: #c9d9f2;
  color: #204786;
}

.primary-btn {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #ffffff;
}

.stop-btn {
  border: 1px solid #e8b4af;
  border-radius: 10px;
  padding: 8px 12px;
  background: #fff2f0;
  color: var(--danger);
}

.message-panel {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.auth-card,
.welcome-panel {
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f7fbff 0%, rgba(255, 255, 255, 0.98) 100%);
}

.auth-badge {
  display: inline-flex;
  margin-bottom: 12px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #eaf1ff;
  color: var(--info);
  font-size: 0.78rem;
  font-weight: 700;
}

.auth-card h3,
.welcome-panel h3 {
  margin: 0;
  font-size: 1.42rem;
}

.auth-card p,
.welcome-panel p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
  max-width: 68ch;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.example-card {
  display: grid;
  gap: 6px;
  border-radius: 14px;
  border: 1px solid #d7e3f7;
  background: #fbfdff;
  padding: 13px;
  text-align: left;
}

.example-card span {
  color: #19386d;
  font-weight: 700;
}

.example-card small {
  color: var(--muted);
  line-height: 1.45;
}

.loading-tip {
  padding: 18px 24px 4px;
  color: var(--muted);
}

.message-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.message-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  content-visibility: auto;
}

.message-row.user {
  grid-template-columns: minmax(0, 1fr) 38px;
  justify-items: end;
}

.message-row.user .avatar {
  order: 2;
}

.message-row.user .bubble-wrap {
  order: 1;
  justify-items: end;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #dfe9ff;
  color: #26467d;
  font-size: 0.8rem;
  font-weight: 800;
}

.message-row.user .avatar {
  background: var(--primary);
  color: #eff5ff;
}

.bubble-wrap {
  min-width: 0;
  max-width: min(820px, 100%);
  display: grid;
  gap: 8px;
}

.bubble {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--assistant-bg);
  border: 1px solid #d3e1fb;
  line-height: 1.7;
  color: #132448;
}

.message-row.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-color: #163eaa;
}

.bubble.pending {
  background: #eef4ff;
}

.bubble.failed {
  border-color: #edb4b0;
  background: #fff3f2;
  color: #8f3128;
}

.plain-text {
  white-space: pre-wrap;
}

.bubble p {
  margin: 0 0 12px;
}

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

.bubble ul,
.bubble ol {
  margin: 0 0 8px;
  padding-left: 20px;
}

.bubble blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid #91b3f2;
  background: rgba(255, 255, 255, 0.7);
  color: #49618f;
}

.bubble table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.bubble th,
.bubble td {
  border: 1px solid #cadefa;
  padding: 7px 9px;
  text-align: left;
}

.bubble a {
  color: #0f4cbc;
  text-decoration: none;
}

.bubble a:hover {
  text-decoration: underline;
}

.inline-code {
  display: inline-flex;
  padding: 1px 6px;
  border-radius: 7px;
  background: #e5eefb;
  color: #1a438c;
  font-size: 0.88em;
}

.md-pre-wrap {
  margin: 10px 0;
  border: 1px solid #d2def2;
  border-radius: 12px;
  overflow: hidden;
  background: #f8fbff;
}

.copy-code-btn {
  display: block;
  margin-left: auto;
  border: none;
  border-left: 1px solid #d8e3f6;
  border-bottom: 1px solid #d8e3f6;
  background: #edf4ff;
  color: #38517f;
  font-size: 0.76rem;
  padding: 7px 11px;
}

.md-pre-wrap pre {
  margin: 0;
  overflow-x: auto;
  padding: 14px;
}

.mermaid-loading,
.mermaid-error {
  padding: 12px;
  border-radius: 12px;
  background: #f6f9ff;
  color: #45608f;
}

.mermaid-block {
  overflow-x: auto;
  padding: 10px 0;
}

.mermaid-block svg {
  width: 100%;
  min-width: 420px;
  height: auto;
}

.fold-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbff;
  overflow: hidden;
}

.fold-card summary {
  list-style: none;
  padding: 10px 12px;
  font-weight: 700;
  color: #1d427f;
  cursor: pointer;
}

.fold-card summary::-webkit-details-marker {
  display: none;
}

.summary-grid {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.summary-item {
  display: grid;
  gap: 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 10px;
}

.summary-item strong {
  color: #244888;
  font-size: 0.82rem;
}

.summary-item span {
  color: #42536f;
  font-size: 0.86rem;
  line-height: 1.45;
}

.harness-trace-list {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.harness-trace-item {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 8px;
  padding: 10px;
}

.harness-trace-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.harness-trace-main strong {
  color: #1d427f;
  font-size: 0.82rem;
}

.harness-trace-main span {
  color: #42536f;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.harness-trace-main em {
  margin-left: auto;
  border-radius: 4px;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 800;
  padding: 2px 6px;
}

.harness-trace-main em.ok {
  background: #d1fae5;
  color: #065f46;
}

.harness-trace-main em.fail {
  background: #fee2e2;
  color: #991b1b;
}

.harness-trace-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.harness-trace-meta span {
  border-radius: 4px;
  background: #eef4ff;
  color: #244888;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 6px;
}

.harness-trace-item p {
  margin: 8px 0 0;
  color: #5c6b84;
  font-size: 0.78rem;
  line-height: 1.45;
}

.business-card {
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid #bed0ee;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(32, 65, 130, 0.12);
  overflow: hidden;
}

.business-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #eaf2ff 0%, #f8fbff 100%);
  border-bottom: 1px solid #dbe7f8;
}

.business-card-head span {
  color: #2350a4;
  font-size: 0.82rem;
  font-weight: 800;
}

.business-card-head strong {
  color: #132a58;
  font-size: 0.98rem;
  text-align: right;
}

.business-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 14px;
}

.business-card-grid div {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f9fbff;
  padding: 10px;
}

.business-card-grid span {
  display: block;
  color: #6b7893;
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.business-card-grid strong {
  color: #182f62;
  font-size: 0.92rem;
  line-height: 1.35;
}

.business-card p {
  margin: 0;
  padding: 0 14px 14px;
  color: #52617c;
  font-size: 0.9rem;
  line-height: 1.55;
}

.order-card .business-card-head {
  background: linear-gradient(135deg, #fff3e2 0%, #fffaf3 100%);
}

.order-card .business-card-head span {
  color: #9a5a0b;
}

.order-card .business-card-grid div:nth-child(4) strong {
  color: #b45309;
  font-size: 1.05rem;
}

.params-block {
  margin: 0;
  padding: 0 12px 12px;
  font-size: 0.8rem;
  color: #324461;
  overflow-x: auto;
}

.reference-list {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.reference-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 12px;
}

.reference-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.reference-head span {
  border-radius: 999px;
  background: #eef4ff;
  color: var(--info);
  padding: 3px 8px;
  font-size: 0.72rem;
}

.reference-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.reference-card a {
  display: inline-block;
  margin-top: 8px;
  color: #1147b4;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid #d5e2f4;
  background: #f6f9ff;
  color: #23447f;
  padding: 7px 10px;
  font-size: 0.78rem;
}

.attachment-chip button {
  border: none;
  background: transparent;
  color: #20427d;
  font-size: 0.9rem;
}

.attachment-chip.static button {
  display: none;
}

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

.message-actions button:disabled,
.composer-input-row > button:disabled,
.ghost-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.banner {
  padding: 12px 14px;
  font-size: 0.9rem;
}

.banner-info {
  border-color: #c9dcf8;
  background: var(--info-bg);
  color: var(--info);
}

.banner-warning {
  border-color: #efd6a0;
  background: var(--warning-bg);
  color: var(--warning);
}

.banner-error {
  border-color: #edbeb8;
  background: var(--danger-bg);
  color: var(--danger);
}

.composer {
  padding: 12px;
  display: grid;
  gap: 12px;
}

.shortcut-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shortcut-btn {
  border: 1px solid #cadefa;
  border-radius: 999px;
  background: #f7fbff;
  color: #21488a;
  padding: 6px 11px;
  font-size: 0.8rem;
}

.shortcut-btn.active {
  border-color: #9fbbf1;
  background: #eef4ff;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-btn.active {
  border-color: #9abaf0;
  background: #eaf1ff;
}

.composer-hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.slash-suggestions {
  display: grid;
  gap: 2px;
  border: 1px solid #d2def5;
  border-radius: 12px;
  overflow: hidden;
  background: #fbfdff;
}

.slash-item {
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.slash-item span {
  color: #173f86;
  font-weight: 700;
}

.slash-item small {
  color: #60779f;
}

.composer-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.composer-input-wrap {
  min-width: 0;
}

.composer textarea {
  width: 100%;
  min-height: 54px;
  max-height: 220px;
  resize: none;
  border: 1px solid #d6e0f2;
  border-radius: 14px;
  background: #ffffff;
  color: #13203a;
  padding: 14px 15px;
  line-height: 1.55;
}

.composer textarea:focus {
  outline: none;
  border-color: #9db8ea;
  box-shadow: 0 0 0 4px rgba(33, 83, 212, 0.08);
}

.composer-input-row > button {
  border: none;
  border-radius: 14px;
  min-width: 110px;
  height: 54px;
  padding: 0 18px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.composer-footnote {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

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

.placeholder {
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 0.84rem;
}

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

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .token-panel {
    margin-top: 0;
  }

  .example-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .chat-main {
    padding: 14px;
  }

  .chat-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions,
  .auth-actions,
  .composer-toolbar {
    justify-content: flex-start;
  }

  .message-list {
    padding: 16px;
  }

  .composer-input-row {
    grid-template-columns: 1fr;
  }

  .composer-input-row > button {
    width: 100%;
  }
}

/* ── Route Result Card ──────────────────────────────── */
.route-card {
  margin: 0.5rem 0;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border: 1px solid #c7d2fe;
  font-size: 0.85rem;
}
.route-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.route-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: #6366f1;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}
.route-confidence {
  margin-left: auto;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: #10b981;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
}
.route-detail {
  margin-top: 0.3rem;
  color: #4f46e5;
  font-weight: 500;
}
.route-reason {
  margin-top: 0.2rem;
  color: #6b7280;
  font-size: 0.8rem;
}
.route-tags {
  margin-top: 0.4rem;
  display: flex;
  gap: 0.3rem;
}
.route-tag {
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.7rem;
  font-weight: 500;
}
.route-tag.risk-low { background: #d1fae5; color: #065f46; }
.route-tag.risk-medium { background: #fef3c7; color: #92400e; }
.route-tag.risk-high { background: #fee2e2; color: #991b1b; }

/* ── Evidence Section ────────────────────────────────── */
.evidence-section {
  margin: 0.4rem 0;
}
.evidence-head {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 0.3rem;
}
.evidence-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.25rem;
  border-radius: 6px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  font-size: 0.78rem;
}
.evidence-source {
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  background: #ede9fe;
  color: #7c3aed;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
}
.evidence-title {
  font-weight: 500;
  color: #374151;
}
.evidence-score {
  margin-left: auto;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  background: #d1fae5;
  color: #065f46;
  font-size: 0.7rem;
  font-weight: 600;
}
.evidence-reason {
  width: 100%;
  color: #9ca3af;
  font-size: 0.7rem;
  margin-top: 0.1rem;
}

/* ── Memory Hits ─────────────────────────────────────── */
.memory-section {
  margin: 0.4rem 0;
}
.memory-head {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 0.3rem;
}
.memory-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  margin-bottom: 0.2rem;
  border-radius: 6px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  font-size: 0.78rem;
}
.memory-type {
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
}
.memory-text {
  color: #78350f;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ── Branded Business Cards ─────────────────────────── */
.course-gradient {
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 50%, #a5b4fc 100%) !important;
  border-bottom: 1px solid #a5b4fc !important;
}
.order-gradient {
  background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 50%, #fdba74 100%) !important;
  border-bottom: 1px solid #fdba74 !important;
}
.card-head-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-type-badge {
  border-radius: 6px;
  background: rgba(255,255,255,0.7);
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #3730a3;
  align-self: flex-start;
}
.order-gradient .card-type-badge {
  color: #9a3412;
}
.card-price-tag {
  font-size: 1.2rem;
  font-weight: 900;
  color: #1e40af;
  background: rgba(255,255,255,0.65);
  padding: 6px 14px;
  border-radius: 10px;
}
.card-price-tag.accent {
  color: #b45309;
}
.card-field strong.mono {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.78rem;
  color: #64748b;
}
.cta-field {
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-cta-btn {
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  color: #fff;
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card-cta-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}
.card-detail {
  margin: 0;
  padding: 0 14px 14px;
  color: #4b5563;
  font-size: 0.86rem;
  line-height: 1.5;
}
strong.discount {
  color: #059669;
}
strong.pay-amount {
  color: #b45309;
  font-size: 1rem;
}

/* ── Route Stepper V2 ───────────────────────────────── */
.route-card-v2 {
  margin: 0.5rem 0;
  padding: 0.75rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border: 1px solid #c7d2fe;
}
.route-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 0.5rem;
}
.route-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
}
.route-step.active { color: #4f46e5; }
.route-step.target { color: #7c3aed; }
.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
}
.route-step.active .step-dot { background: #6366f1; }
.route-step.target .step-dot { background: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,0.2); }
.route-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, #6366f1, #a78bfa);
  margin: 0 6px;
  border-radius: 1px;
}
.route-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.3rem;
}
.route-conf-badge {
  padding: 1px 6px;
  border-radius: 4px;
  background: #10b981;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}
.route-reason-text {
  color: #6b7280;
  font-size: 0.78rem;
}
.route-tag-row {
  display: flex;
  gap: 4px;
}

.route-trace-panel {
  margin: 0 14px 14px;
  padding: 10px 12px;
  border-top: 1px solid #dbe7f8;
  background: #f8fbff;
}

.route-trace-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.route-trace-main span {
  color: #52617c;
  font-size: 0.74rem;
  font-weight: 800;
}

.route-trace-main strong {
  color: #1d427f;
  font-size: 0.82rem;
  word-break: break-word;
}

.route-trace-main em {
  margin-left: auto;
  border-radius: 4px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  padding: 2px 6px;
}

.route-trace-panel p {
  margin: 6px 0 0;
  padding: 0;
  color: #5c6b84;
  font-size: 0.78rem;
  line-height: 1.45;
}

.route-candidate-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.route-candidate-row span {
  border-radius: 4px;
  background: #eef4ff;
  color: #244888;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 6px;
}

.order-state-strip {
  display: grid;
  gap: 4px;
  margin: 0 14px 12px;
  padding: 10px 12px;
  border-top: 1px solid #f0d9b5;
  background: #fffaf3;
}

.order-state-strip strong {
  color: #9a5a0b;
  font-size: 0.82rem;
}

.order-state-strip span {
  color: #7c5a2a;
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.72rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* ── Unified Event Tags ─────────────────────────────── */
.ev-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ev-tag.rag { background: #dbeafe; color: #1e40af; }
.ev-tag.memory { background: #fef3c7; color: #92400e; }
.ev-tag.evidence { background: #ede9fe; color: #6d28d9; }
.ev-tag.risk-low { background: #d1fae5; color: #065f46; }
.ev-tag.risk-medium { background: #fef3c7; color: #92400e; }
.ev-tag.risk-high { background: #fee2e2; color: #991b1b; }

/* ── Evidence V2 ────────────────────────────────────── */
.evidence-section-v2 {
  margin: 0.4rem 0;
}
.evidence-toggle,
.memory-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 4px 0;
}
.evidence-count,
.memory-count {
  font-size: 0.72rem;
  color: #9ca3af;
  font-weight: 600;
}
.evidence-list-v2 {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}
.evidence-item-v2 {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 8px 10px;
}
.evidence-source-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.source-type-label {
  padding: 1px 6px;
  border-radius: 3px;
  background: #ede9fe;
  color: #7c3aed;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
}
.source-type-label.vector { background: #e0e7ff; color: #4338ca; }
.source-type-label.keyword { background: #e0f2fe; color: #0369a1; }
.source-type-label.graph { background: #fef3c7; color: #92400e; }
.source-type-label.web { background: #d1fae5; color: #065f46; }
.evidence-score-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  max-width: 120px;
  height: 6px;
  border-radius: 3px;
  background: #e5e7eb;
  overflow: hidden;
  position: relative;
}
.score-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #10b981, #34d399);
  transition: width 0.3s ease;
}
.score-text {
  font-size: 0.62rem;
  font-weight: 700;
  color: #059669;
  min-width: 28px;
}
.evidence-title-row {
  font-size: 0.82rem;
  font-weight: 600;
  color: #1f2937;
}
.evidence-reason-row {
  font-size: 0.72rem;
  color: #9ca3af;
  margin-top: 2px;
}

/* ── Memory V2 ──────────────────────────────────────── */
.memory-section-v2 {
  margin: 0.4rem 0;
}
.memory-list-v2 {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}
.memory-item-v2 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  font-size: 0.78rem;
}
.memory-type-label {
  padding: 1px 5px;
  border-radius: 3px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.memory-content-text {
  color: #78350f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Quick Bubbles ──────────────────────────────────── */
.quick-bubbles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 22px;
}
.quick-bubble {
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  color: #3730a3;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.quick-bubble:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.2);
}

/* ---------- Model config section ---------- */

.model-config-section {
  margin-top: 8px;
}

.model-config-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.config-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--sidebar-text);
}

.config-label select,
.config-label input[type="range"] {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text);
  font-size: 0.82rem;
}

.config-label select {
  cursor: pointer;
}

.config-label select:focus,
.config-label input[type="range"]:focus {
  outline: none;
  border-color: var(--primary);
}

.config-label input[type="range"] {
  padding: 0;
  height: 6px;
  accent-color: var(--primary);
  cursor: pointer;
}
