:root {
  --canvas: #f2eee6;
  --surface: #fbfaf6;
  --surface-strong: #ffffff;
  --surface-muted: #f6f3ec;
  --ink: #202825;
  --ink-soft: #38433f;
  --muted: #707873;
  --faint: #9ba09c;
  --line: #d9d5ca;
  --line-strong: #c9c3b6;
  --accent: #b4442c;
  --accent-deep: #87311f;
  --accent-soft: #f6ded5;
  --jade: #17796a;
  --jade-soft: #dceee9;
  --amber: #d2792e;
  --amber-soft: #f7e8d6;
  --blue: #276b85;
  --blue-soft: #dceaf0;
  --plum: #6b5b7b;
  --plum-soft: #e8e1ec;
  --gold: #8b6b3f;
  --gold-soft: #ede5d8;
  --shadow-sm: 0 1px 2px rgba(31, 40, 37, 0.06), 0 8px 24px rgba(31, 40, 37, 0.04);
  --shadow-lg: 0 24px 64px rgba(31, 40, 37, 0.18);
  --radius-sm: 6px;
  --radius: 8px;
  --topbar-height: 64px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  text-rendering: optimizeLegibility;
}

body.auth-locked .app-shell {
  display: none;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

button,
[role="button"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

svg {
  display: block;
}

[data-lucide] {
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  height: 100vh;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 22%, rgba(23, 121, 106, 0.10), transparent 46%),
    radial-gradient(circle at 82% 78%, rgba(180, 68, 44, 0.10), transparent 48%),
    var(--canvas);
  background-image: radial-gradient(circle, rgba(78, 88, 83, 0.14) 1px, transparent 1px);
  background-size: 22px 22px;
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  display: flex;
  flex-direction: column;
  width: min(380px, 100%);
  gap: 14px;
  padding: 30px 28px 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-card h1 {
  margin: 10px 0 0;
  font-size: 21px;
  font-weight: 760;
}

.auth-sub {
  margin: -6px 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.auth-password-wrap {
  position: relative;
  display: block;
}

.auth-password-wrap input {
  padding-right: 42px;
}

.auth-reveal {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
}

.auth-reveal:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.auth-error {
  margin: 0;
  padding: 9px 11px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft);
  color: #6f2a1b;
  font-size: 11.5px;
  line-height: 1.6;
}

.auth-error[hidden] {
  display: none;
}

.auth-submit {
  width: 100%;
  min-height: 42px;
  margin-top: 2px;
}

.topbar {
  position: relative;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto minmax(360px, 1fr);
  align-items: center;
  gap: 24px;
  min-width: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.97);
  backdrop-filter: blur(16px);
}

.brand-cluster,
.topbar-actions,
.view-tabs,
.toolbar-group,
.modal-actions,
.composer-actions,
.evidence-summary,
.research-note {
  display: flex;
  align-items: center;
}

.brand-cluster {
  min-width: 0;
  gap: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 8px);
  grid-template-rows: repeat(2, 8px);
  width: 22px;
  height: 22px;
  gap: 3px;
  transform: rotate(45deg);
}

.brand-mark span {
  display: block;
  border-radius: 50%;
  background: var(--accent);
}

.brand-mark span:nth-child(2) {
  background: var(--jade);
}

.brand-mark span:nth-child(3) {
  grid-column: 2;
  background: var(--amber);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 760;
  letter-spacing: 0.02em;
}

.brand-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.workspace-divider {
  width: 1px;
  height: 24px;
  margin: 0 2px;
  background: var(--line);
}

.universe-switcher {
  display: flex;
  align-items: center;
  min-width: 0;
  max-width: 210px;
  gap: 8px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 630;
}

.universe-switcher:hover {
  background: var(--surface-muted);
}

.universe-switcher span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.universe-switcher [data-lucide] {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.universe-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border: 2px solid var(--surface-strong);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.view-tabs {
  align-self: stretch;
  gap: 2px;
}

.view-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 100%;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.view-tab::after {
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  content: "";
}

.view-tab:hover {
  color: var(--ink);
}

.view-tab.is-active {
  color: var(--ink);
}

.view-tab.is-active::after {
  background: var(--accent);
}

.topbar-actions {
  justify-content: flex-end;
  min-width: 0;
  gap: 8px;
}

.icon-button,
.primary-button,
.secondary-button,
.toolbar-button,
.text-button,
.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  gap: 7px;
  padding: 0 15px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 680;
  white-space: nowrap;
  transition: background 140ms ease;
}

