﻿:root {
  color-scheme: light;
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #eef3fb;
  --text: #122033;
  --muted: #627086;
  --thinking-text: #8a93a6;
  --line: #dbe5f2;
  --line-strong: #9ca9ba;
  --primary: #286be8;
  --primary-hover: #1f5ed4;
  --danger: #d9483b;
  --ok: #148a5b;
  --shadow: 0 18px 60px rgba(35, 76, 132, .12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141414;
  --surface: #1b1b1c;
  --surface-2: #2b2c30;
  --text: #e6e8ee;
  --muted: #9aa0aa;
  --thinking-text: #7d8593;
  --line: #2a2c31;
  --line-strong: #62666f;
  --primary: #4f86f7;
  --primary-hover: #6b9cff;
  --danger: #ff7b72;
  --ok: #69d7a0;
  --shadow: 0 18px 60px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}
button, input, textarea, select { font: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary, .primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}
button.primary:hover { background: var(--primary-hover); }
button.ghost { background: transparent; }
button.full { width: 100%; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: var(--surface);
  color: var(--text);
}
textarea { resize: vertical; line-height: 1.65; }
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}
h1, h2, p { margin: 0; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; margin-bottom: 12px; font-weight: 650; }
small, .muted { color: var(--muted); line-height: 1.45; }
.hidden { display: none !important; }
.stack { display: grid; gap: 14px; }
.message { min-height: 20px; color: var(--danger); font-size: 14px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 70%, var(--bg)), var(--bg));
}
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
}
.auth-shell { width: min(440px, 100%); }
.auth-panel {
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.brand-row, .side-brand {
  display: flex;
  gap: 14px;
  align-items: center;
}
.brand-row { margin-bottom: 24px; }
.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--bg);
  font-weight: 700;
}
.brand-mark.small {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}
.brand-row p, .side-brand span, .topbar p { color: var(--muted); margin-top: 4px; font-size: 13px; }
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 18px;
}
.segmented button { border: 0; background: transparent; }
.segmented button.active { background: var(--surface); box-shadow: 0 1px 8px rgba(0,0,0,.08); }

.app-layout {
  height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  overflow: hidden;
}
.sidebar, .inspector {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px;
}
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
:root[data-theme="dark"] .sidebar {
  background: #1b1b1c;
}
:root[data-theme="dark"] .chat-main {
  background: #141414;
}
.inspector {
  border-right: 0;
  border-left: 1px solid var(--line);
  overflow: auto;
}
.side-brand { margin-bottom: 18px; }
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
}
.conversation-list {
  display: grid;
  align-content: start;
  gap: 7px;
  margin-top: 16px;
  padding-bottom: 16px;
  overflow: auto;
}
.conversation-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
}
.conversation-row.active {
  background: var(--surface-2);
  border-color: var(--line);
}
.conversation-item {
  text-align: left;
  border: 0;
  background: transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.conversation-more {
  display: grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}
.conversation-more:hover {
  color: var(--text);
  background: var(--surface-2);
}
.conversation-menu {
  position: fixed;
  z-index: 70;
  display: grid;
  min-width: 112px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.conversation-menu.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.conversation-menu button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}
.conversation-menu .danger-menu-item {
  color: var(--danger);
}
:root[data-theme="dark"] .conversation-row.active {
  background: #38393d;
}
.chat-main {
  --chat-column-gutter: clamp(32px, 8vw, 128px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}
.topbar {
  min-height: 72px;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, var(--surface));
}
:root[data-theme="dark"] .topbar {
  background: #141414;
  border-bottom-color: transparent;
}
.mobile-sidebar-btn {
  display: none;
  align-content: center;
  justify-items: start;
  gap: 4px;
  width: 34px;
  min-width: 34px;
  height: 30px;
  min-height: 30px;
  padding: 6px 7px;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.mobile-sidebar-btn:hover {
  background: transparent;
}
.mobile-sidebar-btn span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}
.mobile-sidebar-btn span:nth-child(2) {
  width: 12px;
}
.mobile-sidebar-btn span:nth-child(3) {
  display: none;
}
.mobile-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, background-color .22s ease;
}
body.mobile-sidebar-open .mobile-sidebar-backdrop {
  background: rgba(0, 0, 0, .48);
  opacity: 1;
  pointer-events: auto;
}
body.mobile-sidebar-open {
  overflow: hidden;
}
.model-picker {
  width: 230px;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}
.model-picker select {
  min-height: 38px;
  padding: 7px 10px;
}
.messages {
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 34px var(--chat-column-gutter) 26px;
}
.empty-state {
  align-self: center;
  justify-self: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 18px 22px;
}
.msg {
  max-width: min(900px, 100%);
  min-width: 0;
  padding: 0;
  line-height: 28px;
}
.msg.user {
  justify-self: end;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 6px;
  max-width: min(760px, 78%);
}
.msg.user .msg-body {
  grid-column: 1 / -1;
  grid-row: 1;
  justify-self: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 12px 18px;
  white-space: pre-wrap;
}
:root[data-theme="dark"] .msg.user .msg-body {
  background: #2b2c30;
  border-color: #303238;
}
.msg.assistant {
  justify-self: stretch;
  width: 100%;
  max-width: 100%;
}
.msg.assistant .msg-body {
  font-size: 17px;
  line-height: 34px;
}
.message-time {
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
}
.assistant-generation-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
  margin-top: 6px;
}
.msg.user .message-time {
  grid-column: 1;
  grid-row: 2;
  justify-self: end;
  align-self: center;
  margin-top: 6px;
}
.msg.assistant .message-time {
  display: block;
  margin-top: 8px;
  text-align: left;
}
.msg.assistant .msg-body.thinking-placeholder {
  color: var(--thinking-text);
  font-style: italic;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.thinking-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: thinking-spin 0.8s linear infinite;
}
@keyframes thinking-spin {
  to { transform: rotate(360deg); }
}
.agent-process {
  margin: 0 0 24px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}
