@font-face {
  font-family: "Montserrat";
  src: url("./fonts/Montserrat-Regular.ttf") format("truetype");
  font-weight: 400;
}

@font-face {
  font-family: "Montserrat";
  src: url("./fonts/Montserrat-Italic.ttf") format("truetype");
  font-style: italic;
  font-weight: 400;
}

@font-face {
  font-family: "Montserrat";
  src: url("./fonts/Montserrat-Bold.ttf") format("truetype");
  font-weight: 800;
}

:root {
  color-scheme: light;
  --ink: #2c2530;
  --muted: #736676;
  --page: #fbf8fb;
  --paper: #ffffff;
  --line: #eadde7;
  --purple: #7b4fc9;
  --purple-soft: #f5f0ff;
  --purple-line: #d8c8ff;
  --rose: #c982a4;
  --rose-soft: #fff1f6;
  --rose-line: #e7bfd0;
  --mint: #4f7c68;
  --mint-soft: #eef9f5;
  --cream: #fffdf8;
  --shadow: 0 18px 44px rgba(87, 54, 78, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Montserrat", Helvetica, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 248, 251, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--ink);
  text-decoration: none;
}

.brand span {
  font-weight: 800;
}

.brand strong {
  margin-left: 8px;
  color: var(--purple);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-actions button,
.mode-grid button,
.shape-palette button,
.wide {
  min-height: 38px;
  border: 1px solid var(--rose-line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.top-actions .primary {
  border-color: var(--purple);
  background: var(--purple);
  color: #ffffff;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  width: min(1500px, 100%);
  min-height: calc(100vh - 65px);
  margin: 0 auto;
  padding: 18px;
}

.sidebar {
  display: grid;
  align-self: start;
  gap: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 15px;
  box-shadow: 0 8px 22px rgba(87, 54, 78, 0.05);
}

.intro-panel {
  background: linear-gradient(135deg, #ffffff, var(--rose-soft));
}

.eyebrow,
.label,
label {
  display: block;
  margin: 0 0 8px;
  color: var(--rose);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 31px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 12px;
  font-size: 16px;
}

.panel p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.shape-palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.shape-palette button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.shape-icon {
  display: inline-block;
  width: 24px;
  height: 18px;
  border: 2px solid var(--purple);
  background: var(--purple-soft);
}

.shape-icon.round {
  border-radius: 7px;
}

.shape-icon.oval {
  border-radius: 999px;
}

.shape-icon.diamond {
  width: 19px;
  height: 19px;
  transform: rotate(45deg);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.mode-grid .is-active {
  border-color: var(--purple);
  background: var(--purple-soft);
  color: var(--purple);
}

.hint {
  min-height: 40px;
}

.editor-panel textarea,
.editor-panel select,
#mapTitle {
  width: 100%;
  border: 1px solid var(--rose-line);
  border-radius: 8px;
  background: var(--rose-soft);
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

.editor-panel textarea:focus,
.editor-panel select:focus,
#mapTitle:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-soft);
}

.editor-panel select {
  margin-bottom: 12px;
}

.size-grid,
.anchor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.size-grid label,
.anchor-grid label {
  margin-bottom: 0;
}

.size-grid input,
.anchor-grid select,
.link-panel input[type="range"] {
  width: 100%;
  border: 1px solid var(--rose-line);
  border-radius: 8px;
  background: var(--rose-soft);
  color: var(--ink);
  padding: 9px 10px;
}

.link-panel {
  border-color: var(--purple-line);
  background: var(--purple-soft);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-transform: none;
}

.check-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--purple);
}

.danger {
  margin-top: 12px;
  border-color: var(--rose);
  background: var(--rose-soft);
  color: #7d3155;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.swatches button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0;
}

.swatches button::after {
  content: attr(data-color);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.swatches .purple {
  background: var(--purple-soft);
  border-color: var(--purple-line);
}

.swatches .rose {
  background: var(--rose-soft);
  border-color: var(--rose-line);
}

.swatches .mint {
  background: var(--mint-soft);
  border-color: #bfe3d5;
}

.swatches .cream {
  background: var(--cream);
  border-color: var(--line);
}

.swatches .is-active {
  box-shadow: 0 0 0 3px rgba(123, 79, 201, 0.25);
}

.wide {
  width: 100%;
}

.guide-card {
  margin-top: 11px;
  border: 1px solid var(--purple-line);
  border-radius: 8px;
  background: var(--purple-soft);
  padding: 12px;
}

.guide-card strong {
  color: var(--purple);
  font-size: 13px;
}

.workspace {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.workspace-head > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

#mapTitle {
  width: min(760px, 100%);
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 31px;
  font-weight: 800;
}

.status {
  flex: 0 0 auto;
  border: 1px solid var(--purple-line);
  border-radius: 999px;
  background: var(--purple-soft);
  color: var(--purple);
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 800;
}

.board-wrap {
  overflow: auto;
  background:
    radial-gradient(circle, rgba(123, 79, 201, 0.14) 0 1px, transparent 2px),
    linear-gradient(135deg, #fff, #fff8fb);
  background-size: 28px 28px, auto;
  padding: 18px;
}

.board {
  position: relative;
  width: 1280px;
  height: 780px;
  border: 1px solid var(--rose-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  overflow: hidden;
}

#linksLayer,
#nodesLayer {
  position: absolute;
  inset: 0;
}

#linksLayer {
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

.link-path {
  stroke: var(--mauve, #8d5a7c);
  stroke-width: 2.4;
  fill: none;
  pointer-events: stroke;
}

.link-path.is-selected {
  stroke: var(--purple);
  stroke-width: 3.2;
}

.link-hit {
  stroke: transparent;
  stroke-width: 18;
  fill: none;
  pointer-events: stroke;
  cursor: pointer;
}

.midpoint {
  fill: #ffffff;
  stroke: var(--purple);
  stroke-width: 2.4;
  pointer-events: none;
}

.node {
  position: absolute;
  display: grid;
  place-items: center;
  border: 2px solid var(--purple-line);
  background: var(--purple-soft);
  color: var(--ink);
  padding: 12px;
  text-align: center;
  font-size: 15px;
  line-height: 1.25;
  user-select: none;
  touch-action: none;
  box-shadow: 0 10px 24px rgba(87, 54, 78, 0.11);
}

.node strong {
  display: block;
  overflow-wrap: anywhere;
}

.node.round {
  border-radius: 8px;
}

.node.rect {
  border-radius: 2px;
}

.node.oval {
  border-radius: 999px;
}

.node.diamond {
  transform: rotate(45deg);
}

.node.diamond strong {
  transform: rotate(-45deg);
  max-width: 96px;
}

.node.rose {
  border-color: var(--rose-line);
  background: var(--rose-soft);
}

.node.mint {
  border-color: #bfe3d5;
  background: var(--mint-soft);
}

.node.cream {
  border-color: var(--line);
  background: var(--cream);
}

.node.is-selected {
  outline: 3px solid rgba(123, 79, 201, 0.28);
  outline-offset: 3px;
}

.node.is-connecting {
  outline: 3px solid rgba(201, 130, 164, 0.45);
  outline-offset: 5px;
}

.drop-note {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  border: 1px dashed var(--rose-line);
  border-radius: 8px;
  background: rgba(255, 248, 251, 0.85);
  color: var(--muted);
  padding: 16px;
  text-align: center;
  font-size: 14px;
  pointer-events: none;
}

.board.has-nodes .drop-note {
  display: none;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .intro-panel,
  .editor-panel {
    grid-column: 1 / -1;
  }

  .workspace-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    padding: 10px;
  }

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

  #mapTitle {
    font-size: 24px;
  }

}

@page {
  size: A4 landscape;
  margin: 10mm;
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .sidebar,
  .status {
    display: none !important;
  }

  .layout,
  .workspace,
  .board-wrap {
    display: block;
    width: 100%;
    min-height: auto;
    padding: 0;
    border: 0;
    box-shadow: none;
    overflow: hidden;
  }

  .workspace-head {
    padding: 0 0 7mm;
  }

  #mapTitle {
    font-size: 24pt;
  }

  .board {
    width: 1280px;
    height: 780px;
    transform: scale(0.8);
    transform-origin: top left;
    break-inside: avoid;
  }

  .board-wrap {
    height: 165mm;
  }
}
