:root {
  --bg-main: #0c1620;
  --text-light: #ecf6ff;
  --line: #2d3e53;
  --panel-bg: rgba(7, 14, 22, 0.86);
  --panel-soft: rgba(7, 16, 26, 0.88);
  --accent: #53d8ff;
  --accent-strong: #33c5f7;
  --danger: #ff6a77;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-main);
  color: var(--text-light);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#app {
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 100svh;
  overflow: hidden;
}

#workspaceWrap {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 18% 16%, rgba(83, 216, 255, 0.1), rgba(83, 216, 255, 0) 42%),
    radial-gradient(circle at 82% 80%, rgba(91, 255, 206, 0.08), rgba(91, 255, 206, 0) 48%),
    linear-gradient(180deg, rgba(3, 10, 18, 0.08), rgba(3, 10, 18, 0.16));
}

body.flowchart-page.has-graph-background::before {
  background:
    radial-gradient(110% 90% at 12% 8%, rgba(255, 198, 122, 0.18) 0%, rgba(255, 198, 122, 0) 38%),
    radial-gradient(92% 88% at 86% 16%, rgba(109, 226, 255, 0.16) 0%, rgba(109, 226, 255, 0) 42%),
    radial-gradient(120% 100% at 50% 100%, rgba(21, 42, 60, 0.4) 0%, rgba(8, 14, 24, 0.72) 74%, rgba(5, 10, 18, 0.88) 100%),
    linear-gradient(180deg, rgba(15, 22, 31, 0.12), rgba(8, 12, 20, 0.58));
}

body.flowchart-page #graph-canvas {
  opacity: 0.72;
  filter: saturate(0.9) hue-rotate(-10deg);
}

body.flowchart-page #workspaceWrap {
  background:
    radial-gradient(circle at 14% 12%, rgba(255, 208, 142, 0.16), rgba(255, 208, 142, 0) 34%),
    radial-gradient(circle at 84% 18%, rgba(91, 219, 255, 0.14), rgba(91, 219, 255, 0) 38%),
    radial-gradient(circle at 62% 84%, rgba(93, 255, 205, 0.09), rgba(93, 255, 205, 0) 42%),
    linear-gradient(135deg, rgba(18, 24, 33, 0.62), rgba(10, 17, 26, 0.2));
}

body.flowchart-page #workspaceWrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.014) 1px, transparent 1px);
  background-size: 96px 96px;
  opacity: 0.8;
}

body.flowchart-page #workspaceWrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.035), transparent 58%),
    linear-gradient(125deg, rgba(255, 196, 120, 0.045), transparent 42%, rgba(112, 222, 255, 0.04) 72%, transparent 100%);
  mix-blend-mode: screen;
}

body.flowchart-page,
body.flowchart-page #inspectorPanel,
body.flowchart-page #infoDock,
body.flowchart-page .list,
body.flowchart-page #topToolbar {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 205, 134, 0.55) rgba(8, 18, 28, 0.72);
}

body.flowchart-page::-webkit-scrollbar,
body.flowchart-page #inspectorPanel::-webkit-scrollbar,
body.flowchart-page #infoDock::-webkit-scrollbar,
body.flowchart-page .list::-webkit-scrollbar,
body.flowchart-page #topToolbar::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body.flowchart-page::-webkit-scrollbar-track,
body.flowchart-page #inspectorPanel::-webkit-scrollbar-track,
body.flowchart-page #infoDock::-webkit-scrollbar-track,
body.flowchart-page .list::-webkit-scrollbar-track,
body.flowchart-page #topToolbar::-webkit-scrollbar-track {
  background: rgba(7, 16, 25, 0.62);
  border-radius: 999px;
  border: 1px solid rgba(120, 151, 176, 0.16);
}

body.flowchart-page::-webkit-scrollbar-thumb,
body.flowchart-page #inspectorPanel::-webkit-scrollbar-thumb,
body.flowchart-page #infoDock::-webkit-scrollbar-thumb,
body.flowchart-page .list::-webkit-scrollbar-thumb,
body.flowchart-page #topToolbar::-webkit-scrollbar-thumb {
  border-radius: 999px;
  border: 2px solid rgba(7, 16, 25, 0.78);
  background:
    linear-gradient(180deg, rgba(255, 211, 144, 0.92), rgba(121, 214, 255, 0.72));
  box-shadow:
    inset 0 0 0 1px rgba(255, 244, 214, 0.2),
    0 0 12px rgba(108, 207, 255, 0.12);
}

