/* ==========================================================================
   「选题」Xuanti V2.0 Dual-Theme Design System
   Light (Default): 「硬记」冷灰蓝磨砂玻璃 (#F3F5F8 / #FFFFFF / #283848 / #7D4247)
   Dark (Toggle):   「全解」深邃极客黑金   (#070708 / #111114 / #FCD34D / #F5F5F7)
   ========================================================================== */

:root,
:root[data-theme="light"] {
  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --surface-elevated: rgba(255, 255, 255, 0.92);
  --surface-inset: #EAEFF4;
  --surface-hover: #E3E9F0;
  --header-bg: rgba(243, 245, 248, 0.82);
  --border: rgba(40, 56, 72, 0.10);
  --border-strong: rgba(40, 56, 72, 0.18);
  --ink: #283848;
  --ink-2: #56687A;
  --muted: #8896A6;
  --accent: #283848;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(40, 56, 72, 0.08);
  --gold: #8A6520;
  --gold-soft: rgba(138, 101, 32, 0.10);
  --ok: #2B624B;
  --ok-soft: rgba(43, 98, 75, 0.10);
  --danger: #7D4247;
  --danger-soft: rgba(125, 66, 71, 0.10);
  --shadow-sm: 0 2px 10px rgba(40, 56, 72, 0.05);
  --shadow-md: 0 10px 30px rgba(40, 56, 72, 0.08);
  --ring-track: rgba(40, 56, 72, 0.14);
}

:root[data-theme="dark"] {
  --bg: #070708;
  --surface: #111114;
  --surface-elevated: rgba(17, 17, 20, 0.92);
  --surface-inset: #0B0B0D;
  --surface-hover: #1B1B20;
  --header-bg: rgba(7, 7, 8, 0.82);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --ink: #F5F5F7;
  --ink-2: #A1A1AA;
  --muted: #71717A;
  --accent: #FCD34D;
  --accent-ink: #0B0B0D;
  --accent-soft: rgba(252, 211, 77, 0.12);
  --gold: #FCD34D;
  --gold-soft: rgba(252, 211, 77, 0.14);
  --ok: #86EFAC;
  --ok-soft: rgba(134, 239, 172, 0.12);
  --danger: #F97171;
  --danger-soft: rgba(249, 113, 113, 0.14);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.55);
  --ring-track: rgba(255, 255, 255, 0.14);
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', 'PingFang SC', 'Noto Sans SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

#dot-grid {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.ico {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.app-root {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==================== Frosted Editorial Topbar ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-inset);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-seal {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.brand-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

.seg-bar {
  display: inline-flex;
  align-items: center;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 11px;
  gap: 2px;
}

.seg-opt {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
  white-space: nowrap;
}

.seg-opt:hover {
  color: var(--ink);
}

.seg-opt.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.16s, background 0.16s;
  white-space: nowrap;
}

.pill-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-inset);
}

.wallet-pill {
  gap: 8px;
  padding: 0 12px 0 8px;
}

.wallet-ring-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.wallet-ring-svg {
  width: 24px;
  height: 24px;
  transform: rotate(-90deg);
}

.wallet-ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 2.6;
}

.wallet-ring-arc {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2.6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s ease;
}

.wallet-pill.pulsing {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-soft);
}

.wallet-pill.pulsing .wallet-ring-arc {
  animation: xt-pulse 1.1s ease-in-out infinite;
}

@keyframes xt-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.wallet-delta-badge {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--gold);
  font-weight: 600;
}

.wallet-val {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 600;
}

/* ==================== Slide-out Left History Drawer ==================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(4px);
  display: none;
}

.drawer-backdrop.open {
  display: block;
}

.history-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 304px;
  z-index: 50;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}

.history-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  font-weight: 600;
  font-size: 13.5px;
}

.drawer-new-btn {
  margin: 12px 14px 8px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.drawer-new-btn:hover {
  opacity: 0.92;
}

.drawer-sessions {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
}

.session-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
}

.session-item:hover {
  background: var(--surface-inset);
}

.session-item.active {
  background: var(--surface-inset);
  border-color: var(--border-strong);
}

.session-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.session-item-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
}

.session-del-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 3px;
  border-radius: 6px;
  opacity: 0;
}

.session-item:hover .session-del-btn {
  opacity: 1;
}

.session-del-btn:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.drawer-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-inset);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 12px;
}

.drawer-link:hover {
  color: var(--ink);
  background: var(--surface-hover);
}

/* ==================== Main Views & Welcome Stage ==================== */
.main-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px 20px 14px;
}

