:root {
  --paper: #f5f5f7;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --panel: rgba(255, 255, 255, .82);
  --panel-strong: rgba(255, 255, 255, .94);
  --line: rgba(0, 0, 0, .06);
  --graph: #0b0f14;
  --graph-2: #111827;
  --teal: #007aff;
  --teal-dark: #145caa;
  --cinnabar: #bf5b45;
  --ochre: #8e8e93;
  --blue: #007aff;
  --green: #30d158;
  --shadow: 0 18px 40px rgba(0, 0, 0, .06);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

[hidden] {
  display: none !important;
}

html,
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(0, 122, 255, .08), transparent 28%),
    radial-gradient(circle at 90% 8%, rgba(100, 210, 255, .12), transparent 26%),
    linear-gradient(180deg, #fbfbfd 0%, #f2f3f6 100%);
  background-size: auto;
}

.topbar {
  height: 72px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
  box-shadow: none;
  backdrop-filter: blur(28px);
  position: sticky;
  top: 0;
}

.topbar-title h1,
h1 {
  font-size: 20px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.subline {
  color: var(--muted);
}

.view-switch {
  gap: 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.view-button {
  min-width: auto;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(18px);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.view-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .06);
}

.view-button.is-active {
  background: var(--blue);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(0, 122, 255, .18);
}

.workspace {
  padding: 12px 20px 14px;
}

.app {
  gap: 20px;
  grid-template-columns: minmax(620px, 2fr) minmax(340px, 1fr);
}

.graph-pane {
  padding: 0;
  border-right: 0;
  background: transparent;
  grid-template-rows: minmax(620px, 1fr) auto auto auto auto;
  gap: 14px;
  overflow-y: auto;
  padding-right: 4px;
}

.kg-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.kg-section-head h1 {
  font-size: 18px;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(48, 209, 88, .22);
  border-radius: 999px;
  background: rgba(48, 209, 88, .08);
  color: #1b7f37;
  font-size: 12px;
  white-space: nowrap;
}

.sync-pill span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(48, 209, 88, .13);
}

.metric-strip {
  gap: 12px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.metric {
  min-height: 72px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .045);
  backdrop-filter: blur(20px);
}

.metric b {
  color: var(--blue);
  font-family: inherit;
  font-size: 28px;
  font-weight: 780;
  letter-spacing: -0.04em;
}

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

.graph-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 330px) 145px 92px;
  gap: 10px;
  align-items: center;
  min-height: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .045);
  backdrop-filter: blur(20px);
}

.filter-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  min-width: 0;
  white-space: nowrap;
}

.legend-row {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .75);
  color: #424245;
  padding: 8px 11px;
  font-size: 12px;
  cursor: pointer;
}

.legend-row.is-active {
  background: #1d1d1f;
  color: white;
  border-color: transparent;
}

.graph-controls input,
.graph-controls select,
.composer input {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(245, 245, 247, .92);
  color: var(--ink);
  padding: 10px 13px;
  font-size: 13px;
}

.graph-controls input:focus,
.graph-controls select:focus,
.composer input:focus {
  border-color: rgba(0, 122, 255, .38);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, .08);
}

.reset,
.send {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  color: var(--ink);
  font-size: 13px;
}

.reset {
  padding: 10px 12px;
}

.send:hover,
.reset:hover {
  background: white;
  border-color: rgba(0, 122, 255, .22);
}

.graph-shell {
  border: 0;
  border-radius: 24px;
  background: #0b0f14;
  box-shadow: none;
  min-height: 620px;
}

.graph-shell::before {
  display: none;
}

.graph-topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.graph-badge,
.graph-toolset {
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  backdrop-filter: blur(20px);
}

.graph-badge {
  padding: 8px 12px;
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
}

.graph-toolset {
  display: flex;
  gap: 7px;
  padding: 6px;
}

.graph-tool {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: rgba(255, 255, 255, .84);
  background: rgba(255, 255, 255, .08);
  cursor: pointer;
}

.graph-meta {
  overflow: visible;
}

.details {
  min-height: 138px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .045);
  backdrop-filter: blur(20px);
  padding: 18px;
}

.details h2 {
  font-size: 18px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

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

.kv div {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(245, 245, 247, .78);
}

.detail-map-action,
.map-popup-action,
.map-search button {
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: white;
  box-shadow: 0 10px 18px rgba(0, 122, 255, .18);
}

.chat-pane.ai-panel {
  position: sticky;
  top: 92px;
  height: calc(100vh - 110px);
  min-height: 690px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  overflow: hidden;
}

.chat-head {
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 18% 6%, rgba(0, 122, 255, .12), transparent 40%),
    rgba(255, 255, 255, .72);
  padding: 20px 20px 16px;
}

.chat-title h2 {
  font-size: 18px;
  font-weight: 760;
}

.status {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.agent-interaction-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  border-bottom: 0;
  background: transparent;
}

.xiaobei-assistant-top {
  grid-template-columns: 54px minmax(0, 1fr);
  padding: 18px 20px 12px;
}