body.flowchart-page::-webkit-scrollbar-thumb:hover,
body.flowchart-page #inspectorPanel::-webkit-scrollbar-thumb:hover,
body.flowchart-page #infoDock::-webkit-scrollbar-thumb:hover,
body.flowchart-page .list::-webkit-scrollbar-thumb:hover,
body.flowchart-page #topToolbar::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(180deg, rgba(255, 223, 162, 0.98), rgba(143, 224, 255, 0.84));
}

#diagramHost {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid rgba(110, 146, 177, 0.25);
  border-radius: 0;
  touch-action: none;
  cursor: grab;
}

#diagramHost.is-panning {
  cursor: grabbing;
}

#diagramHost::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(80, 112, 142, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 112, 142, 0.13) 1px, transparent 1px);
  background-size: 28px 28px;
}

body.flowchart-page #diagramHost::before {
  background-image:
    linear-gradient(rgba(115, 151, 180, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(115, 151, 180, 0.12) 1px, transparent 1px),
    linear-gradient(135deg, rgba(255, 198, 122, 0.035), transparent 34%, rgba(109, 226, 255, 0.025) 68%, transparent 100%);
  background-size: 28px 28px, 28px 28px, 100% 100%;
}

#edgeLayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  z-index: 1;
  pointer-events: auto;
  transform-origin: 0 0;
  will-change: transform;
}

#edgeGroup {
  pointer-events: auto;
}

.edge-path {
  stroke: rgba(135, 223, 255, 0.95);
  stroke-width: 2.2;
  fill: none;
  marker-end: url(#flow-arrow);
  pointer-events: none;
}

.edge-path.is-selected {
  stroke: #fff2a7;
  stroke-width: 3;
}

.edge-hit {
  stroke: rgba(255, 255, 255, 0.001);
  stroke-width: 20;
  fill: none;
  cursor: pointer;
  pointer-events: stroke;
}

.edge-label {
  fill: #d8ecff;
  font-size: 10px;
  font-weight: 600;
  text-anchor: middle;
  user-select: none;
  pointer-events: auto;
  cursor: pointer;
  stroke: rgba(6, 13, 21, 0.9);
  stroke-width: 3;
  paint-order: stroke fill;
}

#nodeLayer {
  position: absolute;
  inset: 0;
  z-index: 2;
  transform-origin: 0 0;
  will-change: transform;
}

