:root {
  color-scheme: dark;
  --ink: #f1eadb;
  --paper: #07101c;
  --panel: #0b1725;
  --panel-raised: #102033;
  --panel-soft: #0d1b2b;
  --line: #25374a;
  --line-strong: #39536b;
  --muted: #90a2b2;
  --accent: #e2b85b;
  --accent-bright: #ffd675;
  --accent-soft: rgba(226, 184, 91, 0.15);
  --cyan: #63c8d4;
  --cyan-soft: rgba(99, 200, 212, 0.15);
  --danger: #ff8a78;
  --radius: 18px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="checkbox"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

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

code,
kbd {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.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;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent-bright);
  color: #07101c;
  font-weight: 700;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
  background: var(--paper);
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 28, 0.96);
}

.brand,
.topbar-actions,
.icon-button,
.detail-meta,
.section-heading,
.switch-row,
.trail,
.status-cluster,
.legend,
.legend span {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent-bright);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.brand-copy small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-actions {
  gap: 8px;
}

.icon-button,
.panel-toggle,
.trail button,
.relation-chip,
.index-item,
.segmented button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
}

.icon-button {
  min-height: 40px;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
}

.icon-button:hover,
.panel-toggle:hover,
.trail button:hover:not(:disabled),
.relation-chip:hover,
.index-item:hover,
.segmented button:hover {
  border-color: var(--line-strong);
  background: var(--panel-raised);
}

.icon-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  height: calc(100vh - 72px);
}

.visual-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
  isolation: isolate;
}

#networkCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#networkCanvas:active {
  cursor: grabbing;
}

