:root {
  color-scheme: dark;
  --bg: #0f1114;
  --panel: #171a1e;
  --panel-2: #1d2127;
  --panel-3: #222830;
  --text: #edf0f3;
  --muted: #a7b0bb;
  --faint: #6d7682;
  --line: #303741;
  --line-soft: #252b33;
  --accent: #d6b35a;
  --accent-2: #7aa8ff;
  --danger: #e18a77;
  --ok: #8ec7a4;
  --shadow: rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  min-height: 72px;
  padding: 14px 22px;
  display: grid;
  grid-template-columns: minmax(210px, 280px) minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 20, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--accent);
  font-weight: 700;
}

.brand strong,
.topic-button span,
.run-summary strong {
  display: block;
}

.brand small,
.run-summary span,
.eyebrow,
.source-sentence,
.section-head p,
.topic-button,
.scope-chips,
.drawer-head p,
.field-note,
.case-option span,
.case-option small,
.card-source,
.card-meta-row,
.card-kicker,
.dialogue-message span,
.source-card small,
.load-status,
.evidence-card span {
  color: var(--muted);
}

.topic-strip {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.topic-button,
.ghost-button,
.primary-button,
.icon-button,
.mobile-dialogue-toggle,
.text-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
}

.topic-button {
  max-width: 360px;
  min-width: 0;
  min-height: 42px;
  padding: 8px 12px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  text-align: left;
}