.danger-button:hover:not(:disabled) {
  background: var(--accent-deep);
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.delete-warning {
  margin: 0;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft);
  color: #6f2a1b;
  font-size: 11.5px;
  line-height: 1.75;
}

.icon-button {
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
}

.icon-button:hover {
  border-color: var(--line);
  background: var(--surface-muted);
}

.icon-button.mini {
  width: 27px;
  height: 27px;
}

.icon-button.mini [data-lucide] {
  width: 14px;
  height: 14px;
}

.primary-button,
.secondary-button {
  min-height: 38px;
  gap: 8px;
  padding: 0 15px;
  font-weight: 680;
  white-space: nowrap;
}

.primary-button {
  background: var(--ink);
  color: #fff;
}

.primary-button:hover {
  background: #101715;
  transform: translateY(-1px);
}

.primary-button.compact {
  min-height: 36px;
  padding: 0 12px;
  background: var(--accent);
  font-size: 13px;
}

.primary-button.compact:hover {
  background: var(--accent-deep);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
}

.secondary-button:hover {
  border-color: var(--ink-soft);
  background: var(--surface-muted);
}

.text-button {
  padding: 2px 4px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 680;
}

.text-button.is-active {
  color: var(--jade);
}

.global-search {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  width: min(340px, 30vw);
  min-width: 190px;
  height: 38px;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 1px 1px rgba(31, 40, 37, 0.03);
}

.global-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(180, 68, 44, 0.09);
}

.global-search > [data-lucide] {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.global-search input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}

.global-search input::placeholder {
  color: var(--faint);
}

.global-search kbd {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--muted);
  font-family: inherit;
  font-size: 9px;
  white-space: nowrap;
}

.search-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  z-index: 80;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
}

.search-result {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  gap: 9px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover,
.search-result.is-selected {
  background: var(--surface-muted);
}

.search-result-copy {
  min-width: 0;
}

.search-result-copy strong,
.search-result-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-copy strong {
  font-size: 13px;
}

.search-result-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.search-result-type {
  color: var(--muted);
  font-size: 10px;
}

.search-empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: 262px minmax(0, 1fr) 372px;
  min-height: 0;
}

.library-sidebar,
.center-stage,
.inspector {
  min-width: 0;
  min-height: 0;
}

.library-sidebar {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #f7f4ed;
}

.sidebar-mobile-head {
  display: none;
}

.new-universe-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  margin: 14px 14px 6px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.new-universe-card:hover {
  border-color: var(--accent);
}

.new-universe-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.new-universe-card strong,
.new-universe-card small {
  display: block;
}

.new-universe-card strong {
  font-size: 13px;
}

.new-universe-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.new-universe-card > [data-lucide] {
  width: 15px;
  color: var(--muted);
}

.sidebar-section {
  padding: 14px;
}

.sidebar-section + .sidebar-section {
  border-top: 1px solid var(--line);
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.universe-list,
.recent-list,
.type-filters {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.universe-item,
.recent-item {
  display: grid;
  align-items: center;
  width: 100%;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
}

.universe-item {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px;
  padding: 0 4px 0 0;
}

.universe-open {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  min-width: 0;
  gap: 9px;
  padding: 9px;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
}

.universe-delete {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: transparent;
  color: var(--faint);
  opacity: 0;
  transition: opacity 130ms ease, background 130ms ease, color 130ms ease;
}

.universe-item:hover .universe-delete,
.universe-item:focus-within .universe-delete {
  opacity: 1;
}

.universe-delete:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.universe-delete:focus-visible {
  opacity: 1;
}

.universe-item:hover,
.universe-item.is-active {
  background: var(--surface-strong);
}

.universe-item.is-active {
  box-shadow: inset 2px 0 0 var(--accent), var(--shadow-sm);
}

.universe-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.universe-item:nth-child(2n) .universe-icon {
  background: var(--jade-soft);
  color: var(--jade);
}

.universe-icon [data-lucide] {
  width: 14px;
  height: 14px;
}

.universe-copy {
  min-width: 0;
}

.universe-copy strong,
.universe-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.universe-copy strong {
  font-size: 12px;
}

.universe-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.universe-count {
  color: var(--faint);
  font-size: 9px;
}

.universe-count.status-processing {
  color: var(--amber);
  font-weight: 700;
}

.universe-count.status-failed {
  color: var(--accent);
  font-weight: 700;
}

.study-loading-hint {
  color: var(--jade) !important;
}

.study-loading-orb svg {
  animation: none;
}

.study-loading-orb .spin {
  animation: spin 1.1s linear infinite;
}

.recent-item {
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  padding: 8px 9px;
}

.recent-item:hover {
  background: var(--surface-strong);
}

.recent-item strong,
.recent-item small {
  display: block;
}

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

.recent-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.type-glyph {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-muted);
}

.type-glyph [data-lucide] {
  width: 14px;
  height: 14px;
}

.type-glyph.person { background: var(--accent-soft); color: var(--accent); }
.type-glyph.event { background: var(--amber-soft); color: var(--amber); }
.type-glyph.place { background: var(--jade-soft); color: var(--jade); }
.type-glyph.organization { background: var(--plum-soft); color: var(--plum); }
.type-glyph.document { background: var(--gold-soft); color: var(--gold); }
.type-glyph.concept { background: var(--blue-soft); color: var(--blue); }
.type-glyph.time { background: #eee9cf; color: #796f36; }

.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
}

.filter-row:hover {
  background: var(--surface-strong);
}

.filter-main {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.filter-check {
  position: relative;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface-strong);
}

.filter-row.is-active .filter-check {
  border-color: var(--type-color);
  background: var(--type-color);
}

.filter-row.is-active .filter-check::after {
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  content: "";
  transform: rotate(42deg);
}

.filter-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 630;
}