.flow-node {
  position: absolute;
  width: 176px;
  min-height: 92px;
  border: 1px solid color-mix(in srgb, var(--node-color, #53d8ff) 34%, rgba(133, 170, 202, 0.3));
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(9, 18, 28, 0.98), rgba(7, 15, 24, 0.95));
  box-shadow:
    0 18px 38px rgba(0, 0, 0, 0.34),
    0 0 0 1px color-mix(in srgb, var(--node-color, #53d8ff) 18%, rgba(113, 197, 237, 0.08)),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  color: #e9f5ff;
  cursor: grab;
  touch-action: none;
  user-select: none;
  overflow: visible;
  isolation: isolate;
  transition: border-color 140ms ease, box-shadow 180ms ease;
}

.flow-node::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 17px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 24%),
    radial-gradient(circle at 18% 14%, color-mix(in srgb, var(--node-color, #53d8ff) 30%, white 10%), transparent 38%),
    linear-gradient(165deg, color-mix(in srgb, var(--node-color, #53d8ff) 18%, rgba(14, 27, 39, 0.9)), rgba(8, 17, 27, 0.88) 58%, rgba(5, 12, 20, 0.96));
  pointer-events: none;
  z-index: 0;
}

.flow-node::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -20px;
  height: 40px;
  border-radius: 999px;
  background: radial-gradient(circle, color-mix(in srgb, var(--node-color, #53d8ff) 34%, rgba(255, 255, 255, 0.14)) 0%, transparent 74%);
  opacity: 0.42;
  filter: blur(18px);
  pointer-events: none;
  z-index: 0;
}

.flow-node > * {
  position: relative;
  z-index: 1;
}

.flow-node:active {
  cursor: grabbing;
}

.flow-node:hover {
  border-color: color-mix(in srgb, var(--node-color, #53d8ff) 52%, rgba(165, 212, 237, 0.38));
  box-shadow:
    0 24px 42px rgba(0, 0, 0, 0.38),
    0 0 0 1px color-mix(in srgb, var(--node-color, #53d8ff) 22%, rgba(113, 197, 237, 0.1)),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.flow-node.is-selected {
  border-color: rgba(126, 245, 220, 0.92);
  box-shadow:
    0 24px 44px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(126, 245, 220, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.flow-node.is-connect-source {
  border-color: rgba(255, 230, 127, 0.98);
  box-shadow:
    0 24px 44px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 230, 127, 0.54),
    inset 0 1px 0 rgba(255, 248, 217, 0.14);
}

.flow-node[data-type="terminator"] {
  border-radius: 999px;
}

.flow-node[data-type="terminator"]::before {
  border-radius: 999px;
}

.flow-node-inner {
  position: relative;
  width: 100%;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 12px 13px 11px;
  overflow: hidden;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 34%),
    linear-gradient(160deg, rgba(33, 80, 106, 0.26), rgba(18, 30, 43, 0.08)),
    color-mix(in srgb, var(--node-color, #53d8ff) 16%, transparent);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 -18px 22px rgba(0, 0, 0, 0.08);
}

.flow-node[data-type="terminator"] .flow-node-inner {
  border-radius: 999px;
  align-items: center;
  text-align: center;
}

.flow-node[data-type="decision"] .flow-node-inner {
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  align-items: center;
  text-align: center;
  padding: 20px 25px;
}

.flow-node[data-type="data"] .flow-node-inner {
  clip-path: polygon(11% 0%, 100% 0%, 89% 100%, 0% 100%);
  padding: 12px 20px;
}

.flow-node-type {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  width: fit-content;
  min-height: 22px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--node-color, #53d8ff) 28%, rgba(178, 224, 247, 0.32));
  background:
    linear-gradient(180deg, rgba(7, 16, 26, 0.84), rgba(7, 16, 26, 0.62));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 8px 14px rgba(0, 0, 0, 0.16);
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: 0.11em;
  font-weight: 800;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--node-color, #53d8ff) 52%, #e5f5ff);
}

.flow-node[data-type="terminator"] .flow-node-type,
.flow-node[data-type="decision"] .flow-node-type {
  align-self: center;
}

.flow-node-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
  color: #edf6ff;
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.16);
}

.flow-node[data-type="decision"] .flow-node-text,
.flow-node[data-type="terminator"] .flow-node-text {
  text-align: center;
}

.flow-node[data-type="decision"] .flow-node-text {
  font-weight: 700;
}

.node-connector {
  position: absolute;
  z-index: 4;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--node-color, #53d8ff) 30%, rgba(136, 201, 233, 0.72));
  background:
    radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg, rgba(10, 21, 32, 0.98), rgba(7, 17, 28, 0.98));
  box-shadow:
    0 0 0 2px rgba(7, 16, 25, 0.9),
    0 8px 16px rgba(0, 0, 0, 0.34);
  cursor: crosshair;
  opacity: 0.95;
  transition: opacity 120ms ease, border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
  touch-action: none;
}

.node-connector::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0.52;
}

.node-connector::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.92), color-mix(in srgb, var(--node-color, #53d8ff) 82%, rgba(136, 223, 255, 0.92)) 58%, rgba(136, 223, 255, 0.16) 100%);
  box-shadow: 0 0 10px color-mix(in srgb, var(--node-color, #53d8ff) 24%, transparent);
}

.node-connector:hover,
.node-connector:focus-visible {
  border-color: rgba(158, 246, 207, 0.98);
  box-shadow:
    0 0 0 2px rgba(7, 16, 25, 0.9),
    0 0 0 5px rgba(112, 238, 210, 0.22),
    0 8px 16px rgba(0, 0, 0, 0.36);
}

.node-connector.is-source {
  border-color: rgba(255, 231, 138, 0.96);
  box-shadow:
    0 0 0 2px rgba(26, 21, 8, 0.85),
    0 0 0 5px rgba(255, 222, 124, 0.26),
    0 8px 16px rgba(0, 0, 0, 0.36);
}

.node-connector.is-source::after {
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.96), rgba(255, 230, 127, 0.98) 56%, rgba(255, 230, 127, 0.16) 100%);
  box-shadow: 0 0 10px rgba(255, 230, 127, 0.3);
}

.node-connector-top {
  left: 50%;
  top: 0;
  transform: translate(-50%, -50%);
}

.node-connector-right {
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
}

.node-connector-bottom {
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 50%);
}

.node-connector-left {
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%);
}

#homeButton {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 15;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  border-radius: 8px;
  border: 1px solid rgba(170, 205, 238, 0.45);
  background: rgba(6, 15, 24, 0.82);
  color: #efffe7;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 12px;
  backdrop-filter: blur(4px);
}

#langToggleBtn {
  position: absolute;
  top: 56px;
  right: 16px;
  z-index: 15;
  min-width: 136px;
  border-radius: 8px;
  border: 1px solid rgba(170, 205, 238, 0.45);
  background: rgba(6, 15, 24, 0.82);
  color: #efffe7;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  text-align: left;
  backdrop-filter: blur(4px);
}

.lang-toggle-title {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(210, 228, 244, 0.86);
}

.lang-toggle-values {
  display: inline-flex;
  gap: 5px;
}

.lang-toggle-option {
  opacity: 0.65;
}

.lang-toggle-option.is-active {
  opacity: 1;
}

#topToolbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  width: min(860px, calc(100vw - 52px));
  padding: 10px 12px;
  border: 1px solid rgba(122, 164, 194, 0.28);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(7, 18, 29, 0.9), rgba(7, 16, 26, 0.78));
  backdrop-filter: blur(10px);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(146, 197, 223, 0.06);
}

.toolbar-btn {
  border-radius: 10px;
  border: 1px solid #4d95c5;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(13, 28, 39, 0.92);
  color: #e1f5ff;
  cursor: pointer;
}

.toolbar-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.toolbar-btn-strong {
  border-color: #4dd6d2;
}

#addMenuBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-color: rgba(119, 255, 166, 0.68);
  color: #e6fff0;
  background: rgba(8, 24, 18, 0.84);
  box-shadow:
    0 0 12px rgba(85, 255, 145, 0.22),
    inset 0 0 0 1px rgba(179, 255, 208, 0.14);
}

#addMenuBtn::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  font-size: 1rem;
  line-height: 1;
  font-weight: 900;
  color: #ddffe8;
  border: 1px solid rgba(120, 255, 165, 0.95);
  background: radial-gradient(circle at 35% 30%, rgba(121, 255, 156, 0.9), rgba(36, 162, 74, 0.92));
  box-shadow:
    0 0 8px rgba(102, 255, 153, 0.8),
    0 0 16px rgba(102, 255, 153, 0.35),
    inset 0 0 5px rgba(214, 255, 228, 0.68);
  flex: 0 0 auto;
}

#addMenuBtn:hover {
  background: rgba(10, 31, 22, 0.9);
  border-color: rgba(119, 255, 166, 0.84);
  box-shadow:
    0 0 18px rgba(85, 255, 145, 0.3),
    inset 0 0 0 1px rgba(179, 255, 208, 0.2);
}

#addMenuBtn:disabled {
  box-shadow: none;
}

.toolbar-btn-secondary {
  opacity: 0.82;
  border-color: rgba(108, 152, 184, 0.72);
  background: rgba(11, 23, 33, 0.78);
}

.toolbar-btn-small {
  min-width: 88px;
}

.toolbar-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toolbar-btn.is-active {
  border-color: #9eeea0;
  background: rgba(19, 50, 40, 0.94);
  color: #e9ffe2;
}

#importJsonInput {
  display: none;
}

