:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --surface-accent: #f5f3ff;
  --surface-info: #eef2ff;
  --text: #202123;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #7B26E8;
  --accent-strong: #6B1FCC;
  --green: #059669;
  --red: #dc2626;
  --edge: rgba(99, 102, 241, 0.24);
  --edge-branch: rgba(123, 38, 232, 0.45);
  --edge-highlight: rgba(107, 31, 204, 0.92);
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body,
button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

:root {
  --sidebar-width: 260px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar workspace";
}

.shell.sidebar-collapsed {
  --sidebar-width: 0px;
}

/* ---- Sidebar ---- */

.sidebar {
  grid-area: sidebar;
  width: var(--sidebar-width);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 35;
  overflow: hidden;
  transition: width 0.2s ease;
}

.shell.sidebar-collapsed .sidebar {
  width: 0;
  border-right: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 650;
  flex: 1;
  white-space: nowrap;
}

.sidebar-collapse-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.sidebar-collapse-btn:hover {
  background: var(--surface-soft);
}

.sidebar-canvas-section {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-new-canvas-btn {
  width: 100%;
  height: 36px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  flex-shrink: 0;
  margin-bottom: 4px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.sidebar-new-canvas-btn:hover {
  border-color: rgba(123, 38, 232, 0.5);
  color: var(--accent-strong);
}

.sidebar-canvas-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-canvas-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  color: var(--text);
  transition: background 0.12s ease;
}

.sidebar-canvas-item:hover {
  background: var(--surface-soft);
}

.sidebar-canvas-item.active {
  background: rgba(123, 38, 232, 0.06);
  color: var(--accent-strong);
  font-weight: 500;
}

.sidebar-canvas-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-canvas-item-del {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: opacity 0.12s ease;
}

.sidebar-canvas-item:hover .sidebar-canvas-item-del {
  opacity: 1;
}

.sidebar-canvas-item-del:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--red);
}