.filter-name [data-lucide] {
  width: 14px;
  height: 14px;
  color: var(--type-color);
}

.filter-count {
  color: var(--faint);
  font-size: 9px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 13px 14px;
  border-top: 1px solid var(--line);
}

.pipeline-status {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: center;
  flex: 1;
  gap: 8px;
}

.pipeline-status strong,
.pipeline-status small {
  display: block;
}

.pipeline-status strong {
  font-size: 10px;
}

.pipeline-status small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 0 4px rgba(23, 121, 106, 0.12);
}

.center-stage {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  background: var(--canvas);
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.82);
}

.stage-title {
  min-width: 0;
}

.eyebrow {
  display: block;
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stage-title h1,
.timeline-header h2,
.evidence-header h2,
.modal-head h2 {
  margin: 4px 0 0;
  letter-spacing: 0;
}

.stage-title h1 {
  overflow: hidden;
  font-size: 17px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-toolbar {
  display: flex;
  align-items: center;
  flex: none;
  gap: 8px;
}

.toolbar-group {
  gap: 3px;
}

.toolbar-button {
  min-height: 34px;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.toolbar-button:hover,
.toolbar-button.is-active {
  border-color: var(--line);
  background: var(--surface-strong);
  color: var(--ink);
}

.toolbar-button [data-lucide] {
  width: 15px;
  height: 15px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
}

.view-panel {
  position: relative;
  display: none;
  min-width: 0;
  min-height: 0;
}

.view-panel.is-active {
  display: block;
}

.graph-panel.is-active {
  display: block;
}

.graph-canvas {
  position: absolute;
  inset: 0;
  background-color: var(--canvas);
  background-image: radial-gradient(circle, rgba(78, 88, 83, 0.17) 1px, transparent 1px);
  background-size: 22px 22px;
}

.graph-canvas.is-tracing {
  cursor: crosshair;
}

.graph-empty {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  width: 100%;
  border: 0;
  place-content: center;
  justify-items: center;
  background: rgba(242, 238, 230, 0.96);
  color: inherit;
  text-align: center;
  cursor: pointer;
}

.graph-empty[hidden] {
  display: none;
}

.graph-empty:hover strong {
  color: var(--accent);
}

.graph-empty span {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--muted);
}

.graph-empty strong {
  margin-top: 14px;
}

.graph-empty p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.graph-empty em {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-top: 15px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--ink-soft);
  font-size: 10px;
  font-style: normal;
  font-weight: 680;
}

.graph-overlay {
  position: absolute;
  z-index: 4;
  pointer-events: none;
}

.graph-overlay.top-left {
  top: 14px;
  left: 14px;
  display: flex;
  gap: 7px;
}

.graph-stat {
  min-width: 66px;
  padding: 8px 10px;
  border: 1px solid rgba(201, 195, 182, 0.85);
  border-radius: var(--radius-sm);
  background: rgba(251, 250, 246, 0.9);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.graph-stat strong,
.graph-stat span {
  display: block;
}

.graph-stat strong {
  font-size: 16px;
  line-height: 1;
}

.graph-stat span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.legend-box {
  bottom: 14px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  max-width: min(470px, 58%);
  gap: 5px 10px;
  padding: 8px 10px;
  border: 1px solid rgba(201, 195, 182, 0.85);
  border-radius: var(--radius-sm);
  background: rgba(251, 250, 246, 0.9);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 9px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--legend-color);
}

.graph-readout {
  right: 14px;
  bottom: 14px;
  padding: 7px 9px;
  border: 1px solid rgba(201, 195, 182, 0.85);
  border-radius: var(--radius-sm);
  background: rgba(251, 250, 246, 0.86);
  color: var(--muted);
  font-size: 9px;
}

.trace-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
  color: var(--ink-soft);
  font-size: 11px;
  transform: translateX(-50%);
}