.menu {
  position: relative;
}

.menu-list {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  min-width: 218px;
  display: none;
  gap: 4px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(133, 170, 202, 0.35);
  background: rgba(7, 16, 26, 0.94);
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.34);
}

.menu.open .menu-list {
  display: grid;
}

.menu-item {
  border: 1px solid rgba(120, 158, 189, 0.36);
  border-radius: 8px;
  background: rgba(12, 24, 36, 0.9);
  color: #e7f2ff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

#emptyFlowAddNodeBtn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 260px;
  border-radius: 14px;
  border: 1px solid rgba(119, 255, 166, 0.58);
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 800;
  color: #e6fff0;
  background: rgba(8, 24, 18, 0.84);
  box-shadow:
    0 0 16px rgba(85, 255, 145, 0.26),
    inset 0 0 0 1px rgba(179, 255, 208, 0.16);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.2s ease, box-shadow 0.2s ease;
}

#emptyFlowAddNodeBtn:hover {
  transform: translate(-50%, -51%);
  background: rgba(10, 31, 22, 0.9);
  box-shadow:
    0 0 22px rgba(85, 255, 145, 0.34),
    inset 0 0 0 1px rgba(179, 255, 208, 0.24);
}

#emptyFlowAddNodeBtn[hidden] {
  display: none !important;
}