.canvas-overlay {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

.canvas-intro {
  top: 34px;
  left: 38px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.canvas-intro h1 {
  margin: 0;
  color: rgba(241, 234, 219, 0.93);
  font-family: var(--serif);
  font-size: clamp(34px, 4.4vw, 68px);
  font-weight: 400;
  line-height: 0.96;
  letter-spacing: -0.045em;
}

.status-cluster {
  top: 30px;
  right: 30px;
  gap: 6px;
}

.status-cluster span {
  padding: 7px 10px;
  border: 1px solid rgba(57, 83, 107, 0.7);
  border-radius: 999px;
  background: rgba(7, 16, 28, 0.74);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.legend {
  right: 30px;
  bottom: 27px;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
}

.legend span {
  gap: 7px;
}

.line {
  display: inline-block;
  width: 28px;
  height: 0;
  border-top: 1px solid var(--line-strong);
}

.line.argument {
  border-top: 1px dashed var(--cyan);
}

.canvas-hint {
  position: absolute;
  z-index: 2;
  bottom: 21px;
  left: 30px;
  margin: 0;
  color: rgba(144, 162, 178, 0.72);
  font-size: 11px;
  pointer-events: none;
}

.tooltip {
  position: absolute;
  z-index: 10;
  max-width: 230px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(11, 23, 37, 0.96);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
}

.tooltip strong {
  color: var(--accent-bright);
}

.side-panel {
  min-width: 0;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  scrollbar-color: var(--line-strong) var(--panel);
}

.controls,
.details,
.index-panel {
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
}

.section-heading.compact .eyebrow {
  margin-bottom: 4px;
}

.panel-toggle {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  transition: transform 180ms ease;
}

.panel-toggle[aria-expanded="false"] {
  transform: rotate(180deg);
}

.filter-body {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

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

.search-field {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 45px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--muted);
}

.search-field:focus-within {
  border-color: var(--accent);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.search-field input::placeholder {
  color: #718495;
}

kbd {
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--muted);
  font-size: 10px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.control-grid label {
  display: grid;
  gap: 7px;
}

.control-grid label > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

select {
  width: 100%;
  min-height: 40px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.segmented button {
  min-height: 36px;
  border-color: transparent;
  border-radius: 9px;
  font-size: 12px;
}

.segmented button[aria-pressed="true"] {
  border-color: var(--line-strong);
  background: var(--panel-raised);
  color: var(--accent-bright);
}

.switch-row {
  justify-content: space-between;
  gap: 12px;
}

.switch-row > span {
  display: grid;
  gap: 2px;
}

.switch-row strong {
  font-size: 12px;
  font-weight: 600;
}

.switch-row small {
  color: var(--muted);
  font-size: 10px;
}

.switch-row input {
  width: 39px;
  height: 22px;
  margin: 0;
  accent-color: var(--accent);
}

.details {
  position: relative;
}

.detail-meta {
  justify-content: space-between;
  margin-bottom: 25px;
}

.proposition-number {
  display: grid;
  min-width: 56px;
  height: 56px;
  padding: 0 12px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent-bright);
  font-family: var(--serif);
  font-size: 17px;
}

.branch-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.details blockquote {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(22px, 2.1vw, 29px);
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.detail-role {
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.relation-block {
  margin-top: 26px;
}

.relation-block h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

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

.relation-chip {
  min-height: 31px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
}

.relation-chip strong {
  margin-right: 4px;
  color: var(--accent-bright);
}

.trail {
  justify-content: space-between;
  gap: 10px;
  margin-top: 25px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.trail button {
  min-height: 35px;
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 11px;
}

.trail span {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.index-panel {
  border-bottom: 0;
}

.proposition-index {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 16px;
}

.index-item {
  min-height: 35px;
  padding: 5px;
  border-radius: 8px;
  font-size: 11px;
}

.index-item[aria-current="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.app-credit {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.loading-screen,
.error-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--paper);
  text-align: center;
}

.loading-screen {
  transition: opacity 350ms ease, visibility 350ms ease;
}

.loading-screen.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.loader-mark {
  display: grid;
  width: 84px;
  height: 84px;
  margin: 0 auto 14px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent-bright);
  font-family: var(--serif);
  font-size: 20px;
  animation: breathe 1.7s ease-in-out infinite;
}

.loading-screen p,
.error-screen p {
  color: var(--muted);
}

.error-screen > div {
  max-width: 560px;
  padding: 30px;
}

.error-screen h2 {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 400;
}

.error-screen code {
  color: var(--accent-bright);
}

[hidden] {
  display: none !important;
}

@keyframes breathe {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(226, 184, 91, 0.08);
    transform: scale(0.97);
  }
  50% {
    box-shadow: 0 0 0 18px rgba(226, 184, 91, 0);
    transform: scale(1.02);
  }
}

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

  .canvas-hint,
  .legend {
    display: none;
  }

  .canvas-intro h1 {
    font-size: 42px;
  }
}

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

  .topbar {
    position: sticky;
    top: 0;
  }

  .workspace {
    display: block;
    height: auto;
  }

  .visual-panel {
    height: min(68vh, 620px);
    min-height: 440px;
    border-bottom: 1px solid var(--line);
  }

  .side-panel {
    overflow: visible;
    border-left: 0;
  }

  .controls,
  .details,
  .index-panel {
    padding: 22px clamp(18px, 5vw, 38px);
  }
}

@media (max-width: 560px) {
  .topbar {
    min-height: 64px;
    padding: 10px 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-copy strong {
    font-size: 16px;
  }

  .brand-copy small,
  .icon-button span:last-child {
    display: none;
  }

  .icon-button {
    width: 40px;
    justify-content: center;
    padding: 0;
  }

  .visual-panel {
    height: 58vh;
    min-height: 390px;
  }

  .canvas-intro {
    top: 22px;
    left: 18px;
  }

  .canvas-intro h1 {
    font-size: 34px;
  }

  .status-cluster {
    top: auto;
    right: 16px;
    bottom: 15px;
  }

  .status-cluster span:nth-child(2) {
    display: none;
  }

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

  .details blockquote {
    font-size: 25px;
  }

  .proposition-index {
    grid-template-columns: repeat(5, 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;
  }
}