.trace-banner [data-lucide] {
  color: var(--accent);
}

.timeline-panel,
.evidence-panel {
  overflow-y: auto;
  background: var(--surface);
}

.study-panel {
  background: var(--surface);
}

.study-panel.is-active {
  display: block;
}

.study-scroll {
  height: 100%;
  overflow-y: auto;
  padding-bottom: 60px;
}

.study-loading {
  display: grid;
  min-height: 60vh;
  place-content: center;
  justify-items: center;
  padding: 40px;
  text-align: center;
}

.study-loading[hidden] {
  display: none;
}

.study-loading-orb {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  animation: pulse-status 1.2s ease-in-out infinite alternate;
}

.study-loading strong {
  margin-top: 16px;
  font-size: 15px;
}

.study-loading p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.study-loading .secondary-button {
  margin-top: 16px;
}

.study-content {
  max-width: 980px;
  margin: 0 auto;
  padding: 26px 28px 0;
}

.study-hero {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.study-hero h2 {
  margin: 9px 0 0;
  font-size: 25px;
  line-height: 1.35;
  font-weight: 760;
}

.study-overview {
  margin: 12px 0 0;
  max-width: 76ch;
  color: var(--ink-soft);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  font-size: 14px;
  line-height: 1.9;
}

.study-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.study-meta {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink-soft);
  font-size: 10px;
}

.study-meta [data-lucide] {
  width: 13px;
  height: 13px;
  color: var(--accent);
}

.study-meta-action {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}

.study-meta-action:hover {
  background: #f2cec2;
}

.study-howto {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 18px;
  padding: 13px 15px;
  border-left: 3px solid var(--accent);
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 11px;
}

.study-howto span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.study-howto strong {
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
}

.study-section {
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}

.study-section:last-child {
  border-bottom: 0;
}

.study-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.study-section-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 720;
}

.study-section-head span {
  color: var(--muted);
  font-size: 10px;
}

.bigidea-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.bigidea-card {
  position: relative;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  transition: border-color 140ms ease, transform 140ms ease;
}

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

.bigidea-index {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.bigidea-card h4 {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 720;
}

.bigidea-card p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 11.5px;
  line-height: 1.8;
}

.study-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 11px;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-size: 10px;
  font-weight: 680;
}

.module-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.module-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.module-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}

.module-order {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.module-head h4 {
  margin: 10px 0 0;
  font-size: 16px;
  font-weight: 740;
}

.module-head p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 11.5px;
}

.module-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 10px;
}

.keypoint-list {
  padding: 4px 18px 14px;
}

.keypoint {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px dashed var(--line);
}

.keypoint:last-child {
  border-bottom: 0;
}

.keypoint-index {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 760;
}

.keypoint-body h5 {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 720;
}

.keypoint-body p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.85;
}

.keypoint-why strong,
.keypoint-action strong {
  color: var(--ink);
}

.keypoint-action {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--jade-soft);
  color: #14584d !important;
}

.study-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 11px;
}

.study-entity-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink-soft);
  font-size: 10px;
}

.study-entity-chip [data-lucide] {
  color: var(--chip-color);
}

.study-entity-chip:hover {
  border-color: var(--chip-color);
}

.learning-path {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.learning-path li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.path-step {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.learning-path strong {
  font-size: 13px;
}

.learning-path p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

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

.entity-tile {
  display: grid;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  text-align: left;
}

.entity-tile:hover {
  border-color: var(--tile-color);
}

.entity-tile-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--tile-color) 14%, #fff);
  color: var(--tile-color);
}