.empty-flow-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  font-size: 1.22rem;
  line-height: 1;
  font-weight: 900;
  color: #ddffe8;
  border: 1px solid rgba(120, 255, 165, 0.95);
  background: radial-gradient(circle at 35% 30%, rgba(121, 255, 156, 0.9), rgba(36, 162, 74, 0.92));
  box-shadow:
    0 0 10px rgba(102, 255, 153, 0.9),
    0 0 20px rgba(102, 255, 153, 0.45),
    inset 0 0 6px rgba(214, 255, 228, 0.72);
  flex: 0 0 auto;
}

#hint {
  position: absolute;
  left: 16px;
  bottom: 94px;
  z-index: 13;
  width: min(320px, calc(100vw - 32px));
  font-size: 0.78rem;
  line-height: 1.45;
  padding: 12px 13px;
  border-radius: 14px;
  background: rgba(8, 17, 26, 0.8);
  border: 1px solid rgba(148, 185, 216, 0.22);
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.2);
}

@media (max-height: 820px) {
  #hint {
    display: none;
  }

  #inspectorPanel {
    max-height: calc(100vh - 174px);
  }

  #infoDock {
    max-height: 42vh;
  }
}

#quickActions {
  position: absolute;
  left: 16px;
  bottom: 14px;
  z-index: 14;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(320px, calc(100vw - 32px));
}

.quick-btn {
  min-width: 0;
  border-radius: 10px;
  border: 1px solid rgba(121, 175, 205, 0.72);
  background: rgba(10, 22, 34, 0.92);
  color: #e6f6ff;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.1;
  padding: 10px 11px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.quick-btn.quick-btn-danger {
  border-color: rgba(255, 113, 136, 0.82);
  background: rgba(70, 22, 28, 0.94);
  color: #ffe4e7;
}

#inspectorPanel {
  position: absolute;
  left: 14px;
  top: 108px;
  z-index: 13;
  width: min(320px, calc(100vw - 28px));
  max-height: calc(100vh - 228px);
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 16, 26, 0.94), rgba(7, 16, 26, 0.78));
  backdrop-filter: blur(12px);
  padding: 14px;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(144, 193, 224, 0.05);
}

#inspectorPanel h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-eyebrow {
  margin: 0 0 10px;
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(180, 213, 239, 0.72);
}

.selection-card,
.editor-section,
.dock-section {
  border-radius: 14px;
  border: 1px solid rgba(132, 169, 201, 0.18);
  background: rgba(9, 19, 30, 0.7);
  box-shadow: inset 0 0 0 1px rgba(135, 191, 225, 0.03);
}

.selection-card {
  padding: 12px 12px 11px;
}

.editor-section {
  margin-top: 10px;
  padding: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.section-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: #edf6ff;
}

#inspectorPanel[data-selection-mode="none"] #nodeEditorSection,
#inspectorPanel[data-selection-mode="none"] #edgeEditorSection {
  opacity: 0.72;
}

#inspectorPanel[data-selection-mode="edge"] #nodeEditorSection,
#inspectorPanel[data-selection-mode="node"] #edgeEditorSection {
  opacity: 0.56;
}

.muted {
  margin: 0;
  color: #9eafc2;
  font-size: 0.74rem;
}

