﻿@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700;800&display=swap');

:root {
  --bg: #161d2b;
  --panel: #151a24;
  --panel-2: #1c2333;
  --line: #28324a;
  --line-soft: rgba(40, 50, 74, 0.6);
  --text: #dde6f5;
  --muted: #7a8eaa;
  --accent: #5bbfb5;
  --accent-2: #7fd6cc;
  --accent-glow: rgba(91, 191, 181, 0.18);
  --danger: #e07070;
  --node: #1e2638;
  --node-border: #2e3d58;
  --node-selected: #c8d8f8;
  --port-size: 12px;
  --port-half: 6px;
  --port-offset: 1px;
  --radius: 11px;
  --radius-sm: 7px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Inter, "Segoe UI", system-ui, sans-serif; font-size: 16px; }
body.dragging, body.connecting { user-select: none; }
button { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; font-size: 0.9rem; font-family: inherit; letter-spacing: 0.02em; transition: background 100ms, border-color 100ms; }
button:hover { background: #232d42; border-color: #3d5070; }
button.primary { background: var(--accent); color: #051211; border-color: var(--accent-2); font-weight: 700; letter-spacing: 0.04em; }
button.primary:hover { background: var(--accent-2); }
button.toggle { background: var(--panel); color: var(--muted); }
button.toggle.is-active { background: var(--panel-2); color: #e8b060; border-color: #c4862a; box-shadow: 0 0 0 1px rgba(196, 134, 42, 0.22) inset; }
.minimal-toggle-btn { width: 38px; height: 38px; border-radius: var(--radius-sm); border: 1px solid #3b4d71; background: #202b40; color: var(--text); font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; transition: background 100ms, border-color 100ms; }
.minimal-toggle-btn svg { width: 16px; height: 16px; display: block; }
.minimal-toggle-btn:hover { background: #2a3751; border-color: #4b6088; }
.minimal-toggle-btn.is-active { background: var(--panel-2); color: #e8b060; border-color: #c4862a; box-shadow: 0 0 0 1px rgba(196, 134, 42, 0.22) inset; }
.is-minimal .minimal-toggle-btn { background: #f7f3ef; border-color: #c9c8c9; color: #2b2b2b; }
.is-minimal .minimal-toggle-btn:hover { background: #f7f3ef; border-color: #c9c8c9; }
.is-minimal .minimal-toggle-btn.is-active { background: #2b2b2b; color: #f1ede8; border-color: #2b2b2b; box-shadow: none; }
.app { display: grid; grid-template-rows: auto 1fr auto; height: 100%; overflow: hidden; }
.main-layout { display: grid; grid-template-columns: 480px 1fr; min-height: 0; }
.toolbar { display: flex; align-items: stretch; background: linear-gradient(180deg, #1b2438 0%, #141d2d 100%); border-bottom: 1px solid #344667; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34); }
.toolbar-left { width: 620px; flex-shrink: 0; padding: 14px 18px 14px; display: flex; flex-direction: column; justify-content: center; }
.toolbar-left h1 { margin: 0; font-size: 1.9rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; font-family: "Barlow Condensed", "Arial Narrow", sans-serif; }
.toolbar-left p { margin: 4px 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.35; }
.toolbar-inspired-link { color: #d99c48; text-decoration: none; }
.toolbar-inspired-link:hover { text-decoration: underline; }
.toolbar-right { flex: 1; padding: 12px 18px; border-bottom: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; background: transparent; }
.toolbar-right button { background: #202b40; border-color: #3b4d71; font-weight: 600; }
.toolbar-right button:hover { background: #2a3751; border-color: #4b6088; }

/* ── Shape drawing tools (toolbar) ─────────────────── */
.shape-tools {
  display: flex;
  gap: 0;
  align-items: center;
  border-right: 1px solid rgba(122,156,206,0.18);
  padding-right: 10px;
  margin-right: 6px;
}
.shape-tools .shape-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent !important;
  border: none !important;
  border-radius: 4px;
  color: rgba(160,185,220,0.65);
  cursor: pointer;
  transition: color 100ms, background 100ms;
  box-shadow: none !important;
}
.shape-tools .shape-tool-btn:hover {
  color: rgba(160,185,220,0.95);
  background: rgba(255,255,255,0.06) !important;
}
.shape-tools .shape-tool-btn.is-active {
  color: #7ab4ff;
  background: rgba(79,141,255,0.14) !important;
}
body.drawing-shape .workspace { cursor: crosshair !important; }
.left-sidebar { border-right: 2px solid var(--line); background: var(--panel); padding: 18px 20px 22px; display: grid; align-content: start; gap: 16px; overflow-y: auto; }
.left-sidebar h2 { margin: 0 0 2px; font-size: 1.1rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-family: "Barlow Condensed", "Arial Narrow", sans-serif; color: var(--text); }
.sidebar-label { font-size: 1.28rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(221,230,245,0.95); font-family: "Barlow Condensed", "Arial Narrow", sans-serif; }
.left-sidebar .sidebar-label:first-of-type { padding-top: 0; border-top: 0; }
.sidebar-input { width: 100%; border: 1px solid var(--node-border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-family: inherit; font-size: 1.08rem; font-weight: 600; padding: 12px 14px; transition: border-color 120ms, box-shadow 120ms; }
.sidebar-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.sidebar-input::placeholder { color: #2e3d58; font-weight: 400; }
.sidebar-text { width: 100%; border: 1px solid var(--node-border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-family: inherit; font-size: 0.95rem; line-height: 1.5; padding: 12px 14px; resize: none; min-height: 120px; max-height: 40vh; overflow-y: hidden; transition: border-color 120ms, box-shadow 120ms, height 120ms; }
.sidebar-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.left-sidebar::-webkit-scrollbar { width: 10px; }
.left-sidebar::-webkit-scrollbar-track { background: #101827; }
.left-sidebar::-webkit-scrollbar-thumb { background: #465777; border-radius: 8px; border: 2px solid #101827; }
.left-sidebar::-webkit-scrollbar-thumb:hover { background: #5a6f96; }
.add-node-panel { padding: 16px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--panel-2); display: grid; gap: 12px; }
.add-node-panel h3 { margin: 0; font-size: 1.28rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-family: "Barlow Condensed", "Arial Narrow", sans-serif; color: var(--text); }
.type-button-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.type-button-list button { padding: 9px 8px; font-size: 0.9rem; border-radius: var(--radius-sm); text-transform: capitalize; background: var(--panel); border-color: var(--node-border); color: var(--muted); }
.type-button-list button:hover { background: var(--panel-2); color: var(--text); border-color: #3d5070; }
.type-button-list button.type-truth { background: rgba(56,180,120,0.2); border-color: rgba(56,180,120,0.65); color: #9fffc8; }
.type-button-list button.type-clue { background: rgba(70,150,255,0.2); border-color: rgba(70,150,255,0.65); color: #aad4ff; }
.type-button-list button.type-scene { background: rgba(240,175,65,0.2); border-color: rgba(240,175,65,0.65); color: #ffe4a0; }
.type-button-list button.type-suspect { background: rgba(230,90,120,0.2); border-color: rgba(230,90,120,0.65); color: #ffb8c6; }
.type-button-list button.type-witness { background: rgba(90,190,235,0.2); border-color: rgba(90,190,235,0.65); color: #bfe9ff; }
.type-button-list button.type-evidence { background: rgba(98,220,190,0.2); border-color: rgba(98,220,190,0.65); color: #b6fff1; }
.type-button-list button.type-location { background: rgba(140,110,235,0.2); border-color: rgba(140,110,235,0.65); color: #d8c8ff; }
.type-button-list button.type-event { background: rgba(240,120,60,0.2); border-color: rgba(240,120,60,0.65); color: #ffc4a0; }
.type-button-list button.type-item { background: rgba(60,200,180,0.2); border-color: rgba(60,200,180,0.65); color: #a0f0e8; }
.type-button-list button.type-custom { background: rgba(150,168,200,0.16); border-color: rgba(150,168,200,0.6); color: #c8d4e8; }
.type-button-list button.type-red-herring { background: rgba(210,80,110,0.22); border-color: rgba(210,80,110,0.68); color: #ffc4d3; }
.type-button-list button.type-revelation  { background: rgba(255,200,60,0.2);   border-color: rgba(255,200,60,0.65);  color: #ffe999; }
.type-button-list button.type-truth:hover,
.type-button-list button.type-clue:hover,
.type-button-list button.type-scene:hover,
.type-button-list button.type-suspect:hover,
.type-button-list button.type-witness:hover,
.type-button-list button.type-evidence:hover,
.type-button-list button.type-location:hover,
.type-button-list button.type-event:hover,
.type-button-list button.type-item:hover,
.type-button-list button.type-custom:hover,
.type-button-list button.type-red-herring:hover,
.type-button-list button.type-revelation:hover { filter: brightness(1.08); border-color: currentColor; }
.new-mystery-panel {
  margin-top: 2px;
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(63, 81, 114, 0.5);
  background: linear-gradient(180deg, rgba(22, 33, 52, 0.86), rgba(17, 25, 40, 0.9));
}
.mystery-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 9px;
}
.new-mystery-panel button,
.new-mystery-btn,
.sidebar-action-btn,
.sidebar-action-btn-primary {
  width: 100%;
  min-height: 38px;
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  background: #202b40;
  border: 1px solid #3b4d71;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: background 100ms, border-color 100ms, color 100ms;
}
.new-mystery-panel button:hover,
.new-mystery-btn:hover,
.sidebar-action-btn:hover,
.sidebar-action-btn-primary:hover {
  background: #2a3751;
  border-color: #4b6088;
  color: #e7efff;
}
.new-mystery-btn {
  background: rgba(68, 34, 46, 0.9);
  border-color: rgba(148, 88, 108, 0.7);
  color: #f2d7de;
}
.new-mystery-btn:hover {
  background: rgba(85, 42, 58, 0.95);
  border-color: rgba(176, 108, 131, 0.84);
  color: #ffe7ec;
}
.sidebar-action-btn-primary,
.new-mystery-panel .sidebar-action-btn-primary {
  background: linear-gradient(180deg, #c4862a, #a86d1c);
  border-color: #d99c48;
  color: #fff8ec;
  font-weight: 700;
}
.sidebar-action-btn-primary:hover,
.new-mystery-panel .sidebar-action-btn-primary:hover {
  background: linear-gradient(180deg, #d6982f, #ba7c22);
  border-color: #e8b060;
  color: #ffffff;
}

.support-panel {
  margin-top: 34px;
  padding: 38px 0 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  position: relative;
}
.support-panel::before {
  content: '';
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(88, 108, 145, 0.46) 25%, rgba(88, 108, 145, 0.46) 75%, transparent);
}
.support-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.support-column { min-width: 0; text-align: center; }
.support-heading { margin: 0 0 8px; font-family: "Barlow Condensed", "Arial Narrow", sans-serif; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.94rem; font-weight: 600; color: rgba(198,211,232,0.84); }
.support-copy { margin: 0 0 8px; color: rgba(132,151,180,0.92); line-height: 1.35; font-size: 0.82rem; }
.support-actions, .support-contact-form { display: grid; gap: 8px; justify-items: center; }
.support-btn, .support-anchor, .support-select {
  width: min(300px, 100%);
  min-height: 36px;
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  background: rgba(20, 30, 46, 0.72);
  border: 1px solid rgba(66, 85, 116, 0.46);
  color: #b7c6db;
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-size: 0.86rem;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
.support-btn-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  opacity: 0.88;
  color: currentColor;
}
.support-btn:hover, .support-anchor:hover { background: rgba(26, 39, 60, 0.82); border-color: rgba(95, 120, 160, 0.56); color: #d2deef; }
.support-select { appearance: none; -webkit-appearance: none; -moz-appearance: none; font-family: inherit; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, #a9bddc 50%), linear-gradient(135deg, #a9bddc 50%, transparent 50%); background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px); background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }
.support-select:focus { outline: none; border-color: rgba(101, 127, 168, 0.7); box-shadow: 0 0 0 2px rgba(84, 112, 151, 0.18); }
.support-donate { background: rgba(72, 58, 27, 0.72); border-color: rgba(152, 128, 69, 0.52); color: #edd69d; }
.support-donate:hover { background: rgba(89, 70, 32, 0.8); border-color: rgba(171, 145, 79, 0.62); color: #f3e2bb; }
.support-meta { margin-top: 12px; padding-top: 0; text-align: center; }
.support-meta-divider { display: none; }
.support-meta-copy { font-size: 0.68rem; line-height: 1.35; color: rgba(124, 143, 170, 0.92); }
.support-meta-copy + .support-meta-copy { margin-top: 2px; }
.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; }
.workspace { position: relative; overflow: hidden; touch-action: none; background-color: #212c40; background-image: radial-gradient(circle, rgba(255,255,255,0.05) 1px, transparent 1px); background-size: 28px 28px; }
.workspace.panning { cursor: grabbing; }
.graph-content { position: absolute; left: 0; top: 0; width: 2000000px; height: 2000000px; transform-origin: 0 0; }
#edgeCanvas { position: absolute; left: -500000px; top: -500000px; width: 2000000px; height: 2000000px; pointer-events: auto; }
.node-layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
#edgeLabelCanvas { position: absolute; left: -500000px; top: -500000px; width: 2000000px; height: 2000000px; pointer-events: none; }
.node.is-hidden { opacity: 0.15; }
.node { position: absolute; width: 220px; min-height: 92px; border-radius: var(--radius); overflow: visible; border: 2px solid #0a0a0a; background: var(--node); box-shadow: 0 4px 16px rgba(0,0,0,0.5); cursor: grab; transition: box-shadow 120ms ease, border-color 120ms ease, transform 120ms ease; pointer-events: auto; }
.node:active { cursor: grabbing; }
.node.selected { border-color: #0a0a0a; transform: translateY(-1px) scale(1.01); box-shadow: 0 0 0 4px rgba(127,214,204,0.5), 0 0 24px rgba(127,214,204,0.42), 0 14px 30px rgba(0,0,0,0.62); }
.node.connect-target { border-color: #0a0a0a; box-shadow: 0 0 0 2px var(--accent-glow), 0 6px 20px rgba(0,0,0,0.55); }
.node-header { padding: 8px 11px; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; border-top-left-radius: calc(var(--radius) - 1px); border-top-right-radius: calc(var(--radius) - 1px); }
.node-header.type-truth       { background: rgba(56,180,120,0.2);  color: #9fffc8; }
.node-header.type-clue        { background: rgba(70,150,255,0.2);  color: #aad4ff; }
.node-header.type-scene       { background: rgba(240,175,65,0.2);  color: #ffe4a0; }
.node-header.type-suspect     { background: rgba(230,90,120,0.2);  color: #ffb8c6; }
.node-header.type-witness     { background: rgba(90,190,235,0.2);  color: #bfe9ff; }
.node-header.type-evidence    { background: rgba(98,220,190,0.2);  color: #b6fff1; }
.node-header.type-location    { background: rgba(140,110,235,0.2); color: #d8c8ff; }
.node-header.type-event       { background: rgba(240,120,60,0.2);  color: #ffc4a0; }
.node-header.type-item        { background: rgba(60,200,180,0.2);  color: #a0f0e8; }
.node-header.type-custom      { background: rgba(150,168,200,0.16);color: #c8d4e8; }
.node-header.type-red-herring { background: rgba(210,80,110,0.22); color: #ffc4d3; }
.node-header.type-revelation  { background: rgba(255,200,60,0.22);  color: #ffe999; }
.node-body { padding: 10px 11px 11px; font-size: 0.9rem; line-height: 1.4; }
.node-name { color: var(--text); font-weight: 600; margin-bottom: 3px; }
.node-description { color: var(--muted); font-size: 0.86rem; }
.node.editing { border-color: var(--accent); }
.node-editor { display: grid; gap: 7px; }
.node-editor input, .node-editor select, .node-editor textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #0e1420; color: var(--text); padding: 8px 10px; font-size: 0.9rem; font-family: inherit; }
.node-editor textarea { resize: vertical; min-height: 52px; max-height: 110px; }
.port { position: absolute; width: var(--port-size); height: var(--port-size); min-width: 0; min-height: 0; padding: 0; border-radius: 1px; border: 2px solid #0a0a0a; background: #ffffff; opacity: 0; pointer-events: none; cursor: crosshair; z-index: 2; transition: opacity 100ms, box-shadow 100ms; }
.node:hover .port, .node.selected .port, .port.is-active, .port.is-target, body.connecting .port { opacity: 1; pointer-events: auto; }
.port.is-target, .port:hover, .port.is-active { background: #ffffff; box-shadow: 0 0 0 4px rgba(255,255,255,0.2); }
.port[data-port="top"]    { left: 50%; top: calc(0px - var(--port-half) - var(--port-offset)); transform: translateX(-50%) rotate(45deg); }
.port[data-port="right"]  { left: calc(100% - var(--port-half) + var(--port-offset)); top: 50%; transform: translateY(-50%) rotate(45deg); }
.port[data-port="bottom"] { left: 50%; top: calc(100% - var(--port-half) + var(--port-offset)); transform: translateX(-50%) rotate(45deg); }
.port[data-port="left"]   { left: calc(0px - var(--port-half) - var(--port-offset)); top: 50%; transform: translateY(-50%) rotate(45deg); }
.edge { stroke: #5a76a2; stroke-opacity: 0.72; stroke-width: 1.5; fill: none; pointer-events: stroke; }
.edge.selected { stroke: #c8d8f8; stroke-width: 2.5; }
.edge-hit { stroke: transparent; stroke-width: 24; fill: none; pointer-events: stroke; }
.edge-handle { fill: #b0c4e8; stroke: #0e1420; stroke-width: 1.5; cursor: crosshair; }
.guide { stroke: rgba(91,191,181,0.75); stroke-width: 1; stroke-dasharray: 4 5; pointer-events: none; }
.draft { stroke: rgba(180,200,238,0.65); stroke-width: 1.5; stroke-dasharray: 6 4; fill: none; pointer-events: none; }
.edge-label { font-size: 11.5px; font-family: inherit; fill: #7a94b8; stroke: var(--bg); stroke-width: 3.5px; paint-order: stroke; pointer-events: none; user-select: none; letter-spacing: 0.07em; }
.selection-box { position: absolute; border: 1px solid rgba(91,191,181,0.65); background: rgba(91,191,181,0.06); pointer-events: none; }
.selection-box.hidden { display: none; }
.workspace-legend { position: absolute; right: 14px; bottom: 14px; z-index: 3; width: min(420px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(21,26,36,0.9); backdrop-filter: blur(2px); padding: 10px 12px; color: var(--muted); font-size: 0.8rem; line-height: 1.45; pointer-events: none; box-shadow: 0 8px 20px rgba(0,0,0,0.35); text-align: center; }
.workspace-legend p { margin: 0; }
.workspace-legend p + p { margin-top: 5px; }
.workspace-legend strong { color: var(--text); letter-spacing: 0.03em; }
.statusbar {
  padding: 5px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  min-height: 32px;
  flex-shrink: 0;
}
.statusbar::-webkit-scrollbar { display: none; }
.status-msg { color: var(--text); font-weight: 600; font-size: 0.82rem; flex-shrink: 0; margin-right: auto; }
.hint-sep { color: rgba(40,50,74,0.5); margin: 0 6px; font-size: 0.76rem; flex-shrink: 0; }
.hint-item { display: inline-flex; align-items: center; gap: 3px; margin-right: 6px; flex-shrink: 0; opacity: 0.8; }
.hint-key {
  display: inline-block;
  background: transparent;
  border: 1px solid rgba(40,50,74,0.55);
  border-radius: 3px;
  padding: 0px 4px;
  font-size: 0.72rem;
  font-family: "Barlow Condensed", "Arial Narrow", monospace;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text);
  line-height: 1.5;
}
.hint-desc { color: var(--text); font-size: 0.74rem; }
.modal { position: fixed; inset: 0; z-index: 40; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4,6,12,0.7); backdrop-filter: blur(2px); }
.modal-dialog { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(440px, calc(100vw - 24px)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 24px 52px rgba(0,0,0,0.6); }
.modal-dialog h2 { margin: 0 0 14px; font-size: 0.88rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.modal-form { display: grid; gap: 10px; }
.modal-form label { font-size: 0.82rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: -4px; }
.modal-form select, .modal-form input, .modal-form textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #0e1420; color: var(--text); padding: 10px 12px; font-size: 0.95rem; font-family: inherit; transition: border-color 120ms; }
.modal-form select:focus, .modal-form input:focus, .modal-form textarea:focus { outline: none; border-color: var(--accent); }
.modal-form textarea { resize: vertical; min-height: 86px; line-height: 1.5; }
.custom-node-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 12px;
}
.custom-node-field {
  display: grid;
  gap: 10px;
}
.custom-node-name-field {
  grid-column: 1;
}
.custom-node-color-field {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.custom-color-picker {
  position: relative;
  width: 36px;
  margin-left: 0;
}
.custom-color-trigger {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  border: 1px solid #3a4d70;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  cursor: pointer;
}
.custom-color-trigger:hover {
  border-color: #6f8fbe;
}
.custom-color-trigger:focus-visible {
  outline: 2px solid #86b9f6;
  outline-offset: 2px;
}
.custom-color-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  padding: 10px;
  border: 1px solid rgba(82, 104, 142, 0.78);
  border-radius: 9px;
  background: rgba(18, 27, 42, 0.98);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.48);
}
.custom-color-popup.hidden {
  display: none;
}
.custom-color-palette {
  display: grid;
  grid-template-columns: repeat(3, 36px);
  gap: 8px;
}
.custom-color-option {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(10, 14, 22, 0.9);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  cursor: pointer;
}
.custom-color-option:hover {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26), 0 0 0 2px rgba(93, 128, 181, 0.38);
}
.custom-color-option.is-selected {
  border-color: #dce8fb;
  box-shadow: inset 0 0 0 2px rgba(15, 22, 34, 0.68), 0 0 0 2px rgba(164, 195, 242, 0.75);
}
.custom-node-color-select-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
@media (max-width: 520px) {
  .custom-node-form {
    grid-template-columns: 1fr;
  }
  .custom-node-name-field,
  .custom-node-color-field {
    grid-column: auto;
  }
  .custom-color-picker {
    margin-left: 0;
  }
  .custom-color-popup {
    left: 0;
  }
}
.modal-actions { margin-top: 14px; display: flex; justify-content: flex-end; gap: 8px; }

/* ── Edge edit modal layout ── */
.edge-edit-dialog { width: min(520px, calc(100vw - 24px)); }
.edge-edit-form { display: grid; gap: 12px; }
.edge-edit-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: start;
}
.edge-edit-label-col { display: grid; gap: 10px; }
.edge-edit-color-col { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.edge-edit-style-col { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.edge-color-picker { position: relative; width: 36px; }
.edge-color-palette { grid-template-columns: repeat(5, 36px); }
.edge-style-picker { position: relative; width: 36px; }
.edge-style-trigger {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0e1420;
  color: #7a9cce;
  border-radius: 7px;
  border: 1px solid #3a4d70;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
  cursor: pointer;
  padding: 0;
}
.edge-style-trigger:hover { border-color: #6f8fbe; color: #a8c4e8; }
.edge-style-trigger:focus-visible { outline: 2px solid #86b9f6; outline-offset: 2px; }

/* Edge style pills (inside popup) */
.edge-style-pills {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.edge-style-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid #3a4d70;
  background: transparent;
  color: rgba(90,118,162,0.85);
  cursor: pointer;
  transition: border-color 120ms, background 120ms, color 120ms;
}
.edge-style-pill:hover {
  border-color: #5a7096;
  color: #a8c4e8;
}
.edge-style-pill.is-selected {
  border-color: #86b9f6;
  background: rgba(86,140,220,0.14);
  color: #c0d8f6;
}
.confirm-dialog { width: min(360px, calc(100vw - 24px)); }
.confirm-message { margin: 0 0 4px; font-size: 0.95rem; line-height: 1.55; color: var(--text); }

.export-meta-form {
  margin-top: 10px;
}

.export-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.export-meta-row[hidden] {
  display: none;
}

.export-meta-row-stack {
  align-items: flex-start;
  flex-direction: column;
}

.export-meta-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.export-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.export-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #42587f;
  border-radius: 999px;
  background: #172135;
  color: var(--text);
  font-size: 0.8rem;
  padding: 4px 10px;
}

.export-chip-auto {
  border-color: #66c8bc;
  font-weight: 700;
}

.export-chip-remove {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  line-height: 1;
  font-size: 0.9rem;
  padding: 0;
}
button.danger { background: #7b1f2a; color: #f5c2c7; border-color: #a33040; }
button.danger:hover { background: #a33040; }
@media (max-width: 720px) {
  .main-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .left-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { width: 100%; justify-content: stretch; }
  .toolbar-right button { flex: 1; }
  .support-grid { grid-template-columns: 1fr; }
  .workspace-legend { bottom: 10px; right: 10px; width: min(420px, calc(100% - 20px)); font-size: 0.76rem; }
}

/* ── Minimal / monochrome mode ── */
.is-minimal .toolbar {
  background: #eee8e2;
  border-bottom: 1px solid #c9c8c9;
  box-shadow: none;
}
.is-minimal .toolbar-left h1,
.is-minimal .toolbar-left p,
.is-minimal .toolbar-inspired-link { color: #2b2b2b; }
.is-minimal .toolbar-inspired-link { color: #2b2b2b; }
.is-minimal .toolbar-right { background: #eee8e2; }
.is-minimal .toolbar-right button {
  background: #f7f3ef;
  border-color: #c9c8c9;
  color: #2b2b2b;
}
.is-minimal .toolbar-right button:hover {
  background: #e3ddd7;
  border-color: #afa7a2;
}
.is-minimal .toolbar-right button.toggle.is-active {
  background: #2b2b2b;
  color: #f1ede8;
  border-color: #2b2b2b;
  box-shadow: none;
}
.is-minimal .left-sidebar {
  background: #ece7e0;
  border-right: 1px solid #c9c8c9;
}
.is-minimal .left-sidebar::-webkit-scrollbar-track { background: #e3ddd7; }
.is-minimal .left-sidebar::-webkit-scrollbar-thumb { background: #c9c8c9; border-color: #e3ddd7; }
.is-minimal .sidebar-label { color: #2b2b2b; }
.is-minimal .sidebar-input {
  background: #f7f3ef;
  border-color: #c9c8c9;
  color: #2b2b2b;
}
.is-minimal .sidebar-input::placeholder { color: #c0b8b3; }
.is-minimal .sidebar-input:focus { border-color: #2b2b2b; box-shadow: 0 0 0 2px rgba(43,43,43,0.1); }
.is-minimal .sidebar-text {
  background: #f7f3ef;
  border-color: #c9c8c9;
  color: #2b2b2b;
}
.is-minimal .sidebar-text:focus { border-color: #2b2b2b; box-shadow: 0 0 0 2px rgba(43,43,43,0.1); }
.is-minimal .add-node-panel {
  background: #e3ddd7;
  border-color: #c9c8c9;
}
.is-minimal .add-node-panel h3 { color: #2b2b2b; }
.is-minimal .type-button-list button,
.is-minimal .type-button-list button[class*="type-"] {
  background: #f7f3ef !important;
  border-color: #c9c8c9 !important;
  color: #2b2b2b !important;
}
.is-minimal .type-button-list button:hover,
.is-minimal .type-button-list button[class*="type-"]:hover {
  background: #e3ddd7 !important;
  border-color: #afa7a2 !important;
  color: #2b2b2b !important;
  filter: none !important;
}
.is-minimal .new-mystery-panel {
  background: #e3ddd7;
  border-color: #c9c8c9;
}
.is-minimal .new-mystery-panel button,
.is-minimal .new-mystery-btn,
.is-minimal .sidebar-action-btn {
  background: #f7f3ef;
  border-color: #c9c8c9;
  color: #2b2b2b;
}
.is-minimal .new-mystery-panel button:hover,
.is-minimal .new-mystery-btn:hover,
.is-minimal .sidebar-action-btn:hover {
  background: #e3ddd7;
  border-color: #afa7a2;
  color: #2b2b2b;
}
.is-minimal .sidebar-action-btn-primary,
.is-minimal .new-mystery-panel .sidebar-action-btn-primary {
  background: #2b2b2b !important;
  border-color: #2b2b2b !important;
  color: #f1ede8 !important;
}
.is-minimal .sidebar-action-btn-primary:hover,
.is-minimal .new-mystery-panel .sidebar-action-btn-primary:hover {
  background: #3d3835 !important;
  border-color: #3d3835 !important;
  color: #f1ede8 !important;
}
.is-minimal .support-panel {
  border-top: none;
  position: relative;
}
.is-minimal .support-panel::before {
  content: '';
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, #c9c8c9 25%, #c9c8c9 75%, transparent);
}
.is-minimal .support-heading { color: #2b2b2b; }
.is-minimal .support-copy { color: #afa7a2; }
.is-minimal .support-btn,
.is-minimal .support-anchor,
.is-minimal .support-select {
  background: #f7f3ef;
  border-color: #c9c8c9;
  color: #2b2b2b;
}
.is-minimal .support-btn:hover,
.is-minimal .support-anchor:hover { background: #e3ddd7; border-color: #afa7a2; color: #2b2b2b; }
.is-minimal .support-donate { background: #f7f3ef; border-color: #c9c8c9; color: #2b2b2b; }
.is-minimal .support-meta-copy { color: #afa7a2; }
.is-minimal .statusbar { background: #eee8e2; border-top-color: #c9c8c9; color: #afa7a2; }
.is-minimal .status-msg { color: #2b2b2b; }
.is-minimal .hint-key { background: transparent; border-color: rgba(175,167,162,0.55); color: #7a7370; }
.is-minimal .hint-desc { color: #6a6360; }
.is-minimal .hint-sep { color: rgba(201,200,201,0.5); }
.is-minimal .workspace {
  background-color: #f1ede8;
  background-image: radial-gradient(circle, rgba(43,43,43,0.08) 1px, transparent 1px);
  background-size: 28px 28px;
}
.is-minimal .node {
  border: 1px solid #c9c8c9;
  background: #faf7f4;
  box-shadow: 0 1px 4px rgba(43,43,43,0.08);
}
.is-minimal .node-header {
  background: #e3ddd7 !important;
  color: #2b2b2b !important;
  border-bottom: 1px solid #c9c8c9 !important;
}
.is-minimal .node-name { color: #2b2b2b; }
.is-minimal .node-description { color: #5a5250; }
.is-minimal .node.selected {
  box-shadow: 0 0 0 2px #2b2b2b, 0 4px 12px rgba(43,43,43,0.14);
  border-color: #2b2b2b;
}
.is-minimal .node.connect-target { border-color: #2b2b2b; }
.is-minimal .edge { stroke: rgba(43,43,43,0.30) !important; }
.is-minimal .edge.selected { stroke: rgba(43,43,43,0.80) !important; }
.is-minimal .edge-label { fill: #afa7a2; stroke: #f1ede8; }
.is-minimal .guide { stroke: rgba(43,43,43,0.15); }
.is-minimal .port { background: #2b2b2b; border-color: #f1ede8; }
.is-minimal .selection-box { border-color: rgba(43,43,43,0.30); background: rgba(43,43,43,0.04); }
/* modals */
.is-minimal .modal-backdrop { background: rgba(43,43,43,.40); backdrop-filter: blur(2px); }
.is-minimal .modal-dialog { background: #f7f3ef; border-color: #c9c8c9; box-shadow: 0 12px 32px rgba(43,43,43,.15); }
.is-minimal .modal-dialog h2 { color: #afa7a2; }
.is-minimal .modal-form label { color: #afa7a2; }
.is-minimal .modal-form select,
.is-minimal .modal-form input,
.is-minimal .modal-form textarea { background: #f1ede8; border-color: #c9c8c9; color: #2b2b2b; }
.is-minimal .modal-form select:focus,
.is-minimal .modal-form input:focus,
.is-minimal .modal-form textarea:focus { border-color: #2b2b2b; box-shadow: 0 0 0 2px rgba(43,43,43,.10); }
.is-minimal .confirm-message { color: #5a5250; }
/* modal buttons */
.is-minimal .modal-actions button { background: #f7f3ef; border-color: #c9c8c9; color: #2b2b2b; }
.is-minimal .modal-actions button:hover { background: #e3ddd7; border-color: #afa7a2; }
.is-minimal .modal-actions button.primary { background: #2b2b2b; border-color: #2b2b2b; color: #f1ede8; }
.is-minimal .modal-actions button.primary:hover { background: #3d3835; }
/* edge style trigger */
.is-minimal .edge-style-trigger { background: #f1ede8; border-color: #c9c8c9; color: #2b2b2b; }
.is-minimal .edge-style-trigger:hover { border-color: #afa7a2; color: #2b2b2b; }
/* edge style pills popup */
.is-minimal .edge-style-pill { border-color: #c9c8c9; color: #5a5250; }
.is-minimal .edge-style-pill:hover { border-color: #afa7a2; color: #2b2b2b; }
.is-minimal .edge-style-pill.is-selected { border-color: #2b2b2b; background: rgba(43,43,43,0.08); color: #2b2b2b; }
/* color/style popup containers */
.is-minimal .custom-color-popup,
.is-minimal .edge-color-popup,
.is-minimal .edge-style-popup { background: #f7f3ef; border-color: #c9c8c9; box-shadow: 0 8px 20px rgba(43,43,43,0.15); }
/* color trigger button */
.is-minimal .custom-color-trigger { border-color: #c9c8c9; }
/* export chips */
.is-minimal .export-chip { background: #ece7e0; border-color: #c9c8c9; color: #2b2b2b; }
.is-minimal .export-chip-auto { border-color: #2b2b2b; }
.is-minimal .export-chip-remove { color: #5a5250; }
.is-minimal .export-meta-label { color: #5a5250; }
.is-minimal .modal-form input[type="text"],
.is-minimal .modal-form input:not([type]),
.is-minimal .modal-form select,
.is-minimal .modal-form textarea { background: #f1ede8; border-color: #c9c8c9; color: #2b2b2b; }
.is-minimal .modal-form input[type="text"]::placeholder,
.is-minimal .modal-form textarea::placeholder { color: #c0b8b3; }

/* ── Shape SVG elements ──────────────────────────────── */
.shape-group { cursor: grab; }
.shape-group:active { cursor: grabbing; }
.shape-hit { fill: transparent; stroke: transparent; stroke-width: 20; pointer-events: all; cursor: grab; }
.shape-text-hit { pointer-events: all; cursor: grab; }
.shape-vis { pointer-events: none; }
.shape-text-vis {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.06em;
  pointer-events: none;
  user-select: none;
}

/* ── Shape text inline cursor ─────────────────────────── */
@keyframes shape-cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
.shape-text-cursor { animation: shape-cursor-blink 0.9s steps(1) infinite; }

/* ── Resize handles ──────────────────────────────────── */
.shape-resize-handle { cursor: default; }
.shape-resize-handle[data-role="nw"],
.shape-resize-handle[data-role="se"] { cursor: nwse-resize; }
.shape-resize-handle[data-role="ne"],
.shape-resize-handle[data-role="sw"] { cursor: nesw-resize; }
.shape-resize-handle[data-role="n"],
.shape-resize-handle[data-role="s"]  { cursor: ns-resize; }
.shape-resize-handle[data-role="e"],
.shape-resize-handle[data-role="w"]  { cursor: ew-resize; }
.shape-resize-handle[data-role="p1"],
.shape-resize-handle[data-role="p2"] { cursor: move; }
.shape-resize-handle[data-role="text-scale"] { cursor: nwse-resize; }
.shape-resize-handle:hover circle:first-child + circle {
  r: 6; stroke-width: 2;
}

/* ── Rotation handle ─────────────────────────────────── */
.shape-rotate-handle { cursor: crosshair; }
.shape-rotate-handle:hover .shape-rotate-vis { opacity: 0.7; }
.is-minimal .shape-rotate-handle:hover .shape-rotate-vis { opacity: 0.7; }

/* ── Minimal mode overrides for shapes ───────────────── */
.is-minimal .add-shape-panel { border-color: #c9c8c9; background: #f1ede8; }
.is-minimal .add-shape-panel h3 { color: #2b2b2b; }
.is-minimal .shape-kind-btn { background: #f7f3ef; border-color: #c9c8c9; color: #5a5250; }
.is-minimal .shape-kind-btn:hover { background: #e3ddd7; color: #2b2b2b; border-color: #afa7a2; }
.is-minimal .shape-text-vis { fill: #5a5250; }
/* ── Minimal mode shape tool buttons ─────────────────── */
.is-minimal .shape-tools { border-right-color: rgba(0,0,0,0.14); }
.is-minimal .shape-tools .shape-tool-btn { color: rgba(90,82,80,0.42); }
.is-minimal .shape-tools .shape-tool-btn:hover { color: #2b2b2b; background: rgba(0,0,0,0.07) !important; }
.is-minimal .shape-tools .shape-tool-btn.is-active { color: #2b2b2b; background: rgba(0,0,0,0.11) !important; }