.entity-tile strong {
  margin-top: 10px;
  font-size: 13px;
}

.entity-tile small {
  margin-top: 3px;
  color: var(--tile-color);
  font-size: 9px;
  font-weight: 680;
}

.entity-tile p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.65;
}

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

.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.faq-item summary {
  padding: 13px 15px;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
}

.faq-item p {
  margin: 0;
  padding: 0 15px 14px;
  color: var(--ink-soft);
  font-size: 11.5px;
  line-height: 1.85;
}

.study-next-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.timeline-header,
.evidence-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 86px;
  gap: 18px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.96);
  backdrop-filter: blur(12px);
}

.timeline-header h2,
.evidence-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.timeline-person-picks {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 55%;
  gap: 5px;
}

.person-pick {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 10px;
}

.person-pick::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--person-color);
  content: "";
}

.person-pick.is-active {
  border-color: color-mix(in srgb, var(--person-color) 55%, var(--line));
  background: color-mix(in srgb, var(--person-color) 8%, var(--surface-strong));
  color: var(--ink);
}

.person-pick.is-capped {
  opacity: 0.52;
}

.timeline-pick-count {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.timeline-scroll {
  overflow: auto;
  padding: 18px 20px 48px;
}

.timeline-canvas {
  position: relative;
  min-width: 900px;
  padding-left: 92px;
}

.timeline-axis {
  position: absolute;
  top: 35px;
  right: 0;
  bottom: 0;
  left: 92px;
  border-top: 1px solid var(--line-strong);
}

.timeline-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed rgba(116, 126, 120, 0.18);
}

.timeline-tick span {
  position: absolute;
  top: -18px;
  left: -15px;
  color: var(--muted);
  font-size: 9px;
}

.timeline-lane {
  position: relative;
  min-height: 72px;
  border-bottom: 1px solid rgba(217, 213, 202, 0.74);
}

.timeline-lane:last-child {
  border-bottom: 0;
}

.lane-label {
  position: absolute;
  top: 19px;
  left: -82px;
  width: 72px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 680;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lane-track {
  position: absolute;
  top: 32px;
  right: 0;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--lane-color) 20%, var(--line));
}

.timeline-event {
  position: absolute;
  top: 26px;
  z-index: 2;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--lane-color);
  box-shadow: 0 0 0 1px var(--lane-color);
}

.timeline-event:hover,
.timeline-event.is-selected {
  z-index: 4;
  transform: scale(1.25);
}

.timeline-event-label {
  position: absolute;
  top: -149px;
  left: 50%;
  width: max-content;
  max-width: 120px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.2;
  text-align: center;
  transform: translateX(-50%);
  white-space: normal;
}

.timeline-event-tooltip {
  position: absolute;
  top: 24px;
  z-index: 5;
  width: 220px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
}

.timeline-event-tooltip strong,
.timeline-event-tooltip small {
  display: block;
}

.timeline-event-tooltip small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.5;
}

.evidence-header {
  align-items: center;
}

.evidence-summary {
  gap: 14px;
  color: var(--muted);
  font-size: 10px;
}

.evidence-summary strong {
  color: var(--ink);
  font-size: 16px;
}

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px 48px;
}

.source-card {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.source-card::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--source-color);
  content: "";
}

.source-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.source-card-head strong {
  display: block;
  font-size: 14px;
}

.source-card-head small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.source-kind {
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.source-excerpt {
  margin: 15px 0 0;
  color: var(--ink-soft);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  font-size: 12px;
  line-height: 1.8;
}

.source-citations {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.citation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  text-align: left;
}

.citation-row:hover {
  background: var(--canvas);
}

.citation-copy {
  min-width: 0;
}

.citation-copy strong,
.citation-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.citation-copy strong {
  font-size: 10px;
}

.citation-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.inspector {
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  border-left: 1px solid var(--line);
  background: var(--surface-strong);
}

.inspector-tabs {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 3px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
}

.inspector-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  gap: 7px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.inspector-tab.is-active {
  color: var(--ink);
}

.inspector-tab.is-active::after {
  position: absolute;
  right: 8px;
  bottom: -1px;
  left: 8px;
  height: 2px;
  background: var(--accent);
  content: "";
}

.tab-live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--jade);
}

.inspector-close-mobile {
  display: none;
  margin-left: auto;
}

.inspector-panel {
  display: none;
  min-height: 0;
}