.agent-process-summary {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  line-height: 20px;
  color: var(--muted);
  font-weight: 600;
  user-select: none;
  transition: color 180ms ease;
}
.agent-process-summary:hover {
  color: var(--text);
}
.agent-process-list {
  border-top: 0;
  display: grid;
  grid-template-rows: 1fr;
  max-height: none;
  overflow: hidden;
  padding: 6px 0 0;
  opacity: 1;
  transition: grid-template-rows 220ms ease, opacity 180ms ease, padding 220ms ease;
}
.agent-process.collapsed .agent-process-list {
  grid-template-rows: 0fr;
  opacity: 0;
  padding-top: 0;
}
.agent-process-list-inner {
  min-height: 0;
}
.agent-process-item {
  padding: 3px 0;
  border-bottom: 0;
}
.agent-process-item:last-child {
  border-bottom: 0;
}
.agent-process-item-title {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  font-weight: 400;
  line-height: 24px;
}
.agent-process-detail {
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
  line-height: 34px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.agent-process-item.process-status .agent-process-item-title {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  line-height: 24px;
}
.agent-process-item.process-tool_call,
.agent-process-item.process-tool_result {
  display: flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 20px;
  overflow-wrap: anywhere;
}
/* 已完成态：把"调用中"那行升级一下——淡化边框、加上绿色勾勾 */
.agent-process-item.process-tool_done {
  background: transparent;
  border-color: rgba(42, 157, 143, 0.35);
  color: var(--muted);
  font-weight: 500;
}
.agent-process-tick {
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #2a9d8f;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  flex-shrink: 0;
}
.agent-process-item.process-tool_call .agent-process-item-title,
.agent-process-item.process-tool_result .agent-process-item-title {
  color: var(--text);
  font-size: 13px;
  font-style: normal;
  font-weight: 600;
  line-height: 20px;
  overflow-wrap: anywhere;
}
.agent-process-item.process-tool_call .agent-process-detail,
.agent-process-item.process-tool_result .agent-process-detail {
  color: var(--muted);
  font-size: 12px;
  line-height: 20px;
}
/* AI live thinking text: same gray as the placeholder line. */
.agent-process-item.process-ai_return.process-live-thinking,
.agent-process-item.process-ai_return.process-live-thinking[data-live-thinking-step] {
  color: var(--thinking-text) !important;
  font-size: 14px !important;
  line-height: 24px !important;
  font-style: italic !important;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  opacity: 0.85;
}
/* PR6: 智能追问卡片 */
.agent-question {
  padding: 14px 18px;
  background: rgba(124, 77, 255, 0.08);
  border: 1px solid rgba(124, 77, 255, 0.28);
  border-radius: 12px;
  margin: 8px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.agent-question-title {
  font-weight: 600;
  color: #7c4dff;
  font-size: 14px;
}
.agent-question-desc {
  font-size: 13px;
  line-height: 1.6;
  color: #4a3f6b;
  white-space: pre-wrap;
  word-break: break-word;
}
.agent-question-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.agent-question-list li {
  margin: 0;
}
.agent-question-pill {
  display: inline-block;
  padding: 6px 14px;
  background: #fff;
  border: 1px solid rgba(124, 77, 255, 0.45);
  border-radius: 999px;
  color: #4a3f6b;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}
.agent-question-pill:hover {
  background: rgba(124, 77, 255, 0.12);
  transform: translateY(-1px);
}
.agent-question-hint {
  font-size: 12px;
  color: #8a82a8;
}
.agent-question-progress {
  font-size: 12px;
  color: #7c4dff;
  font-weight: 600;
}
.agent-question-current {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}
.agent-question-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.agent-question-option {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(124, 77, 255, 0.32);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}
.agent-question-option:hover {
  border-color: rgba(124, 77, 255, 0.65);
  background: rgba(124, 77, 255, 0.1);
  transform: translateY(-1px);
}
.agent-question-other {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  cursor: default;
}
.agent-question-other[hidden] {
  display: none;
}
.agent-question-other:hover {
  transform: none;
}
.agent-question-other-label {
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
}
.agent-question-other-input {
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 0 10px;
  outline: none;
}
.agent-question-other-input:focus {
  border-color: rgba(124, 77, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(124, 77, 255, 0.12);
}
.agent-question-next {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: #7c4dff;
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.agent-question-skip {
  color: var(--muted);
  border-style: dashed;
}
.agent-question.is-complete {
  border-color: rgba(46, 160, 67, 0.35);
  background: rgba(46, 160, 67, 0.08);
}
.agent-question-summary {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}
.agent-question-summary-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.9fr) minmax(0, 1.4fr);
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(46, 160, 67, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  line-height: 1.5;
}
.agent-question-summary-question {
  color: var(--muted);
}
.agent-question-summary-answer {
  color: var(--text);
  overflow-wrap: anywhere;
}
:root[data-theme="dark"] .agent-question-desc {
  color: #c9c2e8;
}
:root[data-theme="dark"] .agent-question-option,
:root[data-theme="dark"] .agent-question-other-input {
  background: var(--surface-2);
}
:root[data-theme="dark"] .agent-question-summary-row {
  background: rgba(255, 255, 255, 0.04);
}
@media (max-width: 720px) {
  .agent-question-other {
    grid-template-columns: 1fr;
  }
  .agent-question-summary-row {
    grid-template-columns: 1fr;
  }
}

/* 写作模式轻提示条：当 final 看起来夹带"信息不足/需要补充"等关键词时，展示给用户看的非阻塞提示。
 * 仅用来告知，不发起追问。 */
.final-uncertainty-banner {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 6px;
  background: #fff7e6;
  border: 1px solid #ffd591;
  color: #874d00;
  font-size: 12px;
  line-height: 1.5;
}
:root[data-theme="dark"] .final-uncertainty-banner {
  background: #2d2418;
  border-color: #8c6a3a;
  color: #f0c891;
}
/* 过程面板里 parallel_tools / question 的差异化样式 */
.agent-process-item.process-parallel_tools .agent-process-item-title {
  color: #2a9d8f;
}
.agent-process-item.process-question .agent-process-item-title {
  color: #7c4dff;
}
.agent-settings-panel {
  max-width: 620px;
}
.agent-toggle-list {
  display: grid;
  gap: 10px;
}
.agent-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

/* 偏好 schema v2:手写 + 自动学习 两个文本框 + 开关 */
.preferences-panel {
  max-width: 640px;
}
.preferences-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.preferences-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.preferences-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}
.preferences-field textarea {
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  min-height: 100px;
}
.preferences-field textarea[readonly] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: default;
}
.muted-2 {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}
.agent-toggle-row:last-child {
  border-bottom: 0;
}
.agent-toggle-row span {
  display: grid;
  gap: 3px;
}
.agent-toggle-row strong {
  font-size: 14px;
  color: var(--text);
}
.agent-toggle-row small {
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}
.agent-toggle-row small.agent-mode-dev-warning {
  display: block;
  margin-top: 4px;
  color: #b85c00;
  font-size: 12px;
  line-height: 18px;
}
.agent-toggle-row input[type="checkbox"],
.agent-toggle-row input[type="radio"][name="agentMode"] {
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  position: relative;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}
.agent-toggle-row input[type="checkbox"]::after,
.agent-toggle-row input[type="radio"][name="agentMode"]::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease;
}
.agent-toggle-row input[type="checkbox"]:checked,
.agent-toggle-row input[type="radio"][name="agentMode"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.agent-toggle-row input[type="checkbox"]:checked::after,
.agent-toggle-row input[type="radio"][name="agentMode"]:checked::after {
  transform: translateX(18px);
}
.agent-planning-steps-row {
  margin-top: 4px;
}
.agent-planning-steps-input {
  width: 80px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  flex: 0 0 auto;
  text-align: center;
}
.agent-planning-steps-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.msg .role {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.msg-body {
  overflow-wrap: anywhere;
}
.article-block {
  margin: 0;
  min-height: 30px;
  line-height: 30px;
  white-space: pre-wrap;
}
.msg.assistant .article-block {
  min-height: 34px;
  line-height: 34px;
}
.article-main-title {
  text-align: center;
  font-size: 22px;
  font-weight: 650;
}
.article-subtitle {
  text-align: center;
}
.article-body,
.article-first-heading,
.article-second-heading,
.article-third-heading,
.article-fourth-heading {
  text-align: justify;
  text-indent: 2em;
}
.article-first-heading { font-weight: 650; }
.article-third-heading { font-weight: 600; }
.article-inline-first-heading { font-weight: 650; }
.article-inline-third-heading { font-weight: 600; }
.article-recipient,
.article-attachment-marker,
.article-attachment-index {
  text-indent: 0;
}
.article-signature {
  text-align: right;
  text-indent: 0;
}
.article-after-title-gap {
  margin-bottom: 30px;
}
.article-before-signature-gap {
  margin-top: 30px;
}
.msg.assistant .article-after-title-gap {
  margin-bottom: 34px;
}
.msg.assistant .article-before-signature-gap {
  margin-top: 34px;
}
.article-table {
  width: 100%;
  max-width: 100%;
  margin: 12px 0;
  overflow-x: auto;
  background: var(--surface);
  border: 0;
  border-radius: 0;
  font-family: inherit;
}
.article-table > table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 14px;
  line-height: 1.55;
}
.article-table th,
.article-table td {
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  padding: 7px 9px;
  vertical-align: middle;
  text-align: left;
  white-space: normal;
  overflow-wrap: break-word;
  background: var(--surface);
  color: var(--text);
}
.article-table thead th {
  background: var(--surface-2);
  font-weight: 600;
  text-align: center;
}
.article-table th p,
.article-table td p { margin: 0; min-height: 1em; }
.article-table th p + p,
.article-table td p + p { margin-top: 4px; }
.article-table-pending {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  font-size: 14px;
}
@media print {
  .article-table { overflow: visible; border: none; }
  .article-table thead { display: table-header-group; }
  .article-table tr,
  .article-table th,
  .article-table td { page-break-inside: avoid; }
}
[data-theme="dark"] .article-table thead th {
  background: rgba(255, 255, 255, 0.06);
}
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.msg.user .msg-actions {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  justify-content: flex-end;
  margin-top: 6px;
}
.msg-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}
.msg-icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.msg-icon-btn svg,
.icon-submit svg,
.add-file-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-submit .stop-icon { display: none; }
.icon-submit.is-stop .send-icon { display: none; }
.icon-submit.is-stop .stop-icon { display: block; }
.icon-submit.is-stop .stop-icon rect {
  fill: currentColor;
  stroke: none;
}
.icon-submit {
  display: inline-grid;
  place-items: center;
}
.icon-submit svg {
  display: block;
}
.icon-submit.is-stop {
  background: var(--danger, #d94646);
  border-color: var(--danger, #d94646);
  color: #fff;
  animation: send-stop-pulse 1.6s ease-in-out infinite;
}
.icon-submit.is-stop:hover {
  background: color-mix(in srgb, var(--danger, #d94646) 88%, #000 12%);
  border-color: color-mix(in srgb, var(--danger, #d94646) 88%, #000 12%);
}
@keyframes send-stop-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger, #d94646) 60%, transparent); }
  50%      { box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger, #d94646) 0%, transparent); }
}
.composer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin: 0 var(--chat-column-gutter) 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.app-layout,
#mobileSidebarBackdrop,
#settingsOverlay {
  transition: filter .16s ease;
}
body.chat-file-drag-active .app-layout,
body.chat-file-drag-active #mobileSidebarBackdrop,
body.chat-file-drag-active #settingsOverlay {
  filter: blur(8px);
}
.page-file-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 16, 30, .24);
  color: #ffffff;
  pointer-events: none;
}
.page-file-drop-copy {
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
}
.page-file-drop-copy strong {
  font-size: clamp(34px, 7vw, 76px);
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: 0 6px 28px rgba(0, 0, 0, .38);
}
.page-file-drop-copy span {
  font-size: clamp(14px, 2.2vw, 20px);
  font-weight: 500;
  letter-spacing: 0;
  opacity: .92;
  text-shadow: 0 3px 16px rgba(0, 0, 0, .32);
}
.composer.drag-active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--surface) 92%, var(--primary));
}
:root[data-theme="dark"] .composer {
  background: #2b2c30;
  border-color: #34363c;
  box-shadow: none;
}
.composer textarea {
  border: 0;
  padding: 9px 42px 9px 9px;
  min-height: 52px;
  background: transparent;
  resize: none;
}
.composer textarea:focus,
.composer select:focus {
  outline: none;
}
.composer-resize-btn {
  position: absolute;
  top: 17px;
  right: 17px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: ns-resize;
  touch-action: none;
}
.composer-resize-btn:hover,
.composer-resize-btn:focus-visible,
.composer-resize-btn.is-dragging {
  color: var(--text);
}
.composer-resize-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.file-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px 4px;
}
.file-tray-notice {
  font-size: 12px;
  color: var(--muted, #888);
  padding: 0 2px 4px;
}
.tray-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.tray-file span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tray-remove {
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}
.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.composer-tools {
  display: flex;
  align-items: center;
  flex: 1;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
}
.add-file-btn {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #8a8f98;
}
.add-file-btn:hover,
.add-file-btn:focus-visible {
  background: var(--surface-2);
  color: #8a8f98;
}
.composer-model {
  flex: 0 0 min(220px, 34vw);
  width: min(220px, 34vw);
}
.composer-model select {
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  background: var(--surface-2);
}
.round-token-usage {
  display: inline-flex;
  align-items: center;
  flex: 1 1 auto;
  min-height: 34px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.round-token-usage:empty {
  display: none;
}

.composer button[type="submit"] {
  width: 40px;
  min-width: 40px;
  height: 40px;
  border-radius: 999px;
  padding: 0;
}
.composer-message {
  margin: -22px var(--chat-column-gutter) 8px;
}
.settings-actions,
.settings-nav-grid {
  display: grid;
  gap: 10px;
}
.settings-nav-grid { grid-template-columns: 1fr 1fr; }
.settings-option-list {
  display: grid;
  gap: 8px;
}
.settings-option {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 54px;
  padding: 10px 12px;
  border-radius: 8px;
  text-align: left;
  background: var(--surface);
}
.settings-option span {
  font-weight: 650;
}
.settings-option small {
  color: var(--muted);
  line-height: 1.35;
}
.settings-option.danger-option,
.settings-option.danger-option small {
  color: var(--danger);
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.settings-section {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.settings-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.settings-metrics > div {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface-2);
}
.settings-metrics strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}
.settings-section h3 {
  margin: 0;
  font-size: 15px;
}
.panel.quiet { background: var(--surface-2); }
.panel-head, .group-title, .detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.credit {
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 8px;
}
.file-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  font-size: 14px;
}
.file-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface-2);
}
.file-item.asset-item-row {
  align-items: flex-start;
}
.asset-item-content {
  margin-top: 8px;
}
.asset-item-content summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 12px;
}
.asset-item-content pre {
  max-height: 260px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
}
.asset-item-textarea {
  display: block;
  width: 100%;
  max-height: 260px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  line-height: 1.7;
  resize: vertical;
}

