:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --sidebar: #f7f7f8;
  --soft: #fafafa;
  --border: #e5e5e5;
  --border-strong: #d7d7d7;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --faint: #9b9b9b;
  --accent: #4d6bfe;
  --accent-soft: #eef1ff;
  --up: #e64545;
  --down: #1a9e4b;
  --fact: #858585;
  --signal: #3478d4;
  --judgment: #7057c7;
  --posterior: #23845f;
  --gap: #a46619;
  --danger: #c83f49;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --sidebar-width: 260px;
  --content-width: 760px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button, summary, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid rgba(77, 107, 254, 0.45);
  outline-offset: 2px;
}
svg { width: 18px; height: 18px; stroke-width: 1.8; flex: 0 0 auto; }
[hidden] { display: none !important; }

.app-shell { display: flex; width: 100%; height: 100dvh; }
.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 16px 12px 14px;
  z-index: 40;
}
.sidebar-head { min-height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-weight: 700;
}
.brand > span:last-child { display: flex; min-width: 0; flex-direction: column; gap: 1px; }
.brand strong { font-size: 13px; line-height: 1.3; }
.brand small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { background: #f0f0f1; }
.new-chat-button {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 18px 0 14px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
}
.new-chat-button:hover { border-color: #bfc6e9; background: #fdfdff; }
.sidebar-label { padding: 8px 9px 6px; color: var(--faint); font-size: 12px; }
.conversation-section { min-height: 100px; flex: 1 1 auto; overflow: hidden; }
.conversation-list { height: calc(100% - 34px); overflow-y: auto; scrollbar-width: thin; }
.conversation-row { position: relative; display: flex; align-items: center; margin: 1px 0; }
.conversation-button {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 38px 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.conversation-button svg { width: 16px; height: 16px; color: var(--faint); }
.conversation-button .conversation-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.conversation-running { flex: 0 0 auto; display: grid; place-items: center; margin-left: auto; color: var(--faint); }
.conversation-running svg { width: 14px; height: 14px; animation: rotate 1s linear infinite; }
.conversation-row.active .conversation-button { background: #eaeaec; font-weight: 600; }
.conversation-row:not(.active) .conversation-button:hover { background: #efeff0; }
.archive-chat {
  position: absolute;
  right: 4px;
  width: 34px;
  height: 34px;
  display: none;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.archive-chat svg { width: 15px; height: 15px; }
.conversation-row:hover .archive-chat, .archive-chat:focus-visible { display: grid; }
.data-section { flex: 0 0 auto; border-top: 1px solid var(--border); padding-top: 8px; }
.data-toggle, .data-links button {
  width: 100%; min-height: 42px; display: flex; align-items: center; gap: 10px;
  padding: 0 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; text-align: left;
}
.data-toggle { justify-content: space-between; font-weight: 600; }
.data-toggle > span { display: flex; align-items: center; gap: 10px; }
.data-toggle:hover, .data-links button:hover { background: #ededee; }
.data-toggle[aria-expanded="true"] .toggle-chevron { transform: rotate(180deg); }
.toggle-chevron { transition: transform 160ms ease; }
.data-links { padding: 2px 0; }
.data-links button { min-height: 38px; padding-left: 16px; color: #464646; font-size: 13px; }
.data-links button svg { width: 16px; height: 16px; color: var(--muted); }
.sidebar-foot { flex: 0 0 auto; padding: 12px 8px 0; }
.service-state { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #b8b8b8; }
.status-dot.online { background: var(--posterior); box-shadow: 0 0 0 3px rgba(35, 132, 95, 0.12); }
.status-dot.offline { background: var(--danger); }
.sidebar-foot small { display: block; margin-top: 7px; color: var(--faint); font-size: 11px; }
.sidebar-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-foot-row small { min-width: 0; }
.logout-button { width: 32px; height: 32px; min-width: 32px; }
.icp-link { display: inline-block; margin-top: 5px; color: var(--faint); font-size: 10px; text-decoration: none; }
.icp-link:hover { color: var(--accent); }

.login-page { min-height: 100dvh; overflow-y: auto; display: grid; place-items: center; padding: 24px; background: #f7f7f8; }
.login-shell { width: min(380px, 100%); }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.login-brand > div { display: grid; gap: 2px; }
.login-brand strong { font-size: 14px; }
.login-brand small { color: var(--muted); font-size: 11px; }
.login-panel { padding: 26px; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: 0 12px 36px rgba(0,0,0,.07); }
.login-panel h1 { margin: 0 0 22px; font-size: 24px; }
.login-panel form { display: grid; gap: 15px; }
.login-panel label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
.login-panel input { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--text); font-size: 15px; }
.login-panel input:focus { border-color: #aab8ff; outline: 3px solid var(--accent-soft); }
.login-panel .primary-button { width: 100%; min-height: 44px; margin-top: 3px; }
.login-error { padding: 10px 11px; border: 1px solid #efc4c8; border-radius: 8px; background: #fff4f5; color: var(--danger); font-size: 12px; line-height: 1.5; }
.login-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; color: var(--faint); font-size: 10px; }
.login-footer a { color: inherit; text-decoration: none; }

.chat-main { min-width: 0; flex: 1 1 auto; height: 100dvh; display: grid; grid-template-rows: 58px 42px minmax(0, 1fr) auto; background: var(--bg); }
.chat-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 22px; border-bottom: 1px solid rgba(229, 229, 229, 0.72); background: rgba(255,255,255,0.96); z-index: 20;
}
.conversation-heading { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conversation-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.conversation-heading span { color: var(--faint); font-size: 11px; }
.header-actions { display: flex; align-items: center; gap: 2px; }
.header-actions time { margin-right: 4px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.mobile-menu, .mobile-data, .mobile-only { display: none; }
.message-filter-bar { display: flex; align-items: center; justify-content: center; gap: 3px; border-bottom: 1px solid var(--border); background: #fff; }
.message-filter-bar button { min-width: 68px; min-height: 32px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.message-filter-bar button.active { background: var(--soft); color: var(--text); font-weight: 650; }
.chat-scroll { min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.message-list { width: min(100%, var(--content-width)); min-height: 100%; margin: 0 auto; padding: 42px 20px 24px; }
.welcome { padding: 54px 0 24px; }
.welcome-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: var(--text); color: #fff; font-weight: 700; }
.welcome h1 { margin: 20px 0 10px; font-size: 24px; line-height: 1.35; font-weight: 650; }
.welcome p { max-width: 590px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.75; }
.welcome-layers { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 22px; }
.welcome-layers span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.welcome-layers i { width: 6px; height: 6px; border-radius: 50%; }
.welcome-layers .fact i { background: var(--fact); }
.welcome-layers .signal i { background: var(--signal); }
.welcome-layers .judgment i { background: var(--judgment); }
.welcome-layers .posterior i { background: var(--posterior); }

.message { margin: 0 0 28px; min-width: 0; }
.message.user { display: flex; justify-content: flex-end; }
.user-bubble { max-width: 76%; padding: 11px 15px; border-radius: 14px 14px 4px 14px; background: #f0f1f3; line-height: 1.65; overflow-wrap: anywhere; }
.assistant-message { min-width: 0; }
.assistant-identity { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.assistant-avatar { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--text); color: #fff; font-size: 11px; font-weight: 700; }
.card-flow { display: grid; gap: 10px; }
.layer-card {
  min-width: 0; padding: 15px 16px 14px 18px; border: 1px solid var(--border); border-left: 3px solid var(--fact);
  border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); overflow-wrap: anywhere;
}
.layer-card.signal { border-left-color: var(--signal); }
.layer-card.judgment { border-left-color: var(--judgment); }
.layer-card.posterior { border-left-color: var(--posterior); }
.layer-card.gap { border-left-color: var(--gap); }
.layer-label { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--fact); font-size: 11px; font-weight: 650; }
.layer-card.signal .layer-label { color: var(--signal); }
.layer-card.judgment .layer-label { color: var(--judgment); }
.layer-card.posterior .layer-label { color: var(--posterior); }
.layer-card.gap .layer-label { color: var(--gap); }
.layer-label svg { width: 14px; height: 14px; }
.markdown-body { color: #292929; font-size: 15px; line-height: 1.72; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 8px 0; }
.markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 14px 0 7px; font-size: 15px; line-height: 1.5; }
.markdown-body ul, .markdown-body ol { margin: 8px 0; padding-left: 22px; }
.markdown-body li { margin: 4px 0; }
.markdown-body blockquote { margin: 10px 0; padding: 2px 0 2px 12px; border-left: 2px solid var(--border-strong); color: var(--muted); }
.markdown-body code { padding: 1px 5px; border-radius: 4px; background: #f3f3f4; font-family: Consolas, monospace; font-size: 13px; }
.plain-answer { padding: 2px 0; }
.message-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.message-actions button, .card-action {
  min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--muted); font-size: 12px; cursor: pointer;
}
.message-actions button:hover, .card-action:hover { border-color: #c8cee8; color: var(--accent); }
.message-actions svg, .card-action svg { width: 14px; height: 14px; }
.typing-card { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--faint); animation: pulse 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: 120ms; }
.typing-dots i:nth-child(3) { animation-delay: 240ms; }
@keyframes pulse { 0%, 70%, 100% { opacity: .3; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }
.error-card { border-color: #efcdd0; border-left-color: var(--danger); background: #fffafa; }

.stock-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stock-card { min-width: 0; padding: 15px; border: 1px solid var(--border); border-left: 3px solid var(--judgment); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.stock-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.stock-name { min-width: 0; }
.stock-name strong { display: block; font-size: 15px; }
.stock-name span { color: var(--muted); font: 12px Consolas, monospace; }
.candidate-badge { flex: 0 0 auto; color: var(--judgment); font-size: 11px; }
.stock-detail { margin: 8px 0; }
.stock-detail dt { margin-bottom: 2px; color: var(--faint); font-size: 11px; }
.stock-detail dd { margin: 0; color: #353535; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.stock-card footer { display: flex; justify-content: flex-end; margin-top: 12px; }
.stock-card .add-watchlist { min-height: 38px; color: var(--accent); }
.stock-card .add-watchlist.done { color: var(--posterior); }

.review-draft { display: grid; gap: 10px; }
.review-field { display: block; padding: 14px 15px; border: 1px solid var(--border); border-left: 3px solid var(--fact); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.review-field.actions { border-left-color: var(--signal); }
.review-field.assessment { border-left-color: var(--judgment); }
.review-field.next { border-left-color: var(--posterior); }
.review-field > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 650; }
.review-field textarea { width: 100%; min-height: 92px; resize: vertical; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.6; }
.review-readonly { color: var(--text); font-size: 13px; line-height: 1.65; }
.review-readonly p { margin: 0 0 7px; }
.review-readonly p:last-child { margin-bottom: 0; }
.review-draft:not(.editing) textarea, .review-draft:not(.editing) .review-confirm { display: none; }
.review-draft.editing .review-readonly, .review-draft.editing [data-review-edit] { display: none; }
.review-draft footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.review-save-state { color: var(--muted); font-size: 12px; }
.output-collection { width: 100%; padding-bottom: 30px; }
.output-collection > header { margin-bottom: 18px; }
.output-collection h2 { margin: 0; font-size: 20px; }

.posterior-banner { margin: 0 0 26px; padding: 14px 16px; border: 1px solid #cde6dc; border-left: 3px solid var(--posterior); border-radius: 12px; background: #f8fdfb; }
.posterior-banner strong { display: block; margin-bottom: 5px; color: var(--posterior); font-size: 12px; }
.posterior-banner p { margin: 4px 0; color: #40534b; font-size: 13px; line-height: 1.55; }
.cache-notice { margin-bottom: 16px; padding: 9px 12px; border-radius: 8px; background: #fff7e8; color: #805817; font-size: 12px; }

.composer-dock { position: relative; z-index: 18; background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 18px); padding: 18px 20px max(12px, env(safe-area-inset-bottom)); }
.composer-inner { width: min(100%, var(--content-width)); margin: 0 auto; }
.capability-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 3px 8px; }
.capability-chips button {
  min-height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: #4c4c4c; font-size: 12px; cursor: pointer;
}
.capability-chips button:hover { border-color: #c9d0fa; background: var(--accent-soft); color: var(--accent); }
.capability-chips svg { width: 14px; height: 14px; }
.composer { min-height: 60px; display: flex; align-items: flex-end; gap: 10px; padding: 10px 10px 10px 16px; border: 1px solid var(--border-strong); border-radius: 14px; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.07); }
.composer:focus-within { border-color: #b8c3fb; box-shadow: 0 4px 20px rgba(39, 67, 188, .09); }
.composer textarea { min-width: 0; flex: 1 1 auto; max-height: 160px; resize: none; padding: 8px 0; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.55; overflow-y: auto; }
.composer textarea::placeholder { color: var(--faint); }
.send-button { width: 40px; height: 40px; min-width: 40px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 9px; background: var(--accent); color: #fff; cursor: pointer; }
.send-button:hover { background: #3f5be5; }
.send-button:disabled { background: #c5c9d9; cursor: default; }
.composer-note { margin-top: 6px; text-align: center; color: var(--faint); font-size: 10px; }

.primary-button, .secondary-button {
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 15px;
  border-radius: 8px; cursor: pointer; font-weight: 600;
}
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.primary-button:hover { background: #3f5be5; }
.primary-button:disabled { border-color: #bfc4d8; background: #bfc4d8; cursor: default; }
.secondary-button { border: 1px solid var(--border-strong); background: #fff; color: #444; }
.secondary-button:hover { border-color: #bfc6e9; }

.data-backdrop, .sidebar-backdrop { position: fixed; inset: 0; border: 0; background: rgba(0,0,0,.26); z-index: 60; }
.data-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, calc(100vw - var(--sidebar-width)));
  display: grid; grid-template-rows: auto minmax(0, 1fr); background: #fff; border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgba(0,0,0,.09); transform: translateX(102%); transition: transform 180ms ease; z-index: 70;
}
.data-panel.open { transform: translateX(0); }
.data-panel > header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; border-bottom: 1px solid var(--border); }
.eyebrow { display: block; margin-bottom: 3px; color: var(--faint); font-size: 11px; }
.data-panel h2, .scene-dialog h2 { margin: 0; font-size: 18px; line-height: 1.35; }
.data-tabs { display: flex; gap: 4px; padding: 9px 18px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.data-tabs button { min-height: 38px; flex: 0 0 auto; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.data-tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.data-content { min-width: 0; overflow-y: auto; padding: 22px; }
.data-loading, .data-empty { padding: 44px 10px; text-align: center; color: var(--muted); }
.data-block { margin-bottom: 28px; }
.data-block > header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.data-block h3 { margin: 0; font-size: 15px; }
.data-block header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.data-actions { display: grid; gap: 8px; margin-bottom: 24px; }
.data-disclosure, .history-disclosure { border-bottom: 1px solid var(--border); }
.data-disclosure > summary, .history-disclosure > summary { min-height: 46px; display: flex; align-items: center; gap: 8px; list-style: none; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; }
.data-disclosure > summary::-webkit-details-marker, .history-disclosure > summary::-webkit-details-marker { display: none; }
.data-disclosure > summary svg { width: 16px; height: 16px; color: var(--muted); }
.data-disclosure .inline-form { margin-bottom: 14px; }
.disclosure-body { padding-bottom: 14px; }
.section-note { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.history-disclosure { margin-top: 8px; }
.history-disclosure > .data-block { margin: 8px 0 22px; }
.history-disclosure > .data-block h3 { margin: 0 0 10px; }
.inline-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--soft); }
.inline-form .span-2 { grid-column: span 2; }
.inline-form .span-4 { grid-column: 1 / -1; }
.inline-form label, .scene-dialog label { min-width: 0; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.inline-form input, .inline-form select, .inline-form textarea, .scene-dialog input {
  width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--text);
}
.inline-form textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
.inline-form footer { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.data-table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: nowrap; }
.data-table th { background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 600; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .wrap { max-width: 260px; white-space: normal; line-height: 1.5; }
.status-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 7px; border-radius: 6px; background: #f1f1f2; color: var(--muted); font-size: 11px; }
.status-badge.candidate { background: #f2effc; color: var(--judgment); }
.status-badge.confirmed { background: #eaf7f2; color: var(--posterior); }
.status-badge.rejected { background: #f4f4f4; color: var(--faint); }
.row-actions { display: flex; gap: 5px; }
.row-actions button { min-height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--muted); font-size: 11px; cursor: pointer; }
.row-actions .confirm { color: var(--posterior); }
.row-actions .reject { color: var(--danger); }
.record-list { display: grid; gap: 9px; }
.record-item { padding: 14px 15px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.record-item header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.record-item h4 { margin: 0; font-size: 14px; }
.record-item p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.record-meta { color: var(--faint); font-size: 11px; }
.record-link { display: inline-block; margin-top: 8px; color: var(--accent); font-size: 11px; text-decoration: none; }
.status-summary { display: grid; grid-template-columns: .8fr 1fr 1.7fr; gap: 8px; }
.status-summary article { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.status-summary article > span, .status-summary small { display: block; color: var(--faint); font-size: 11px; }
.status-summary strong { min-width: 0; display: block; margin-top: 6px; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.status-summary small { margin-top: 4px; }
.weibo-status .data-disclosure { margin-top: 12px; }
.market-indices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.market-index, .market-metrics article { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.market-index span, .market-metrics span { display: block; color: var(--muted); font-size: 11px; }
.market-index strong { display: block; margin: 7px 0 2px; font-size: 18px; }
.market-index em { font-size: 12px; font-style: normal; }
.market-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.market-metrics strong { display: block; margin-top: 6px; font-size: 15px; }
.rise { color: #c83c43; }
.fall { color: #23845f; }
.data-warning { margin-top: 10px; padding: 11px 12px; border: 1px solid #edd6a8; border-radius: 8px; background: #fff9ed; color: #7b591d; font-size: 12px; line-height: 1.5; }
.sector-rank-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.sector-rank-grid > section { min-width: 0; }
.sector-rank-grid h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.sector-rank-list { display: grid; }
.sector-rank-list > div { min-height: 34px; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 7px; border-bottom: 1px solid var(--border); font-size: 12px; }
.sector-rank-list .rank { color: var(--faint); font-variant-numeric: tabular-nums; }
.sector-rank-list strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sector-rank-list em { font-style: normal; white-space: nowrap; }
.custom-sector-list { display: grid; gap: 10px; margin-top: 14px; }
.custom-sector { padding: 14px; border: 1px solid var(--border); border-radius: 8px; }
.custom-sector > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.custom-sector h4 { margin: 0; font-size: 14px; }
.custom-sector header p { margin: 4px 0 0; }
.sector-performance { text-align: right; }
.sector-performance strong, .sector-performance span { display: block; }
.sector-performance span { margin-top: 3px; color: var(--faint); font-size: 11px; }
.constituent-list { display: flex; flex-wrap: wrap; gap: 5px; margin: 12px 0; }
.constituent-chip { min-height: 30px; display: inline-flex; align-items: center; gap: 4px; padding: 0 4px 0 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 11px; }
.constituent-chip button { width: 26px; height: 26px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--faint); cursor: pointer; }
.constituent-chip svg { width: 13px; height: 13px; }
.compact-form { display: grid; grid-template-columns: 120px minmax(120px, 1fr) auto; gap: 7px; }
.compact-form input { min-width: 0; min-height: 38px; padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 7px; }
.custom-sector > footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; }
.danger-action { color: var(--danger); }

.scene-dialog { width: min(480px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: 0 18px 60px rgba(0,0,0,.2); }
.scene-dialog::backdrop { background: rgba(0,0,0,.3); }
.scene-dialog form { padding: 20px; }
.scene-dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.scene-dialog p { margin: 13px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.scene-dialog footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.scene-dialog fieldset { display: flex; gap: 8px; margin: 0; padding: 0; border: 0; }
.scene-dialog legend { margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.radio-option { position: relative; }
.radio-option input { position: absolute; opacity: 0; pointer-events: none; }
.radio-option span { min-width: 90px; min-height: 42px; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--muted); cursor: pointer; }
.radio-option input:checked + span { border-color: #aab8ff; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.toast-region { position: fixed; right: 22px; bottom: 22px; display: grid; gap: 8px; z-index: 100; pointer-events: none; }
.toast { max-width: min(380px, calc(100vw - 32px)); padding: 11px 14px; border: 1px solid var(--border); border-radius: 8px; background: #252525; color: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.18); font-size: 13px; line-height: 1.5; animation: toast-in 160ms ease; }
.toast.error { background: #8e2f37; }
@keyframes toast-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.spin { animation: rotate 1s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .stock-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form .span-4 { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); transform: translateX(-102%);
    transition: transform 180ms ease; box-shadow: 10px 0 28px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { z-index: 35; }
  .mobile-only, .mobile-menu, .mobile-data { display: inline-grid; }
  .mobile-only, .mobile-menu, .mobile-data { width: 44px; height: 44px; min-width: 44px; }
  .chat-main { width: 100%; grid-template-rows: 56px 42px minmax(0, 1fr) auto; }
  .chat-header { padding: 0 8px; }
  .conversation-heading { flex: 1 1 auto; }
  .conversation-heading span { display: none; }
  .header-actions time { font-size: 11px; }
  .header-actions #refreshMarket { display: none; }
  .message-list { padding: 24px 14px 18px; }
  .welcome { padding: 36px 4px 18px; }
  .welcome h1 { font-size: 21px; }
  .user-bubble { max-width: 88%; }
  .composer-dock { padding: 12px 10px max(8px, env(safe-area-inset-bottom)); }
  .capability-chips { min-width: 0; max-width: 100%; flex-wrap: nowrap; margin-left: 0; margin-right: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .capability-chips::-webkit-scrollbar { display: none; }
  .capability-chips button { min-height: 44px; flex: 0 0 auto; }
  .composer { min-height: 56px; padding: 7px 7px 7px 13px; }
  .send-button { width: 44px; height: 44px; min-width: 44px; }
  .message-actions button, .card-action { min-height: 44px; }
  .stock-card .add-watchlist { min-height: 44px; }
  .data-panel { inset: 0; width: 100vw; height: 100dvh; border-left: 0; }
  .data-panel > header { min-height: 64px; padding: 10px 14px; }
  .data-tabs { padding: 7px 10px; }
  .data-tabs button { min-height: 44px; }
  .data-content { padding: 16px 12px 28px; }
  .inline-form { grid-template-columns: 1fr; padding: 13px; }
  .inline-form .span-2, .inline-form .span-4 { grid-column: 1; }
  .inline-form input, .inline-form select, .inline-form textarea { min-height: 44px; }
  .row-actions button { min-height: 40px; }
  .market-indices { grid-template-columns: 1fr; }
  .market-metrics { grid-template-columns: 1fr 1fr; }
  .sector-rank-grid { grid-template-columns: 1fr; }
  .status-summary { grid-template-columns: 1fr; }
  .weibo-status > header { align-items: flex-start; }
  .weibo-status > header .primary-button { min-width: 114px; min-height: 44px; padding: 0 11px; }
  .custom-sector > header { display: block; }
  .sector-performance { margin-top: 8px; text-align: left; }
  .compact-form { grid-template-columns: 1fr; }
  .toast-region { right: 16px; bottom: 16px; }
}

@media (max-width: 420px) {
  .header-actions time { max-width: 86px; white-space: normal; text-align: right; line-height: 1.25; }
  .conversation-heading strong { max-width: 150px; }
  .layer-card { padding: 13px 13px 13px 15px; }
  .stock-card { padding: 13px; }
  .review-field { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