.inspector-panel.is-active {
  display: block;
}

.inspector-panel.ai-panel.is-active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.entity-wiki {
  overflow-y: auto;
  height: 100%;
}

.wiki-hero {
  position: relative;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.wiki-hero::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--entity-color);
  content: "";
}

.wiki-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wiki-type-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--entity-color) 14%, #fff);
  color: var(--entity-color);
}

.wiki-type-copy strong,
.wiki-type-copy small {
  display: block;
}

.wiki-type-copy strong {
  font-size: 11px;
}

.wiki-type-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.wiki-hero h2 {
  margin: 17px 0 0;
  font-size: 25px;
  font-weight: 760;
  letter-spacing: 0;
}

.wiki-period {
  display: inline-flex;
  margin-top: 6px;
  color: var(--muted);
  font-family: "Noto Serif SC", "Source Han Serif SC", serif;
  font-size: 12px;
}

.wiki-summary {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  font-size: 13px;
  line-height: 1.86;
}

.wiki-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 15px;
}

.wiki-tag {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9px;
}

.wiki-actions {
  display: flex;
  gap: 7px;
  margin-top: 16px;
}

.wiki-sections {
  padding: 0 20px 40px;
}

.wiki-section {
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.wiki-section:last-child {
  border-bottom: 0;
}

.wiki-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.wiki-section-head strong {
  font-size: 11px;
}

.wiki-section-head span {
  color: var(--muted);
  font-size: 9px;
}

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

.attribute-item {
  padding: 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.attribute-item span,
.attribute-item strong {
  display: block;
}

.attribute-item span {
  color: var(--muted);
  font-size: 9px;
}

.attribute-item strong {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.5;
}

.relation-list,
.source-link-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.relation-item,
.source-link {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
}

.relation-item:hover,
.source-link:hover {
  background: var(--surface-muted);
}

.relation-glyph {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--relation-color) 13%, #fff);
  color: var(--relation-color);
}

.relation-copy,
.source-link-copy {
  min-width: 0;
}

.relation-copy strong,
.relation-copy small,
.source-link-copy strong,
.source-link-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relation-copy strong,
.source-link-copy strong {
  font-size: 10px;
}

.relation-copy small,
.source-link-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.confidence {
  color: var(--muted);
  font-size: 9px;
}

.source-quote {
  margin: 0;
  padding: 12px 13px;
  border-left: 3px solid var(--accent);
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  font-size: 11px;
  line-height: 1.75;
}

.empty-inspector {
  display: grid;
  height: 100%;
  place-content: center;
  justify-items: center;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.empty-inspector span {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-muted);
}

.empty-inspector strong {
  margin-top: 13px;
  color: var(--ink-soft);
}

.empty-inspector p {
  margin: 5px 0 0;
  font-size: 11px;
  line-height: 1.6;
}

.ai-context {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 12px 12px 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.ai-orb {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
}

.ai-context strong,
.ai-context small {
  display: block;
}

.ai-context strong {
  font-size: 10px;
}

.ai-context small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.chat-history {
  overflow-y: auto;
  min-height: 0;
  padding: 8px 12px 12px;
}

.chat-message {
  margin-top: 10px;
}

.chat-message.user {
  display: flex;
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 92%;
  padding: 10px 11px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.65;
}

.chat-message.user .chat-bubble {
  border-radius: 8px 8px 2px 8px;
  background: var(--ink);
  color: #fff;
}

.chat-message.assistant .chat-bubble {
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.chat-bubble p {
  margin: 0;
}

.answer-section {
  margin-top: 12px;
}

.answer-section > strong {
  display: block;
  margin-bottom: 7px;
  font-size: 10px;
}

.answer-item {
  display: block;
  width: 100%;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  text-align: left;
}

.answer-item:hover {
  color: var(--ink);
}

.answer-item strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink-soft);
  font-size: 10px;
}

.answer-evidence {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.evidence-chip,
.action-chip {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink-soft);
  font-size: 9px;
}

.evidence-chip:hover,
.action-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.typing-dots {
  display: flex;
  align-items: center;
  height: 16px;
  gap: 4px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 900ms infinite alternate;
}

.typing-dots span:nth-child(2) { animation-delay: 150ms; }
.typing-dots span:nth-child(3) { animation-delay: 300ms; }

@keyframes typing {
  from { opacity: 0.25; transform: translateY(1px); }
  to { opacity: 1; transform: translateY(-1px); }
}

.ai-suggestions {
  display: flex;
  overflow-x: auto;
  gap: 5px;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
}

.suggestion-chip {
  flex: none;
  max-width: 210px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.suggestion-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-composer {
  margin: 0 12px 12px;
  padding: 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.chat-composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(180, 68, 44, 0.08);
}

.chat-composer textarea {
  display: block;
  width: 100%;
  max-height: 110px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 11px;
  line-height: 1.55;
}

.composer-actions {
  justify-content: space-between;
  margin-top: 5px;
}

.send-button {
  width: 30px;
  height: 30px;
  background: var(--accent);
  color: #fff;
}

.send-button:hover {
  background: var(--accent-deep);
}

.modal {
  width: min(580px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.modal::backdrop {
  background: rgba(23, 29, 27, 0.38);
  backdrop-filter: blur(4px);
}

.modal-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-size: 19px;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
  padding: 20px;
}

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

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

.field select {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: 0;
  background: var(--surface-strong);
  font-size: 12px;
}

.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(180, 68, 44, 0.08);
}

.field > span {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 680;
}

.field input,
.field textarea,
.source-input-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: 0;
  background: var(--surface-strong);
  font-size: 12px;
}

.field input,
.source-input-row input {
  height: 40px;
  padding: 0 11px;
}

.field textarea {
  min-height: 84px;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.6;
}

.field input:focus,
.field textarea:focus,
.source-input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(180, 68, 44, 0.08);
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 132px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-muted);
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease;
}

