:root {
  --ink: #111827;
  --muted: #667085;
  --line: #dce3ed;
  --blue: #1672ee;
  --blue-dark: #0f63df;
  --sidebar: 250px;
  --panel: 284px;
  --header: 80px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eef3f8;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-width: 320px; height: 100%; overflow: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }
svg { display: block; }

body {
  background: #f7f9fc;
  text-align: left;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--panel);
  grid-template-rows: var(--header) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  border: 1px solid #dbe2eb;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 18px 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 250px;
  color: #111827;
  font-size: 23px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -.5px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 5px 14px rgba(22, 114, 238, .25);
}

.brand-mark svg { width: 30px; height: 30px; }
.brand-mark path:first-child { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark path:last-child { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }

.toolbar-divider { width: 1px; height: 39px; background: #e1e6ee; margin: 0 3px 0 0; }
.toolbar-divider.short { margin: 0 1px; }
.history-controls, .toolbar, .topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-actions { margin-left: auto; }

button { cursor: pointer; }
.icon-button, .tool-button, .small-square-button, .save-button, .change-button, .fit-button, .zoom-controls button, .panel-actions button {
  border: 0;
  background: transparent;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
}

.icon-button:hover { background: #f3f6fa; }
.icon-button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button .fill-icon { fill: currentColor; stroke: none; width: 20px; }
.icon-button.muted { color: #98a2b3; }
.icon-button.bordered { border: 1px solid #dce3eb; box-shadow: 0 1px 2px rgba(15,23,42,.04); }

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #dce3eb;
  border-radius: 10px;
  background: #fff;
  font-size: 16px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
  transition: background .15s, border-color .15s, transform .15s;
}

.tool-button:hover { border-color: #bec9d7; background: #f8fafc; }
.tool-button:active { transform: translateY(1px); }
.tool-button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-button.compact { min-width: 110px; }
.file-input { display: none; }

.file-menu {
  position: fixed;
  top: 68px;
  right: 18px;
  width: 176px;
  padding: 8px;
  border: 1px solid #dce3eb;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 32px rgba(15,23,42,.16);
  z-index: 70;
}
.file-menu[hidden] { display: none; }
.file-menu button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
}
.file-menu button:hover { background: #f2f6fb; }
.file-menu svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.save-button {
  min-width: 86px;
  height: 44px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(180deg, #287ff2 0%, #116be9 100%);
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(22,114,238,.24);
}
.save-button:hover { background: linear-gradient(180deg, #1e76ea 0%, #0e60d5 100%); }

.maps-sidebar {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  padding: 18px 15px;
  border-right: 1px solid var(--line);
  background: linear-gradient(90deg, #fff 0%, #fbfcfe 100%);
  z-index: 10;
}

.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 7px 11px; }
.sidebar-heading h1 { margin: 0; font-size: 16px; line-height: 1.2; }
.small-square-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #d9e1eb;
  border-radius: 9px;
  background: #fff;
}
.small-square-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.small-square-button:hover { background: #f4f7fb; }
.map-list { display: flex; flex-direction: column; gap: 3px; }
.map-row { position: relative; }
.map-item {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  height: 46px;
  padding: 0 44px 0 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 16px;
  text-align: left;
}
.map-item > span:first-child { width: 25px; font-size: 19px; filter: saturate(.9); }
.map-item:hover { background: #f1f5fa; }
.map-item.active { background: #e1eeff; color: #103777; }
.map-delete-button {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #8a96a8;
  opacity: 0;
  transition: opacity .15s, color .15s, background .15s;
}
.map-delete-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.map-row:hover .map-delete-button, .map-row:focus-within .map-delete-button { opacity: 1; }
.map-delete-button:hover { color: #e3273c; background: #fff0f2; }
.create-map-button { display: flex; align-items: center; gap: 15px; width: 100%; margin-top: 8px; padding: 0 12px; border: 0; background: transparent; font-size: 15px; }
.create-map-button:hover { color: var(--blue); }

.minimap {
  position: absolute;
  left: 17px;
  right: 14px;
  bottom: 33px;
  height: 195px;
  display: grid;
  place-items: center;
  border: 1px solid #dce3eb;
  border-radius: 12px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 8px 22px rgba(15,23,42,.04);
  overflow: hidden;
}
.minimap svg { width: 92%; height: 87%; }
.mini-line { fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.mini-line.red { stroke: #ff7d88; } .mini-line.yellow { stroke: #f8bd3e; } .mini-line.green { stroke: #53c985; } .mini-line.purple { stroke: #9a68ea; } .mini-line.blue { stroke: #4598ee; }
.mini-nodes rect { rx: 5; stroke-width: 1; }
.mini-nodes .red { fill: #ffe9ec; stroke: #ffadb5; } .mini-nodes .yellow { fill: #fff4d7; stroke: #ffd36c; } .mini-nodes .green { fill: #e5f8eb; stroke: #86dba5; } .mini-nodes .purple { fill: #efe8ff; stroke: #be99f7; } .mini-nodes .blue { fill: #def0ff; stroke: #78b9ef; } .mini-nodes .root { fill: #3988f5; stroke: #0f6fe8; rx: 5; }

.workspace {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  overflow: hidden;
  outline: none;
  background-color: #f8fbfe;
  background-image: radial-gradient(circle, #d8e2ec 1px, transparent 1.25px), linear-gradient(135deg, rgba(230,238,246,.3), transparent 48%);
  background-size: 22px 22px, 100% 100%;
}

.workspace::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 18px 35px rgba(52,84,118,.025); }
.canvas { position: absolute; inset: 0; transform-origin: 50% 50%; transition: transform .2s ease; }
.connectors, .nodes-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.connectors path { fill: none; stroke-width: 2.2; vector-effect: non-scaling-stroke; stroke-linecap: round; }

.mind-node {
  --node-color: #1672ee;
  --node-bg: #e6f2ff;
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 122px;
  min-height: 48px;
  padding: 11px 20px;
  border: 1.7px solid var(--node-color);
  border-radius: 22px;
  background: var(--node-bg);
  color: #152033;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(15,23,42,.06);
  user-select: none;
  touch-action: none;
  cursor: grab;
  transition: filter .15s, box-shadow .15s, transform .15s;
}
.mind-node:hover { filter: brightness(.985); box-shadow: 0 4px 12px rgba(15,23,42,.09); }
.mind-node.dragging {
  z-index: 40;
  cursor: grabbing;
  transition: none;
  box-shadow: 0 8px 24px rgba(15,23,42,.18);
}
.mind-node.selected:not(.root) { box-shadow: 0 0 0 4px color-mix(in srgb, var(--node-color) 16%, transparent), 0 4px 12px rgba(15,23,42,.1); }
.mind-node.root {
  min-width: 238px;
  min-height: 106px;
  padding: 22px 26px;
  flex-direction: column;
  gap: 5px;
  border-width: 3px;
  border-color: #fff;
  border-radius: 38px;
  background: linear-gradient(160deg, #287bf1 0%, #1467e8 100%);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 0 0 6px rgba(101,194,244,.21), 0 10px 22px rgba(22,114,238,.24);
}
.mind-node.root .node-icon { font-size: 31px; line-height: 1; }
.mind-node.branch { min-height: 64px; min-width: 166px; font-weight: 650; }
.mind-node.leaf { min-height: 46px; font-size: 15px; }
.mind-node.pill { border-radius: 999px; }
.mind-node.rectangle { border-radius: 7px; }
.mind-node.red { --node-color: #ff3d50; --node-bg: #ffe7e9; }
.mind-node.green { --node-color: #16b75b; --node-bg: #dff7e8; }
.mind-node.yellow { --node-color: #f1a900; --node-bg: #fff3d4; }
.mind-node.purple { --node-color: #7c3bed; --node-bg: #eee4ff; }
.mind-node.blue { --node-color: #1680ef; --node-bg: #dff0ff; }
.mind-node.gray { --node-color: #8290a4; --node-bg: #edf1f5; }
.mind-node.teal { --node-color: #0f9f95; --node-bg: #ddf8f4; }
.mind-node.orange { --node-color: #f97316; --node-bg: #fff0e5; }
.mind-node.pink { --node-color: #ec4899; --node-bg: #fce7f3; }
.mind-node.cyan { --node-color: #06a9c7; --node-bg: #ddf7fc; }
.mind-node.indigo { --node-color: #4f46e5; --node-bg: #e9e7ff; }
.mind-node.brown { --node-color: #9a6746; --node-bg: #f3e8df; }
.node-icon { font-size: 23px; line-height: 1; }

.zoom-controls {
  position: absolute;
  left: 16px;
  bottom: 38px;
  display: flex;
  align-items: center;
  height: 49px;
  border: 1px solid #dce3eb;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(15,23,42,.08);
  z-index: 5;
}
.zoom-controls button { width: 46px; height: 100%; font-size: 25px; font-weight: 300; }
.zoom-controls button:hover { background: #f6f8fb; }
.zoom-controls output { min-width: 72px; padding: 0 14px; border-left: 1px solid #e3e8ef; border-right: 1px solid #e3e8ef; text-align: center; }
.fit-button { position: absolute; left: 200px; bottom: 38px; display: grid; place-items: center; width: 49px; height: 49px; border: 1px solid #dce3eb; border-radius: 10px; background: #fff; box-shadow: 0 5px 16px rgba(15,23,42,.08); z-index: 5; }
.fit-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.properties-panel {
  grid-column: 3;
  grid-row: 2;
  padding: 18px 20px 24px 22px;
  border-left: 1px solid var(--line);
  background: #fff;
  overflow-y: auto;
  z-index: 10;
}
.properties-panel.collapsed { display: none; }
.properties-heading { display: flex; align-items: center; justify-content: space-between; padding-bottom: 11px; border-bottom: 1px solid #e1e6ed; }
.properties-heading h2 { margin: 0; font-size: 18px; }
.properties-heading .icon-button { width: 32px; height: 32px; }
.properties-heading .icon-button svg { width: 20px; height: 20px; }
.property-group { margin-top: 18px; }
.property-group > label, .font-row > label { display: block; margin-bottom: 10px; font-weight: 650; }
.property-group input, .property-group select, .font-row input {
  width: 100%;
  height: 41px;
  padding: 0 13px;
  border: 1px solid #ccd5e0;
  border-radius: 8px;
  background: #fff;
  outline: none;
  font-size: 15px;
}
.property-group input:focus, .property-group select:focus, .font-row input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22,114,238,.12); }
.icon-row { display: grid; grid-template-columns: 58px 1fr 1fr; gap: 8px; }
.icon-preview, .change-button, .remove-icon-button {
  display: grid;
  place-items: center;
  height: 44px;
  border: 1px solid #d4dce6;
  border-radius: 8px;
  background: #fff;
}
.icon-preview { font-size: 22px; }
.icon-preview.empty { color: #8995a6; font-size: 13px; }
.change-button, .remove-icon-button { padding: 0 10px; font-size: 14px; }
.remove-icon-button { color: #e33143; }
.remove-icon-button:hover:not(:disabled) { border-color: #f4a1aa; background: #fff6f7; }
.remove-icon-button:disabled { color: #aab3c0; cursor: not-allowed; background: #f7f9fb; }
.color-picker { display: grid; grid-template-columns: repeat(6, 1fr); align-items: center; gap: 14px 8px; }
.color-swatch { width: 30px; height: 30px; border: 0; border-radius: 50%; background: currentColor; box-shadow: inset 0 0 0 1px rgba(0,0,0,.03); }
.color-swatch.blue { color: #2580ee; } .color-swatch.green { color: #4fc27c; } .color-swatch.yellow { color: #f7bd37; } .color-swatch.red { color: #f36d7b; } .color-swatch.purple { color: #9254de; } .color-swatch.gray { color: #95a2b5; }
.color-swatch.teal { color: #0f9f95; } .color-swatch.orange { color: #f97316; } .color-swatch.pink { color: #ec4899; } .color-swatch.cyan { color: #06a9c7; } .color-swatch.indigo { color: #4f46e5; } .color-swatch.brown { color: #9a6746; }
.color-swatch.selected { outline: 3px solid #cfe6ff; outline-offset: 2px; }
.font-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.font-row > label { margin: 0; }
.font-row input { width: 90px; text-align: center; }
.format-row { display: flex; gap: 26px; margin-top: 14px; }
.format-row label { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.format-row input { position: absolute; opacity: 0; pointer-events: none; }
.checkmark { display: grid; place-items: center; width: 23px; height: 23px; border: 1px solid #c6d0dd; border-radius: 5px; color: transparent; background: #fff; }
.format-row input:checked + .checkmark { border-color: var(--blue); color: #fff; background: var(--blue); }
.panel-divider { height: 1px; margin: 30px 0 20px; background: #e1e6ed; }
.properties-panel h3 { margin: 0 0 14px; font-size: 16px; }
.panel-actions { display: flex; flex-direction: column; gap: 11px; }
.panel-actions button { display: flex; align-items: center; gap: 12px; width: 100%; height: 43px; padding: 0 14px; border: 1px solid #d4dce6; border-radius: 8px; background: #fff; text-align: left; }
.panel-actions button:hover { background: #f7f9fc; }
.panel-actions button span { font-size: 22px; }
.panel-actions button.danger { border-color: #ff8e99; color: #ff2137; }

.context-menu {
  position: absolute;
  width: 205px;
  padding: 10px;
  border: 1px solid #e2e7ee;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15,23,42,.16);
  z-index: 50;
}
.context-menu[hidden] { display: none; }
.context-menu button { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; width: 100%; min-height: 41px; padding: 0 7px; border: 0; border-radius: 6px; background: transparent; font-size: 15px; text-align: left; }
.context-menu button:hover { background: #f3f6fa; }
.context-menu button span { font-size: 20px; }
.context-menu button.danger { color: #ff1f34; }
.context-menu hr { height: 1px; margin: 7px 4px; border: 0; background: #e4e8ee; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 24px);
  padding: 11px 18px;
  border-radius: 9px;
  background: #172033;
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(2px);
  z-index: 100;
}
.dialog-backdrop[hidden] { display: none; }
.confirm-dialog {
  width: min(400px, 100%);
  padding: 24px;
  border: 1px solid #e1e6ed;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15,23,42,.25);
}
.confirm-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #fff0f2;
  color: #e3273c;
}
.confirm-icon svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.confirm-dialog h2 { margin: 17px 0 8px; font-size: 21px; }
.confirm-dialog p { margin: 0; color: #5d697a; line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.confirm-actions button { height: 42px; padding: 0 17px; border-radius: 8px; font-weight: 600; }
.cancel-button { border: 1px solid #d2dae5; background: #fff; }
.cancel-button:hover { background: #f5f7fa; }
.confirm-delete-button { border: 1px solid #e3273c; background: #e3273c; color: #fff; }
.confirm-delete-button:hover:not(:disabled) { background: #c91f32; }
.confirm-delete-button:disabled { opacity: .65; cursor: wait; }

@media (max-width: 1180px) {
  :root { --sidebar: 215px; --panel: 260px; }
  .brand { min-width: 215px; font-size: 20px; }
  .toolbar { gap: 8px; }
  .topbar-actions { gap: 8px; }
  .tool-button { padding: 0 11px; }
  .toolbar .tool-button:nth-child(3) span, .toolbar .tool-button:nth-child(4) span { display: none; }
}

@media (max-width: 900px) {
  :root { --sidebar: 76px; --panel: 248px; }
  .brand { min-width: 45px; }
  .brand > span:last-child, .map-item > span:last-child, .create-map-button > span:last-child, .sidebar-heading h1, .minimap, .toolbar-divider { display: none; }
  .maps-sidebar { padding: 16px 9px; }
  .sidebar-heading { justify-content: center; padding: 0 0 10px; }
  .map-item { justify-content: center; padding: 0; }
  .map-item > span:first-child { width: auto; }
  .map-row { display: flex; align-items: center; }
  .map-row .map-item { flex: 1; min-width: 0; }
  .map-delete-button { position: static; flex: 0 0 26px; width: 26px; opacity: 1; }
  .create-map-button { justify-content: center; padding: 0; }
  .toolbar .tool-button span, .topbar-actions .tool-button span { display: none; }
  .tool-button, .tool-button.compact { min-width: 44px; padding: 0 10px; }
  .topbar { gap: 8px; padding: 0 12px; }
}

@media (max-width: 670px) {
  :root { --header: 66px; }
  .app-shell { grid-template-columns: 58px minmax(0, 1fr); border-radius: 0; }
  .properties-panel { display: none; }
  .topbar .toolbar .tool-button:nth-child(n+3), .history-controls, .topbar-actions .compact { display: none; }
  .brand-mark { width: 38px; height: 38px; }
  .maps-sidebar { padding-left: 7px; padding-right: 7px; }
  .small-square-button { width: 38px; height: 38px; }
  .zoom-controls { bottom: 18px; }
  .fit-button { left: 198px; bottom: 18px; }
}
