:root {
  --bg: #f4f4f5;
  --surface: #fff;
  --border: #e4e4e7;
  --text: #18181b;
  --muted: #71717a;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --ok-bg: #f0fdf4;
  --ok-border: #bbf7d0;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%);
  --radius: 10px;
  --left-w: 300px;
  --right-w: 340px;
  --rail-w: 40px;
  --header-h: 44px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  max-height: 100%;
  margin: 0;
  overflow: hidden !important;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.sw-cascade {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* 对齐全市场扫描左侧 .l3-theme-select（0.78rem）；盖过 .field select 的 0.9rem */
.sw-cascade select,
.field .sw-cascade select {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text);
}

.sw-cascade select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Native <option> color support is browser-dependent; still help where allowed */
#sw-l3-select option.sw-l3-online {
  color: #15803d;
}

#sw-l3-select option.sw-l3-offline {
  color: #64748b;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* 全屏壳：禁止页面级滚动 */
.app {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 顶栏极简：仅品牌 + 健康状态 */
.app-header {
  flex: 0 0 var(--header-h);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.nav-link:hover {
  text-decoration: underline;
}

.btn-text {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
}

.btn-text:hover {
  color: var(--text);
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 10%, #dbeafe 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, #e0e7ff 0%, transparent 45%),
    var(--bg);
}

.login-gate.hidden {
  display: none;
}

.login-card {
  width: min(360px, calc(100vw - 2rem));
  padding: 1.75rem 1.5rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.login-sub {
  margin: 0.35rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.login-card .field {
  margin-bottom: 0.85rem;
}

.login-card label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.login-card input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.login-card button[type="submit"]:hover {
  background: var(--accent-hover);
}

.login-card button[type="submit"]:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.login-error {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: #991b1b;
}

.login-error.hidden {
  display: none;
}

.app-header .brand {
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.layout-tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: #dbeafe;
  color: #1d4ed8;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  background: #eef2ff;
  color: #3730a3;
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

/* 窗口 A：一屏三栏（grid 便于折叠时把宽度让给互动区） */
.workbench {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--left-w) minmax(260px, 1fr) var(--right-w);
  width: 100%;
  overflow: hidden;
  transition: grid-template-columns 0.2s ease;
}

.workbench.left-collapsed:not(.center-collapsed) {
  /* 只收筛选：结果大致保持一列宽度，剩余给互动 */
  grid-template-columns: var(--rail-w) minmax(280px, 38vw) 1fr;
}

.workbench:not(.left-collapsed).center-collapsed {
  grid-template-columns: var(--left-w) var(--rail-w) 1fr;
}

.workbench.left-collapsed.center-collapsed {
  grid-template-columns: var(--rail-w) var(--rail-w) 1fr;
}

.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  position: relative;
}

.col-collapse-btn {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.col-collapse-btn:hover {
  color: var(--text);
  border-color: #cbd5e1;
}

.col-rail {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  height: 100%;
  padding: 0.65rem 0.2rem;
  background: inherit;
}

.col-rail-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em;
  user-select: none;
}

.col.collapsed > .col-head,
.col.collapsed > .col-body,
.col.collapsed > .col-foot {
  display: none !important;
}

.col.collapsed > .col-rail {
  display: flex;
}

.col-left {
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.col-center {
  min-width: 0;
  background: var(--bg);
}

.col-center .col-head {
  background: var(--surface);
}

.col-right {
  min-width: 0;
  background: #f8fafc;
  border-left: 1px solid var(--border);
}

.workbench.left-collapsed.center-collapsed .col-right {
  border-left: none;
}

.col-head {
  flex: 0 0 auto;
  padding: 0.75rem 0.9rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: inherit;
  min-height: 4.1rem;
  box-sizing: border-box;
}

.col-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.col-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 1.6rem;
}

.col-head .col-sub {
  margin: 0.35rem 0 0;
  line-height: 1.35;
  min-height: 1.35em;
}

.col-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.75rem 0.9rem;
  -webkit-overflow-scrolling: touch;
}

.col-foot {
  flex: 0 0 auto;
  padding: 0.65rem 0.9rem 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 -4px 12px rgb(0 0 0 / 4%);
  z-index: 2;
}

.col-right .col-foot {
  background: #f1f5f9;
}

.col-right .col-body {
  padding: 0.65rem 0.75rem;
}

.foot-status {
  margin: 0 0 0.4rem;
  min-height: 1.1em;
}

.hint {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.section-label {
  margin: 0.75rem 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.85rem 0;
}

.field {
  margin-bottom: 0.65rem;
}

.stock-locate-row {
  display: flex;
  gap: 0.35rem;
  align-items: stretch;
}

.stock-locate-row input {
  flex: 1 1 auto;
  width: 0; /* force flex to give leftover space to input */
  min-width: 0;
}

.stock-locate-row button {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  padding: 0.4rem 0.5rem;
  font-size: 0.82rem;
  white-space: nowrap;
}

#stock-locate-hint {
  margin-top: 0.3rem;
  margin-bottom: 0;
  line-height: 1.4;
}

.stock-card-focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
  background: #eff6ff;
}

.focus-tag {
  margin-left: 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  background: #dbeafe;
  color: #1d4ed8;
  vertical-align: middle;
}

.field label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.field input,
.field select,
.chat-form textarea {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.hard-filters-box {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0.25rem 0 0.5rem;
}

.hard-filters-box .field-check {
  margin-bottom: 0.15rem;
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

button,
.btn {
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  width: 100%;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover:not(:disabled) {
  background: #fafafa;
}

.meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.meta-bar:empty {
  display: none;
}

.meta-bar strong {
  color: var(--text);
}

.alert {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
}

.alert-warn {
  background: var(--warn-bg);
  border: 1px solid #fcd34d;
  color: #92400e;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: #166534;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.85rem;
}

.panel h2,
.results-block h2 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.stock-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stock-card .rank {
  font-size: 0.72rem;
  color: var(--muted);
}

.stock-card .title-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.5rem;
}

.stock-card h3 {
  margin: 0;
  font-size: 1rem;
}

.score-pill {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 0.65rem;
  font-size: 0.82rem;
}

.metrics dt {
  color: var(--muted);
  margin: 0;
}

.metrics dd {
  margin: 0;
  font-weight: 500;
  text-align: right;
}

.signals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.signal-tag {
  font-size: 0.72rem;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #fde68a;
}

.card-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
}

.card-foot button {
  width: auto;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.llm-panel {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
}

.llm-panel h3 {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
}

.llm-pick {
  margin: 0.5rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #dcfce7;
}

.llm-pick:last-child {
  border-bottom: none;
}

.policy-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}

.policy-list li {
  margin: 0.3rem 0;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chat-history-wrap {
  margin: 0;
  position: relative;
}

.chat-history-btn {
  width: auto;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}

.chat-history-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  width: min(20rem, 78vw);
  max-height: 16rem;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border, #d0d0d0);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  padding: 0.25rem;
}

.chat-history-empty {
  font-size: 0.75rem;
  padding: 0.55rem 0.45rem;
}

.chat-history-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0;
  margin: 0;
}

.chat-history-item.is-current .chat-history-open {
  background: #eef4ff;
}

.chat-history-open {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.4rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text, #222);
}

.chat-history-open:hover {
  background: #f3f3f3;
}

.chat-history-open-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-history-open-meta {
  display: block;
  color: var(--muted, #888);
  font-size: 0.68rem;
  margin-top: 0.1rem;
}

.chat-history-del {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.15rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #999;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}

.chat-history-del:hover {
  background: #fdecec;
  color: #c0392b;
}

.chat-history-select {
  width: 100%;
  max-width: 11rem;
  font-size: 0.72rem;
  padding: 0.22rem 0.35rem;
  border: 1px solid var(--border, #d0d0d0);
  border-radius: 4px;
  background: #fff;
  color: var(--text, #222);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-new-btn {
  width: auto;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}

.chat-log {
  background: #fafafa;
  border-radius: 0;
}

.chat-empty {
  font-size: 0.85rem;
  padding: 0.75rem 0.15rem;
}

.chat-msg {
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}

.chat-msg .role {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.chat-msg.user .role {
  color: #3f6212;
}

.chat-msg.assistant .role {
  color: #475569;
}

.chat-msg.status .role {
  color: #a16207;
}

/* 用户：淡绿，和助手白底、系统琥珀明显区分 */
.chat-msg.user .bubble {
  background: #f3f9ee;
  border: 1px solid #b7d4a8;
  border-left: 3px solid #65a30d;
}

.chat-msg.assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid #94a3b8;
}

.chat-msg .bubble {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.screen-progress {
  padding: 0.75rem 0.25rem 1rem;
}

.screen-steps {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.82rem;
  color: var(--muted);
  max-height: 220px;
  overflow: auto;
}

.screen-steps li {
  margin: 0.25rem 0;
}

.screen-steps li.done {
  color: var(--muted);
}

.screen-steps li.current {
  color: var(--text);
  font-weight: 600;
}

.market-line {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
}

.valuation-line {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
}

.val-flag {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  font-weight: 600;
}

.val-flag.val-over {
  color: #8b1e1e;
  background: #f8e8e8;
}

.val-flag.val-cheap {
  color: #1e5a32;
  background: #e6f4ea;
}

.val-flag.val-cycle {
  color: #92400e;
  background: #fef3c7;
}

.val-flag.val-neutral {
  color: #4a5568;
  background: #f4f4f5;
}

/* Detail modal: valuation panel (readable, left-aligned) */
.valuation-panel {
  margin-top: 1rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #fafafa 0%, #fff 40%);
}

.val-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.15rem;
}

.val-panel-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}

.val-panel-sub {
  margin: 0 0 0.65rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.val-regime {
  font-size: 0.84rem;
  margin-bottom: 0.55rem;
  color: var(--text);
}

.val-conclusion {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.65rem;
  font-size: 0.86rem;
  line-height: 1.55;
  text-align: left;
  background: #f4f4f5;
  border-radius: 6px;
  color: var(--text);
}

.val-conflicts {
  margin-bottom: 0.75rem;
}

.val-conflicts-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.val-conflicts ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.val-conflicts li {
  text-align: left;
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  background: #fff7ed;
  border: 1px solid #ffedd5;
}

.val-conflict-name {
  font-weight: 600;
  color: #9a3412;
}

.val-conflict-detail {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.val-metrics {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.val-metric {
  display: grid;
  grid-template-columns: minmax(7.5rem, 42%) 1fr;
  gap: 0.5rem 0.75rem;
  align-items: start;
  font-size: 0.84rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid #f4f4f5;
}

.val-metric:last-child {
  border-bottom: none;
}

.val-metric .val-k {
  color: var(--muted);
  text-align: left;
}

.val-metric .val-v {
  text-align: left;
  font-weight: 550;
  color: var(--text);
}

.val-metric .val-v em {
  font-style: normal;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: 0.25rem;
}

.val-metric-note .val-v {
  font-weight: 500;
}
  background: #edf0f4;
}

.cite-box {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.cite-box ul {
  margin: 0.2rem 0 0;
  padding-left: 1.1rem;
}

.cite-box li {
  margin-bottom: 0.25rem;
}

.cite-detail summary {
  cursor: pointer;
  color: var(--text);
  font-size: 0.75rem;
}

.cite-detail summary a {
  margin-left: 0.35rem;
  font-size: 0.75rem;
}

.cite-excerpt {
  margin: 0.35rem 0 0;
  padding: 0.4rem 0.5rem;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--muted);
  max-height: 160px;
  overflow: auto;
}

.chat-msg.status .bubble {
  background: #fffbeb;
  border: 1px solid #f6de8a;
  border-left: 3px solid #d97706;
  color: #92400e;
  font-size: 0.8rem;
}

.chat-switch-bar {
  margin: 0.5rem 0 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
}

.chat-switch-hint {
  font-size: 0.82rem;
  color: #92400e;
  margin-bottom: 0.5rem;
}

.chat-switch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chat-switch-yes,
.chat-switch-no {
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.chat-switch-yes {
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #fff;
}

.chat-switch-no {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chat-form textarea {
  resize: none;
  min-height: 2.6rem;
  max-height: 5.5rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  padding: 1.25rem;
  box-shadow: 0 8px 30px rgb(0 0 0 / 18%);
}

.modal header {
  margin-bottom: 1rem;
}

.modal .close {
  float: right;
  width: auto;
}

.doc-list {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
  padding-left: 0;
  list-style: none;
}

.doc-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.loading {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}

/* 窄屏：纵向堆叠，仍限制为可视高度内滚动 */
@media (max-width: 960px) {
  .workbench,
  .workbench.left-collapsed:not(.center-collapsed),
  .workbench:not(.left-collapsed).center-collapsed,
  .workbench.left-collapsed.center-collapsed {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    overflow-y: auto;
  }

  .col-left,
  .col-center,
  .col-right {
    width: 100%;
    max-width: none;
    flex: 0 0 auto;
    border: none;
    border-bottom: 1px solid var(--border);
  }

  .col.collapsed {
    max-height: 48px;
  }

  .col.collapsed > .col-rail {
    flex-direction: row;
    justify-content: flex-start;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .col-rail-label {
    writing-mode: horizontal-tb;
  }

  .col-left:not(.collapsed) {
    max-height: 52vh;
  }

  .col-center:not(.collapsed) {
    min-height: 40vh;
    max-height: 55vh;
  }

  .col-right {
    min-height: 42vh;
    max-height: 50vh;
  }

  .workbench.left-collapsed.center-collapsed .col-right {
    max-height: none;
    flex: 1 1 auto;
    min-height: 60vh;
  }
}
