:root {
  --bg: #050505;
  --bg-elevated: #09090b;
  --bg-node: rgba(10, 10, 12, 0.94);
  --bg-panel: rgba(9, 9, 11, 0.98);
  --bg-hover: rgba(255, 255, 255, 0.035);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-active: rgba(122, 156, 191, 0.34);
  --text: #eceef2;
  --text-muted: #9ba1a9;
  --text-faint: #676d75;
  --accent: #7a9cbf;
  --accent-soft: rgba(122, 156, 191, 0.1);
  --accent-glow: rgba(122, 156, 191, 0.14);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at top left, rgba(122, 156, 191, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 40px auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 5, 5, 0.9);
  backdrop-filter: blur(18px);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
}

.topbar-left {
  gap: 10px;
}

.brand-mark {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.brand-rule {
  width: 1px;
  height: 12px;
  background: var(--border-strong);
}

.brand-meta,
.topbar-mode {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.company-header {
  position: relative;
  z-index: 5;
  padding: 32px 24px 18px;
}

.company-header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.company-header-kicker {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.company-title {
  margin: 0;
  max-width: 760px;
  font-size: clamp(2.35rem, 4vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: -0.055em;
  font-weight: 600;
}

.company-tagline {
  margin: 18px 0 0;
  max-width: 860px;
  font-size: clamp(1rem, 1.45vw, 1.32rem);
  line-height: 1.45;
  color: var(--text-muted);
}

.company-support {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0;
  align-items: stretch;
  gap: 0;
  padding: 0 24px 24px;
}

.workspace.panel-open {
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
}

.graph-stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.graph-stage-header {
  display: flex;
  align-items: center;
  min-height: 30px;
  padding: 0 2px 12px;
}

.graph-stage-label {
  margin: 0;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.surface {
  position: relative;
  min-height: 560px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 22%),
    rgba(7, 7, 9, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.surface::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at center, black 44%, transparent 100%);
  pointer-events: none;
}

.surface::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(122, 156, 191, 0.07), transparent 44%);
  pointer-events: none;
}

.lines,
.canvas {
  position: absolute;
  inset: 0;
}

.lines {
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.canvas {
  z-index: 2;
}

.node {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  outline: none;
}

.node:active {
  cursor: grabbing;
}

.node-body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--bg-node);
  box-shadow: var(--shadow);
  transition:
    border-color 180ms var(--ease),
    transform 180ms var(--ease),
    box-shadow 180ms var(--ease),
    background-color 180ms var(--ease);
}

.node:hover .node-body,
.node:focus-visible .node-body,
.node.is-active .node-body {
  border-color: var(--border-active);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(122, 156, 191, 0.1);
}

.node--core {
  z-index: 3;
}

.node--core .node-body {
  width: 236px;
  min-height: 236px;
  align-items: center;
  justify-content: center;
  padding: 30px 24px;
  border-radius: 50%;
  text-align: center;
}

.node--core .node-mark {
  font-size: 42px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.06em;
  color: var(--accent);
}

.node--core .node-title {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.node--core .node-subline {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 164px;
}

.node--child .node-body,
.node--access .node-body {
  min-width: 160px;
  padding: 18px 18px 17px;
  border-radius: 16px;
}

.node--child .node-title,
.node--access .node-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.node-role {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.node--access .node-body {
  border-color: rgba(122, 156, 191, 0.2);
  background:
    linear-gradient(180deg, rgba(122, 156, 191, 0.05), transparent 100%),
    var(--bg-node);
}

.node--access .node-role {
  color: var(--accent);
}

.edge-line {
  stroke: rgba(122, 156, 191, 0.24);
  stroke-width: 1.15;
}

.edge-glow {
  stroke: url(#edge-glow);
  stroke-width: 2;
  opacity: 0;
  transition: opacity 180ms var(--ease);
}

.edge-line.is-active {
  stroke: rgba(122, 156, 191, 0.48);
}

.edge-glow.is-active {
  opacity: 0.55;
}

.panel {
  position: relative;
  width: 0;
  min-height: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  border-left: 1px solid transparent;
  transition:
    width 180ms var(--ease),
    opacity 180ms var(--ease),
    border-color 180ms var(--ease);
}

.panel.is-open {
  width: 380px;
  opacity: 1;
  pointer-events: auto;
  border-left-color: var(--border);
}

.panel-body {
  position: relative;
  min-height: 100%;
  padding: 24px 24px 32px;
  background: var(--bg-panel);
  border-radius: 20px;
}

.panel-close,
.sheet-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--text-faint);
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}

.panel-close:hover,
.sheet-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sheet-backdrop,
.sheet {
  display: none;
}

.p-name {
  margin: 0;
  padding-right: 40px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.p-layer {
  margin: 10px 0 22px;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.p-text {
  display: grid;
  gap: 18px;
}

.p-section {
  display: grid;
  gap: 7px;
}

.p-label {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.p-value {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
}

.p-structure {
  display: grid;
  gap: 10px;
}

.p-structure-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.p-structure-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.p-structure-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.access-panel {
  display: grid;
  gap: 14px;
}

.access-title {
  margin: 0;
  padding-right: 40px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.access-console {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(122, 156, 191, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(122, 156, 191, 0.04), transparent 100%),
    rgba(6, 6, 8, 0.9);
  font-family: var(--mono);
}

.access-log {
  min-height: 260px;
  max-height: 340px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding-right: 2px;
}

.access-entry {
  display: grid;
  gap: 6px;
  font-size: 12px;
  line-height: 1.7;
}

.access-entry-user {
  color: var(--text);
}

.access-entry-system {
  color: var(--text-muted);
}

.access-prefix {
  color: var(--accent);
  margin-right: 8px;
}

.access-response-line {
  display: block;
}

.access-response-line--gap {
  min-height: 0.7rem;
}

.access-form {
  position: sticky;
  bottom: 0;
  padding-top: 4px;
  background: linear-gradient(180deg, rgba(6, 6, 8, 0), rgba(6, 6, 8, 0.96) 28%);
}

.access-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

.access-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.access-input::placeholder {
  color: var(--text-faint);
  text-transform: uppercase;
}

.access-input:focus {
  outline: none;
  border-color: rgba(122, 156, 191, 0.22);
}

.access-actions {
  display: flex;
  justify-content: flex-end;
}

.access-copy-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition:
    border-color 160ms var(--ease),
    color 160ms var(--ease),
    background-color 160ms var(--ease);
}

.access-copy-action:hover,
.access-copy-action:focus-visible {
  border-color: rgba(122, 156, 191, 0.22);
  color: var(--text);
  outline: none;
}

.access-copy-action[hidden] {
  display: none;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

@media (max-width: 1120px) {
  .workspace.panel-open {
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
  }

  .panel.is-open {
    width: 340px;
  }
}

@media (max-width: 767px) {
  body {
    overflow-x: hidden;
  }

  .app {
    grid-template-rows: 40px auto 1fr;
  }

  .topbar {
    padding: 0 16px;
  }

  .topbar-mode {
    display: none;
  }

  .company-header {
    padding: 24px 16px 14px;
  }

  .company-header-inner {
    padding-top: 18px;
  }

  .company-title {
    font-size: clamp(2rem, 11vw, 3rem);
  }

  .company-tagline {
    font-size: 15px;
  }

  .company-support {
    font-size: 12px;
    line-height: 1.6;
  }

  .workspace,
  .workspace.panel-open {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0 16px 24px;
  }

  .graph-stage-header {
    padding-bottom: 10px;
  }

  .surface {
    min-height: 0;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-radius: 20px;
  }

  .surface::before,
  .surface::after,
  .lines {
    display: none;
  }

  .canvas {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .node {
    position: static;
    transform: none;
    width: 100%;
  }

  .node:active {
    cursor: pointer;
  }

  .node--core .node-body,
  .node--child .node-body,
  .node--access .node-body {
    width: 100%;
    min-width: 0;
    min-height: 0;
    border-radius: 18px;
  }

  .node--core .node-body {
    align-items: flex-start;
    padding: 22px 18px;
    text-align: left;
  }

  .node--core .node-mark {
    font-size: 30px;
  }

  .node--core .node-subline {
    max-width: none;
  }

  .node--child .node-body,
  .node--access .node-body {
    padding: 18px;
  }

  .panel {
    display: none;
  }

  .sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.56);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms var(--ease);
  }

  .sheet-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .sheet {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    transform: translateY(100%);
    transition: transform 220ms var(--ease);
  }

  .sheet.is-open {
    transform: translateY(0);
  }

  .sheet-shell {
    position: relative;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
  }

  .sheet-body {
    position: relative;
    max-height: min(76vh, 720px);
    overflow-y: auto;
    padding: 12px 20px 28px;
  }

  .sheet-handle {
    width: 38px;
    height: 4px;
    margin: 10px auto 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
  }

  .access-log {
    min-height: 220px;
    max-height: 38vh;
  }

  .access-actions {
    justify-content: stretch;
  }

  .access-copy-action {
    width: 100%;
  }
}

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