.sidebar-account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
  flex-shrink: 0;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-username {
  display: block;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-balance {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.sidebar-balance.low {
  color: var(--red);
}

.sidebar-account-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.sidebar-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-action-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.sidebar-toggle-btn {
  display: none;
}

.shell.sidebar-collapsed .sidebar-toggle-btn {
  display: inline-flex;
}

.topbar-left-minimal {
  display: flex;
  align-items: center;
}

/* ---- Topbar ---- */

.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.zoom-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.tool-btn:hover {
  background: var(--surface-soft);
}

.zoom-pill {
  min-width: 68px;
}

.status {
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

.status.busy {
  background: var(--surface-accent);
  border-color: rgba(123, 38, 232, 0.2);
  color: var(--accent-strong);
}

.workspace {
  grid-area: workspace;
  padding: 10px 10px 118px;
  overflow: hidden;
}

.canvas-viewport {
  position: relative;
  height: calc(100vh - 70px);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(180deg, #f7f7f8 0%, #f4f4f5 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  cursor: grab;
}

.canvas-viewport.panning {
  cursor: grabbing;
}

.canvas-grid,
.canvas-stage,
.edge-layer {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

.canvas-grid {
  background-image:
    linear-gradient(rgba(17, 24, 39, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 24, 39, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(17, 24, 39, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 24, 39, 0.02) 1px, transparent 1px);
  background-size: 160px 160px, 160px 160px, 32px 32px, 32px 32px;
}

.edge-layer {
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}

.selection-actions {
  position: absolute;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(10px);
}

.selection-actions .small-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.edge-path {
  fill: none;
  stroke: var(--edge);
  stroke-width: 2;
  transition: stroke 0.18s ease, stroke-width 0.18s ease, opacity 0.18s ease;
}

.edge-path.branch {
  stroke: var(--edge-branch);
  stroke-dasharray: 8 6;
}

.edge-path.context {
  stroke: var(--edge-branch);
  stroke-dasharray: 6 4;
  opacity: 0.65;
}

.edge-path.active {
  stroke: var(--edge-highlight);
  stroke-width: 3;
  opacity: 1;
}

.edge-path.dimmed {
  opacity: 0.24;
}

.canvas-stage {
  z-index: 2;
}

.minimap {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  width: 210px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.minimap-title {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.minimap-content {
  position: relative;
  height: 140px;
  background: linear-gradient(180deg, #fbfbfc 0%, #f4f4f5 100%);
  overflow: hidden;
}

.minimap-nodes,
.minimap-viewport {
  position: absolute;
  inset: 0;
}

.minimap-node {
  position: absolute;
  border-radius: 4px;
  border: 1px solid rgba(107, 31, 204, 0.25);
  background: rgba(107, 31, 204, 0.12);
}

.minimap-node.user {
  background: rgba(37, 99, 235, 0.1);
  border-color: rgba(37, 99, 235, 0.25);
}

.minimap-node.active {
  background: rgba(107, 31, 204, 0.22);
  border-color: rgba(107, 31, 204, 0.55);
}

.minimap-node.running {
  box-shadow: 0 0 0 1px rgba(123, 38, 232, 0.55);
}

.minimap-viewport {
  border: 2px solid rgba(123, 38, 232, 0.55);
  border-radius: 6px;
  background: rgba(123, 38, 232, 0.06);
  cursor: pointer;
}

.node {
  position: absolute;
  width: 420px;
  min-height: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease, opacity 0.28s ease;
}

.node.entering {
  opacity: 0;
  transform: scale(0.94);
}

.node.user-node {
  width: 500px;
  min-height: 220px;
}

.node.dragging {
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
}

.node.cluster-running {
  box-shadow: 0 0 0 1px rgba(107, 31, 204, 0.12), 0 16px 42px rgba(107, 31, 204, 0.12);
}

.node.active {
  border-color: rgba(107, 31, 204, 0.42);
  box-shadow: 0 18px 42px rgba(107, 31, 204, 0.14);
}

.node.selected {
  border-color: rgba(123, 38, 232, 0.72);
  box-shadow: 0 0 0 2px rgba(123, 38, 232, 0.16), 0 18px 40px rgba(123, 38, 232, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(240, 253, 250, 0.98) 100%);
  transform: translateY(-2px);
}

.node.dimmed {
  opacity: 0.78;
}

.node-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: grab;
  user-select: none;
}

.node.dragging .node-header {
  cursor: grabbing;
}

.node-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.node-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: var(--accent);
}

.node-title strong {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-title > div {
  min-width: 0;
  overflow: hidden;
}

.node-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.user-node .node-header {
  background: rgba(123, 38, 232, 0.06);
}

.user-content {
  padding: 16px;
}

.user-message {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 14px;
  max-height: 200px;
  overflow-y: auto;
}

.context-indicator {
  margin-bottom: 10px;
  padding: 6px 10px;
  background: rgba(123, 38, 232, 0.06);
  border: 1px solid rgba(123, 38, 232, 0.12);
  border-radius: 6px;
  font-size: 12px;
  color: var(--accent-strong, #7b26e8);
  font-weight: 500;
}

.user-flags {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.info-chip.branch-origin {
  border-color: rgba(107, 31, 204, 0.28);
  background: rgba(107, 31, 204, 0.08);
  color: var(--accent-strong);
}

.user-node-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.info-chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 11px;
  color: var(--muted);
}

.search-panel {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
  overflow: hidden;
}

.search-panel.hidden,
.branch-box.hidden {
  display: none;
}

.search-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(79, 70, 229, 0.04);
}

.search-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-toggle {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.search-results.collapsed {
  display: none;
}

.search-head strong {
  font-size: 12px;
}

.search-query {
  color: var(--muted);
  font-size: 11px;
}

.search-results {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.cluster-outline {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(107, 31, 204, 0.04);
}

.outline-list {
  display: grid;
  gap: 8px;
}

.outline-item {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(107, 31, 204, 0.1);
}

.outline-item strong {
  font-size: 12px;
}

.outline-item span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.search-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--surface);
}

.search-item-title {
  font-size: 12px;
  font-weight: 600;
}

.search-item-link {
  display: block;
  margin-top: 4px;
  color: var(--accent-strong);
  font-size: 11px;
  text-decoration: none;
}

.search-item-link:hover {
  text-decoration: underline;
}

.search-item-snippet {
  margin-top: 6px;
  color: #374151;
  font-size: 12px;
  line-height: 1.55;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 14px;
  padding: 7px 10px;
  font-size: 12px;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 88px;
  max-width: 160px;
  flex-shrink: 0;
}

.tab-btn-main {
  font-weight: 600;
  white-space: nowrap;
}

.tab-btn-summary {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.tab-btn.active {
  background: var(--surface-accent);
  border-color: rgba(123, 38, 232, 0.3);
  color: var(--accent-strong);
}

.tab-panels {
  position: relative;
  height: 360px;
}

.tab-panel {
  position: absolute;
  inset: 0;
  display: none;
  overflow: auto;
  padding: 14px 16px 18px;
}

.tab-panel.active {
  display: block;
}

.turn-meta {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.turn-word-count {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.08);
  color: #3b82f6;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.turn-summary-chip {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(107, 31, 204, 0.08);
  color: var(--accent-strong);
  font-size: 11px;
}

/* ── 骨架屏 Loading ──────────────────────────────────────────────── */

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

.skeleton-line {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(123,38,232,0.06) 25%, rgba(123,38,232,0.12) 50%, rgba(123,38,232,0.06) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-line.w80 { width: 80%; }
.skeleton-line.w60 { width: 60%; animation-delay: 0.15s; }
.skeleton-line.w90 { width: 90%; animation-delay: 0.3s; }

/* Badge spinner */
.badge.generating {
  color: var(--accent-strong);
  border-color: rgba(123, 38, 232, 0.3);
}

.badge.generating::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border: 2px solid rgba(123, 38, 232, 0.2);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: auth-spin 0.6s linear infinite;
  vertical-align: middle;
}

/* ── 空白响应占位 ────────────────────────────────────────────────── */

.empty-response-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-response-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-response-hint p {
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.6;
}

.empty-response-sub {
  font-size: 12px;
  opacity: 0.7;
}

.md {
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}

.md h1,
.md h2,
.md h3,
.md h4,
.md h5,
.md h6 {
  margin: 0 0 12px;
  line-height: 1.4;
}

.md p {
  margin: 0 0 12px;
}

.md ul,
.md ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.md blockquote {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid rgba(123, 38, 232, 0.3);
  background: rgba(123, 38, 232, 0.05);
  color: #374151;
}

.md pre {
  margin: 0 0 12px;
  padding: 12px;
  background: #111827;
  color: #f9fafb;
  border-radius: 14px;
  overflow: auto;
}

.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 13px;
}

.md table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 12px;
}

.md th,
.md td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

.md a {
  color: var(--accent-strong);
  text-decoration: none;
}

.md a:hover {
  text-decoration: underline;
}

.node-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
}

.node-actions-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.small-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.small-btn:hover {
  background: var(--surface-accent);
}

.small-btn.danger {
  border-color: rgba(220, 38, 38, 0.18);
  color: #b91c1c;
}

.small-btn.danger:hover {
  background: rgba(220, 38, 38, 0.08);
}

.branch-box {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  background: #fcfcfd;
}

.branch-input {
  width: 100%;
  min-height: 44px;
  max-height: 110px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.branch-input:focus {
  outline: none;
  border-color: rgba(123, 38, 232, 0.34);
  box-shadow: 0 0 0 4px rgba(123, 38, 232, 0.1);
}

.branch-controls {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.branch-meta {
  color: var(--muted);
  font-size: 11px;
}

.composer-shell {
  position: fixed;
  bottom: 10px;
  z-index: 160;
  left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
  transform: translateX(-50%);
  width: min(900px, calc(100vw - var(--sidebar-width) - 40px));
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(14px);
}

.selected-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 6px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.selected-chips::-webkit-scrollbar {
  display: none;
}


.selection-summary {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  border: 1px solid rgba(99, 102, 241, 0.14);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(244, 247, 255, 0.98) 0%, rgba(250, 251, 255, 0.98) 100%);
}

.selection-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.selection-summary-count,
.selection-summary-model {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  font-size: 11px;
}

.selection-summary-count {
  color: rgb(12, 140, 108);
  border-color: rgba(123, 38, 232, 0.18);
  background: rgba(123, 38, 232, 0.08);
}

.selection-summary-text {
  color: #334155;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.selection-summary.loading .selection-summary-model {
  color: var(--accent-strong);
  border-color: rgba(107, 31, 204, 0.18);
  background: rgba(107, 31, 204, 0.08);
}

.selection-summary.error .selection-summary-model {
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.18);
  background: rgba(220, 38, 38, 0.08);
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 6px 0 10px;
  border-radius: 999px;
  background: rgba(123, 38, 232, 0.1);
  border: 1px solid rgba(123, 38, 232, 0.35);
  color: rgb(12, 140, 108);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.chip-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 10px;
  cursor: pointer;
  border: none;
  padding: 0;
  line-height: 1;
  opacity: 0.65;
}

.chip-close:hover {
  background: rgba(123, 38, 232, 0.25);
  opacity: 1;
}

.chips-clear {
  margin-left: auto;
  flex-shrink: 0;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.chips-clear:hover {
  border-color: rgba(123, 38, 232, 0.5);
  color: rgb(12, 140, 108);
}

.compact-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.composer-meta-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.mode-pill,
.save-status {
  height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.mode-pill {
  color: var(--accent-strong);
  border-color: rgba(107, 31, 204, 0.18);
  background: rgba(107, 31, 204, 0.06);
}

.save-status.ok {
  color: rgb(12, 140, 108);
  border-color: rgba(123, 38, 232, 0.18);
  background: rgba(123, 38, 232, 0.08);
}

.save-status.pending {
  color: var(--muted);
}

.save-status.error {
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.18);
  background: rgba(220, 38, 38, 0.08);
}

.compact-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.toggle-pill input {
  accent-color: var(--accent);
}

select,
textarea {
  border: 1px solid var(--border);
  background: var(--surface);
}

select {
  height: 32px;
  border-radius: 10px;
  padding: 0 12px;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 8px;
  align-items: end;
}

textarea {
  min-height: 46px;
  max-height: 108px;
  padding: 8px 10px;
  border-radius: 12px;
  resize: none;
  line-height: 1.45;
}

textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(123, 38, 232, 0.34);
  box-shadow: 0 0 0 4px rgba(123, 38, 232, 0.1);
}

.composer.has-selection textarea {
  border-color: rgba(123, 38, 232, 0.45);
  box-shadow: 0 0 0 4px rgba(123, 38, 232, 0.08);
}

.primary-btn {
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #7B26E8, #6B1FCC);
  color: #ffffff;
  font-weight: 650;
}

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

@media (max-width: 980px) {
  .shell {
    --sidebar-width: 0px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 200;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-toggle-btn {
    display: inline-flex !important;
  }

  .sidebar-collapse-btn {
    display: none;
  }

  .composer-shell {
    left: 50%;
    width: min(900px, calc(100% - 20px));
  }
}

@media (max-width: 860px) {
  .workspace {
    padding-bottom: 126px;
  }

  .canvas-viewport {
    min-height: 500px;
    height: calc(100vh - 178px);
  }

  .node,
  .node.user-node {
    width: 360px;
  }

  .minimap {
    display: none;
  }

  .compact-meta,
  .composer {
    display: block;
  }

  .composer-meta-right {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 10px;
  }

  .composer textarea,
  .composer button,
  #roundHint {
    margin-top: 12px;
  }

  .primary-btn {
    width: 100%;
  }
}


a.auth-link {
  color: var(--accent-strong);
}

.auth-body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #f5f7fb 0%, #eef2f7 100%);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 2fr 1fr;
  padding: 0;
}

/* ─── 左侧展示区 ─── */
.login-area {
  position: relative;
  overflow: hidden;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(rgba(123, 38, 232, 0.07) 1.2px, transparent 1.2px),
    linear-gradient(180deg, #f5f3ff 0%, #ede9fe 50%, #f0ebff 100%);
  background-size: 32px 32px, 100% 100%;
  background-position: center, center;
}

.login-area-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 40px 24px;
  max-width: 100%;
  min-width: 0;
}

/* Logo + Brand */
.login-area-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.login-logo {
  height: 52px;
  width: 52px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(123, 38, 232, 0.15));
}

.login-brand-title {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, #7B26E8, #A96BF0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

/* Footer: tagline + pills */
.login-area-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.login-tagline {
  margin: 0;
  font-size: 14px;
  color: #6b7280;
  letter-spacing: 0.02em;
}

.feature-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.feature-pills .pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(123, 38, 232, 0.08);
  color: #6B1FCC;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid rgba(123, 38, 232, 0.12);
}

/* ─── 光晕 ─── */
.glow-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(60px);
}

.orb-1 {
  width: 300px; height: 300px;
  top: -60px; left: -60px;
  background: radial-gradient(circle, rgba(123, 38, 232, 0.18), transparent 70%);
  animation: orb-drift-1 24s ease-in-out infinite alternate;
}

.orb-2 {
  width: 250px; height: 250px;
  bottom: -40px; right: -40px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
  animation: orb-drift-2 28s ease-in-out infinite alternate;
}

.orb-3 {
  width: 200px; height: 200px;
  bottom: 20%; left: 40%;
  background: radial-gradient(circle, rgba(255, 217, 61, 0.12), transparent 70%);
  animation: orb-drift-3 22s ease-in-out infinite alternate;
}

@keyframes orb-drift-1 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.15); }
}