.admin-shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 18px auto;
}
.embedded-admin-page {
  background: var(--bg);
}
.embedded-admin-page .admin-shell {
  width: 100%;
  margin: 0;
}
.embedded-admin-page .topbar {
  min-height: 58px;
  padding: 10px 12px;
}
.embedded-admin-page .topbar .actions {
  display: none;
}
.embedded-admin-page .panel {
  margin-bottom: 12px;
}
.admin-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  border-bottom: 1px solid var(--line);
}
.admin-tabs .tab {
  background: transparent;
  color: var(--muted);
  border-radius: 8px 8px 0 0;
}
.admin-tabs .tab.active {
  color: var(--text);
  background: var(--surface);
  border-bottom-color: var(--surface);
}
.account-nav.admin-tabs {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  border-bottom: 0;
}
.account-nav.admin-tabs button {
  width: 100%;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.model-settings-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.model-settings-actions .model-default-check {
  min-height: 42px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}
.check-label input { width: auto; }
.admin-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}
.table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
}
.table-row {
  display: grid;
  grid-template-columns: 1.2fr 1.5fr .7fr 1fr 2fr;
  gap: 10px;
  align-items: center;
  min-width: 860px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.table-row.header {
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
}
.small-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.small-actions input {
  width: 98px;
  height: 36px;
}
.small-actions button {
  min-height: 36px;
  padding: 6px 10px;
}
.danger-btn {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}
.data-backup-panel {
  display: grid;
  gap: 14px;
  max-width: 760px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.data-backup-panel h2 {
  margin: 0 0 6px;
}
.data-backup-actions,
.data-backup-import-box {
  display: grid;
  gap: 12px;
}
.data-backup-file-label,
.data-backup-confirm-label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.data-backup-file-label input,
.data-backup-confirm-label input {
  width: min(520px, 100%);
}
.data-backup-inspect {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  line-height: 1.5;
}
.backup-table-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.backup-table-summary span {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
}
.model-list {
  display: grid;
  gap: 0;
}
.model-card {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 160px 100px auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-2);
}
.channel-groups {
  display: grid;
  gap: 14px;
}
.channel-group {
  display: grid;
  gap: 8px;
}
.draggable-list {
  display: grid;
  gap: 8px;
}
.channel-card {
  display: grid;
  grid-template-columns: 62px minmax(0, 1.4fr) minmax(180px, .8fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-2);
}
.drag-handle {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  cursor: grab;
}
.status {
  display: inline-flex;
  font-weight: 650;
}
.status.ok { color: var(--ok); }
.status.warn { color: #d99600; }
.status.bad { color: var(--danger); }
.pill {
  display: inline-flex;
  width: fit-content;
  margin-top: 8px;
  padding: 3px 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--line));
  border-radius: 999px;
  color: var(--primary);
  font-size: 12px;
  line-height: 1.3;
}
.ledger-panel { margin-top: 16px; }
.detail-box {
  display: grid;
  gap: 12px;
}
.ledger-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.ledger-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px;
}
.date-filter {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}
.date-filter label {
  min-width: 150px;
}
.usage-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.usage-stat-grid article {
  display: grid;
  gap: 8px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.usage-stat-grid span {
  color: var(--muted);
  font-size: 13px;
}
.usage-stat-grid strong {
  font-size: 24px;
  overflow-wrap: anywhere;
}
.usage-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.usage-daily-chart-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.usage-pie-chart-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.usage-chart-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.usage-chart-card canvas {
  width: 100%;
  display: block;
}
.usage-pie-card canvas {
  min-height: 240px;
}
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.usage-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.mini-table {
  display: grid;
  gap: 8px;
}
.mini-table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.mini-table-row span {
  color: var(--muted);
  text-align: right;
}
.login-record-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.login-record-table th,
.login-record-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}
.login-record-table th {
  color: var(--muted);
  font-weight: 700;
  background: var(--surface-2);
}
.login-record-table td:last-child,
.login-record-table th:last-child {
  text-align: right;
}
.login-record-table tr:last-child td {
  border-bottom: 0;
}
#adminLoginRecords {
  overflow-x: auto;
}
#page-billing .mini-table {
  gap: 0;
}
#page-billing .mini-table-row {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 12px 0;
}
#page-billing .mini-table-row:last-child {
  border-bottom: 0;
}
.model-card-wide {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.model-main-fields,
.model-price-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.model-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.model-list-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(360px, 1.5fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 74px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.model-list-row:first-child {
  border-top: 1px solid var(--line);
}
.model-row-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.model-row-main strong {
  font-size: 16px;
  overflow-wrap: anywhere;
}
.model-row-main span,
.model-row-prices span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.model-row-prices {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.model-row-prices span {
  display: inline-flex;
  padding: 4px 0;
  white-space: nowrap;
}
.model-row-actions {
  justify-content: flex-end;
}
.model-default-button.is-default,
.model-default-button.is-default:disabled {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line));
  background: color-mix(in srgb, var(--ok) 12%, var(--surface));
  opacity: 1;
}
.user-list-row {
  grid-template-columns: minmax(0, 1fr) minmax(420px, auto);
  column-gap: 20px;
}
.user-list-row .model-row-main {
  display: grid;
  gap: 7px;
  overflow: hidden;
  min-width: 0;
}
.user-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
}
.user-title-line strong,
.user-title-line span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-row-meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.user-row-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.user-row-meta span:first-child {
  min-width: 118px;
}
.user-row-meta span:nth-child(2),
.user-row-meta span:nth-child(3) {
  min-width: 72px;
}
.modal-form-grid {
  grid-template-columns: 1fr 1fr;
  margin-top: 14px;
}
.modal-form-note {
  align-self: center;
}
.chart-tooltip {
  position: fixed;
  z-index: 80;
  display: grid;
  gap: 3px;
  min-width: 92px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  color: var(--text);
  box-shadow: var(--shadow);
  pointer-events: none;
}
.chart-tooltip strong {
  font-size: 12px;
}
.chart-tooltip span {
  color: var(--muted);
  font-size: 12px;
}
.account-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
}
.account-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.account-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.account-brand span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}
.account-nav {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}
.account-nav button {
  width: 100%;
  justify-content: start;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.account-nav-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--line);
}
.account-nav button.active {
  background: var(--surface-2);
  color: var(--text);
}
.account-sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
}
.account-main {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 58px);
}
.account-mobile-sidebar-btn {
  display: none;
}
.account-page {
  display: grid;
  gap: 20px;
}
.account-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.account-page-head h1 {
  font-size: 30px;
}
.account-page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.button-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 8px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}
.balance-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--surface-2);
}
#page-recharge .account-page-head h1 {
  font-size: 24px;
}
#page-recharge .account-page-head p {
  font-size: 13px;
}
#page-recharge .balance-badge {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 14px;
}
#page-recharge input {
  min-height: 36px;
  padding: 7px 10px;
}
.recharge-panel {
  display: grid;
  gap: 14px;
  width: min(760px, 100%);
  font-size: 14px;
}
.recharge-segment {
  width: 320px;
  margin: 0;
  background: var(--surface-2);
}
.recharge-segment button.active {
  background: var(--surface);
  color: var(--text);
}
.amount-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.amount-grid button {
  min-width: 72px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
}
.amount-grid button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.payment-list {
  display: grid;
  gap: 10px;
}
.payment-option {
  min-height: 48px;
  justify-content: start;
  border-radius: 8px;
  border-color: var(--line);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  text-align: left;
}
.payment-option.active {
  border: 2px solid var(--primary);
}
.recharge-submit {
  min-height: 44px;
  font-size: 15px;
  border-radius: 8px;
}
.qr-box {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.qr-box img {
  width: 168px;
  height: 168px;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
}
.qr-box div {
  display: grid;
  gap: 8px;
}
.qr-box span {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.pay-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  text-decoration: none;
}
.recharge-tips {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.recharge-tips p {
  color: var(--text);
  line-height: 1.55;
  font-size: 13px;
}
.recharge-panel h2 {
  margin-bottom: 4px;
  font-size: 14px;
}
.account-settings-panel {
  display: grid;
  gap: 14px;
  width: min(520px, 100%);
}
.account-settings-panel input {
  min-height: 40px;
}
.account-settings-panel input:disabled {
  color: var(--muted);
  background: var(--surface-2);
  cursor: not-allowed;
}
.account-settings-submit {
  min-height: 44px;
  border-radius: 8px;
}
.user-model-list {
  display: grid;
  gap: 12px;
}
.user-model-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.user-model-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.user-model-card h2 {
  margin: 0 0 6px;
  font-size: 18px;
}
.user-model-card p {
  color: var(--muted);
  line-height: 1.55;
}
.model-price-line {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.model-price-line span {
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, background-color .18s ease, backdrop-filter .18s ease;
}
.modal-overlay.is-open {
  background: rgba(0, 0, 0, .46);
  backdrop-filter: blur(10px);
  opacity: 1;
  pointer-events: auto;
}
.modal-panel {
  position: relative;
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px) scale(.985);
  transition: opacity .18s ease, transform .18s ease;
}
.settings-panel {
  padding-top: 26px;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}
.modal-close:hover {
  background: var(--surface-2);
  color: var(--text);
}
.modal-overlay.is-open .modal-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.process-log-panel {
  width: min(920px, 100%);
}
.process-log-textarea {
  width: 100%;
  min-height: min(58vh, 560px);
  margin-top: 14px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
}
.process-log-subtitle {
  color: var(--thinking-text);
}
.process-log-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}
.modal-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.modal-title-row h2 {
  margin-bottom: 6px;
}
.user-audit-modal {
  width: min(820px, 100%);
}
.audit-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.audit-select-all,
.audit-user-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--text);
}
.audit-select-all input,
.audit-user-check input {
  width: auto;
}
.audit-user-list {
  display: grid;
  gap: 0;
  max-height: min(460px, calc(100vh - 320px));
  overflow: auto;
  border-top: 1px solid var(--line);
}
.audit-user-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.audit-user-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.audit-user-main strong {
  overflow-wrap: anywhere;
}
.audit-user-main span,
.audit-user-main p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.audit-user-main p {
  margin: 0;
  overflow-wrap: anywhere;
}
.audit-row-actions {
  justify-content: flex-end;
}
.user-detail-modal {
  width: min(760px, 100%);
}
.user-detail-head {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.user-detail-head > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.admin-chat-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  width: min(1180px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  overflow: hidden;
}
.admin-chat-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}
.admin-chat-sidebar,
.admin-chat-thread {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.admin-chat-sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.admin-chat-sidebar-head,
.admin-chat-thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.admin-chat-sidebar-head span,
.admin-chat-thread-head span {
  color: var(--muted);
  font-size: 12px;
}
.admin-chat-thread-head > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.admin-chat-thread-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-chat-conversation-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  padding: 10px 14px 10px 10px;
  overflow: auto;
  scrollbar-gutter: stable;
}
.admin-chat-conversation-row {
  display: grid;
  align-content: start;
  gap: 5px;
  width: 100%;
  min-height: 72px;
  min-width: 0;
  padding: 12px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  line-height: normal;
  text-align: left;
}
.admin-chat-conversation-row:hover {
  background: var(--surface-2);
}
.admin-chat-conversation-row.is-active {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.admin-chat-conversation-row strong,
.admin-chat-conversation-row span,
.admin-chat-conversation-row small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-chat-conversation-row strong {
  min-height: 22px;
  font-size: 14px;
  font-weight: 650;
  line-height: 22px;
}
.admin-chat-conversation-row span,
.admin-chat-conversation-row small {
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}
.admin-chat-thread {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.admin-chat-messages {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  padding: 16px;
  overflow: auto;
  background: color-mix(in srgb, var(--surface-2) 45%, transparent);
}
.admin-chat-turn {
  display: grid;
  gap: 10px;
}
.admin-chat-turn-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.admin-chat-turn-title strong {
  color: var(--text);
}
.admin-chat-bubble-row {
  display: flex;
}
.admin-chat-bubble-row.user {
  justify-content: flex-end;
}
.admin-chat-bubble-row.assistant {
  justify-content: flex-start;
}
.admin-chat-bubble {
  display: grid;
  gap: 7px;
  max-width: min(760px, 82%);
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.admin-chat-bubble-row.user .admin-chat-bubble {
  border-radius: 18px 18px 4px 18px;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}
.admin-chat-bubble-row.assistant .admin-chat-bubble {
  border-radius: 18px 18px 18px 4px;
}
.admin-chat-bubble-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}
.admin-chat-bubble-head strong {
  color: var(--text);
}
.admin-chat-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.admin-chat-tags span {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}
.admin-chat-bubble-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
}
.admin-chat-empty {
  padding: 12px;
}
.model-management-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  width: min(1120px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  padding: 18px;
}
.model-management-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.balance-modal {
  width: min(420px, 100%);
}
.modal-panel.qr-modal-panel {
  width: min(460px, 100%);
}
.balance-user-hint {
  margin: 4px 0 16px;
}
.balance-field {
  display: grid;
  gap: 8px;
}
.balance-modal-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

@media (max-width: 1080px) {
  .app-layout { grid-template-columns: 1fr; height: 100vh; height: 100dvh; overflow: hidden; }
  .sidebar, .inspector {
    border: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(292px, 84vw);
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform .24s ease;
  }
  body.mobile-sidebar-open .sidebar {
    transform: translateX(0);
  }
  .chat-main {
    --chat-column-gutter: 16px;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  .messages {
    min-height: 0;
    overflow: auto;
    padding: 18px 16px 14px;
  }
  .composer {
    margin: 0 16px 8px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .composer textarea {
    height: 52px;
    min-height: 52px;
  }
  .composer-tools {
    flex-wrap: wrap;
  }
  .round-token-usage {
    flex-basis: 100%;
  }
  .composer-message {
    min-height: 0;
    margin: 0 16px 8px;
  }
  .admin-grid, .settings-grid { grid-template-columns: 1fr; }
  .settings-nav-grid { grid-template-columns: 1fr; }
  .model-card { grid-template-columns: 1fr; }
  .model-list-row { grid-template-columns: 1fr; }
  .user-list-row {
    grid-template-columns: 1fr;
  }
  .user-title-line,
  .user-row-meta {
    flex-wrap: wrap;
    white-space: normal;
  }
  .account-page-actions,
  .audit-toolbar {
    justify-content: flex-start;
  }
  .audit-user-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }
  .audit-row-actions {
    justify-content: flex-start;
  }
  .user-detail-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .admin-chat-modal {
    width: min(100%, calc(100vw - 20px));
    height: min(860px, calc(100vh - 20px));
  }
  .admin-chat-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(170px, 32vh) minmax(0, 1fr);
  }
  .admin-chat-bubble {
    max-width: 94%;
  }
  .model-main-fields, .model-price-fields { grid-template-columns: 1fr; }
  .modal-form-grid { grid-template-columns: 1fr; }
  .channel-card { grid-template-columns: 1fr; }
  .topbar {
    min-height: 54px;
    align-items: center;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 9px 14px;
  }
  .topbar h1 {
    font-size: 18px;
    line-height: 1.2;
  }
  .topbar p {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.3;
  }
  .mobile-sidebar-btn { display: grid; }
  .model-picker { width: min(100%, 360px); }
  .usage-stat-grid, .usage-chart-grid, .usage-two-col { grid-template-columns: 1fr; }
  .account-layout { grid-template-columns: 1fr; }
  .account-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(260px, 84vw);
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform .24s ease;
  }
  body.mobile-sidebar-open .account-sidebar {
    transform: translateX(0);
  }
  .account-main { padding: 20px 16px; }
  .account-page-head h1,
  #page-recharge .account-page-head h1 {
    font-size: 22px;
    line-height: 1.2;
  }
  .account-page-head p,
  #page-recharge .account-page-head p {
    font-size: 12px;
    line-height: 1.4;
  }
  .account-mobile-sidebar-btn {
    position: sticky;
    top: 10px;
    z-index: 30;
    margin: 0 0 12px;
    border: 0;
    background: transparent;
    color: var(--text);
  }
  .date-filter { width: 100%; }
  .date-filter label { min-width: min(100%, 180px); }
  .recharge-segment { width: 100%; }
  .qr-box { align-items: flex-start; flex-direction: column; }