.field {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.field label {
  font-size: 0.76rem;
  font-weight: 600;
  color: #d5e3f3;
}

.field textarea,
.field input[type="color"],
.field input[type="text"] {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(88, 113, 133, 0.92);
  padding: 9px 10px;
  font-size: 0.8rem;
  color: #f2f7ff;
  background: rgba(5, 11, 17, 0.92);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.field textarea:focus,
.field input[type="color"]:focus,
.field input[type="text"]:focus {
  outline: none;
  border-color: rgba(120, 230, 219, 0.9);
  box-shadow: 0 0 0 3px rgba(91, 214, 197, 0.12);
}

.field input:disabled,
.field textarea:disabled {
  opacity: 0.6;
}

.field textarea {
  resize: vertical;
  min-height: 66px;
}

.field-hint {
  margin: 2px 0 0;
  font-size: 0.7rem;
  line-height: 1.35;
  color: rgba(168, 190, 210, 0.88);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip-btn {
  border-radius: 999px;
  border: 1px solid rgba(110, 176, 205, 0.5);
  background: rgba(10, 24, 35, 0.86);
  color: #dcf1ff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 7px 10px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.chip-btn:hover,
.chip-btn:focus-visible {
  outline: none;
  border-color: rgba(133, 241, 212, 0.82);
  background: rgba(14, 35, 44, 0.94);
  transform: translateY(-1px);
}

.chip-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.panel-actions {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.decision-action-callout {
  position: absolute;
  top: 194px;
  right: 16px;
  z-index: 15;
  width: 280px;
  display: grid;
  gap: 10px;
  padding: 13px;
  border-radius: 16px;
  border: 1px solid rgba(241, 194, 106, 0.34);
  background:
    linear-gradient(180deg, rgba(47, 34, 17, 0.84), rgba(13, 24, 34, 0.82)),
    radial-gradient(circle at top right, rgba(241, 194, 106, 0.16), transparent 54%);
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.2),
    inset 0 0 0 1px rgba(255, 222, 159, 0.06);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(16px);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease,
    transform 140ms ease,
    opacity 140ms ease,
    visibility 140ms ease;
}

.decision-action-callout[data-state="active"] {
  border-color: rgba(255, 209, 116, 0.72);
  background:
    linear-gradient(180deg, rgba(57, 40, 18, 0.94), rgba(17, 28, 36, 0.9)),
    radial-gradient(circle at top right, rgba(241, 194, 106, 0.22), transparent 58%);
  box-shadow:
    0 20px 38px rgba(0, 0, 0, 0.24),
    0 0 0 1px rgba(255, 209, 116, 0.08),
    0 0 26px rgba(241, 194, 106, 0.14);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
}

.decision-action-copy {
  display: grid;
  gap: 4px;
}

.decision-action-eyebrow {
  margin: 0 0 4px;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 221, 164, 0.82);
}

.decision-action-hint {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.45;
  color: rgba(224, 233, 244, 0.88);
}

.action-btn {
  border-radius: 10px;
  border: 1px solid #4dd6d2;
  background: rgba(16, 44, 52, 0.94);
  color: #e8feff;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.action-btn-primary {
  width: 100%;
  min-height: 48px;
  border-color: rgba(255, 209, 116, 0.88);
  background:
    linear-gradient(180deg, rgba(73, 49, 18, 0.96), rgba(27, 49, 58, 0.96)),
    radial-gradient(circle at 18% 18%, rgba(255, 229, 170, 0.18), transparent 42%);
  color: #fff4da;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.18),
    0 0 20px rgba(241, 194, 106, 0.12),
    inset 0 0 0 1px rgba(255, 231, 182, 0.1);
}

.action-btn-primary:hover,
.action-btn-primary:focus-visible {
  outline: none;
  border-color: rgba(255, 221, 146, 0.96);
  background:
    linear-gradient(180deg, rgba(88, 59, 21, 0.98), rgba(31, 57, 66, 0.98)),
    radial-gradient(circle at 18% 18%, rgba(255, 229, 170, 0.24), transparent 44%);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.22),
    0 0 26px rgba(241, 194, 106, 0.18),
    inset 0 0 0 1px rgba(255, 234, 194, 0.14);
  transform: translateY(-1px);
}

.action-btn-primary:disabled {
  opacity: 0.68;
  border-color: rgba(194, 170, 123, 0.46);
  background:
    linear-gradient(180deg, rgba(47, 35, 18, 0.74), rgba(20, 32, 40, 0.78)),
    radial-gradient(circle at 18% 18%, rgba(255, 220, 150, 0.08), transparent 44%);
  color: rgba(233, 225, 206, 0.74);
  box-shadow: none;
  transform: none;
}

.action-btn-danger {
  border-color: rgba(255, 106, 119, 0.8);
  background: rgba(70, 22, 28, 0.95);
  color: #ffe4e7;
}

#infoDock {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 292px;
  max-height: 48vh;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 16, 26, 0.94), rgba(7, 16, 26, 0.78));
  backdrop-filter: blur(12px);
  z-index: 13;
  padding: 14px;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(144, 193, 224, 0.05);
}

