:root {
  --bg: #090d14;
  --panel: #111827;
  --panel2: #0f1724;
  --ink: #eef6ff;
  --muted: #8ca3bd;
  --line: #253449;
  --accent: #89caff;
  --gold: #ffd166;
  --danger: #ff6b6b;
  --ok: #7ee787;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    14px/1.4 Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  overflow: hidden;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  border: 1px solid #31435c;
  background: #172236;
  color: #f3f8ff;
  border-radius: 12px;
  padding: 9px 12px;
  cursor: pointer;
}
button:hover {
  background: #20304a;
}
button.primary {
  background: linear-gradient(135deg, #2563eb, #0f766e);
  border-color: #57a9ff;
}
button.danger {
  background: #3a1820;
  border-color: #7f2836;
}
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 380px 8px 1fr;
}
.sidebar {
  background: linear-gradient(180deg, #121a28, #0c111b);
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 16px;
}
.splitter {
  cursor: col-resize;
  background: #080c13;
  border-left: 1px solid #172033;
  border-right: 1px solid #172033;
}
.canvas-shell {
  position: relative;
  overflow: hidden;
  background: #090d14;
  touch-action: none;
  cursor: grab;
}
.canvas-shell.panning {
  cursor: grabbing;
}
.world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  width: 1px;
  height: 1px;
}
.grid {
  position: absolute;
  left: -100000px;
  top: -100000px;
  width: 200000px;
  height: 200000px;
  background-image:
    linear-gradient(rgba(137, 202, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(137, 202, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(137, 202, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(137, 202, 255, 0.04) 1px, transparent 1px);
  background-size:
    100px 100px,
    100px 100px,
    20px 20px,
    20px 20px;
}
.links {
  position: absolute;
  left: -100000px;
  top: -100000px;
  width: 200000px;
  height: 200000px;
  overflow: visible;
}
.link path {
  fill: none;
  stroke: #78a7cf;
  stroke-width: 3;
  opacity: 0.85;
  cursor: pointer;
}
.link.selected path {
  stroke: var(--gold);
  stroke-width: 5;
}
.temp-link {
  fill: none;
  stroke: var(--gold);
  stroke-width: 3;
  stroke-dasharray: 10 8;
}
.box {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  color: #fff;
  user-select: none;
  touch-action: none;
}
.box.selected {
  outline: 3px solid var(--gold);
  z-index: 3;
}
.box.multi {
  outline-color: #b38cff;
}
.box-summary {
  width: 100%;
  height: 100%;
  display: block;
  align-content: center;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  outline: none;
}
.box-summary:focus {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}
.resize {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #111827;
  cursor: nwse-resize;
}
.box-actions {
  position: absolute;
  left: 50%;
  top: -45px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.circle-action {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #111827;
  border: 1px solid #51657e;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.circle-action:hover {
  background: #20304a;
}
.circle-action.delete {
  border-color: #a33;
  color: #ffb4b4;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.brand {
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -0.03em;
}
.version {
  color: var(--muted);
  font-size: 12px;
}
.hint {
  color: var(--muted);
  font-size: 12px;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.section {
  border: 1px solid var(--line);
  background: rgba(15, 23, 36, 0.72);
  border-radius: 16px;
  padding: 12px;
  margin: 12px 0;
}
.section h3 {
  font-size: 13px;
  margin: 0 0 10px;
  color: #c8dcf0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.field {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}
.field label {
  color: #aebfd1;
  font-size: 12px;
}
input,
textarea,
select {
  width: 100%;
  border: 1px solid #34445b;
  border-radius: 12px;
  background: #0b1220;
  padding: 10px 11px;
  outline: none;
}
textarea {
  min-height: 110px;
  resize: vertical;
}
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.kpi {
  background: #0b1220;
  border: 1px solid #253449;
  border-radius: 14px;
  padding: 10px;
}
.kpi b {
  font-size: 19px;
}
.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
}
.swatch {
  height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
}
.tag-picker,
.tag-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid #33445b;
  border-radius: 999px;
  background: #0b1220;
  cursor: pointer;
}
.tag-pill.active {
  border-color: var(--gold);
  color: #fff;
}
.tag-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.box-list {
  display: grid;
  gap: 6px;
}
.box-list button {
  text-align: left;
}
.small-muted {
  font-size: 12px;
  color: var(--muted);
}
.status {
  position: absolute;
  left: 14px;
  bottom: 12px;
  background: rgba(8, 12, 19, 0.82);
  border: 1px solid #243348;
  border-radius: 999px;
  padding: 8px 12px;
  color: #cfe6ff;
  backdrop-filter: blur(8px);
}
.empty-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #9fb7d0;
  border: 1px dashed #38506c;
  border-radius: 22px;
  padding: 28px;
  background: rgba(10, 15, 24, 0.72);
}
.empty-hint b {
  display: block;
  color: #fff;
  font-size: 22px;
  margin-bottom: 5px;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 20px;
}
.dialog {
  width: min(760px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: #101827;
  border: 1px solid #38506c;
  border-radius: 22px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  padding: 16px;
}
.dialog.large {
  width: min(1000px, 96vw);
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.dialog h2 {
  margin: 0;
}
.json-area {
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.notice {
  border: 1px solid #304158;
  background: #0b1220;
  border-radius: 14px;
  padding: 10px;
}
.save-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  margin-right: 6px;
}
.save-dot.ok {
  background: var(--ok);
}
.save-dot.err {
  background: var(--danger);
}
.save-dot.saving {
  background: var(--gold);
}
.lock {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 13, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 30;
}
.lock-card {
  width: min(480px, 92vw);
  padding: 22px;
  border-radius: 22px;
  background: #101827;
  border: 1px solid #38506c;
}
@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: absolute;
    z-index: 10;
    width: min(92vw, 390px);
    height: 100%;
    transform: translateX(calc(-100% + 44px));
    transition: 0.2s;
  }
  .sidebar:hover,
  .sidebar.open {
    transform: translateX(0);
  }
  .splitter {
    display: none;
  }
  .canvas-shell {
    grid-column: 1;
  }
  .toolbar button {
    padding: 8px 10px;
  }
  .status {
    right: 10px;
    left: 54px;
    font-size: 12px;
  }
  .box-actions {
    top: -42px;
  }
}
.mini-options {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.mini-options summary {
  cursor: pointer;
  user-select: none;
}
.checkline {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  color: #dcecff;
}
.checkline input {
  width: auto;
  accent-color: var(--gold);
}
