:root {
  --ink: #1f2933;
  --muted: #5d6672;
  --paper: #fbfaf5;
  --paper-deep: #eee8d8;
  --human: #f0b45f;
  --agent: #8db4d8;
  --surface: #86cfc1;
  --core: #a8c686;
  --wallet: #d98989;
  --data: #c7addf;
  --external: #d8d2c4;
  --executor: #d8d2c4;
  --vendor: #fffdf7;
  --line: #2b3340;
  --shadow: rgba(31, 41, 51, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  color: var(--ink);
  background:
    linear-gradient(rgba(31, 41, 51, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 41, 51, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family:
    ui-rounded,
    "Trebuchet MS",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(16px, 4vw, 42px) 14px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.logo-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  flex: 0 0 auto;
  border: 3px solid var(--line);
  background:
    linear-gradient(135deg, rgba(240, 180, 95, 0.82), rgba(134, 207, 193, 0.72)),
    #fffdf7;
  box-shadow: 5px 6px 0 rgba(31, 41, 51, 0.2);
  transform: rotate(-2deg);
}

.logo-mark::before,
.logo-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px dashed rgba(31, 41, 51, 0.42);
  transform: rotate(3deg);
}

.logo-mark::after {
  inset: 14px;
  border-style: solid;
  transform: rotate(-4deg);
}

.logo-glyph {
  position: relative;
  z-index: 1;
  margin-top: -7px;
  font-family:
    "Kaiti SC",
    "STKaiti",
    "KaiTi",
    "BiauKai",
    serif;
  font-size: 37px;
  font-weight: 700;
  line-height: 1;
}

.logo-word {
  position: absolute;
  z-index: 1;
  bottom: 10px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.app-header h1,
.diagram-toolbar h2,
.details-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  max-width: none;
  font-size: 44px;
  line-height: 1;
  white-space: nowrap;
}

.kicker,
.crumb {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.snapshot-record {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 7px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.snapshot-record code {
  font-size: 11px;
  overflow-wrap: anywhere;
}

.app-header nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.icon-button,
.github-link,
.back-button {
  min-height: 42px;
  border: 2px solid var(--line);
  color: var(--ink);
  background: #fffdf7;
  box-shadow: 3px 4px 0 var(--line);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.icon-button {
  width: 44px;
  font-size: 22px;
}

.github-link,
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
}

.icon-button:active,
.github-link:active,
.back-button:active {
  transform: translate(3px, 4px);
  box-shadow: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 330px);
  align-items: start;
  gap: 22px;
  padding: 0 clamp(16px, 4vw, 42px) 34px;
}

.diagram-region,
.details-panel {
  border: 3px solid var(--line);
  background: rgba(255, 253, 247, 0.9);
  box-shadow: 7px 8px 0 var(--shadow);
}

.diagram-region {
  min-width: 0;
  overflow: hidden;
}

.diagram-toolbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px 8px;
}

.diagram-toolbar h2,
.details-panel h2 {
  font-size: clamp(23px, 3vw, 34px);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 14px;
  max-width: 390px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  transform: rotate(-2deg);
}

.swatch.human {
  background: var(--human);
}

.swatch.agent {
  background: var(--agent);
}

.swatch.surface {
  background: var(--surface);
}

.swatch.core {
  background: var(--core);
}

.swatch.wallet {
  background: var(--wallet);
}

.swatch.data {
  background: var(--data);
}

.swatch.external {
  background: var(--external);
  border-style: dashed;
}

.swatch.executor {
  background: var(--executor);
}

.swatch.vendor {
  background: var(--vendor);
  border-radius: 50%;
}

.architecture-canvas {
  display: block;
  width: 100%;
  height: min(72vh, 780px);
  min-height: 520px;
  background:
    radial-gradient(circle at 9px 9px, rgba(31, 41, 51, 0.16) 1.4px, transparent 1.5px),
    #fffdf7;
  background-size: 18px 18px;
  border-top: 2px dashed rgba(31, 41, 51, 0.28);
  border-bottom: 2px dashed rgba(31, 41, 51, 0.28);
}

.diagram-summary {
  margin: 0;
  padding: 12px 18px 16px;
  color: var(--muted);
  font-size: 14px;
}

.details-panel {
  padding: 18px 20px 22px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  align-self: start;
}

.back-button {
  margin-bottom: 18px;
}

.details-panel p {
  margin-bottom: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.detail-list h3 {
  margin: 20px 0 10px;
  font-size: 16px;
}

.detail-list h3:first-child {
  margin-top: 0;
}

.detail-list ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.4;
}

.source-links a {
  font-weight: 800;
  overflow-wrap: anywhere;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.node {
  cursor: default;
}

.node.is-drillable {
  cursor: pointer;
}

.node .node-fill {
  stroke: var(--line);
  stroke-width: 3;
  filter: drop-shadow(3px 4px 0 rgba(31, 41, 51, 0.22));
}

.node.is-drillable:hover .node-fill,
.node.is-drillable:focus .node-fill {
  stroke-width: 4.5;
}

.actor-node .node-fill {
  stroke-linejoin: round;
}

.storage-node .node-fill {
  stroke-linejoin: round;
}

.storage-cap {
  stroke: rgba(31, 41, 51, 0.48);
  stroke-width: 3;
  stroke-linecap: round;
}

.storage-node.is-drillable:hover .storage-cap,
.storage-node.is-drillable:focus .storage-cap {
  stroke-width: 4;
}

.node text {
  pointer-events: none;
  fill: var(--ink);
  font-weight: 800;
  letter-spacing: 0;
}

.node .subtext {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.arrow-line {
  fill: none;
  stroke: var(--line);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 7;
}

.arrow-label {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.arrow-label-back {
  fill: #fffdf7;
  stroke: rgba(31, 41, 51, 0.28);
  stroke-width: 1.5;
}

.zone-fill {
  fill: rgba(216, 210, 196, 0.28);
  stroke: rgba(31, 41, 51, 0.55);
  stroke-width: 3;
  stroke-dasharray: 10 9;
}

.zone-label {
  fill: var(--muted);
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
}

.vendor-node .node-fill {
  stroke-linecap: round;
}

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

@media (max-width: 940px) {
  .app-header,
  .diagram-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .app-header h1 {
    font-size: 28px;
  }

  .app-header nav,
  .legend {
    justify-content: flex-start;
  }

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

  .details-panel {
    position: static;
    max-height: none;
    overflow-y: visible;
  }

  .architecture-canvas {
    height: 620px;
  }
}

@media (max-width: 560px) {
  .brand-lockup {
    gap: 10px;
  }

  .logo-mark {
    width: 56px;
    height: 56px;
    border-width: 2px;
    box-shadow: 3px 4px 0 rgba(31, 41, 51, 0.2);
  }

  .logo-mark::before {
    inset: 6px;
  }

  .logo-mark::after {
    inset: 10px;
  }

  .logo-glyph {
    margin-top: -6px;
    font-size: 27px;
  }

  .logo-word {
    bottom: 7px;
    font-size: 9px;
  }

  .app-header h1 {
    font-size: 17px;
  }

  .architecture-canvas {
    min-height: 500px;
    height: 540px;
    width: 900px;
    max-width: none;
  }

  .diagram-region {
    overflow-x: auto;
  }

  .details-panel,
  .diagram-region {
    box-shadow: 4px 5px 0 var(--shadow);
  }

}

@media (max-width: 360px) {
  .app-header h1 {
    font-size: 15px;
  }
}
