﻿:root {
  --bg-a: #f7fbff;
  --bg-b: #eef7f2;
  --panel: #ffffff;
  --ink: #173042;
  --muted: #4d6777;
  --dialogue: #4ca8ff;
  --dialogue-soft: #d6ebff;
  --condition: #ff9f3f;
  --condition-soft: #ffe3c0;
  --function: #2f7c8f;
  --function-soft: #d2edf5;
  --function-start: #2b8f69;
  --function-start-soft: #d2f3e6;
  --switch: #a06bff;
  --switch-soft: #eadbff;
  --start: #2fa85f;
  --start-soft: #d6f5df;
  --danger: #c93d37;
  --line: #d9e4ec;
  --block-width: 520px;
  --properties-width: 460px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top right, #ffffff 0, var(--bg-a) 40%, var(--bg-b) 100%);
  min-height: 100vh;
}

code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95em;
  padding: 0.08em 0.35em;
  border-radius: 6px;
  background: rgba(23, 48, 66, 0.08);
}

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

.brand h1 {
  margin: 0;
  font-size: 20px;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn,
.mini {
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
  background: #ecf3f8;
}

.mini {
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
}

.btn:focus-visible,
.mini:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid #193247;
  outline-offset: 1px;
}

.btn-dialogue {
  background: var(--dialogue);
  color: #fff;
}

.btn-condition {
  background: var(--condition);
  color: #fff;
}

.btn-function {
  background: var(--function);
  color: #fff;
}

.btn-switch {
  background: var(--switch);
  color: #fff;
}

.btn-test {
  background: #1f7a57;
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn.active {
  background: #193247;
  color: #fff;
}

.mini.active {
  background: #193247;
  color: #fff;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: calc(100vh - 74px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(23, 48, 66, 0.06);
  padding: 12px;
}

.editor-panel {
  grid-column: 1 / -1;
  min-width: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  box-shadow: none;
  min-height: calc(100vh - 74px);
}

.properties-panel {
  position: fixed;
  top: 82px;
  right: 12px;
  width: var(--properties-width);
  max-height: calc(100vh - 96px);
  overflow: auto;
  z-index: 7;
  box-shadow: 0 14px 28px rgba(23, 48, 66, 0.18);
}

.properties-resize-handle {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: -7px;
  width: 14px;
  border-radius: 10px;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8;
}

.properties-resize-handle::before {
  content: "";
  width: 3px;
  height: 46px;
  border-radius: 3px;
  background: rgba(76, 113, 137, 0.4);
  transition: background 0.12s ease;
}

.properties-resize-handle:hover::before {
  background: rgba(25, 50, 71, 0.6);
}

body.resizing-properties,
body.resizing-properties * {
  user-select: none !important;
  cursor: ew-resize !important;
}

.runtime-panel {
  grid-column: 1 / -1;
}

.hidden {
  display: none !important;
}

.native-textarea {
  width: 100%;
  min-height: calc(100vh - 250px);
  border: 1px solid #abc1d1;
  border-radius: 10px;
  padding: 10px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}

.panel-head h2 {
  margin: 0;
}

.panel-head p {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.panel-copy {
  margin: 0 0 10px;
  color: #39586b;
  font-size: 13px;
  line-height: 1.5;
}

.panel-copy-subtle {
  color: #607b8c;
}

.panel-intro {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px solid #d9e6ef;
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fbff, #f0f8f3);
}

.panel-intro p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #39586b;
}

.layout-note {
  margin: 0 0 10px;
  font-size: 12px;
  color: #5f7b8d;
  padding: 8px 10px;
  border: 1px dashed #c4d5e3;
  border-radius: 9px;
  background: #f6fbff;
}

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

.workspace-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.native-docs {
  margin-bottom: 10px;
}

.native-docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.doc-card {
  border: 1px solid #d7e4ec;
  border-radius: 12px;
  padding: 12px;
  background: #fbfdff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.doc-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.doc-card pre {
  margin: 0;
  overflow: auto;
  border-radius: 10px;
  padding: 10px;
  background: #173042;
  color: #eff8ff;
  font-size: 12px;
  line-height: 1.45;
}

.doc-card code {
  font-family: Consolas, "Courier New", monospace;
}

.doc-card pre code {
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.doc-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 7px;
  color: #39586b;
  font-size: 13px;
  line-height: 1.45;
}

.workspace-viewport {
  position: relative;
  height: calc(100vh - 210px);
  min-height: 520px;
  overflow: hidden;
  border: 1px dashed #9bb7cb;
  border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(138, 173, 198, 0.15) 1px, transparent 1px) 0 0/24px 24px,
    linear-gradient(rgba(138, 173, 198, 0.15) 1px, transparent 1px) 0 0/24px 24px,
    #f7fbff;
  cursor: grab;
  touch-action: none;
}

.workspace-viewport.panning {
  cursor: grabbing;
}

.workspace-canvas {
  transform-origin: 0 0;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  padding: 12px;
  will-change: transform;
}

.tree {
  display: grid;
  gap: 10px;
  width: max-content;
}

.empty-note {
  background: #f5f8fc;
  border: 1px dashed #b6c8d6;
  border-radius: 10px;
  padding: 12px;
  color: var(--muted);
}

