:root {
  --bg: #edf3fa;
  --surface: #ffffff;
  --surface-soft: #eef5ff;
  --text: #111d31;
  --muted: #65748b;
  --line: #bfd0e8;
  --accent: #2563eb;
  --accent-deep: #12345b;
  --ring: rgba(37, 99, 235, 0.24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(170, 191, 219, 0.32) 1px, transparent 1px),
    linear-gradient(rgba(170, 191, 219, 0.32) 1px, transparent 1px),
    radial-gradient(circle at 18% 16%, rgba(37, 99, 235, 0.14), transparent 34%),
    radial-gradient(circle at 92% 78%, rgba(8, 145, 178, 0.13), transparent 30%),
    var(--bg);
  background-size: 28px 28px, 28px 28px, auto, auto, auto;
}

button {
  font: inherit;
}

.learning-canvas {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  cursor: grab;
  user-select: none;
}

.learning-canvas.is-panning {
  cursor: grabbing;
}

.hud {
  position: fixed;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.hud > *,
.canvas-help,
.lightbox {
  pointer-events: auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(30px, 5vw, 64px);
  line-height: 1.02;
  letter-spacing: 0;
  text-shadow: 0 2px 16px rgba(255, 255, 255, 0.86);
}

.hud-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
}

.hud-actions button {
  border: 1px solid rgba(191, 208, 232, 0.92);
  border-radius: 8px;
  padding: 10px 13px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  box-shadow: 0 12px 28px rgba(18, 32, 51, 0.1);
  cursor: pointer;
}

.hud-actions button:hover {
  border-color: var(--accent);
}

.canvas-help {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.canvas-help span {
  border: 1px solid rgba(191, 208, 232, 0.86);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 10px 28px rgba(18, 32, 51, 0.08);
}

.world {
  position: absolute;
  left: 0;
  top: 0;
  width: 2400px;
  height: 1600px;
  transform-origin: 0 0;
  will-change: transform;
}

.connector-layer,
.node-layer {
  position: absolute;
  inset: 0;
}

.connector-layer {
  pointer-events: none;
  width: 2400px;
  height: 1600px;
  overflow: visible;
}

.connector-layer path {
  fill: none;
  stroke: rgba(37, 99, 235, 0.68);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 0;
  filter: drop-shadow(0 5px 10px rgba(37, 99, 235, 0.22));
}

.node {
  position: absolute;
  display: grid;
  align-content: center;
  width: 184px;
  min-height: 76px;
  border: 1px solid rgba(191, 208, 232, 0.98);
  border-radius: 8px;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  box-shadow: 0 18px 42px rgba(18, 32, 51, 0.16);
  cursor: grab;
  text-align: left;
  opacity: 1;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  touch-action: none;
}

.node.has-image {
  cursor: zoom-in;
}

.node:hover,
.node.is-open {
  border-color: var(--accent);
  box-shadow: 0 22px 52px rgba(37, 99, 235, 0.2);
}

.node:active,
.node.is-dragging {
  cursor: grabbing;
}

.node.root {
  width: 232px;
  min-height: 128px;
  padding: 22px;
  background: linear-gradient(135deg, #12345b, #1d4d7c);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.42);
}

.node.category {
  background: rgba(238, 245, 255, 0.96);
}

.node.term {
  width: 176px;
}

.node-title {
  display: block;
  font-size: 16px;
  font-weight: 880;
  line-height: 1.24;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.root .node-title {
  font-size: 33px;
}

.node-subtitle {
  display: block;
  margin-top: 7px;
  color: inherit;
  font-size: 13px;
  line-height: 1.35;
  opacity: 0.68;
}

.node-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border: 1px solid rgba(191, 208, 232, 0.96);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(18, 32, 51, 0.12);
}

.node.term .node-badge {
  color: #0f766e;
  pointer-events: none;
}

.node-enter {
  opacity: 1;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(10, 21, 36, 0.72);
  cursor: zoom-out;
}

.lightbox-card {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  width: min(1180px, 94vw);
  max-height: 92vh;
  margin: 0;
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
}

.lightbox.is-fullscreen {
  padding: 0;
  background: #081524;
}

.lightbox.is-fullscreen .lightbox-backdrop {
  background: #081524;
}

.lightbox.is-fullscreen .lightbox-card {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border-radius: 0;
  padding: 14px;
}

.lightbox.is-fullscreen .zoom-stage {
  max-height: none;
}

.lightbox.is-fullscreen .lightbox-card img {
  width: min(100%, 1400px);
  max-height: none;
}

.lightbox-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.lightbox-top p {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.lightbox-card figcaption {
  color: var(--text);
  font-size: 24px;
  font-weight: 880;
  line-height: 1.15;
}

.zoom-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.zoom-toolbar span {
  min-width: 56px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.text-button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.zoom-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  max-height: 72vh;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(203, 216, 234, 0.42) 1px, transparent 1px),
    linear-gradient(rgba(203, 216, 234, 0.42) 1px, transparent 1px),
    #f8fbff;
  background-size: 24px 24px;
  cursor: grab;
}

.zoom-stage.is-dragging {
  cursor: grabbing;
}

.lightbox-card img {
  width: min(100%, 980px);
  min-height: 0;
  max-height: 72vh;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.lightbox-focus {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

button:focus-visible,
.node:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}

@media (max-width: 720px) {
  .hud {
    flex-direction: column;
  }

  .hud-actions {
    padding-top: 0;
  }

  .canvas-help {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .node {
    width: 166px;
    min-height: 70px;
  }

  .node.root {
    width: 210px;
  }

  .lightbox {
    padding: 12px;
  }

  .lightbox-card {
    width: 100%;
    max-height: 95vh;
    padding: 12px;
  }
}