.drop-zone.is-dragging,
.drop-zone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone input {
  display: none;
}

.drop-icon {
  display: grid;
  width: 37px;
  height: 37px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--accent);
}

.drop-zone strong {
  margin-top: 10px;
  font-size: 12px;
}

.drop-zone small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.source-token-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-token {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 10px;
}

.source-status-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
}

.source-token[data-state="parsing"] .source-status-dot {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(210, 121, 46, 0.14);
  animation: pulse-status 1s ease-in-out infinite alternate;
}

.source-token[data-state="ready"] .source-status-dot {
  background: var(--jade);
}

.source-token[data-state="error"] .source-status-dot {
  background: var(--accent);
}

@keyframes pulse-status {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

.source-token span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-token button {
  display: grid;
  width: 16px;
  height: 16px;
  padding: 0;
  place-items: center;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.source-token button:hover {
  background: var(--line);
  color: var(--ink);
}

.source-token button [data-lucide] {
  width: 11px;
  height: 11px;
}

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

.modal-actions {
  justify-content: flex-end;
  gap: 8px;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-muted);
}

.processing-card {
  padding: 36px 38px 30px;
  text-align: center;
}

.processing-visual {
  position: relative;
  display: grid;
  width: 86px;
  height: 86px;
  margin: 0 auto 22px;
  place-items: center;
}

.processing-ring {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

.processing-core {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
}

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

.processing-card h2 {
  margin: 8px 0 0;
  font-size: 21px;
}

.processing-card > p {
  margin: 8px 0 22px;
  color: var(--muted);
  font-size: 12px;
}

.pipeline-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 19px;
}

.pipeline-step {
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.pipeline-step.is-done {
  border-color: rgba(23, 121, 106, 0.35);
  background: var(--jade-soft);
  color: var(--jade);
}

.pipeline-step.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.progress-track {
  overflow: hidden;
  height: 5px;
  border-radius: 6px;
  background: var(--line);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 220ms ease;
}

.processing-percent {
  margin-top: 10px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.evidence-card {
  width: min(640px, calc(100vw - 32px));
}

.evidence-modal-body {
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  padding: 20px;
}

.evidence-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.evidence-meta {
  padding: 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.evidence-meta span,
.evidence-meta strong {
  display: block;
}

.evidence-meta span {
  color: var(--muted);
  font-size: 9px;
}

.evidence-meta strong {
  margin-top: 4px;
  font-size: 10px;
}

.evidence-quote {
  margin: 0;
  padding: 18px;
  border-left: 3px solid var(--accent);
  background: var(--surface-muted);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  font-size: 14px;
  line-height: 1.95;
}

.research-card {
  width: min(600px, calc(100vw - 32px));
}

.research-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.research-examples button {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 10px;
}

.research-examples button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.research-note {
  flex: 1;
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
}

.research-note [data-lucide] {
  width: 13px;
  height: 13px;
  color: var(--jade);
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  max-width: 360px;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink);
  box-shadow: var(--shadow-lg);
  color: #fff;
  font-size: 10px;
  animation: toast-in 180ms ease;
}

.toast [data-lucide] {
  color: #fff;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.mobile-backdrop {
  position: fixed;
  inset: var(--topbar-height) 0 0;
  z-index: 45;
  display: none;
  background: rgba(23, 29, 27, 0.36);
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 238px minmax(0, 1fr) 340px;
  }

  .brand-copy small,
  .global-search kbd {
    display: none;
  }

  .topbar {
    grid-template-columns: minmax(220px, 1fr) auto minmax(290px, 1fr);
  }
}

@media (max-width: 1040px) {
  .workspace {
    grid-template-columns: 226px minmax(0, 1fr);
  }

  .inspector {
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    bottom: 56px;
    z-index: 70;
    width: min(390px, 92vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(102%);
    transition: transform 180ms ease;
  }

  body.inspector-open .inspector {
    transform: translateX(0);
  }

  .inspector-close-mobile {
    display: inline-flex;
  }

  .toolbar-button span {
    display: none;
  }

  .toolbar-button {
    width: 34px;
    padding: 0;
  }
}

@media (max-width: 820px) {
  :root {
    --topbar-height: 58px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 0 10px;
    background: var(--surface);
    backdrop-filter: none;
  }

  .brand-copy,
  .universe-switcher,
  .workspace-divider,
  .research-button {
    display: none;
  }

  .view-tabs {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    display: flex;
    height: 56px;
    justify-content: center;
    gap: 18px;
    border-top: 1px solid var(--line);
    background: rgba(251, 250, 246, 0.98);
    backdrop-filter: blur(14px);
  }

  .view-tab {
    height: 56px;
    padding: 0 10px;
  }

  .view-tab::after {
    right: 5px;
    left: 5px;
  }

  .topbar-actions {
    gap: 4px;
  }

  .global-search {
    width: min(45vw, 280px);
    min-width: 145px;
  }

  .primary-button.compact span {
    display: none;
  }

  .primary-button.compact {
    width: 36px;
    padding: 0;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .library-sidebar {
    position: fixed;
    top: var(--topbar-height);
    bottom: 56px;
    left: 0;
    z-index: 70;
    width: min(310px, 88vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

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

  body.sidebar-open .mobile-backdrop,
  body.inspector-open .mobile-backdrop {
    display: block;
  }

  .sidebar-mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
  }

  .universe-delete {
    opacity: 1;
    color: var(--muted);
  }

  .center-stage {
    grid-template-rows: 60px minmax(0, 1fr);
    padding-bottom: 56px;
  }

  .stage-header {
    gap: 8px;
    padding: 0 10px;
  }

  .stage-title h1 {
    max-width: 42vw;
    font-size: 14px;
  }

  .eyebrow {
    font-size: 8px;
  }

  .graph-toolbar {
    overflow-x: auto;
  }

  .toolbar-divider {
    display: none;
  }

  .graph-toolbar .icon-button {
    width: 32px;
    height: 32px;
  }

  .legend-box,
  .graph-readout {
    display: none;
  }

  .timeline-header,
  .evidence-header {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
    gap: 10px;
  }

  .study-content {
    padding: 18px 16px 0;
  }

  .study-hero h2 {
    font-size: 20px;
  }

  .study-section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .keypoint {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .keypoint-index {
    width: 22px;
    height: 22px;
    font-size: 10px;
  }

  .bigidea-grid,
  .entity-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline-person-picks {
    justify-content: flex-start;
    max-width: 100%;
  }

  .evidence-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal-body {
    max-height: calc(100vh - 230px);
  }

  .mobile-backdrop {
    bottom: 56px;
  }

  .toast-region {
    bottom: 70px;
  }
}

@media (max-width: 520px) {
  .global-search {
    width: 42vw;
  }

  .sidebar-toggle,
  #create-universe-button {
    width: 32px;
    height: 32px;
  }

  .stage-title h1 {
    max-width: 35vw;
  }

  .toolbar-group:first-child .toolbar-button:nth-child(2) {
    display: none;
  }

  .pipeline-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .processing-card {
    padding: 30px 22px 24px;
  }

  .evidence-meta-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .modal-actions > button {
    width: 100%;
  }

  .research-note {
    justify-content: center;
  }

  .attribute-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .field-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

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