:root {
  --paper: #f6f4ee;
  --panel: #fffefb;
  --panel-soft: #fbf9f3;
  --ink: #20241f;
  --ink-soft: #333831;
  --muted: #6d726a;
  --faint: #969a90;
  --line: #e5e1d6;
  --line-strong: #d2cdbf;
  --accent: #a4512f;
  --accent-dark: #873f22;
  --accent-soft: #f8ece4;
  --green: #4f6b52;
  --amber: #946a24;
  --danger: #9c3b32;
  --shadow: 0 18px 44px rgba(38, 34, 25, 0.09);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 266px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid rgba(164, 81, 47, 0.4); outline-offset: 2px; }
::selection { background: rgba(164, 81, 47, 0.18); }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; grid-template-columns: 1.08fr 1fr; background: var(--panel); }
.login-brand {
  display: flex; flex-direction: column; justify-content: space-between;
  background: #1f241f; color: #f3efe5; padding: 46px 8%; min-height: 100dvh;
}
.wordmark { font-size: 14px; letter-spacing: 1.4px; font-weight: 600; }
.wordmark b { color: #8f9a8d; margin: 0 10px; font-weight: 400; }
.login-copy { max-width: 520px; }
.eyebrow, .mini-label { font-size: 10.5px; letter-spacing: 2.2px; color: var(--faint); font-weight: 600; }
.login-brand .eyebrow { color: #c9b39f; }
.login-brand h1 {
  font-family: "Songti SC", "SimSun", Georgia, serif; font-weight: 500;
  font-size: clamp(38px, 4.2vw, 62px); line-height: 1.42; margin: 18px 0 24px; letter-spacing: 0.6px;
}
.login-brand p:not(.eyebrow) { color: #c4ccc2; line-height: 2.05; font-size: 14px; max-width: 460px; }
.login-brand small { color: #93a092; font-size: 10.5px; letter-spacing: 1.8px; }
.login-form { width: min(380px, 84%); margin: auto; padding: 40px 0; }
.login-form h2 { font-size: 27px; margin: 14px 0 10px; letter-spacing: 0.4px; }
.login-form > p { color: var(--muted); line-height: 1.85; margin: 0 0 26px; font-size: 13px; }
.login-form label { display: block; font-weight: 600; margin: 18px 0 8px; font-size: 12.5px; }
.login-form input {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; padding: 12px 13px; min-height: 44px;
}
.login-form input:focus { border-color: var(--accent); }
.login-form small { display: block; margin-top: 18px; color: var(--faint); font-size: 11px; line-height: 1.8; }
.error { color: var(--danger); font-size: 12.5px; min-height: 18px; margin: 12px 0 0; }
.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 14px;
  border-radius: 9px; padding: 10px 17px; font-size: 13px; font-weight: 600; min-height: 40px;
  transition: background 0.15s, border-color 0.15s;
}
.primary { background: var(--ink); color: #f6f1e5; }
.primary:hover { background: #343a32; }
.secondary { background: var(--panel); border: 1px solid var(--line-strong); color: var(--ink-soft); }
.secondary:hover { background: var(--panel-soft); }
.wide { width: 100%; margin-top: 24px; padding: 12px 18px; font-size: 13.5px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); height: 100dvh; }
.app.has-pane { grid-template-columns: var(--sidebar) minmax(0, 1fr) minmax(370px, 42%); }

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: #f1eee5; border-right: 1px solid var(--line); padding: 20px 14px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; flex: 0 0 34px; display: block;
}
.brand div { display: flex; flex-direction: column; line-height: 1.35; }
.brand strong { font-size: 14.5px; letter-spacing: 0.4px; }
.brand small { font-size: 10px; color: var(--muted); letter-spacing: 0; margin-top: 3px; }
.new-chat {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-strong); background: var(--panel); border-radius: 11px;
  padding: 11px 12px; font-weight: 600; font-size: 13px; transition: background 0.15s, border-color 0.15s;
}
.new-chat:hover { background: #fff; border-color: var(--accent); color: var(--accent); }
.nav-label { font-size: 10.5px; letter-spacing: 1.6px; color: var(--faint); padding: 20px 9px 8px; font-weight: 600; }
.features { display: flex; flex-direction: column; gap: 2px; }
.feature {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 9px; text-align: left; color: var(--ink-soft);
  transition: background 0.14s;
}
.feature:hover { background: rgba(255, 255, 255, 0.7); }
.feature.active { background: var(--panel); box-shadow: 0 1px 0 rgba(35, 32, 25, 0.05); font-weight: 600; }
.feature .glyph { font-family: "Songti SC", "SimSun", serif; color: var(--faint); font-size: 13px; }
.feature.active .glyph { color: var(--accent); }
.feature .label { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.feature .label strong { font-weight: inherit; font-size: 13px; }
.feature .label small { color: var(--faint); font-size: 10.5px; letter-spacing: 0.2px; }
.feature .badge {
  font-size: 9.5px; padding: 2px 6px; border-radius: 999px; border: 1px solid var(--line-strong);
  color: var(--muted); background: var(--panel-soft);
}
.feature:disabled { opacity: 0.62; }
.feature.coming { opacity: 0.62; cursor: help; }
.feature.coming:hover { background: rgba(255, 255, 255, 0.45); }
.history-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 9px 7px; color: var(--faint); font-size: 10.5px; letter-spacing: 1.6px; font-weight: 600;
}
.history { flex: 1; overflow-y: auto; min-height: 60px; display: flex; flex-direction: column; gap: 1px; padding-bottom: 8px; }
.history-empty { color: var(--faint); font-size: 11.5px; padding: 8px 10px; line-height: 1.7; }
.history-item {
  display: flex; align-items: center; gap: 2px; border-radius: 8px; min-width: 0; padding: 0;
}
.history-item:hover { background: rgba(255, 255, 255, 0.7); }
.history-item.active { background: var(--panel); }
.history-item-button {
  display: flex; flex-direction: column; gap: 2px; text-align: left; min-width: 0; flex: 1;
  padding: 8px 4px 8px 10px; color: var(--ink-soft); border-radius: 8px;
}
.history-del {
  width: 24px; height: 24px; border-radius: 6px; color: var(--faint); font-size: 14px;
  opacity: 0; flex: 0 0 auto; margin-right: 4px;
}
.history-item:hover .history-del, .history-del:focus-visible { opacity: 1; }
.history-del:hover { color: var(--danger); background: rgba(156, 59, 50, 0.08); }
.history-title { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { font-size: 10px; color: var(--faint); }
.sidebar-foot { border-top: 1px solid var(--line); padding: 10px 4px 0; display: flex; flex-direction: column; gap: 6px; }
.who { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--muted); padding: 0 6px; }
.text-btn { font-size: 11.5px; color: var(--muted); padding: 5px 6px; border-radius: 6px; text-align: left; }
.text-btn:hover { color: var(--accent); background: rgba(255, 255, 255, 0.7); }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-height: 0; height: 100dvh; background: var(--paper); }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 22px; height: 60px; flex: 0 0 auto;
  border-bottom: 1px solid var(--line); background: rgba(246, 244, 238, 0.94); backdrop-filter: blur(6px);
}
.crumbs { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
#feature-label { font-weight: 600; font-size: 14px; letter-spacing: 0.3px; white-space: nowrap; }
.provider-label { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; flex: 0 0 auto; }
.run-status { font-size: 11px; color: var(--accent); white-space: nowrap; }
.controls { display: flex; align-items: center; gap: 8px; }
.select {
  display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 4px 8px; font-size: 11.5px; color: var(--muted);
}
.select span { white-space: nowrap; }
.select select { border: 0; background: transparent; font-size: 12px; color: var(--ink); max-width: 190px; padding: 4px 2px; outline: none; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  color: var(--muted); font-size: 15px;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.8); color: var(--ink); }
.mobile-only { display: none; }

.chat { flex: 1; overflow-y: auto; padding: 26px 7% 12px; scroll-behavior: smooth; }
.welcome { max-width: 800px; margin: 0 auto; padding: 5vh 0 20px; }
.welcome .eyebrow { color: var(--accent); }
.welcome h1 {
  font-family: "Songti SC", "SimSun", Georgia, serif; font-weight: 500;
  font-size: clamp(30px, 3.1vw, 42px); line-height: 1.38; margin: 14px 0 14px; letter-spacing: 0.4px;
}
.welcome .lede { color: var(--muted); line-height: 1.95; font-size: 13.5px; max-width: 620px; margin: 0 0 26px; }
.example-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 30px; }
.example {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 8px 13px;
  font-size: 12px; color: var(--ink-soft); text-align: left; transition: border-color 0.14s, color 0.14s;
}
.example:hover { border-color: var(--accent); color: var(--accent); }
.flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.flow-card { border: 1px solid var(--line); background: var(--panel-soft); border-radius: 11px; padding: 15px 15px 13px; }
.flow-card b { display: block; font-size: 12.5px; margin-bottom: 6px; }
.flow-card p { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.75; }
.flow-card .step { font-size: 10px; letter-spacing: 1.4px; color: var(--accent); font-weight: 600; display: block; margin-bottom: 7px; }