@keyframes orb-drift-2 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-30px, -25px) scale(1.1); }
}

@keyframes orb-drift-3 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(20px, -15px) scale(1.08); }
}

/* ─── 浮动装饰 ─── */
.float-deco {
  position: absolute;
  pointer-events: none;
  z-index: 2;
}

/* 对话气泡 */
.deco-chat {
  width: 52px; height: 32px;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid rgba(123, 38, 232, 0.25);
  border-radius: 6px 6px 6px 2px;
  animation: float-y 5s ease-in-out infinite alternate;
  box-shadow: 0 4px 12px rgba(123, 38, 232, 0.06);
}

.deco-chat::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 22px; height: 4px;
  border-radius: 2px;
  background: rgba(123, 38, 232, 0.12);
  box-shadow:
    0 8px 0 rgba(123, 38, 232, 0.08);
}

/* 打字点动画 */
.deco-chat::after {
  content: '';
  position: absolute;
  bottom: 6px; right: 8px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: rgba(123, 38, 232, 0.3);
  box-shadow:
    -7px 0 0 rgba(123, 38, 232, 0.3),
    -14px 0 0 rgba(123, 38, 232, 0.3);
  animation: typing-dot 1.4s ease-in-out infinite;
}

.deco-chat-sm {
  width: 40px; height: 24px;
  animation-duration: 6.5s;
  border-radius: 6px 6px 2px 6px;
}