.xiaobei-avatar-stage {
  width: 54px;
  height: 54px;
}

.xiaobei-avatar-mark {
  width: 52px;
  height: 52px;
  border: 0;
  background: linear-gradient(145deg, #007aff, #64d2ff);
  box-shadow: 0 10px 26px rgba(0, 122, 255, .22);
  font-size: 12px;
}

.xiaobei-sound-ring {
  display: none;
}

.xiaobei-hero-copy > span {
  color: #1b7f37;
  font-size: 12px;
  font-weight: 600;
}

.xiaobei-hero-copy h2 {
  color: var(--ink);
  font-size: 16px;
  font-weight: 760;
}

.xiaobei-hero-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.xiaobei-state-bubble {
  padding: 6px 10px;
  border-radius: 999px;
  color: #145caa;
  background: rgba(0, 122, 255, .07);
  box-shadow: none;
}

.state-dots i {
  background: var(--green);
}

.current-context {
  margin: 0 20px 14px;
  border: 1px solid rgba(0, 122, 255, .1);
  border-radius: 18px;
  background: rgba(0, 122, 255, .07);
  padding: 12px 13px;
  color: #145caa;
  font-size: 12px;
  line-height: 1.55;
}

.voice-agent-widget {
  min-height: 0;
}

.voice-agent-panel {
  min-height: 0;
}

.voice-agent-log {
  min-height: 0;
  max-height: none;
  height: 100%;
  margin: 0;
  padding: 18px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

#voice-agent-widget {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#voice-agent-widget .voice-agent-panel {
  height: 100%;
}

.voice-agent-message {
  max-width: 84%;
  border-radius: 16px 16px 16px 6px;
  font-size: 13px;
  line-height: 1.68;
}

.voice-agent-message.bot {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #f5f5f7;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .035);
}

.voice-agent-message.bot::before {
  content: "AI";
  color: white;
  background: var(--blue);
}

.voice-agent-message.user {
  margin-left: auto;
  border-radius: 16px 16px 6px 16px;
  background: var(--blue);
  color: white;
  box-shadow: none;
}

.xiaobei-scroll-section {
  padding: 12px 18px 14px;
  border-width: 1px 0 0;
  border-color: var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, .56);
}

.agent-quick-prompts h3 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.quick-demand-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agent-quick-prompts button {
  min-height: auto;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(245, 245, 247, .86);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.voice-agent-input-zone {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
}

.xiaobei-input-row {
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
}

.xiaobei-input-wrap {
  display: flex;
  align-items: center;
  min-height: 52px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 999px;
  background: rgba(245, 245, 247, .95);
  padding: 8px 10px 8px 44px;
}

.xiaobei-input-wrap:focus-within {
  border-color: rgba(0, 122, 255, .38);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, .08);
  background: white;
}

#voice-agent-input {
  min-height: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  line-height: 34px;
  font-size: 14px;
}

.input-mic-button {
  left: 14px;
  color: var(--muted);
}

.send-icon-button {
  width: 40px;
  height: 40px;
  min-height: 40px;
  background: var(--blue);
  box-shadow: 0 10px 18px rgba(0, 122, 255, .22);
  font-size: 18px;
}

#voice-agent-count {
  right: 64px;
  bottom: -18px;
  color: var(--muted);
}

.voice-agent-actions {
  margin-top: 12px;
}

.voice-agent-actions button {
  border-color: var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
}

.legacy-chat,
.legacy-composer {
  display: none !important;
}

.map-workspace {
  height: calc(100vh - 72px);
  background: transparent;
  padding: 22px 28px 16px;
  gap: 20px;
}

.map-sidebar {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.map-sidebar-head {
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 6%, rgba(0, 122, 255, .1), transparent 40%),
    rgba(255, 255, 255, .72);
  border-bottom: 1px solid var(--line);
}

.map-sidebar-head .map-subtitle,
.map-count,
.map-resource-card span,
.map-popup p {
  color: var(--muted);
}

.map-resource-card,
.map-search {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .05);
}

.map-search input,
.map-search select,
.map-side-search input {
  border-color: var(--line);
  border-radius: 999px;
  background: rgba(245, 245, 247, .95);
}

#cultureMap {
  border-radius: var(--radius-lg);
  background: #eef1f4;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .topbar {
    height: auto;
    min-height: 82px;
    display: grid;
    align-items: start;
    padding: 16px 14px;
  }

  .workspace,
  .map-workspace {
    height: auto;
    padding: 16px 14px;
  }

  .app {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .graph-pane {
    overflow: visible;
  }

  .graph-shell {
    height: 560px;
    min-height: 560px;
  }

  .chat-pane.ai-panel {
    position: static;
    height: auto;
    min-height: 680px;
  }
}

@media (max-width: 720px) {
  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .graph-controls {
    grid-template-columns: 1fr;
  }

  .kv {
    grid-template-columns: 1fr;
  }

  .view-switch {
    justify-content: flex-start;
    overflow-x: auto;
  }
}