.dock-header {
  margin-bottom: 10px;
}

#infoDock h3 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: #d5deea;
}

.stats-strip {
  margin: 0 0 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #d6ecff;
  background: #112031;
  border: 1px solid #2f475f;
}

.status-copy {
  line-height: 1.45;
}

.dock-section {
  padding: 12px;
}

.dock-section + .dock-section {
  margin-top: 10px;
}

.list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  font-size: 0.74rem;
  max-height: 132px;
  overflow-y: auto;
}

.list li {
  margin-bottom: 6px;
  color: #d9ecff;
}

.list li:last-child {
  margin-bottom: 0;
}

.list-item-btn {
  width: 100%;
  border: 1px solid rgba(91, 121, 145, 0.56);
  border-radius: 10px;
  background: rgba(9, 18, 28, 0.86);
  color: #d9ecff;
  font-size: 0.75rem;
  line-height: 1.35;
  text-align: left;
  padding: 9px 10px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.list-item-btn:hover,
.list-item-btn:focus-visible {
  outline: none;
  border-color: rgba(131, 214, 245, 0.82);
  background: rgba(11, 24, 37, 0.96);
}

.list-item-btn.is-selected {
  color: #fff3b4;
  border-color: rgba(255, 231, 138, 0.7);
  background: rgba(39, 36, 16, 0.62);
}

#zoomControls.zoom-dock {
  position: absolute;
  top: 108px;
  right: 16px;
  z-index: 15;
  width: 110px;
  border-radius: 10px;
  border: 1px solid rgba(133, 170, 202, 0.35);
  background: rgba(7, 16, 26, 0.88);
  backdrop-filter: blur(7px);
  padding: 8px;
  display: grid;
  gap: 7px;
}

.zoom-status-btn {
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(112, 170, 203, 0.42);
  background: rgba(11, 22, 34, 0.84);
  color: #dff4ff;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  padding: 7px 6px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.zoom-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.zoom-action-btn {
  border-radius: 8px;
  border: 1px solid rgba(111, 192, 223, 0.66);
  background: rgba(15, 31, 45, 0.92);
  color: #e6f7ff;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  min-height: 32px;
  cursor: pointer;
}

@media (max-width: 980px) {
  #topToolbar {
    top: 12px;
    width: calc(100vw - 24px);
  }

  #homeButton {
    top: 10px;
    right: 10px;
  }

  #langToggleBtn {
    top: 50px;
    right: 10px;
    min-width: 118px;
    padding: 5px 9px;
  }

  #zoomControls.zoom-dock {
    top: 100px;
    right: 10px;
  }

  .decision-action-callout {
    top: 186px;
    right: 10px;
    width: 264px;
  }

  #inspectorPanel {
    top: 100px;
    left: 10px;
  }

  #infoDock {
    right: 10px;
    bottom: 10px;
  }
}

