:root {
  --bg: #09090b;
  --panel: rgb(24 24 27 / 0.72);
  --panel-strong: #18181b;
  --line: #27272a;
  --line-soft: rgb(63 63 70 / 0.72);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --faint: #71717a;
  --amber: #fcd34d;
  --amber-strong: #fbbf24;
  --green: #7dd3a8;
  --red: #fca5a5;
  --blue: #93c5fd;
  --font-sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
}

button {
  font: inherit;
}

a {
  color: inherit;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgb(63 63 70) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgb(63 63 70 / 0.55);
  border-radius: 4px;
}

.app-shell {
  /* 固定应用根容器高度，避免内容把 body 撑高后触发整页滚动。 */
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  min-height: 118px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: max(18px, env(safe-area-inset-top)) 28px 18px;
  border-bottom: 1px solid var(--line);
  overflow: visible;
}

.topbar-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgb(252 211 77 / 0.82);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0;
}

.context-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  max-width: 980px;
}

.context-item {
  max-width: 100%;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid var(--line-soft);
  background: #111113;
}

.context-label,
.context-value {
  font-family: var(--font-mono);
  font-size: 10px;
}

.context-label {
  color: var(--faint);
}

.context-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.source-filter {
  position: relative;
}

.source-filter-button {
  min-width: 104px;
  text-align: left;
}

.source-filter-menu {
  position: absolute;
  top: 38px;
  right: 0;
  z-index: 10;
  width: 184px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  background: var(--panel-strong);
  box-shadow: 0 18px 44px rgb(0 0 0 / 0.36);
}

.source-filter-menu[hidden] {
  display: none;
}

.source-filter-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.source-filter-option {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
}

.source-filter-option input {
  width: 14px;
  height: 14px;
  accent-color: var(--amber);
}

.source-filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.source-filter-clear,
.source-filter-confirm {
  width: 100%;
  min-height: 28px;
  border: 1px solid var(--line-soft);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.source-filter-clear {
  background: #111113;
  color: var(--muted);
}

.source-filter-confirm {
  border-color: rgb(251 191 36 / 0.72);
  background: var(--amber);
  color: #09090b;
  font-weight: 700;
}

.data-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
}

.ghost-button,
.tab-button,
.topic-button,
.evidence-button,
.copy-button {
  border: 0;
  cursor: pointer;
}

.ghost-button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-soft);
  background: #111113;
  color: var(--text);
}

.workspace {
  /* 三栏共享同一个视口高度，但滚动只发生在各自面板内部。 */
  flex: 1;
  max-width: 100%;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: 300px minmax(420px, 1fr) 360px;
  grid-template-rows: minmax(0, 1fr);
  gap: 18px;
  padding: 18px 28px 24px;
  overflow: hidden;
}

.topic-pane,
.detail-pane,
.source-pane {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}

.tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-bottom: 1px solid var(--line);
}

.tab-button {
  min-height: 48px;
  padding: 9px 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.tab-button:nth-child(2n) {
  border-right: 0;
}

.tab-button.active {
  background: var(--amber);
  color: #09090b;
}

.tab-label {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

.tab-count {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
}

.topic-list {
  /* 左侧主题队列独立滚动，不把滚动传递给整页。 */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 0;
}

.topic-button {
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  color: var(--muted);
  background: transparent;
  border-bottom: 1px solid rgb(39 39 42 / 0.72);
}

.topic-button:hover,
.topic-button.active {
  color: var(--text);
  background: rgb(39 39 42 / 0.75);
}

.topic-button.active {
  box-shadow: inset 3px 0 0 var(--amber);
}

.topic-title {
  display: block;
  margin-bottom: 8px;
  color: inherit;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 650;
}

.topic-meta,
.source-meta,
.argument-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
}

.research-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 7px;
  margin: 12px 0 0;
}

.research-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 8px;
  border: 1px solid var(--line-soft);
  background: rgb(17 17 19 / 0.72);
}

.research-field-label,
.research-field-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 10px;
}

.research-field-label {
  color: var(--faint);
}

.research-field-value {
  color: var(--text);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border: 1px solid var(--line-soft);
  color: var(--muted);
}

.pill.confirmed,
.pill.usable,
.pill.strong {
  border-color: rgb(125 211 168 / 0.45);
  color: var(--green);
}

.pill.insufficient,
.pill.weak,
.pill.risk {
  border-color: rgb(252 165 165 / 0.45);
  color: var(--red);
}

.pill.medium,
.pill.gap {
  border-color: rgb(147 197 253 / 0.45);
  color: var(--blue);
}

.detail-content,
.source-content {
  /* 中间详情和右侧原文各自滚动，证据切换时不会带动其它栏位。 */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px;
}

.detail-title {
  margin-bottom: 10px;
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.1;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.section:first-child {
  padding-top: 0;
  border-top: 0;
}

.section h3 {
  margin-bottom: 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgb(252 211 77 / 0.82);
}

.claim-text,
.argument-statement {
  margin-bottom: 12px;
  color: #e4e4e7;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.argument-block {
  padding: 13px 14px;
  background: #111113;
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.gap-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.copy-button {
  min-height: 28px;
  padding: 0 9px;
  background: var(--amber);
  color: #09090b;
  font-size: 12px;
  font-weight: 650;
}

.evidence-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.evidence-button {
  width: 100%;
  padding: 13px 14px;
  text-align: left;
  background: #111113;
  color: var(--muted);
  border: 1px solid var(--line);
}

.evidence-button.active,
.evidence-button:hover {
  color: var(--text);
  border-color: var(--amber-strong);
}

.evidence-text {
  display: block;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.source-title {
  font-family: var(--font-display);
  font-size: 25px;
  line-height: 1.15;
  margin-bottom: 14px;
  overflow-wrap: anywhere;
}

.source-link {
  display: inline-flex;
  margin-top: 14px;
  color: var(--amber);
  text-decoration: none;
  border-bottom: 1px solid rgb(252 211 77 / 0.45);
}

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.1;
}

.empty-clear-button {
  align-self: flex-start;
  margin-top: 14px;
}

.error-box {
  border: 1px solid rgb(252 165 165 / 0.45);
  background: rgb(127 29 29 / 0.18);
  color: #fecaca;
  padding: 16px;
}

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(240px, 0.55fr);
  }

  .source-pane {
    grid-column: 1 / -1;
    min-height: 0;
  }
}

@media (max-width: 760px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  .topbar {
    height: auto;
    align-items: start;
    padding: max(22px, env(safe-area-inset-top)) 18px 16px;
    flex-direction: column;
    overflow: visible;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .workspace {
    /* 移动端三栏纵向堆叠，允许页面滚动，避免第三栏被固定视口裁掉。 */
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 170px 360px 300px;
    padding: 14px 18px 20px;
    overflow: visible;
  }

  .topic-pane,
  .detail-pane,
  .source-pane {
    min-height: 0;
  }
}