.deco-chat-sm::before { width: 16px; }

/* 迷你节点卡片 */
.deco-node {
  width: 56px; height: 38px;
  background: rgba(255, 255, 255, 0.8);
  border: 1.5px solid rgba(123, 38, 232, 0.15);
  border-radius: 8px;
  animation: float-y 7s ease-in-out infinite alternate;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

.deco-node::before {
  content: '';
  position: absolute;
  top: 8px; left: 8px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #7B26E8;
  box-shadow: 9px 0 0 rgba(107, 31, 204, 0.15);
}

.deco-node::after {
  content: '';
  position: absolute;
  bottom: 8px; left: 8px; right: 8px;
  height: 3px;
  border-radius: 2px;
  background: rgba(123, 38, 232, 0.08);
  box-shadow: 0 -7px 0 rgba(123, 38, 232, 0.06);
}

.deco-node-sm {
  width: 44px; height: 30px;
  animation-duration: 5.5s;
}

/* 像素星星 */
.deco-star {
  width: 12px; height: 12px;
  animation: twinkle 3s ease-in-out infinite;
}

.deco-star::before,
.deco-star::after {
  content: '';
  position: absolute;
  background: rgba(123, 38, 232, 0.45);
}

.deco-star::before {
  top: 4px; left: 0;
  width: 12px; height: 4px;
  border-radius: 1px;
}

.deco-star::after {
  top: 0; left: 4px;
  width: 4px; height: 12px;
  border-radius: 1px;
}

.deco-star-yellow::before,
.deco-star-yellow::after {
  background: rgba(255, 217, 61, 0.6);
}

.deco-star-blue::before,
.deco-star-blue::after {
  background: rgba(99, 102, 241, 0.4);
}

/* 像素菱形 */
.deco-diamond {
  width: 14px; height: 14px;
  border: 2px solid rgba(123, 38, 232, 0.25);
  transform: rotate(45deg);
  animation: float-y 6s ease-in-out infinite alternate, twinkle 4s ease-in-out infinite;
}

.deco-diamond-blue {
  border-color: rgba(99, 102, 241, 0.3);
}

/* 圆点 */
.deco-circle {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(123, 38, 232, 0.2);
  animation: float-y 4.5s ease-in-out infinite alternate;
}

.deco-circle-yellow {
  background: rgba(255, 217, 61, 0.35);
  width: 8px; height: 8px;
}

.deco-circle-blue {
  background: rgba(99, 102, 241, 0.2);
  width: 12px; height: 12px;
}

/* SVG 连接线 */
.deco-connections {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
}

.deco-connections path {
  animation: dash-flow 4s linear infinite;
}

/* ─── 装饰动画 ─── */
@keyframes float-y {
  0% { transform: translateY(0); }
  100% { transform: translateY(-14px); }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

@keyframes dash-flow {
  to { stroke-dashoffset: -24; }
}

@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.2; }
  30% { opacity: 0.8; }
}