.topic-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-switch,
.provider-switch {
  min-height: 42px;
  max-width: 210px;
  padding: 6px 10px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.source-switch span,
.provider-switch span {
  white-space: nowrap;
}

.source-switch select,
.provider-switch select {
  min-width: 88px;
  max-width: 140px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-switch select:focus-visible,
.provider-switch select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.provider-switch {
  max-width: 210px;
}

.source-switch {
  max-width: 160px;
}

.provider-switch select option:disabled {
  color: #747a83;
}

.account-widget {
  min-height: 42px;
  max-width: 430px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.account-status {
  min-width: 72px;
  display: grid;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
}

.account-status strong {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.account-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
  flex-wrap: wrap;
}

.account-controls input {
  width: 150px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #101317;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.account-controls button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
}

.account-widget.is-blocked {
  border-color: rgba(225, 138, 119, 0.36);
}

.account-widget.is-active {
  border-color: rgba(142, 199, 164, 0.4);
}

.account-widget.is-pending {
  border-color: rgba(214, 179, 90, 0.48);
}

.case-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: min(560px, calc(100vw - 44px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111419;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
}

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

.case-option {
  width: 100%;
  min-height: 68px;
  padding: 10px;
  display: grid;
  gap: 4px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.case-option:hover,
.case-option.is-active {
  border-color: var(--line);
  background: var(--panel-2);
}

.case-option.is-active strong {
  color: var(--accent);
}

.case-option small {
  overflow-wrap: anywhere;
  font-size: 11px;
}

.empty-case-option {
  cursor: default;
}

.empty-case-option:hover {
  border-color: transparent;
  background: transparent;
}

.scope-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.scope-chip {
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #14171b;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.top-actions,
.composer-actions,
.drawer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.ghost-button,
.primary-button {
  max-width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0 12px;
  white-space: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ghost-button svg,
.primary-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.primary-button {
  background: var(--accent);
  color: #19170f;
  border-color: var(--accent);
  font-weight: 700;
}

.export-button.is-working {
  border-color: rgba(122, 168, 255, 0.42);
  color: var(--accent-2);
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.dialogue-panel {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.panel-head {
  min-height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.bridge-pill {
  max-width: 124px;
  padding: 4px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
}

.bridge-pill.available {
  border-color: rgba(142, 199, 164, 0.4);
  color: var(--ok);
}

.bridge-pill.unavailable {
  border-color: rgba(225, 138, 119, 0.36);
  color: var(--danger);
}

.dialogue-stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.dialogue-message {
  width: fit-content;
  max-width: 92%;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #121519;
  color: #cfd5dd;
  align-self: flex-start;
}

.dialogue-message.system {
  border-color: #2a3038;
  background: #121519;
}

.dialogue-message.user {
  max-width: 86%;
  align-self: flex-end;
  border-color: rgba(214, 179, 90, 0.55);
  background: rgba(214, 179, 90, 0.12);
  color: var(--text);
}

.dialogue-message span {
  display: inline-flex;
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 700;
}

.dialogue-message.user span {
  color: var(--accent);
}

.dialogue-message.system span {
  color: var(--faint);
}

.dialogue-message p {
  margin: 4px 0 0;
  line-height: 1.55;
}

.dialogue-message.pending {
  border-color: rgba(214, 179, 90, 0.46);
  background: rgba(214, 179, 90, 0.08);
}

.dialogue-message.loading {
  border-color: rgba(122, 168, 255, 0.34);
  background: rgba(122, 168, 255, 0.08);
}

.dialogue-message.loading p::after {
  content: "";
  display: inline-block;
  width: 1.4em;
  animation: loading-dots 1.1s steps(4, end) infinite;
}

.dialogue-message.blocked {
  border-color: rgba(225, 138, 119, 0.42);
  background: rgba(225, 138, 119, 0.08);
}

.composer.is-loading textarea {
  border-color: rgba(122, 168, 255, 0.34);
}

.dialogue-job-actions {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #14171b;
}

.dialogue-job-actions[hidden] {
  display: none;
}

.dialogue-job-actions button {
  flex: 1 1 120px;
}

.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line-soft);
  padding: 12px;
  display: grid;
  gap: 10px;
  background: rgba(23, 26, 30, 0.98);
}

textarea {
  resize: vertical;
  min-height: 86px;
  max-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101317;
  color: var(--text);
  padding: 10px;
  line-height: 1.45;
}

.result-shell {
  min-width: 0;
  min-height: 0;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.result-shell > * {
  flex: 0 0 auto;
}

.mobile-dialogue-toggle,
.mobile-only {
  display: none;
}

.belief-hero,
.path-section,
.board-section,
.boundary-grid article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.belief-hero {
  min-height: 104px;
  padding: 12px 14px;
  display: flex;
  gap: 14px;
  align-items: start;
  overflow: visible;
}

.belief-copy,
.run-summary,
.path-section,
.board-section,
.boundary-grid {
  min-width: 0;
}

.belief-copy {
  flex: 1 1 auto;
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  text-transform: uppercase;
}

.belief-label-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}

.text-button {
  min-height: 30px;
  padding: 0 9px;
  border-color: var(--line-soft);
  background: #121519;
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
}

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

h1 {
  margin-bottom: 6px;
  font-size: 22px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 14px;
  letter-spacing: 0;
}

p {
  line-height: 1.58;
}

.belief-copy p {
  max-width: 860px;
}

.belief-summary {
  margin-bottom: 0;
  color: #d9dee5;
  line-height: 1.45;
}

.belief-hero:not(.is-expanded) .source-sentence {
  display: none;
}

.source-sentence {
  margin-top: 6px;
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.4;
}

.run-summary {
  flex: 0 1 380px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-content: start;
}

.run-summary[hidden] {
  display: none;
}

.run-summary div {
  min-width: 74px;
  padding: 7px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #121519;
}

.run-summary strong {
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.25;
}

.run-summary span {
  font-size: 11px;
}

.run-summary div:nth-child(1),
.run-summary div:nth-child(2),
.run-summary div:nth-child(4) {
  flex: 0 0 auto;
}

.run-summary div:nth-child(3) {
  flex: 1 1 160px;
}

.load-status {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.load-status {
  margin: 0;
  padding: 10px 12px;
  font-size: 12px;
}

.load-status.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.load-status.error {
  border-color: rgba(225, 138, 119, 0.45);
  color: #f0b2a5;
}

@keyframes loading-dots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}

.section-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: end;
  min-width: 0;
}

.section-head p {
  max-width: 520px;
  margin: 0;
  font-size: 13px;
}

.path-strip {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.path-row {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #121519;
  overflow: hidden;
}

.path-row header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}

.path-row header strong {
  display: block;
  font-size: 16px;
  line-height: 1.35;
}

.path-row header p {
  max-width: 78ch;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.path-steps {
  padding: 4px 14px 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.path-step {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 12px 8px 12px 46px;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 5px 8px;
}

.path-step::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 18px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(214, 179, 90, 0.12);
}

.path-step::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 31px;
  bottom: -7px;
  width: 1px;
  background: var(--line-soft);
}

.path-step:last-child::after {
  display: none;
}

.path-step + .path-step {
  border-top: 1px solid rgba(48, 55, 65, 0.5);
}

.path-step-index,
.path-step-role {
  display: inline-flex;
  color: var(--accent);
  font-size: 12px;
  line-height: 1.2;
}

.path-step-index {
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.path-step strong {
  grid-column: 1 / -1;
  max-width: 86ch;
  color: #dfe5ec;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.55;
}

.path-row.is-selected {
  border-color: rgba(214, 179, 90, 0.72);
  box-shadow: 0 0 0 1px rgba(214, 179, 90, 0.28);
}

.card-board {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  overflow-x: visible;
}

.lane {
  min-width: 0;
  display: block;
}

.lane-head {
  display: none;
}

.lane-head strong {
  display: block;
  margin-bottom: 6px;
}

.field-note {
  margin: 0;
  font-size: 12px;
}

.lane-stack {
  display: grid;
  gap: 8px;
}

.factor-card {
  min-width: 0;
  min-height: 136px;
  height: 100%;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent-2);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 7px;
}

.card-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.card-kicker {
  font-size: 12px;
  line-height: 1.35;
  color: var(--accent);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-field-label {
  display: inline-flex;
  flex: 0 0 auto;
  width: fit-content;
  max-width: 100%;
  padding: 3px 6px;
  border: 1px solid rgba(214, 179, 90, 0.32);
  border-radius: 7px;
  background: rgba(214, 179, 90, 0.1);
  color: var(--accent);
  font-size: 12px;
  line-height: 1.2;
}

.factor-card:hover,
.path-step:hover,
.ghost-button:hover,
.text-button:hover,
.topic-button:hover {
  border-color: #5a6674;
}

.factor-card:focus-visible,
.path-step:focus-visible,
.ghost-button:focus-visible,
.primary-button:focus-visible,
.icon-button:focus-visible,
.text-button:focus-visible,
.topic-button:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.factor-card.is-selected,
.path-step.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.factor-card strong {
  line-height: 1.25;
}

.factor-card p {
  margin: 0;
  color: #d9dee5;
  font-size: 13px;
  line-height: 1.42;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-source {
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta-row,
.evidence-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-meta-row span,
.evidence-pills span {
  max-width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #14181e;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.empty-card {
  min-height: 96px;
  color: var(--muted);
}

.empty-public-state {
  min-height: 140px;
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.empty-public-state strong {
  color: var(--text);
  font-size: 18px;
}

.empty-public-state p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.boundary-grid article {
  padding: 16px;
}

.boundary-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.boundary-grid p {
  margin-bottom: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 35;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 48vw);
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px var(--shadow);
  z-index: 40;
  transform: translateX(100%);
  transition: transform 180ms ease;
  display: flex;
  flex-direction: column;
}

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

.drawer-head {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.drawer-head > div,
.drawer-body section,
.source-card,
.evidence-card,
.dialogue-message {
  min-width: 0;
  max-width: 100%;
}

.drawer-head h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  display: grid;
  gap: 18px;
}

.drawer-body section {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
}

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

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

.linked-pill {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121519;
  color: var(--muted);
  font-size: 12px;
}

.linked-pill:hover,
.linked-pill:focus-visible {
  border-color: var(--accent);
  color: var(--text);
}

.evidence-list {
  display: grid;
  gap: 10px;
}

.evidence-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121519;
}

.evidence-card.warning {
  border-color: rgba(225, 138, 119, 0.38);
}

.evidence-card span {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.evidence-card p {
  margin-bottom: 0;
}

.gap-list {
  margin: 0;
  padding-left: 18px;
  color: #e4c9be;
  line-height: 1.5;
}

.source-trail {
  display: grid;
  gap: 10px;
}

.viewpoint-clusters {
  display: grid;
  gap: 10px;
}

#drawer-viewpoint-section {
  padding: 14px;
  border: 1px solid rgba(122, 168, 255, 0.36);
  border-radius: 8px;
  background: rgba(122, 168, 255, 0.08);
}

#drawer-viewpoint-section[hidden] {
  display: none;
}

#drawer-concept-section[hidden] {
  display: none;
}

.drawer-concept-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 700;
}

.drawer-concept-label::before {
  content: "概念：";
  color: var(--muted);
  font-weight: 600;
}

.viewpoint-cluster {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121519;
}

.viewpoint-cluster header {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}

.viewpoint-cluster header strong {
  color: var(--accent);
}

.viewpoint-cluster header span {
  color: var(--muted);
  font-size: 12px;
}

.viewpoint-cluster p {
  margin: 8px 0 0;
}

.cluster-source-count {
  color: #d5dce6;
  font-size: 12px;
}

.cluster-limit {
  color: #f1dca1;
}

.cluster-sources {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cluster-sources span {
  max-width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.cluster-sources b {
  color: var(--text);
}

.source-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121519;
}

.source-card strong {
  display: block;
  margin-bottom: 4px;
}

.source-card a {
  color: var(--accent-2);
  overflow-wrap: anywhere;
}

.source-limitation {
  color: #e9b5a9;
}

.access-pill {
  display: inline-block;
  margin: 8px 0;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ok);
  font-size: 12px;
}

.access-pill.blocked {
  color: var(--danger);
}

.drawer-boundary p {
  color: #f1dca1;
}

.drawer-actions {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

@media (max-width: 1439px) {
  .topbar {
    grid-template-columns: minmax(190px, 280px) minmax(0, 1fr);
    gap: 12px 16px;
    align-items: start;
  }

  .top-actions {
    grid-column: 2;
    justify-content: start;
    flex-wrap: wrap;
  }

  .topic-strip {
    align-items: flex-start;
  }

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

  .belief-hero {
    flex-direction: column;
    gap: 10px;
  }

  .run-summary {
    width: 100%;
    flex-basis: auto;
    justify-content: flex-start;
  }

  .card-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: clip;
  }

  .detail-drawer {
    width: min(640px, 70vw);
  }
}

@media (max-width: 767px) {
  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .topbar {
    position: static;
    padding: 14px;
    grid-template-columns: minmax(0, 1fr);
    overflow-x: hidden;
  }

  .brand,
  .topic-strip,
  .top-actions,
  .mobile-dialogue-toggle,
  .result-shell,
  .belief-hero,
  .path-section,
  .board-section,
  .boundary-grid {
    width: 100%;
    max-width: 100%;
  }

  .topic-button {
    width: 100%;
    max-width: none;
  }

  .source-switch,
  .provider-switch,
  .account-widget {
    width: 100%;
    max-width: none;
    justify-content: space-between;
  }

  .source-switch select,
  .provider-switch select {
    min-width: 0;
    flex: 1;
  }

  .account-widget {
    align-items: flex-start;
  }

  .account-controls {
    justify-content: flex-end;
  }

  .account-controls input {
    width: min(42vw, 160px);
  }

  .case-menu {
    width: 100%;
  }

  .top-actions {
    display: none;
  }

  .top-actions .ghost-button,
  .top-actions .primary-button {
    flex: 1 1 0;
  }

  .workspace {
    display: block;
    overflow: visible;
  }

  .dialogue-panel {
    position: fixed;
    inset: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    width: min(100vw, 420px);
    height: 100dvh;
    min-height: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .dialogue-panel.is-open {
    transform: translateX(0);
  }

  .mobile-only,
  .mobile-dialogue-toggle {
    display: inline-flex;
  }

  .mobile-dialogue-toggle {
    min-height: 42px;
    gap: 8px;
    align-items: center;
    justify-content: center;
  }

  .result-shell {
    padding: 14px;
    overflow: visible;
  }

  .belief-hero {
    min-height: 0;
    padding: 12px;
    gap: 10px;
  }

  .belief-label-row {
    align-items: flex-start;
  }

  .run-summary {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .run-summary div,
  .run-summary div:nth-child(3) {
    flex: 0 0 auto;
    max-width: 230px;
  }

  .belief-hero:not(.is-expanded) .belief-summary {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  h1 {
    font-size: 24px;
  }

  .section-head {
    display: block;
    padding: 10px 12px;
  }

  .section-head p {
    display: none;
  }

  .card-board,
  .boundary-grid {
    grid-template-columns: 1fr;
  }

  .path-steps {
    grid-template-columns: 1fr;
  }

  .lane {
    min-width: 0;
  }

  .detail-drawer {
    left: 0;
    right: auto;
    width: 100vw;
  }

  .drawer-head {
    padding: 14px;
  }
}

/* Headless Chrome lays out --window-size=390 captures at 500 CSS px, then crops the image to 390 px. */
@media (width: 500px) {
  .app-shell {
    width: 390px;
    max-width: 390px;
  }

  .topbar,
  .workspace,
  .result-shell {
    max-width: 100%;
  }

  .dialogue-panel,
  .detail-drawer {
    right: auto;
    width: min(100vw, 390px);
    max-width: 390px;
  }

  .detail-drawer:not(.is-open) {
    transform: translateX(100vw);
  }

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