.block {
  border-radius: 14px;
  padding: 10px;
  border: 2px solid transparent;
  position: relative;
  width: var(--block-width);
  min-width: var(--block-width);
  overflow: visible;
}

.block.is-new {
  animation: appear 0.18s ease;
}

.block::before,
.block::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 8px;
  border-radius: 6px;
  left: 18px;
}

.block::before {
  top: -5px;
  background: rgba(255, 255, 255, 0.85);
}

.block::after {
  bottom: -5px;
  background: rgba(23, 48, 66, 0.15);
}

.block.dialogue {
  background: linear-gradient(180deg, var(--dialogue-soft), #c8e3ff);
}

.block.condition {
  background: linear-gradient(180deg, var(--condition-soft), #ffd8a6);
}

.block.function {
  background: linear-gradient(180deg, var(--function-soft), #c2e5ee);
}

.block.function_start {
  background: linear-gradient(180deg, var(--function-start-soft), #c2ebda);
}

.block.switch {
  background: linear-gradient(180deg, var(--switch-soft), #ddc3ff);
}

.block.start {
  background: linear-gradient(180deg, var(--start-soft), #c2f1d2);
}

.block.selected {
  border-color: #193247;
  box-shadow: 0 0 0 2px rgba(25, 50, 71, 0.2);
}

.block.dragging {
  opacity: 0.66;
}

.block-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.block-title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.block-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.block-body {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.kv {
  font-size: 13px;
}

.kv span {
  color: var(--muted);
}

.minimal-question {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.minimal-dialogue-body {
  margin-top: 0;
  gap: 0;
  padding-bottom: 0px;
}

.minimal-dialogue-block {
  padding-top: 7px;
}

body.minimal-mode .tree,
body.minimal-mode .children {
  gap: 0;
}

body.minimal-mode .children {
  margin-top: 0;
}

body.minimal-mode .drop-zone {
  height: 4px;
  min-height: 4px;
  border-radius: 2px;
  border-color: rgba(152, 180, 200, 0.4);
  opacity: 0.3;
}

body.minimal-mode .drop-zone.active {
  height: 6px;
}

body.minimal-mode .drop-zone-label {
  display: none;
}

body.minimal-mode .block::before,
body.minimal-mode .block::after {
  display: none;
}

.children {
  margin-top: 10px;
  margin-left: 18px;
  padding-left: 10px;
  border-left: 2px dashed rgba(23, 48, 66, 0.24);
  display: grid;
  gap: 8px;
  width: max-content;
}

.switch-cases {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.switch-case {
  border: 1px solid rgba(74, 47, 132, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
  padding: 8px;
  width: max-content;
}

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

.drop-zone {
  height: 18px;
  border: 1px dashed #98b4c8;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.7);
  opacity: 0.25;
  transition: all 0.12s ease;
}

.drop-zone.active {
  opacity: 1;
  height: 24px;
  border-color: #2f89d8;
  background: rgba(76, 168, 255, 0.22);
}

body.drag-active .drop-zone {
  opacity: 0.9;
}

.drop-zone-label {
  font-size: 10px;
  color: #5e7c90;
  padding: 2px 7px;
}

.property-content {
  display: grid;
  gap: 10px;
}

.property-note {
  font-size: 13px;
  color: var(--muted);
  padding: 10px;
  border: 1px dashed #abc1d1;
  border-radius: 10px;
  background: #f7fbff;
}

.editor-grid {
  display: grid;
  gap: 8px;
}

.editor-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.editor-grid input,
.editor-grid textarea,
.editor-grid select {
  width: 100%;
  border: 1px solid #afc5d6;
  border-radius: 8px;
  padding: 7px;
  font-family: inherit;
}

.editor-grid textarea {
  min-height: 72px;
  resize: vertical;
}

.inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline select,
.inline input {
  width: auto;
}

.cond-group {
  border: 1px solid #d8e5ef;
  border-radius: 10px;
  padding: 8px;
  background: #f8fbff;
  display: grid;
  gap: 8px;
}

.cond-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.cond-row {
  display: grid;
  grid-template-columns: 80px 1fr 76px 1fr auto;
  gap: 6px;
}

.cond-row .join-lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #6e8596;
  border: 1px solid #c6d7e4;
  border-radius: 7px;
  background: #f3f8fc;
}

.runtime-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fdfefe;
}

.runtime-question {
  margin: 4px 0 12px;
  font-size: 20px;
}

.runtime-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.runtime-options .btn {
  border-radius: 9px;
  border: 1px solid #8db2ce;
  background: #fff;
  color: var(--ink);
}

.runtime-input-form {
  display: grid;
  gap: 8px;
}

.runtime-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.runtime-input-row input {
  min-width: 0;
  flex: 1 1 auto;
}

.runtime-back {
  margin-bottom: 10px;
}

.runtime-note {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.runtime-result {
  white-space: pre-wrap;
  background: #edf5fc;
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
}

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1220px) {
  .properties-panel {
    position: static;
    width: auto;
    max-height: none;
    box-shadow: 0 8px 20px rgba(23, 48, 66, 0.06);
  }

  .properties-resize-handle {
    display: none;
  }
}

@media (max-width: 820px) {
  :root {
    --block-width: 360px;
  }

  .cond-row {
    grid-template-columns: 1fr;
  }

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

  .block-head {
    flex-direction: column;
  }

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