/* ─── 香蕉场景 ─── */
.banana-scene {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  position: relative;
  padding: 0 20px;
  max-width: 400px;
  width: 100%;
}

/* ─── SVG 像素香蕉（内联 SVG 版本） ─── */

.banana-wrap {
  position: relative;
  display: inline-block;
  width: 100px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.banana-wrap-center {
  width: 115px;
  margin: 0 -2px;
  z-index: 2;
}

.banana-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
}

/* 浮动 idle 动画 */
#wrap-pirate {
  animation: banana-idle 3s ease-in-out infinite alternate;
}

#wrap-ninja {
  animation: banana-idle 3.5s ease-in-out infinite alternate;
  animation-delay: -0.5s;
}

#wrap-hero {
  animation: banana-idle 3.2s ease-in-out infinite alternate;
  animation-delay: -1s;
}

@keyframes banana-idle {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}

/* ── Hover 个性反应 ── */
#wrap-pirate:hover {
  transform: rotate(-2deg) translateY(-4px);
}

#wrap-ninja:hover {
  animation: ninja-dodge 0.4s ease forwards;
}

#wrap-hero:hover {
  transform: scale(1.06) translateY(-3px);
}

@keyframes ninja-dodge {
  0%   { transform: translateX(0) translateY(-3px); }
  30%  { transform: translateX(-5px) translateY(-3px); }
  60%  { transform: translateX(3px) translateY(-3px); }
  100% { transform: translateX(0) translateY(-3px); }
}

/* ── 点击跳跃 ── */
.banana-wrap.click-jump {
  animation: click-jump-anim 0.4s ease-out !important;
}

@keyframes click-jump-anim {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-18px) scale(1.08); }
}

/* ── 点击气泡 ── */
.click-bubble {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  font-size: 18px;
  z-index: 10;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.click-bubble.pop {
  animation: bubble-pop 0.8s ease-out forwards;
}

@keyframes bubble-pop {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0) scale(0.5); }
  50%  { opacity: 1; transform: translateX(-50%) translateY(-22px) scale(1.3); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-36px) scale(1); }
}

/* 像素地面 */
.banana-ground {
  position: absolute;
  bottom: -4px;
  width: 320px;
  height: auto;
}

/* ─── 香蕉交互状态 ─── */

/* 用户名聚焦 — 微微倾斜 */
.banana-scene.state-username .banana-wrap {
  animation-play-state: paused;
  transform: rotate(2deg) translateX(2px);
}

/* 密码聚焦 — 暂停浮动 */
.banana-scene.state-password .banana-wrap {
  animation-play-state: paused;
  transform: translateY(-2px);
}

/* 验证码 — 微微低头 */
.banana-scene.state-captcha .banana-wrap {
  animation-play-state: paused;
  transform: rotate(-1deg) translateY(3px);
}

/* 成功跳跃 */
@keyframes banana-jump {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(-24px) scale(1.05); }
}

