:root {
  color-scheme: light;
  --canvas: #edf4f8;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --ink: #17202d;
  --muted: #778292;
  --muted-strong: #5e6a79;
  --line: #e0e7ed;
  --line-strong: #ced9e3;
  --blue: #2f6fde;
  --blue-dark: #2058b7;
  --blue-soft: #edf5ff;
  --purple: #7761e8;
  --purple-dark: #5f49c8;
  --purple-soft: #f6f3ff;
  --shadow: 0 14px 36px rgba(31, 70, 103, 0.1);
  --shadow-soft: 0 6px 18px rgba(31, 70, 103, 0.06);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
body.auth-pending { overflow: hidden; }
.login-gate { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, rgba(237,244,248,.97), rgba(247,251,253,.98)); }
.login-gate.hidden { display: none; }
.login-card { width: min(100%, 390px); padding: 34px; border: 1px solid #d5e0e9; border-radius: 16px; background: rgba(255,255,255,.96); box-shadow: 0 20px 50px rgba(36,66,98,.14); }
.login-logo { display: block; width: 188px; max-width: 100%; mix-blend-mode: multiply; }
.login-kicker { margin: 24px 0 7px; color: #6480a0; font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.login-card h1 { margin: 0; color: #1d2b3b; font-size: 23px; }
.login-card > p:not(.login-kicker):not(.login-error) { margin: 11px 0 24px; color: #718094; font-size: 13px; line-height: 1.65; }
.login-label { display: block; margin-bottom: 7px; color: #46566a; font-size: 12px; font-weight: 650; }
.login-input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #cbd8e5; border-radius: 8px; outline: 0; color: #17202d; font-size: 15px; }
.login-input:focus { border-color: #6f9ce3; box-shadow: 0 0 0 3px rgba(47,111,222,.12); }
.login-error { min-height: 18px; margin: 8px 0 0; color: #b42318; font-size: 12px; }
.login-submit { width: 100%; min-height: 42px; margin-top: 12px; border-radius: 8px; background: var(--blue); color: #fff; cursor: pointer; font-size: 14px; font-weight: 650; }
.login-submit:hover { background: var(--blue-dark); }
.login-submit:disabled { cursor: wait; opacity: .7; }
button, textarea { font: inherit; }
button { border: 0; }

.app-shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); width: 100%; height: 100vh; min-height: 0; overflow: hidden; }
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 16px 18px;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
}
.brand-block { padding: 2px 8px 0; }
.brand-logo {
  display: block;
  width: 186px;
  max-width: 100%;
  height: auto;
  background: transparent;
  /* logo.png contains a white matte; multiply lets it blend into the sidebar */
  mix-blend-mode: multiply;
}
.brand-caption { margin-top: 13px; color: var(--muted-strong); font-size: 12px; letter-spacing: 0.06em; }
.new-chat {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 43px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink);
  cursor: pointer; transition: 0.18s ease; box-shadow: 0 2px 8px rgba(29, 49, 78, 0.03);
}
.new-chat:hover { border-color: #b8c6d8; background: #f5f8fc; transform: translateY(-1px); }
.new-chat:active { transform: translateY(0); }
.plus { color: var(--blue); font-size: 21px; line-height: 1; font-weight: 400; }
.sidebar-section { min-height: 0; }
.sidebar-label { padding: 0 10px 10px; color: #929ba7; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.history-list { display: grid; gap: 4px; }
.history-item {
  width: 100%; min-height: 38px; padding: 0 10px; border-radius: 7px; background: transparent; color: #4f5a68;
  text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; transition: 0.16s ease;
}
.history-item:hover, .history-item.active { background: #eef2f6; color: var(--ink); }
.history-item.active { box-shadow: inset 2px 0 0 var(--blue); }
.sidebar-footnote { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 10px 10px 0; border-top: 1px solid var(--line); color: #8a95a2; font-size: 11px; line-height: 1.45; }
.footnote-dot, .status-dot { width: 7px; height: 7px; border-radius: 50%; background: #37b26c; flex: 0 0 auto; }

.workspace { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; }
.workspace-header {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 50px;
  padding: 10px clamp(20px, 3vw, 42px);
  border-bottom: 1px solid #d6e1e8;
  background: rgba(247, 251, 253, 0.9);
  backdrop-filter: blur(16px);
}
.workspace-header h1 { margin: 0; font-size: 18px; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; }
.workspace-status { display: flex; align-items: center; gap: 7px; padding: 7px 11px; border: 1px solid #d5e1ea; border-radius: 999px; color: #657687; background: #fff; font-size: 11px; white-space: nowrap; }

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-height: 0;
  padding: 18px clamp(16px, 3vw, 42px) 14px;
  overflow: hidden;
}
.engine-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.volcano-panel { border-top: 3px solid var(--blue); }
.doubao-panel { border-top: 3px solid var(--purple); }
.panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 62px; padding: 13px 15px 12px; border-bottom: 1px solid var(--line); background: #fff;
}
.engine-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.engine-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff; font-size: 14px; font-weight: 750; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); }
.volcano-icon { background: linear-gradient(145deg, #4387f0, #255ac5); }
.doubao-icon { background: linear-gradient(145deg, #9a86f4, #6651d5); }
.engine-identity h2 { margin: 0; font-size: 14px; font-weight: 680; }
.engine-identity p { margin: 3px 0 0; color: #8b96a3; font-size: 10px; }
.panel-tools { display: flex; align-items: center; gap: 5px; }
.panel-badge { display: flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 999px; font-size: 10px; white-space: nowrap; }
.blue-badge { border: 1px solid #d2e1f8; color: var(--blue); background: var(--blue-soft); }
.purple-badge { border: 1px solid #e0d9fb; color: var(--purple-dark); background: var(--purple-soft); }
.panel-badge .status-dot { width: 5px; height: 5px; background: currentColor; }
.panel-tool { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid transparent; border-radius: 7px; color: #9aa5b0; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; }
.panel-tool:hover { border-color: var(--line); color: var(--muted-strong); background: var(--surface-soft); }

.panel-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scrollbar-color: #aebdca transparent; scrollbar-width: thin; }
.panel-scroll::-webkit-scrollbar { width: 9px; }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }
.panel-scroll::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 999px; background: #c3ced8; background-clip: padding-box; }
.panel-scroll::-webkit-scrollbar-thumb:hover { background: #aab9c6; background-clip: padding-box; }
.panel-intro { display: grid; place-items: center; align-content: center; min-height: 100%; padding: 50px 26px; text-align: center; color: var(--muted); }
.panel-intro.hidden { display: none; }
.panel-intro h3 { margin: 14px 0 6px; color: #536174; font-size: 14px; font-weight: 650; }
.panel-intro p { max-width: 285px; margin: 0; font-size: 11px; line-height: 1.65; }
.intro-orbit { position: relative; width: 50px; height: 50px; border: 1px dashed #b9cdef; border-radius: 50%; }
.intro-orbit::before, .intro-orbit::after { content: ""; position: absolute; inset: 8px; border: 1px solid #dce7fb; border-radius: 50%; }
.intro-orbit::after { inset: 19px; border: 0; background: #e9f1ff; }
.intro-orbit span { position: absolute; top: -3px; left: 21px; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.doubao-orbit { border-color: #cec6f4; }
.doubao-orbit::before { border-color: #e4defa; }
.doubao-orbit::after { background: #f0ecff; }
.doubao-orbit span { background: var(--purple); }

.thread { display: grid; gap: 20px; padding: 19px 18px 26px; }
.thread:empty { display: none; }
.turn { display: grid; gap: 11px; animation: turn-in 0.24s ease; }
.user-row { display: flex; justify-content: flex-end; gap: 8px; align-items: flex-start; }
.user-bubble { max-width: 87%; padding: 9px 12px; border: 1px solid #cfe0fa; border-radius: 10px 3px 10px 10px; background: #edf5ff; color: #2c4f87; font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.user-avatar { display: grid; place-items: center; flex: 0 0 25px; width: 25px; height: 25px; border-radius: 8px; background: var(--blue); color: #fff; font-size: 10px; font-weight: 700; }
.assistant-row { display: flex; align-items: flex-start; gap: 8px; }
.assistant-avatar { display: grid; place-items: center; flex: 0 0 25px; width: 25px; height: 25px; border-radius: 8px; color: #fff; font-size: 10px; font-weight: 700; }
.volcano-panel .assistant-avatar { background: var(--blue); }
.doubao-panel .assistant-avatar { background: var(--purple); }
.assistant-bubble { min-width: 0; flex: 1; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 3px 10px 10px 10px; background: #fcfdff; color: #3d4c5e; font-size: 13px; line-height: 1.7; }
.answer-meta { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; color: #8894a1; font-size: 10px; }
.answer-meta strong { color: #5e6d7e; font-weight: 650; }
.answer-meta .meta-dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.assistant-bubble h4 { margin: 0 0 7px; color: #2b3a4f; font-size: 14px; font-weight: 680; }
.assistant-bubble p { margin: 0 0 8px; }
.assistant-bubble p:last-child { margin-bottom: 0; }
.assistant-bubble ul { margin: 7px 0 8px 18px; padding: 0; }
.assistant-bubble li { margin: 4px 0; }
.answer-content { color: #3d4c5e; min-height: 20px; }
.answer-content-live { white-space: normal; overflow-wrap: anywhere; }
.answer-error { color: #b42318; }
.answer-content p { margin: 0 0 9px; }
.answer-content p:last-child { margin-bottom: 0; }
.answer-content h3, .answer-content h4 { margin: 12px 0 8px; color: #2b3a4f; line-height: 1.4; }
.answer-content h3 { font-size: 14px; }
.answer-content h4 { font-size: 13px; }
.answer-content ul, .answer-content ol { margin: 7px 0 10px 20px; padding: 0; }
.answer-content li { margin: 4px 0; }
.answer-content hr { margin: 12px 0; border: 0; border-top: 1px solid #dfe6ee; }
.answer-content code { padding: 1px 4px; border-radius: 4px; background: #f0f3f7; color: #4a5870; font-size: .92em; }
.answer-content a { color: #3d73c4; text-decoration: underline; overflow-wrap: anywhere; cursor: pointer; }
.answer-table-wrap { max-width: 100%; margin: 10px 0 12px; overflow-x: hidden; border: 1px solid #dce4ee; border-radius: 8px; }
.answer-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; font-size: 12px; line-height: 1.55; background: #fff; }
.answer-table th, .answer-table td { padding: 8px 9px; border-right: 1px solid #dce4ee; border-bottom: 1px solid #dce4ee; text-align: left; vertical-align: top; overflow-wrap: anywhere; word-break: break-word; }
.answer-table th:last-child, .answer-table td:last-child { border-right: 0; }
.answer-table tr:last-child td { border-bottom: 0; }
.answer-table th { background: #f3f7fb; color: #344d69; font-weight: 700; white-space: normal; }
.answer-table tbody tr:nth-child(even) td { background: #fbfdff; }
.stream-notes { display: grid; gap: 7px; margin-top: 9px; }
.thinking-note, .search-note { margin-bottom: 9px; padding: 7px 9px; border-radius: 7px; font-size: 10px; line-height: 1.55; }
.thinking-note { border: 1px solid #e3dcfc; background: #faf8ff; color: #6e5bb0; }
.search-note { border: 1px solid #f2e1b5; background: #fffaf0; color: #9b6a1a; }
.search-note.note-complete { opacity: .72; }
.citation-note { margin-top: 12px; padding-top: 9px; border-top: 1px dashed #d9e0e9; color: #7c8794; font-size: 10px; line-height: 1.55; }
.citation-note strong { display: block; margin-bottom: 5px; color: #4e5b6b; font-size: 10px; }
.citation-note a { display: block; width: fit-content; max-width: 100%; margin: 4px 0; padding: 4px 7px; border: 1px solid #dce4ee; border-radius: 5px; background: #fafcff; color: #55769b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.citation-note a:hover { border-color: #b6cbe1; background: #f3f8fd; }
.citation-note span { display: inline-block; margin: 2px 5px 2px 0; padding: 3px 6px; border: 1px solid #dce4ee; border-radius: 5px; background: #fafcff; }
.loading-state { display: grid; gap: 9px; }
.loading-label { color: #6e7c8c; font-size: 11px; }
.loading-line { height: 8px; border-radius: 5px; background: linear-gradient(90deg, #edf1f6 20%, #f8fafc 50%, #edf1f6 80%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.loading-line:nth-child(2) { width: 88%; }
.loading-line:nth-child(3) { width: 74%; }
.loading-line:nth-child(4) { width: 82%; }

.panel-footer { display: flex; align-items: center; gap: 6px; min-height: 43px; padding: 8px 13px; border-top: 1px solid var(--line); background: #fcfdff; }
.source-chip { padding: 4px 7px; border: 1px solid var(--line); border-radius: 999px; color: #84909e; background: #fff; font-size: 9px; white-space: nowrap; }
.blue-chip { border-color: #cfe0fb; color: var(--blue); background: #f5f9ff; }
.purple-chip { border-color: #ddd6fb; color: var(--purple-dark); background: #faf8ff; }
.panel-count { margin-left: auto; color: #a3acb7; font-size: 9px; }

.composer-area { padding: 8px clamp(16px, 3vw, 42px) 10px; border-top: 1px solid #d5e0e7; background: rgba(249, 252, 254, 0.94); }
.mode-row { display: flex; align-items: center; gap: 20px; width: 100%; margin: 0 auto 8px; }
.toggle-control { display: flex; align-items: center; gap: 7px; color: #4d5b6e; font-size: 12px; cursor: pointer; user-select: none; }
.toggle-control input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { position: relative; width: 30px; height: 17px; border-radius: 10px; background: #d2d9e2; transition: 0.18s ease; }
.toggle-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(35,49,70,.2); transition: 0.18s ease; }
.toggle-control input:checked ~ .toggle-track { background: var(--blue); }
.toggle-control input:checked ~ .toggle-track::after { transform: translateX(13px); }
.toggle-icon { color: #7e8a9a; font-size: 13px; }
.mode-hint { margin-left: auto; color: #a1aab5; font-size: 10px; }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; width: 100%; margin: 0 auto; padding: 9px 10px 9px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); transition: 0.18s ease; }
.composer:focus-within { border-color: #a9c2e8; box-shadow: 0 10px 28px rgba(45,108,223,.10); }
.composer textarea { width: 100%; min-height: 30px; max-height: 100px; resize: none; border: 0; outline: 0; padding: 4px 0; color: var(--ink); background: transparent; font-size: 16px; line-height: 1.5; }
.composer textarea::placeholder { color: #a0aab6; }
.composer-actions { display: flex; align-items: center; gap: 10px; align-self: end; font-size: 16px; }
.send-button { display: flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 12px; border-radius: 7px; background: var(--blue); color: #fff; cursor: pointer; font-size: inherit; transition: 0.18s ease; }
.send-button:hover { background: var(--blue-dark); transform: translateY(-1px); }
.send-button:active { transform: translateY(0); }
.send-button:disabled { cursor: wait; background: #a7bee7; transform: none; }
.send-arrow { font-size: 20px; line-height: 1; }
.stop-mark { display: none; width: 12px; height: 12px; border-radius: 3px; background: currentColor; }
.send-button.stop-mode { width: 36px; min-width: 36px; height: 36px; min-height: 36px; padding: 0; justify-content: center; border: 1px solid #d3dbe5; border-radius: 50%; background: #eef1f5; color: #4d5b6e; }
.send-button.stop-mode:hover { background: #e3e8ee; }
.send-button.stop-mode .send-label,
.send-button.stop-mode .send-arrow { display: none; }
.send-button.stop-mode .stop-mark { display: block; }
.suggestions { display: none; }
.suggestions-label { margin-right: 2px; color: #99a3af; font-size: 10px; }
.suggestion { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: #5d6b7c; font-size: 10px; cursor: pointer; transition: 0.16s ease; }
.suggestion:hover { border-color: #b9cbe5; background: #f8fbff; color: var(--blue); }
.disclaimer { display: none; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 280px; padding: 10px 13px; border: 1px solid #d7e1ee; border-radius: 8px; background: #fff; color: #526176; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: 0.2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@keyframes turn-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-block { padding: 0; }
  .brand-logo { width: 168px; }
  .brand-caption, .sidebar-section, .sidebar-footnote { display: none; }
  .new-chat { min-height: 36px; padding: 0 12px; }
  .workspace { height: 100%; min-height: 0; }
}
@media (max-width: 480px) {
  html, body { overflow: auto; height: auto; }
  .app-shell { height: auto; min-height: 100vh; overflow: visible; }
  .workspace { height: auto; min-height: calc(100vh - 66px); overflow: visible; }
  .workspace-header { align-items: flex-start; padding: 18px 13px 14px; }
  .workspace-header h1 { font-size: 19px; }
  .workspace-status { display: none; }
  .panel-grid { grid-template-columns: 1fr; gap: 12px; padding: 12px; overflow-y: auto; }
  .engine-panel { min-height: 410px; }
  .panel-scroll { min-height: 275px; }
  .composer-area { padding: 9px 12px 13px; }
  .mode-row { flex-wrap: wrap; gap: 9px 14px; }
  .mode-hint { width: 100%; margin-left: 0; }
  .composer { grid-template-columns: 1fr; gap: 7px; padding: 9px 10px 9px 13px; }
  .composer-actions { justify-content: space-between; }
  .suggestions { display: none; }
  .disclaimer { line-height: 1.45; }
}
