:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --ink: #151515;
  --muted: #6f6f68;
  --line: #c9c6bd;
  --panel: #ffffff;
  --red: #d71920;
  --blue: #2f6fbd;
  --green: #288a3d;
  --amber: #b06a00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(21, 21, 21, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(21, 21, 21, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  border-bottom: 2px solid var(--ink);
  background: rgba(255, 255, 255, 0.92);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.title {
  display: grid;
  gap: 3px;
}

.title h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toggle {
  border: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
}

.toggle .switch {
  width: 34px;
  height: 18px;
  border: 2px solid currentColor;
  background: #e9e6de;
  position: relative;
}

.toggle .switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  background: currentColor;
  transition: transform 120ms ease;
}

.toggle.is-on .switch::after {
  transform: translateX(16px);
}

.toggle.skill-toggle.is-on {
  border-color: var(--blue);
  color: var(--blue);
}

.toggle.risk-toggle.is-on {
  border-color: var(--red);
  color: var(--red);
}

.toggle.focus-toggle.is-on {
  border-color: var(--green);
  color: var(--green);
}

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
  background: #fff;
}

.dot.action {
  border-style: dashed;
  border-color: #777;
  background: #f3f3f3;
}

.dot.dep {
  border-color: var(--amber);
  background: #fff7e6;
}

.dot.skill {
  border-color: var(--blue);
  background: #eef5ff;
}

.dot.learn {
  border-color: var(--green);
  background: #e9ffe9;
}

.dot.risk {
  border-color: var(--red);
  background: #ffecec;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
}

.map-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.map {
  position: relative;
  background: rgba(255, 255, 255, 0.66);
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(21, 21, 21, 0.11);
}

svg.edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.node {
  position: absolute;
  width: 138px;
  min-height: 54px;
  border: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 4px;
  align-content: center;
  box-shadow: 4px 4px 0 rgba(21, 21, 21, 0.12);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    opacity 120ms ease;
}

.node:hover,
.node:focus-visible {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 rgba(21, 21, 21, 0.16);
  outline: 3px solid rgba(215, 25, 32, 0.22);
  outline-offset: 2px;
}

.node.is-selected {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

.node .kind {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.node .label {
  font-size: 14px;
  line-height: 1.25;
  font-weight: 800;
}

.node.final {
  background: var(--ink);
  color: #fff;
  border-color: var(--red);
  box-shadow: 4px 4px 0 rgba(215, 25, 32, 0.28);
}

.node.final .kind {
  color: #f2b6b9;
}

.node.action {
  border-style: dashed;
  border-color: #777;
  background: #f3f3f3;
}

.node.dep {
  border-color: var(--amber);
  background: #fff7e6;
}

.node.skill {
  border-color: var(--blue);
  background: #eef5ff;
}

.node.learn {
  border-color: var(--green);
  background: #e9ffe9;
}

.node.risk {
  border-color: var(--red);
  background: #ffecec;
}

.node.is-hidden {
  display: none;
}

.node.is-dimmed {
  opacity: 0.16;
  filter: grayscale(1);
  box-shadow: none;
}

.node.is-focus {
  outline: 4px solid var(--green);
  outline-offset: 3px;
  box-shadow: 7px 7px 0 rgba(40, 138, 61, 0.22);
}

.node.is-current-action {
  outline-color: var(--red);
  box-shadow: 7px 7px 0 rgba(215, 25, 32, 0.2);
}

.detail {
  border-left: 2px solid var(--ink);
  background: rgba(255, 255, 255, 0.95);
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.detail-head {
  padding: 18px;
  border-bottom: 2px solid var(--ink);
  display: grid;
  gap: 8px;
}

.detail-head .badge {
  width: fit-content;
  border: 2px solid var(--ink);
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 800;
  background: #fff;
}

.detail-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.18;
}

.detail-body {
  padding: 18px;
  overflow: auto;
}

.section {
  border-top: 2px solid var(--ink);
  padding-top: 12px;
  margin-top: 14px;
}

.section:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.section h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.section p {
  margin: 0;
  color: #333;
  line-height: 1.65;
  font-size: 14px;
}

.section ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.section li {
  line-height: 1.55;
  font-size: 14px;
}

.now {
  border: 2px solid var(--red);
  background: #fff;
  padding: 10px;
  margin-top: 14px;
}

.now h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.now ul {
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px;
  }

  .controls {
    width: 100%;
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .map-wrap {
    height: min(56dvh, 520px);
    min-height: 390px;
    padding: 12px;
    border-top: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
  }

  .detail {
    border-left: 0;
    border-top: 2px solid var(--ink);
    min-height: 440px;
  }
}

@media (max-width: 700px) {
  body {
    background-size: 24px 24px;
  }

  .topbar {
    gap: 12px;
  }

  .title h1 {
    font-size: 18px;
  }

  .title p {
    font-size: 12px;
    line-height: 1.45;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .toggle {
    width: 100%;
    min-width: 0;
    height: 40px;
    justify-content: center;
    padding: 0 9px;
    gap: 7px;
    white-space: nowrap;
  }

  .toggle .switch {
    flex: 0 0 auto;
  }

  .legend {
    grid-column: 1 / -1;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 1px 0 4px;
    scrollbar-width: none;
  }

  .legend::-webkit-scrollbar {
    display: none;
  }

  .legend span {
    flex: 0 0 auto;
  }

  .map {
    box-shadow: 5px 5px 0 rgba(21, 21, 21, 0.11);
  }

  .detail {
    min-height: 0;
  }

  .detail-head {
    padding: 14px;
    gap: 7px;
  }

  .detail-head h2 {
    font-size: 19px;
  }

  .detail-body {
    padding: 14px;
  }

  .section {
    margin-top: 12px;
    padding-top: 10px;
  }
}

@media (max-width: 420px) {
  .toggle {
    font-size: 14px;
  }

  .toggle .switch {
    width: 30px;
  }

  .toggle.is-on .switch::after {
    transform: translateX(12px);
  }
}