.view-panel {
  display: none;
  flex: 1;
  flex-direction: column;
}

.view-panel.active {
  display: flex;
}

.welcome-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-bottom: 18px;
}

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.hero-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
  max-width: 760px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.kpi-box {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.kpi-num {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.kpi-lbl {
  font-size: 11.5px;
  color: var(--ink-2);
  margin-top: 2px;
}

.section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.03em;
}

.starter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.starter-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s, border-color 0.14s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink);
}

.starter-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.starter-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
}

.starter-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
}

.starter-desc {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
}

.action-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.chip-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-inset);
}

.chip-btn.danger-outline {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.strip-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini-hitl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
}

.mini-hitl-card:hover {
  border-color: var(--border-strong);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-inset);
  color: var(--ink-2);
}

.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

/* ==================== Conversation Thread & Composer ==================== */
.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 18px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-user {
  align-self: flex-end;
  max-width: 78%;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 11px 16px;
  border-radius: 16px 16px 4px 16px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.msg-assistant-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.thinking-box {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.thinking-toggle {
  width: 100%;
  background: transparent;
  border: none;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.thinking-body {
  padding: 0 12px 10px;
  font-size: 12px;
  color: var(--ink-2);
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.thinking-box.collapsed .thinking-body {
  display: none;
}

.tools-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool-pill {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
}

.tool-pill-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tool-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}

.tool-dot.running {
  animation: xt-pulse 0.9s infinite;
}

.tool-dot.done {
  background: var(--ok);
}

.tool-dot.err {
  background: var(--danger);
}

/* Inline Structured Tool Cards (Boundary, JAPE, Collision, PDF) */
.boundary-card {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.boundary-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--danger);
}

.boundary-steps {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--ink);
}

.copy-template-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.inline-struct-card {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jape-bar-row {
  display: grid;
  grid-template-columns: 165px 1fr 78px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.jape-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
  border: 1px solid var(--border);
}

.jape-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.pdf-pill-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
}

.prose {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
}

.prose h1, .prose h2, .prose h3, .prose h4 {
  margin: 14px 0 6px;
  line-height: 1.35;
}

.prose h2 { font-size: 16px; }
.prose h3 { font-size: 14.5px; }
.prose p { margin: 6px 0; }
.prose ul, .prose ol { margin: 6px 0; padding-left: 20px; }
.prose li { margin: 3px 0; }
.prose blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid var(--gold);
  background: var(--surface-inset);
  border-radius: 0 8px 8px 0;
  color: var(--ink-2);
}

.prose code {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-inset);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12.5px;
}

.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 6px 9px;
  text-align: left;
}

.prose th {
  background: var(--surface-inset);
  font-weight: 600;
}

.prose a {
  color: var(--gold);
  font-weight: 600;
  text-decoration: underline;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.receipt-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
}

/* ==================== Composer Dock ==================== */
.composer-dock {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding-top: 8px;
  padding-bottom: 10px;
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}

.composer-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.composer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.model-select {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-inset);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.composer-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.composer-textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  min-height: 44px;
  max-height: 160px;
}

.send-btn {
  height: 38px;
  padding: 0 16px;
  border-radius: 11px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ==================== HITL Console ==================== */
.hitl-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 24px;
}

.hitl-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.hitl-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.hitl-card-box {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hitl-card-box.fused {
  border-color: var(--danger);
  opacity: 0.85;
}

.ttl-track {
  height: 5px;
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}

.ttl-fill {
  height: 100%;
  background: var(--ok);
}

.ttl-fill.expiring { background: var(--gold); }
.ttl-fill.fused { background: var(--danger); }

.data-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th,
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--ink-2);
  font-weight: 600;
  background: var(--surface-inset);
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ops-box {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==================== Modals ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-inset);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
}

.form-textarea {
  min-height: 82px;
  resize: vertical;
}

.btn-primary {
  padding: 8px 14px;
  border-radius: 9px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--surface-inset);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==================== Minimal Editorial Auth Gate ==================== */