.banana-scene.state-success .banana-wrap {
  animation: banana-jump 0.5s ease-out !important;
}

/* 失败震动 */
@keyframes banana-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px) rotate(-2deg); }
  30% { transform: translateX(8px) rotate(2deg); }
  50% { transform: translateX(-6px) rotate(-1deg); }
  70% { transform: translateX(4px) rotate(1deg); }
  85% { transform: translateX(-2px); }
}

.banana-scene.state-error {
  animation: banana-shake 0.5s ease-out;
}

/* 撒花粒子 */
@keyframes confetti-fall {
  0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(120px) translateX(var(--drift, 0px)) rotate(720deg); opacity: 0; }
}

.confetti-particle {
  position: absolute;
  width: 6px; height: 6px;
  pointer-events: none;
  z-index: 20;
  animation: confetti-fall 1s ease-out forwards;
}

/* ─── 右侧表单区 ─── */
.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-width: 0;
  background:
    radial-gradient(circle at top right, rgba(123, 38, 232, 0.06), transparent 50%),
    #ffffff;
}

.auth-card {
  width: min(420px, 100%);
  padding: 30px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(16px);
}

.auth-brand {
  margin-bottom: 20px;
}

.auth-logo {
  height: 48px;
  width: auto;
  margin-bottom: 6px;
}

/* ─── 响应式 ─── */
@media (max-width: 960px) {
  .auth-shell {
    grid-template-columns: 1fr 1fr;
  }
  .banana-wrap { width: 80px; }
  .banana-wrap-center { width: 100px; }
  .banana-ground { width: 260px; }
  .login-brand-title { font-size: 26px; }
  .login-logo { height: 42px; }
  .deco-node, .deco-chat:nth-child(n+3) { display: none; }
}

@media (max-width: 768px) {
  .auth-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .login-area {
    min-height: 200px;
    max-height: 240px;
  }
  .login-area-content { padding: 20px 16px; gap: 12px; }
  .login-area-header { flex-direction: row; gap: 10px; }
  .login-brand-title { font-size: 22px; }
  .login-logo { height: 36px; }
  .banana-wrap { width: 60px; }
  .banana-wrap-center { width: 70px; }
  .banana-ground { width: 200px; }
  .login-area-footer { display: none; }
  .glow-orb { display: none; }
  .float-deco { display: none; }
  .deco-connections { display: none; }
  .auth-form-side { padding: 16px; }
  .auth-card { border-radius: 24px; }
}