@media (max-width: 760px) {
  #workspaceWrap {
    padding-bottom: calc(env(safe-area-inset-bottom) + 142px);
  }

  #topToolbar {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: max(8px, calc(env(safe-area-inset-bottom) + 6px));
    transform: none;
    width: auto;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding: 8px;
    scrollbar-width: thin;
  }

  .toolbar-btn {
    min-width: 124px;
    flex: 0 0 auto;
  }

  .menu-list {
    left: auto;
    right: 0;
    min-width: min(260px, calc(100vw - 16px));
  }

  #homeButton {
    top: max(8px, calc(env(safe-area-inset-top) + 4px));
    right: 8px;
    min-width: 72px;
    font-size: 0.75rem;
  }

  #langToggleBtn {
    top: max(46px, calc(env(safe-area-inset-top) + 42px));
    right: 8px;
    min-width: 112px;
  }

  #zoomControls.zoom-dock {
    top: max(96px, calc(env(safe-area-inset-top) + 92px));
    right: 8px;
    width: 102px;
    padding: 7px;
  }

  .decision-action-callout {
    top: max(148px, calc(env(safe-area-inset-top) + 144px));
    right: 8px;
    width: min(232px, calc(100vw - 124px));
    padding: 11px;
    gap: 8px;
  }

  .zoom-status-btn {
    font-size: 0.7rem;
    padding: 6px 5px;
  }

  .zoom-action-btn {
    min-height: 30px;
    font-size: 0.95rem;
  }

  #inspectorPanel {
    top: max(98px, calc(env(safe-area-inset-top) + 94px));
    left: 8px;
    right: 116px;
    width: auto;
    max-height: 36svh;
    padding: 8px;
  }

  .field textarea {
    min-height: 58px;
    font-size: 16px;
  }

  .field input[type="text"] {
    font-size: 16px;
  }

  #emptyFlowAddNodeBtn {
    min-width: 0;
    width: min(420px, calc(100vw - 20px));
    padding: 12px 14px;
    font-size: 0.94rem;
  }

  #infoDock {
    left: 8px;
    right: 8px;
    width: auto;
    bottom: calc(env(safe-area-inset-bottom) + 56px);
    max-height: 24svh;
  }

  #hint {
    left: 8px;
    right: 8px;
    width: auto;
    bottom: calc(env(safe-area-inset-bottom) + 180px);
    font-size: 0.7rem;
    line-height: 1.25;
  }

  #quickActions {
    left: 8px;
    right: 8px;
    width: auto;
    bottom: calc(env(safe-area-inset-bottom) + 120px);
  }

  .flow-node {
    width: 156px;
    min-height: 84px;
  }

  .flow-node-inner {
    min-height: 84px;
    padding: 9px 10px 8px;
  }

  .flow-node[data-type="decision"] .flow-node-inner {
    padding: 18px 20px;
  }
}

@media (max-width: 520px) {
  .toolbar-btn {
    min-width: 114px;
    font-size: 0.76rem;
    padding: 8px 10px;
  }

  #zoomControls.zoom-dock {
    width: 96px;
  }

  .decision-action-callout {
    width: min(204px, calc(100vw - 118px));
    padding: 10px;
  }

  .decision-action-hint {
    font-size: 0.7rem;
    line-height: 1.35;
  }

  .action-btn-primary {
    min-height: 42px;
    font-size: 0.8rem;
  }

  .selection-card,
  .editor-section,
  .dock-section {
    border-radius: 12px;
  }

  #inspectorPanel {
    max-height: 36svh;
    right: 104px;
  }

  #infoDock {
    max-height: 26svh;
  }
}

@media (hover: none) and (pointer: coarse) and (max-height: 560px) {
  #workspaceWrap {
    padding-bottom: calc(env(safe-area-inset-bottom) + 102px);
  }

  #topToolbar {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: max(8px, calc(env(safe-area-inset-bottom) + 6px));
    transform: none;
    width: auto;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding: 4px 2px;
    scrollbar-width: thin;
  }

  .toolbar-btn {
    min-width: 110px;
    padding: 8px 10px;
    font-size: 0.72rem;
    flex: 0 0 auto;
  }

  #zoomControls.zoom-dock {
    top: max(8px, calc(env(safe-area-inset-top) + 4px));
  }

  #inspectorPanel {
    top: max(84px, calc(env(safe-area-inset-top) + 80px));
    max-height: calc(100svh - 166px);
  }

  #hint,
  #infoDock {
    display: none;
  }

  #quickActions {
    bottom: calc(env(safe-area-inset-bottom) + 56px);
  }
}