.auth-screen {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-screen[hidden],
.app-root[hidden] {
  display: none !important;
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px 60px;
}

.auth-shell {
  width: 100%;
  max-width: 900px;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
  align-items: center;
}

.auth-intro {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-headline {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -0.015em;
}

.auth-lead {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink-2);
  line-height: 1.65;
}

.auth-pillars {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.auth-pillar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.auth-pillar strong {
  display: block;
  font-size: 13px;
  margin-bottom: 3px;
}

.auth-pillar span {
  font-size: 12px;
  color: var(--ink-2);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 24px 24px 22px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-error {
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 600;
}

.progress-box {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}

/* ==================== Interactive User Question Card ==================== */
.question-card {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.question-card.resolved {
  border-width: 1px;
  border-color: var(--border);
  background: var(--surface-inset);
  padding: 10px 14px;
  gap: 6px;
  box-shadow: none;
}

.q-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.q-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.q-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.q-item:first-of-type {
  padding-top: 0;
  border-top: none;
}

.q-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.q-item-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.q-item-prompt {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
}

.q-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.q-opt-btn {
  appearance: none;
  text-align: left;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  color: var(--ink);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.q-opt-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.q-opt-btn.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.q-opt-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.q-opt-desc {
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.4;
}

.q-custom-input {
  width: 100%;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
}

.q-custom-input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.q-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.q-summary-lines {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--ink-2);
}

/* ==================== Rich Preset & Generative Chat Cards ==================== */
.rich-card-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.rich-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.rich-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.rich-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
}

.rich-card-sub {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
}

.radial-metric-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.radial-ring-svg {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.radial-ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 3.4;
}

.radial-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3.4;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.radial-ring-fill.ok { stroke: var(--ok); }
.radial-ring-fill.gold { stroke: var(--gold); }
.radial-ring-fill.danger { stroke: var(--danger); }

.radial-ring-txt {
  font-size: 10px;
  font-weight: 700;
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: central;
}

.topic-meta-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.meta-pill {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--surface-inset);
  color: var(--ink-2);
  border: 1px solid var(--border);
}

.dual-callout-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.callout-inset {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.callout-inset.positive {
  border-left: 3px solid var(--ok);
}

.callout-inset.warning {
  border-left: 3px solid var(--danger);
}

.callout-inset-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink);
}

.callout-inset ul {
  margin: 0;
  padding-left: 16px;
  color: var(--ink-2);
  line-height: 1.5;
}

.card-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cite-ref-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cite-ref-row {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.cite-ref-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.cite-ref-txt {
  font-size: 12px;
  color: var(--ink);
  line-height: 1.45;
  word-break: break-word;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.compare-item {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.compare-item.highlight {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chk-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-inset);
  overflow: hidden;
}

.chk-progress-fill {
  height: 100%;
  background: var(--ok);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.chk-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chk-row {
  appearance: none;
  width: 100%;
  text-align: left;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 11px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.45;
}

.chk-row:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.chk-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--accent-ink);
}

.chk-row.checked .chk-box {
  background: var(--ok);
  border-color: var(--ok);
  color: #FFFFFF;
}

.chk-row.checked .chk-label {
  text-decoration: line-through;
  color: var(--muted);
}

.action-chips-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==================== V2 Smart-Paste Builder & Human Escrow ==================== */
.modal-card.modal-card-wide {
  max-width: 720px;
}

.escrow-banner {
  background: var(--gold-soft);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.5;
}

.qa-panel {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qa-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

.qa-pill-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.qa-pill-btn {
  appearance: none;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.qa-pill-btn strong {
  font-size: 12.5px;
}

.qa-pill-btn span {
  font-size: 11px;
  color: var(--ink-2);
}

.qa-pill-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.qa-pill-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.qa-pill-btn.active span {
  color: var(--accent-ink);
  opacity: 0.85;
}

.smart-preview-box {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.escrow-orders-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.escrow-order-card {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.escrow-order-card.returned {
  background: var(--surface);
  border-color: var(--accent);
}

.dispute-drawer {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==================== Unified Collapsible Activity Stream ==================== */
.activity-box {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.activity-box.live {
  border-color: var(--border-strong);
}

.activity-toggle {
  width: 100%;
  background: transparent;
  border: none;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-2);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
}

.activity-toggle:hover {
  background: var(--surface-hover);
}

.activity-toggle-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}

.activity-dot.running {
  animation: xt-pulse 0.9s infinite;
}

.activity-dot.done {
  background: var(--ok);
}

.activity-dot.err {
  background: var(--danger);
}

.activity-check-ico {
  width: 15px;
  height: 15px;
  color: var(--ok);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.activity-headline {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--ink);
}

.activity-summary-hint {
  color: var(--muted);
  font-weight: 400;
}

.activity-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 11.5px;
  color: var(--muted);
}

.activity-chips {
  padding: 0 12px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.activity-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11px;
  color: var(--ink-2);
  font-weight: 500;
}

.activity-chip.running {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--accent-soft);
}

.activity-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}

.activity-chip-dot.running {
  background: var(--gold);
  animation: xt-pulse 0.9s infinite;
}

.activity-chip-dot.err {
  background: var(--danger);
}

.activity-detail {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.activity-box.collapsed .activity-detail {
  display: none;
}

.activity-summary-text {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.55;
  white-space: pre-wrap;
}

.activity-admin-raw {
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 11.5px;
  color: var(--muted);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.activity-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding: 2px 0;
}

.activity-step-left {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  min-width: 0;
}

.activity-step-status {
  color: var(--muted);
  font-size: 11.5px;
  text-align: right;
  flex-shrink: 0;
}

.prose-skeleton {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.skel-line {
  height: 11px;
  border-radius: 6px;
  background: var(--surface-inset);
  animation: xt-pulse 1.2s ease-in-out infinite;
}

.cards-deck {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==================== Scene Differentiation (选题策划 vs 投稿体检) ==================== */
.hero-card {
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
}

.hero-card[data-scene="topic_select"] {
  border-top: 3px solid var(--gold);
  background: linear-gradient(155deg, var(--gold-soft) 0%, var(--surface) 44%);
}

.hero-card[data-scene="manuscript_check"] {
  border-top: 3px solid var(--ok);
  background: linear-gradient(155deg, var(--ok-soft) 0%, var(--surface) 44%);
}

.hero-card[data-scene="manuscript_check"] .hero-eyebrow {
  color: var(--ok);
}

.hero-card[data-scene="manuscript_check"] .starter-tag,
.welcome-stage[data-scene="manuscript_check"] .starter-tag {
  color: var(--ok);
}

.chip-btn.chip-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}

.chip-btn.chip-primary:hover {
  background: var(--accent);
  color: var(--accent-ink);
  opacity: 0.9;
}

.scene-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--gold);
  background: var(--gold-soft);
  color: var(--gold);
  white-space: nowrap;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.scene-mode-pill .scene-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.scene-mode-pill[data-scene="manuscript_check"] {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}

.scene-mode-pill.pulse-once {
  animation: xt-scene-pulse 0.55s ease;
}

@keyframes xt-scene-pulse {
  0% { transform: scale(0.96); box-shadow: 0 0 0 0 var(--gold-soft); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 5px var(--gold-soft); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}

.welcome-stage.scene-switching {
  animation: xt-stage-swap 0.22s ease;
}

@keyframes xt-stage-swap {
  0% { opacity: 0.72; transform: translateY(3px); }
  100% { opacity: 1; transform: translateY(0); }
}

.scene-switch-banner {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.scene-switch-banner-txt {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
}

.scene-switch-banner .btn-primary,
.scene-switch-banner .btn-secondary {
  padding: 5px 10px;
  font-size: 12px;
}

.scene-switch-banner .icon-btn {
  width: 26px;
  height: 26px;
}

@media (max-width: 1180px) {
  .brand-sub {
    display: none;
  }
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .topbar-left,
  .topbar-right {
    gap: 6px;
  }
  .pill-btn {
    padding: 0 10px;
    font-size: 12px;
  }
}

@media (max-width: 820px) {
  .auth-shell,
  .auth-pillars,
  .kpi-strip,
  .starter-grid,
  .strip-cards,
  .hitl-cards-grid,
  .ops-grid,
  .form-grid,
  .dual-callout-grid,
  .compare-grid,
  .q-options-grid,
  .qa-pill-grid {
    grid-template-columns: 1fr;
  }
  .wallet-kpi-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .topbar {
    padding: 0 12px;
  }
  .brand-sub {
    display: none;
  }
}