.auth-brand h1 {
  margin: 10px 0 10px;
  font-size: 28px;
  line-height: 1.18;
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.auth-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(123, 38, 232, 0.1);
  color: #6B1FCC;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.auth-tab {
  height: 44px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  font-weight: 700;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.auth-tab.active {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.auth-tab.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.auth-panel-shell {
  min-height: 240px;
}

.auth-form.hidden {
  display: none;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-field span {
  font-size: 13px;
  color: var(--muted);
}

.auth-field input {
  height: 50px;
  border-radius: 16px;
  border: 1px solid #d8dde6;
  padding: 0 14px;
  background: white;
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.auth-field input:focus {
  outline: none;
  border-color: rgba(123, 38, 232, 0.48);
  box-shadow: 0 0 0 4px rgba(123, 38, 232, 0.12);
}

.auth-submit {
  width: 100%;
  margin-top: 6px;
  height: 50px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s ease, opacity 0.2s ease, transform 0.15s ease;
}

.auth-submit:disabled {
  opacity: 0.72;
  cursor: wait;
}

.auth-submit.loading {
  opacity: 0.85;
  pointer-events: none;
}

.auth-submit.success {
  background: linear-gradient(135deg, #059669, #10b981);
  pointer-events: none;
  transform: scale(1.02);
}

.auth-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin 0.6s linear infinite;
  flex-shrink: 0;
}

.auth-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  font-size: 12px;
  flex-shrink: 0;
  animation: auth-pop 0.25s ease;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

@keyframes auth-pop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.auth-message {
  min-height: 22px;
  margin-top: 14px;
  font-size: 13px;
}

.auth-message.pending {
  color: #6B1FCC;
}

.auth-message.success {
  color: var(--green);
}

.auth-message.error {
  color: var(--red);
}

.auth-captcha {
  position: relative;
}

.auth-hp {
  position: absolute;
  left: -9999px;
  top: -9999px;
  height: 0;
  overflow: hidden;
}

.captcha-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.captcha-question {
  font-size: 15px;
  color: var(--text);
  letter-spacing: 0.5px;
}

.captcha-refresh {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s ease, transform 0.2s ease;
}

.captcha-refresh:hover {
  color: var(--purple);
  transform: rotate(90deg);
}

.auth-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.auth-field select {
  height: 50px;
  border-radius: 16px;
  border: 1px solid #d8dde6;
  padding: 0 14px;
  background: white;
  color: var(--text);
  font: inherit;
  width: 100%;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.auth-field select:focus {
  outline: none;
  border-color: rgba(123, 38, 232, 0.48);
  box-shadow: 0 0 0 4px rgba(123, 38, 232, 0.12);
}

.setup-card {
  width: min(600px, 100%);
}

.setup-form {
  display: grid;
  gap: 16px;
}

.setup-models-section {
  display: grid;
  gap: 10px;
}

.setup-models-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

.setup-model-labels {
  display: grid;
  grid-template-columns: 1fr 1fr 36px;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  padding: 0 2px;
}

.setup-model-list {
  display: grid;
  gap: 8px;
}

.setup-model-row {
  display: grid;
  grid-template-columns: 1fr 1fr 36px;
  gap: 8px;
  align-items: center;
}

.setup-model-row input {
  height: 44px;
  border-radius: 12px;
  border: 1px solid #d8dde6;
  padding: 0 12px;
  background: white;
  color: var(--text);
  font: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.setup-model-row input:focus {
  outline: none;
  border-color: rgba(123, 38, 232, 0.48);
  box-shadow: 0 0 0 4px rgba(123, 38, 232, 0.12);
}

.model-remove-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.model-remove-btn:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.3);
  color: var(--red);
}

.settings-group {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin: 0;
  display: grid;
  gap: 14px;
}

.settings-group legend {
  padding: 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.settings-key-hint {
  margin-left: 6px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-back {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
}

.settings-back:hover {
  color: var(--text);
}

.needs-setup-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px;
  border-radius: 16px;
  border: 1px solid rgba(220, 38, 38, 0.18);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.1);
  color: #b91c1c;
  font-size: 14px;
  backdrop-filter: blur(10px);
}

.needs-setup-banner .small-btn {
  white-space: nowrap;
  text-decoration: none;
  border-color: rgba(220, 38, 38, 0.3);
  color: #b91c1c;
}

.needs-setup-banner .small-btn:hover {
  background: rgba(220, 38, 38, 0.08);
}

a.tool-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}



.settings-account-info {
  font-size: 14px;
  color: var(--text);
  margin: 0;
}

.settings-shell {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

.settings-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.settings-section h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.settings-hint {
  font-size: 12px;
  color: var(--muted);
  margin: -4px 0 12px;
  line-height: 1.5;
}

.settings-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.settings-stat-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.settings-stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.settings-stat-value {
  font-size: 20px;
  font-weight: 700;
}

.settings-stat-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.settings-balance {
  color: rgb(12, 140, 108);
}

.settings-table-wrap {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.settings-table th,
.settings-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.settings-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  z-index: 1;
}

.settings-muted {
  color: var(--muted);
  font-size: 13px;
}

.settings-form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.settings-label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  min-width: 200px;
}

.settings-label input {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

.settings-label input:focus {
  outline: none;
  border-color: rgba(107, 31, 204, 0.4);
  box-shadow: 0 0 0 3px rgba(107, 31, 204, 0.08);
}

.settings-msg {
  margin-top: 8px;
  font-size: 13px;
  min-height: 18px;
}

.settings-msg.ok { color: var(--green); }
.settings-msg.err { color: var(--red); }

.settings-key-status {
  margin-bottom: 10px;
  font-size: 13px;
}

.settings-key-active {
  color: rgb(12, 140, 108);
  font-weight: 500;
}

.settings-key-inactive {
  color: var(--muted);
}

.settings-key-info {
  font-size: 13px;
  color: var(--text);
}

.settings-key-info code {
  font-size: 12px;
  padding: 2px 6px;
  background: var(--surface-soft);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.settings-key-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: rgba(107, 31, 204, 0.06);
  border: 1px solid rgba(107, 31, 204, 0.18);
  font-size: 13px;
  color: var(--accent-strong);
}

.settings-key-link {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.settings-key-link:hover {
  text-decoration: underline;
}

.settings-model-keys {
  margin: 12px 0;
}

.settings-model-keys h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px;
}

.settings-model-keys-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-model-key-row {
  display: grid;
  grid-template-columns: 140px 1fr 1fr;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.settings-model-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-model-key-status {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-model-key-input {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

.settings-model-key-input:focus {
  outline: none;
  border-color: rgba(107, 31, 204, 0.4);
  box-shadow: 0 0 0 3px rgba(107, 31, 204, 0.08);
}

.settings-readonly-note {
  margin: 16px 0;
  padding: 14px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.settings-readonly-note p {
  margin: 0 0 6px;
}

.settings-readonly-note p:last-child {
  margin-bottom: 0;
}

/* ── Conclusion node ── */

.conclusion-node {
  width: 520px;
  border: 1.5px solid rgba(123, 38, 232, 0.35);
  background: rgba(255, 255, 255, 0.98);
}

.conclusion-header {
  background: linear-gradient(135deg, rgba(123, 38, 232, 0.08), rgba(123, 38, 232, 0.02));
}

.conclusion-dot {
  background: rgb(16, 163, 127) !important;
}

.conclusion-badge {
  font-size: 11px;
}

.conclusion-badge.ok {
  background: rgba(123, 38, 232, 0.12);
  color: rgb(12, 140, 108);
}

.conclusion-badge.err {
  background: rgba(220, 38, 38, 0.1);
  color: var(--red);
}

.conclusion-body {
  padding: 12px 16px;
  max-height: 600px;
  overflow-y: auto;
}

.conclusion-md {
  font-size: 13px;
  line-height: 1.65;
}

.conclusion-actions {
  display: flex;
  gap: 8px;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
}

.conclusion-actions .small-btn.active {
  background: rgba(123, 38, 232, 0.1);
  border-color: rgba(123, 38, 232, 0.3);
  color: rgb(12, 140, 108);
}

.auth-admin-link {
  margin-top: 12px;
}

.search-organized-content {
  font-size: 13px;
  line-height: 1.6;
  padding: 8px 0;
}

.conclusion-hint {
  font-size: 12px;
  color: rgb(12, 140, 108);
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(123, 38, 232, 0.08);
  border: 1px solid rgba(123, 38, 232, 0.2);
  white-space: nowrap;
}

/* ── Modal dialog ──────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0);
  transition: background 0.18s ease, backdrop-filter 0.18s ease;
}
.modal-overlay.active {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}
.modal-dialog {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 14px;
  padding: 28px 30px 22px;
  min-width: 340px;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  transform: scale(0.94) translateY(8px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.modal-overlay.active .modal-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text, #1a1a2e);
}
.modal-message {
  font-size: 14px;
  color: var(--text-secondary, #6b7280);
  line-height: 1.6;
  margin-bottom: 16px;
}
.modal-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  background: var(--bg, #f5f5f5);
  color: var(--text, #1a1a2e);
  outline: none;
  margin-bottom: 18px;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}
.modal-input:focus {
  border-color: var(--accent, #6b1fc8);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.modal-btn {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--card-bg, #fff);
  color: var(--text, #1a1a2e);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.modal-btn:hover {
  background: var(--bg, #f5f5f5);
}
.modal-btn.modal-confirm {
  background: var(--accent, #6b1fc8);
  color: #fff;
  border-color: var(--accent, #6b1fc8);
}
.modal-btn.modal-confirm:hover {
  opacity: 0.9;
}
.modal-btn.modal-confirm.danger {
  background: #dc2626;
  border-color: #dc2626;
}
.modal-btn.modal-confirm.danger:hover {
  background: #b91c1c;
}

/* ── Preview fullscreen modal ──────────────────────────────────────────────── */

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0);
  transition: background 0.2s ease, backdrop-filter 0.2s ease;
}
.preview-overlay.active {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}
.preview-dialog {
  width: 90vw;
  max-width: 900px;
  height: 88vh;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
  transform: scale(0.95) translateY(12px);
  opacity: 0;
  transition: transform 0.24s ease, opacity 0.24s ease;
  overflow: hidden;
}
.preview-overlay.active .preview-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  flex-shrink: 0;
}
.preview-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text, #1a1a2e);
}
.preview-actions {
  display: flex;
  gap: 8px;
}
.preview-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--surface, #fff);
  color: var(--text, #1a1a2e);
  cursor: pointer;
  transition: background 0.15s ease;
}
.preview-btn:hover {
  background: var(--bg, #f5f5f5);
}
.preview-close {
  font-size: 16px;
  padding: 6px 10px;
  line-height: 1;
}
.preview-body {
  flex: 1;
  overflow: auto;
  padding: 28px 36px 40px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text, #1a1a2e);
}
.preview-body h1,
.preview-body h2,
.preview-body h3 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}
.preview-body h1 { font-size: 1.6em; }
.preview-body h2 { font-size: 1.35em; }
.preview-body h3 { font-size: 1.15em; }
.preview-body p {
  margin: 0.6em 0;
}
.preview-body pre {
  background: var(--bg, #f5f5f5);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
.preview-body code {
  background: var(--bg, #f5f5f5);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}
.preview-body pre code {
  background: none;
  padding: 0;
}
.preview-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}
.preview-body th,
.preview-body td {
  border: 1px solid var(--border, #e5e7eb);
  padding: 8px 12px;
  text-align: left;
}
.preview-body th {
  background: var(--bg, #f5f5f5);
  font-weight: 600;
}
.preview-body blockquote {
  border-left: 3px solid var(--accent, #7B26E8);
  padding-left: 16px;
  margin: 1em 0;
  color: var(--muted, #6b7280);
}
.preview-body img {
  max-width: 100%;
  border-radius: 8px;
}
.preview-body ul,
.preview-body ol {
  padding-left: 1.5em;
}
.preview-body li {
  margin: 0.3em 0;
}

/* 搜索方向指示样式 */
.search-direction {
  color: var(--accent, #7B26E8);
  font-size: 12px;
  padding: 4px 0;
}

/* 预览按钮高亮 */
.small-btn.preview-btn-trigger {
  color: var(--accent, #7B26E8);
  border-color: rgba(123, 38, 232, 0.3);
}
.small-btn.preview-btn-trigger:hover {
  background: rgba(123, 38, 232, 0.08);
}