.messages { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 26px; padding-bottom: 20px; }
.message { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.message.user { align-self: flex-end; max-width: min(84%, 640px); background: var(--accent-soft); border: 1px solid #eedbce; border-radius: 16px 16px 5px 16px; padding: 12px 16px; }
.message.user .body { white-space: pre-wrap; line-height: 1.85; font-size: 14px; overflow-wrap: anywhere; }
.msg-head { display: flex; align-items: center; gap: 9px; font-size: 10.5px; color: var(--faint); letter-spacing: 0.4px; }
.msg-head .who { font-weight: 600; color: var(--muted); letter-spacing: 0.8px; }
.message.assistant .body { font-size: 15px; line-height: 1.95; overflow-wrap: anywhere; }
.message.assistant .body p:first-child { margin-top: 0; }
.cursor { display: inline-block; width: 7px; height: 16px; background: var(--accent); vertical-align: -2px; margin-left: 2px; animation: blink 1.05s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.msg-meta { font-size: 10.5px; color: var(--faint); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.msg-meta button { font-size: 10.5px; color: var(--accent); }
.msg-error { border-left: 3px solid var(--danger); background: #fbeeec; padding: 11px 13px; border-radius: 0 8px 8px 0; color: #7f2f27; font-size: 12.5px; line-height: 1.8; }
.msg-note { font-size: 12px; color: var(--muted); }
.attach-row { display: flex; flex-wrap: wrap; gap: 6px; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 4px 8px; color: var(--muted); text-decoration: none; max-width: 100%; }
.attach-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip em { font-style: normal; color: var(--faint); }
.attach-chip button { color: var(--faint); font-size: 13px; line-height: 1; }
.attach-chip button:hover { color: var(--danger); }

.tool-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-chip {
  font-size: 10.5px; color: var(--muted); background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 9px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tool-chip b { color: var(--ink-soft); font-weight: 600; margin-right: 4px; }
.thinking { border: 1px dashed var(--line-strong); border-radius: 9px; padding: 9px 12px; background: var(--panel-soft); }
.thinking summary { cursor: pointer; font-size: 11px; color: var(--muted); letter-spacing: 0.4px; }
.thinking pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.85 -apple-system, "Microsoft YaHei", sans-serif; color: var(--muted); margin: 9px 0 0; max-height: 260px; overflow: auto; }
.optimized-card { border: 1px solid #eadbcf; background: #fdf7f1; border-radius: 10px; padding: 11px 13px; }
.optimized-card summary { cursor: pointer; font-size: 11px; color: var(--accent); letter-spacing: 0.5px; font-weight: 600; }
.optimized-card .brief { font-size: 12.5px; line-height: 1.85; color: var(--ink-soft); margin: 9px 0 0; }
.optimized-card ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 11.5px; line-height: 1.8; }
.optimized-card h4 { margin: 12px 0 4px; font-size: 10.5px; letter-spacing: 1px; color: var(--faint); font-weight: 600; }
.optimized-running { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--accent); }
.spinner { width: 12px; height: 12px; border: 2px solid rgba(164, 81, 47, 0.25); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- composer ---------- */
.composer-wrap { flex: 0 0 auto; padding: 6px 7% 14px; background: linear-gradient(180deg, rgba(246, 244, 238, 0), var(--paper) 26%); }
.quick-actions { max-width: 860px; margin: 0 auto 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.quick {
  font-size: 11.5px; border: 1px solid var(--line-strong); background: var(--panel); border-radius: 999px;
  padding: 6px 12px; color: var(--accent);
}
.quick:hover { border-color: var(--accent); }
.attachments { max-width: 860px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 7px; }
.composer {
  max-width: 860px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 17px; padding: 11px 13px 9px; box-shadow: 0 4px 16px rgba(35, 32, 25, 0.05);
  transition: border-color 0.15s, box-shadow 0.15s; position: relative; container-type: inline-size;
}
.composer:focus-within { border-color: #b98b76; box-shadow: 0 6px 22px rgba(35, 32, 25, 0.08); }
.composer textarea {
  width: 100%; border: 0; resize: none; background: transparent; outline: none;
  font-size: 14.5px; line-height: 1.8; min-height: 28px; max-height: 190px; padding: 2px 2px 8px;
}
.composer textarea::placeholder { color: var(--faint); }
.composer-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.composer-options { display: flex; align-items: center; gap: 12px; }
.composer-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; max-width: 100%; }
.composer-actions .select { min-width: 0; }
.composer-actions .select:first-child { flex: 1 1 auto; }
.composer-actions .select select { min-width: 0; width: 100%; max-width: 160px; }
.composer-actions .select:last-of-type select { max-width: 110px; }
.composer-actions .send { flex: 0 0 auto; white-space: nowrap; }
@container (max-width: 600px) {
  .composer-actions { width: 100%; }
}
@container (max-width: 380px) {
  .composer-actions .select { padding: 3px 6px; }
  .composer-actions .select span { display: none; }
  .composer-actions .select select { font-size: 11px; }
  .composer-actions .select:last-of-type { flex: 0 1 110px; }
}
.tool-btn {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line); background: var(--panel-soft); border-radius: 7px; padding: 5px 9px; cursor: pointer;
}
.tool-btn:hover { color: var(--accent); border-color: #dcc3b6; }
.tool-btn:disabled { opacity: 0.45; cursor: default; }
.mention-menu {
  position: absolute; left: 12px; right: 12px; bottom: 49px; z-index: 15; max-height: 230px; overflow-y: auto;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 5px; background: var(--panel); box-shadow: var(--shadow);
}
.mention-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 8px 9px; border-radius: 7px; }
.mention-option:hover, .mention-option.active { background: var(--accent-soft); }
.mention-option strong { display: block; max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--ink); }
.mention-option span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; color: var(--faint); }
.opt-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.opt-toggle input { accent-color: var(--accent); width: 14px; height: 14px; }
.opt-toggle.disabled { opacity: 0.45; cursor: default; }
.composer-hint { flex: 1 0 100%; min-width: 0; font-size: 10.5px; color: var(--faint); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-hint:empty { display: none; }
.send {
  background: var(--ink); color: #f6f1e5; border-radius: 9px; padding: 8px 18px; font-size: 12.5px;
  font-weight: 600; letter-spacing: 0.4px; transition: background 0.15s;
}
.send:hover:not(:disabled) { background: #343a32; }
.send.stop { background: var(--accent); color: #fff; }
.send.stop:hover { background: var(--accent-dark); }
.fineprint { max-width: 860px; margin: 8px auto 0; font-size: 10px; color: var(--faint); text-align: center; letter-spacing: 0.2px; }

/* ---------- right pane ---------- */
.pane { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
.pane-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 3px; background: var(--paper); border-radius: 9px; padding: 3px; }
.tab { font-size: 11.5px; color: var(--muted); border-radius: 7px; padding: 6px 11px; }
.tab.active { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(35, 32, 25, 0.06); }
.tab .count { font-size: 9.5px; color: var(--accent); margin-left: 3px; }
.pane-actions { display: flex; align-items: center; gap: 4px; }
.ghost { font-size: 11px; color: var(--accent); border: 1px solid #e3cbbc; border-radius: 7px; padding: 5px 9px; background: #fdf7f2; }
.ghost:hover:not(:disabled) { background: var(--accent-soft); }
.pane-body { flex: 1; overflow-y: auto; padding: 18px 22px 30px; }
.doc-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 10.5px; color: var(--faint); margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.doc-meta b { color: var(--muted); font-weight: 500; max-width: 100%; overflow-wrap: anywhere; }
.doc-file { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-file.active { color: var(--accent); border-color: #e3cbbc; background: #fdf7f2; }
.pane-empty { border: 1px dashed var(--line-strong); border-radius: 11px; padding: 22px 18px; color: var(--muted); background: var(--panel-soft); }
.pane-empty strong { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 7px; }
.pane-empty p { margin: 0; font-size: 11.5px; line-height: 1.85; }

/* ---------- markdown ---------- */
.markdown { font-size: 14.5px; line-height: 1.95; color: var(--ink-soft); overflow-wrap: anywhere; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  font-family: "Songti SC", "SimSun", Georgia, serif; font-weight: 600; color: var(--ink);
  line-height: 1.5; margin: 1.6em 0 0.6em;
}
.markdown h1 { font-size: 24px; letter-spacing: 0.3px; margin-top: 0.2em; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.markdown h2 { font-size: 19px; }
.markdown h3 { font-size: 16px; }
.markdown h4 { font-size: 14px; }
.markdown p { margin: 0.75em 0; }
.markdown ul, .markdown ol { margin: 0.7em 0; padding-left: 1.4em; }
.markdown li { margin: 0.28em 0; }
.markdown blockquote { margin: 1em 0; padding: 4px 0 4px 14px; border-left: 3px solid #ddc3b4; color: var(--muted); background: linear-gradient(90deg, #fdf8f3, transparent); }
.markdown blockquote p { margin: 0.3em 0; }
.markdown code { background: #f1eee5; border-radius: 4px; padding: 1px 5px; font-size: 0.88em; font-family: Consolas, "SFMono-Regular", "Microsoft YaHei", monospace; }
.markdown pre.code { background: #232821; color: #e8e4d8; border-radius: 9px; padding: 13px 15px; overflow-x: auto; margin: 1em 0; }
.markdown pre.code code { background: none; color: inherit; padding: 0; font-size: 12px; line-height: 1.7; }
.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 1.8em 0; }
.markdown a { text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.markdown table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.table-wrap { overflow-x: auto; margin: 1em 0; border: 1px solid var(--line); border-radius: 8px; }
.markdown th, .markdown td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.markdown th { background: var(--panel-soft); font-weight: 600; color: var(--ink); white-space: nowrap; }
.markdown tr:last-child td { border-bottom: 0; }
.markdown del { color: var(--faint); }

/* ---------- sources ---------- */
.source-list { display: flex; flex-direction: column; gap: 9px; }
.source-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px; background: var(--panel); }
.source-card .title { font-size: 13px; font-weight: 600; line-height: 1.6; margin: 0 0 5px; }
.source-card .title a { color: var(--ink); text-decoration: none; }
.source-card .title a:hover { color: var(--accent); text-decoration: underline; }
.source-card .meta { font-size: 10.5px; color: var(--faint); display: flex; flex-wrap: wrap; gap: 3px 10px; margin-bottom: 6px; }
.source-card .summary { font-size: 11.5px; color: var(--muted); line-height: 1.8; margin: 0; }
.source-card .used { font-size: 10px; color: var(--accent); margin-top: 6px; }

/* ---------- dialogs & toast ---------- */
.dialog { width: min(620px, 92vw); border: 1px solid var(--line-strong); border-radius: 15px; padding: 22px 24px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(28, 31, 27, 0.45); backdrop-filter: blur(2px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 8px 0 0; font-size: 20px; }
.dialog .hint { color: var(--muted); font-size: 11.5px; line-height: 1.8; margin: 12px 0 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.material-dialog { width: min(700px, 94vw); max-height: 88vh; overflow: auto; }
.material-upload { display: flex; flex-direction: column; gap: 4px; border: 1px dashed #d4b7a6; border-radius: 10px; padding: 13px 14px; background: #fdf8f3; cursor: pointer; }
.material-upload:hover { border-color: var(--accent); background: var(--accent-soft); }
.material-upload strong { color: var(--accent); font-size: 12.5px; }
.material-upload span { color: var(--muted); font-size: 11px; }
.material-existing-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 19px 0 8px; }
.material-existing-head > div { display: flex; align-items: baseline; gap: 8px; }
.material-existing-head strong { font-size: 12.5px; }
.material-existing-head span { color: var(--accent); font-size: 10.5px; }
.material-existing-head input { width: min(260px, 48%); border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 9px; font-size: 11.5px; background: #fff; }
.material-list { min-height: 110px; max-height: 36vh; overflow-y: auto; border-top: 1px solid var(--line); }
.material-empty { padding: 26px 10px; text-align: center; color: var(--faint); font-size: 11.5px; }
.material-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 5px; border-bottom: 1px solid var(--line); cursor: pointer; }
.material-row:hover { background: var(--panel-soft); }
.material-row.selected { background: var(--accent-soft); }
.material-row input { accent-color: var(--accent); }
.material-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--ink); }
.material-row small { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; color: var(--faint); }
.material-row em { font-style: normal; color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.member-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member-row .who { padding: 0; gap: 10px; }
.member-row strong { font-size: 12.5px; color: var(--ink); font-weight: 600; }
.member-row small { font-size: 10.5px; color: var(--faint); }
.member-row .actions { display: flex; gap: 4px; }
.member-row button { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.member-row button:hover { color: var(--accent); border-color: #dcc3b6; }
.member-add { margin-top: 20px; }
.member-add h3 { font-size: 13px; margin: 0 0 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.form-row input { border: 1px solid var(--line-strong); border-radius: 7px; padding: 8px 9px; font-size: 12.5px; background: #fff; }
.new-password { margin-top: 12px; border: 1px solid #e3cbbc; background: #fdf7f2; border-radius: 8px; padding: 11px 12px; font-size: 12px; line-height: 1.8; color: var(--ink-soft); }
.new-password code { display: block; font-family: Consolas, monospace; font-size: 13px; color: var(--accent); margin-top: 5px; word-break: break-all; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #262b25; color: #f3efe5; border-radius: 9px; padding: 10px 16px; font-size: 12px; box-shadow: var(--shadow); z-index: 50; max-width: 80vw; }
.toast.bad { background: #7d2f27; }
.scrim { position: fixed; inset: 0; background: rgba(28, 31, 27, 0.36); z-index: 30; }

/* ---------- responsive ---------- */
.space-summary { display: grid; gap: 6px; width: 100%; text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 8px; background: var(--panel); }
.space-summary strong { font-size: 12px; } .space-summary span { font-size: 11px; color: var(--muted); }
.space-summary progress { width: 100%; height: 5px; accent-color: var(--accent); }
.space-summary.full { border-color: #a84030; }
.quota-banner { margin: 0 auto 8px; max-width: 860px; padding: 10px 12px; border-radius: 8px; color: #7d2f27; background: #ffede7; font-size: 12px; }
.quota-banner button { text-decoration: underline; margin-left: 8px; }
.space-dialog { width: min(760px, 94vw); max-height: 90vh; overflow: auto; }
.space-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.space-actions button { font-size: 12px; padding: 6px 10px; }
.danger { color: #9b382c; }
.space-path { display: flex; flex-wrap: wrap; gap: 12px; padding: 15px 0 10px; font-size: 12px; overflow-wrap: anywhere; }
.space-files { max-height: 32vh; overflow-y: auto; border-top: 1px solid var(--line); }
.space-file { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.space-file-name { min-width: 0; overflow-wrap: anywhere; }
.space-file-name strong { display: block; font-size: 12px; } .space-file-name small { color: var(--muted); font-size: 11px; }
.space-file .space-actions { flex-shrink: 0; }
.agent-editor, .account-password { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.agent-editor summary, .account-password summary { font-size: 13px; font-weight: 600; cursor: pointer; }
.agent-editor textarea { display: block; width: 100%; box-sizing: border-box; margin: 8px 0 10px; padding: 10px; border: 1px solid var(--line-strong); border-radius: 8px; font: 13px/1.7 Consolas, "Microsoft YaHei", monospace; resize: vertical; background: var(--paper); }
.account-password form { margin-top: 12px; }
@media (max-width: 540px) { .space-dialog { padding: 18px 14px; } .space-file { align-items: flex-start; flex-direction: column; } }
@media (max-width: 1180px) {
  .app.has-pane { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .pane { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 92vw); z-index: 40; box-shadow: var(--shadow); }
  .app.has-pane .scrim-pane { display: block; }
}
@media (max-width: 860px) {
  .app, .app.has-pane { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 276px; z-index: 35;
    transform: translateX(-102%); transition: transform 0.2s ease; box-shadow: var(--shadow);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .mobile-only { display: grid; }
  .topbar { padding: 0 12px; gap: 8px; height: 56px; }
  .controls { gap: 5px; }
  .provider-label { display: none; }
  .chat { padding: 16px 14px 8px; }
  .composer-wrap { padding: 4px 12px 10px; }
  .welcome { padding-top: 18px; }
  .welcome h1 { font-size: 27px; }
  .flow { grid-template-columns: 1fr; }
  .message.user { max-width: 92%; }
  .composer-tools { gap: 8px; flex-wrap: wrap; }
  .composer-hint { order: 3; flex-basis: 100%; text-align: left; }
  .login { display: block; }
  .login-brand { min-height: 0; padding: 24px 22px; }
  .login-brand .login-copy, .login-brand small { display: none; }
  .login-form { width: auto; margin: 0 auto; padding: 48px 24px; }
  .pane { width: 100vw; }
  .pane-body { padding: 14px 16px 26px; }
  .doc-meta { gap: 5px 8px; }
  .form-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
.comparison-pane { padding: 0; height: 100%; }
#comparison-frame { display: block; width: 100%; height: 100%; min-height: 65vh; border: 0; background: #fff; }
#comparison-frame[hidden] { display: none; }
.pane-head { flex-wrap: wrap; gap: 6px; }
.pane-head .tabs, .pane-actions { flex-wrap: wrap; }