/* PR6: admin 用户偏好列表 */
.preference-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding-left: 12px;
}
.preference-row-admin {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 6px 10px;
  background: rgba(124, 77, 255, 0.05);
  border: 1px solid rgba(124, 77, 255, 0.18);
  border-radius: 8px;
}
.preference-key-admin {
  font-weight: 600;
  color: #4a3f6b;
  font-size: 13px;
}
.preference-value-admin {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}
.preference-row-admin button.danger-btn {
  padding: 4px 12px;
  font-size: 12px;
}
}

/** 提示词管理：左侧选项列 + 右侧编辑面板。颜色全部走项目变量，自动适配深色。 */
.prompt-manager {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
  margin-top: 18px;
  align-items: flex-start;
}
.prompt-nav {
  list-style: none;
  margin: 0;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.prompt-nav li { margin: 0; }
.prompt-nav-btn {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font: inherit;
  border-left: 3px solid transparent;
  border-radius: 8px;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.prompt-nav-btn:hover { background: var(--surface-2); }
.prompt-nav-btn.is-active {
  background: var(--surface-2);
  border-left-color: var(--primary);
  color: var(--primary);
}
.prompt-nav-label { font-size: 14px; font-weight: 600; }
.prompt-nav-meta { font-size: 11px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.prompt-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: var(--surface);
}
.prompt-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.prompt-editor-head h2 { margin: 0; font-size: 20px; color: var(--text); }
.prompt-editor-head p { margin: 4px 0 0; }
.prompt-editor-textarea {
  width: 100%;
  min-height: 480px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.55;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  caret-color: var(--primary);
  resize: vertical;
}
.prompt-editor-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}
.prompt-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.prompt-status-badge {
  display: inline-block;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.prompt-status-badge.is-custom {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}
.prompt-status-badge.muted { /* keep parity with .muted utility */ }

@media (max-width: 720px) {
  .prompt-manager { grid-template-columns: 1fr; }
}

.template-admin-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.26fr) minmax(280px, 0.34fr) minmax(440px, 1fr);
  gap: 14px;
  align-items: stretch;
  height: calc(100vh - 180px);
  min-height: 0;
  overflow: hidden;
}
.template-admin-column {
  display: grid;
  gap: 12px;
  align-content: stretch;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.template-type-column {
  grid-template-rows: auto auto minmax(0, 1fr);
}
.template-article-column {
  grid-template-rows: auto minmax(0, 1fr);
}
.template-editor-column {
  grid-template-rows: minmax(0, 1fr) auto;
}
.template-column-head,
.template-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.template-column-head h2,
.template-editor-head h2 {
  margin: 0;
}
.template-column-head p,
.template-editor-head p {
  margin: 4px 0 0;
}
.template-add-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}
.template-add-form input,
.template-add-form button,
.template-column-actions button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
}
.template-admin-form {
  display: grid;
  gap: 10px;
}
.template-admin-form input,
.template-admin-form textarea {
  width: 100%;
}
.template-nav-list {
  display: grid;
  gap: 6px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.template-nav-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 8px;
}
.template-nav-row.is-active {
  background: var(--surface-2);
}
.template-nav-main {
  justify-content: start;
  text-align: left;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.template-nav-row.is-active .template-nav-main {
  color: var(--text);
}
.template-nav-main strong,
.template-nav-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.template-nav-main strong {
  font-size: 14px;
  font-weight: 700;
}
.template-nav-main small {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}
.template-nav-actions {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
}
.template-nav-actions button {
  min-height: 30px;
  padding: 4px 7px;
  font-size: 12px;
}
.template-item-row small {
  white-space: normal;
}
.template-readonly-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}
.template-editor-form {
  align-content: start;
  height: 100%;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
}
.template-editor-actions {
  justify-content: flex-end;
}
.template-editor-textarea {
  height: 100%;
  min-height: 0;
  resize: none;
  overflow: auto;
  line-height: 1.75;
}
.template-editor-empty,
.template-empty-state {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
}
@media (max-width: 900px) {
  .template-admin-layout {
    height: auto;
    overflow: visible;
    grid-template-columns: 1fr;
  }
  .template-nav-list {
    max-height: 360px;
  }
  .template-editor-textarea {
    min-height: 420px;
  }
}
