
/* ---------- real Minecraft font — "Minecraft" by Craftron Gaming (CC BY 4.0) ----------
   The in-game font is Mojangles (Mojang proprietary, not redistributable).
   This is the fan-made 16px bitmap recreation — free for commercial use.
   Monocraft (OFL-1.1, below) is the fallback for full Unicode coverage. */
@font-face {
  font-family: "MinecraftPixel";
  src: url("../fonts/Minecraft.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Monocraft";
  src: url("../fonts/Monocraft.otf") format("opentype");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
/* ============================================================
   DYNACROWN VISUAL SCRIPT UI EDITOR — blueprint studio styles
   ============================================================ */
:root {
  --blue-900: #062a5e;
  --blue-800: #0b3f8f;
  --blue-700: #1154b4;
  --blue-600: #1668d8;
  --blue-500: #2b7de9;
  --blue-400: #4f9bf5;
  --blue-300: #7db6fa;
  --blue-100: #dceaff;
  --blue-050: #eef5ff;
  --panel: #0e2c5c;
  --panel-2: #12376f;
  --panel-3: #1a4690;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.28);
  --text: #e8f1ff;
  --muted: #9db9e6;
  --muted-2: #6f8fc4;
  --accent: #ffa726;
  --green: #35d07f;
  --red: #ff5d6c;
  --yellow: #ffce3d;
  --cyan: #4fd8ff;
  --purple: #b78bff;
  --tr: rgba(255,255,255,.1);
  --radius: 10px;
  --font: "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "Fira Code", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
@supports (height: 100dvh) { #workspace { height: calc(100dvh - 56px); } }
@media (orientation: landscape) and (max-height: 520px) {
  :root { --toolbarH: 48px; --barbarH: 48px; }
  #toolbar { height: var(--toolbarH); }
  #workspace { grid-template-rows: 1fr auto; }
  body { padding-top: var(--toolbarH); padding-bottom: calc(var(--barbarH) + env(safe-area-inset-bottom)); }
  #palette, #props { height: min(80vh, 100%); }
  #preview { height: min(70vh, 100%); }
  #mobile-bar { height: calc(var(--barbarH) + env(safe-area-inset-bottom)); }
  .mb-btn { min-height: 40px; padding: 2px; }
  .modal-card, .modal-wide { max-height: 100dvh; }
  #tour-card { width: min(300px, 60vw); }
  #export-code { max-height: 34vh; }
  .props-body { padding-bottom: 12px; }
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--blue-800);
  overflow: hidden;
  user-select: none;
}
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
input, textarea { user-select: text; }
code, pre, .mono { font-family: var(--mono); }
.mono { font-size: .92em; }
kbd {
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: .85em;
}
b { color: #fff; }

/* ================= TOOLBAR ================= */
#toolbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: linear-gradient(180deg, #0d2f63, #0a2a58);
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 2px 14px rgba(0,0,0,.35);
  position: relative;
  z-index: 30;
}
.brand { display: flex; align-items: baseline; gap: 8px; padding-right: 6px; min-width: 210px; }
.brand-mark { font-size: 20px; display: inline-flex; }
.brand-mark img { border-radius: 7px; display: block; }
.brand-name { font-weight: 600; font-size: 17px; letter-spacing: .2px; white-space: nowrap; }
.brand-name b { color: var(--accent); font-weight: 800; }
.brand-sub { font-size: 10.5px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 1.4px; }

.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-spacer { flex: 1; }
.tb-sep { width: 1px; height: 26px; background: var(--line); margin: 0 8px; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 11px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text); font-size: 13px;
  transition: background .12s, border-color .12s, transform .05s;
  white-space: nowrap;
}
.tb-btn:hover { background: rgba(255,255,255,.09); border-color: var(--line); }
.tb-btn:active { transform: translateY(1px); }
.tb-btn:disabled { opacity: .35; cursor: not-allowed; }
a.tb-btn { text-decoration: none; }
.tb-ico { font-size: 15px; line-height: 1; color: #fff; }
.tb-ico svg, .mb-ico svg, .n-ico svg, .gh-ico svg, .p-ico svg, .hc-ico svg, .ce-ico svg, .pe-ico svg {
  width: 1.05em; height: 1.05em; display: inline-block; color: #fff; stroke: currentColor; fill: none;
}
.mb-ico { font-size: 19px; line-height: 1.15; color: #fff; }
.mb-btn .mb-ico { color: #fff; }
.mb-primary .mb-ico { color: #2c2200; }
.p-ico svg { color: var(--cat, #fff); }
.n-ico svg { color: #fff; }
.hc-ico svg { color: #e6eef7; width: 22px; height: 22px; }
.hc-ico { color: #e6eef7; }
.ce-ico svg, .pe-ico svg, .export-empty-ico svg { color: var(--accent); width: 34px; height: 34px; }
.adv-pane-head .tb-ico { margin-right: 6px; }
.tb-btn.tb-toggle.is-on { background: rgba(255,255,255,.12); border-color: var(--line-strong); }
.tb-btn.tb-primary {
  background: linear-gradient(180deg, #ffb340, #f79a00);
  color: #3a2500; font-weight: 700;
  border-color: #ffd28a;
  box-shadow: 0 2px 10px rgba(255,167,38,.35);
}
.tb-btn.tb-primary .tb-ico svg { color: #3a2500; }
.tb-btn.tb-primary:hover { background: linear-gradient(180deg, #ffc05e, #ffa726); }
.tb-toggle.tb-btn.is-on span:first-child { filter: none; }

.tb-search {
  display: flex; align-items: center; gap: 8px;
  width: min(360px, 30vw);
  height: 36px; padding: 0 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.tb-search:focus-within { border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(79,155,245,.18); }
.tb-search-ico { font-size: 13px; opacity: .8; }
.tb-search input {
  flex: 1; border: 0; background: none; outline: none;
  color: var(--text); font-size: 13px;
}
.tb-search input::placeholder { color: var(--muted-2); }
.tb-search-count { font-size: 11px; color: var(--accent); background: rgba(255,167,38,.15); padding: 2px 7px; border-radius: 10px; }

.tb-zoom { display: flex; align-items: center; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.tb-zoom .tb-btn { height: 30px; padding: 0 9px; }
.tb-zoom-label { min-width: 46px; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ================= WORKSPACE LAYOUT ================= */
#workspace {
  display: grid;
  grid-template-columns: 250px 1fr 300px;
  grid-template-rows: 1fr auto;
  grid-template-areas: "palette canvas props" "preview preview preview";
  height: calc(100vh - 56px);
}
#workspace.no-preview { grid-template-rows: 1fr; grid-template-areas: "palette canvas props"; }

/* ---------- panels ---------- */
.panel { background: var(--panel); min-height: 0; display: flex; flex-direction: column; }
#palette { grid-area: palette; border-right: 1px solid var(--line-strong); }
#props { grid-area: props; border-left: 1px solid var(--line-strong); }
#preview { grid-area: preview; border-top: 1px solid var(--line-strong); }
.panel-head {
  display: flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.panel-title { font-weight: 700; font-size: 13px; letter-spacing: .3px; }
.panel-hint { font-size: 11px; color: var(--muted-2); margin-left: auto; }
.panel-foot {
  padding: 9px 12px; font-size: 11.5px; color: var(--muted);
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}
.mini-btn {
  border: 1px solid var(--line); background: var(--panel-3); color: var(--muted);
  border-radius: 6px; width: 24px; height: 24px; line-height: 1; font-size: 11px;
  margin-left: auto;
}
.mini-btn:hover { color: #fff; border-color: var(--line-strong); }

/* ---------- palette ---------- */
.palette-search { padding: 10px 10px 6px; position: relative; flex: 0 0 auto; }
.ps-ico { position: absolute; left: 20px; top: 17px; font-size: 12px; opacity: .7; }
.palette-search input, .props-search input {
  width: 100%; height: 32px; padding: 0 10px 0 30px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 7px; color: var(--text); outline: none; font-size: 12.5px;
}
.palette-search input:focus, .props-search input:focus { border-color: var(--blue-400); }
.palette-search input::placeholder { color: var(--muted-2); }

.palette-body { overflow-y: auto; padding: 6px 10px 14px; flex: 1; }
.pal-group { margin-bottom: 12px; }
.pal-group-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--muted-2); margin: 8px 4px 6px; display: flex; align-items: center; gap: 6px;
}
.pal-group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.pal-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; margin: 2px 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cat, var(--blue-400));
  border-radius: 7px;
  cursor: grab;
  transition: background .1s, transform .1s, border-color .1s;
}
.pal-item:hover { background: var(--panel-3); border-color: var(--line-strong); transform: translateX(2px); }
.pal-item:active { cursor: grabbing; }
.pal-item .p-ico { font-size: 15px; width: 20px; text-align: center; }
.pal-item .p-name { font-size: 12.5px; font-weight: 600; }
.pal-item .p-desc { font-size: 10.5px; color: var(--muted-2); margin-top: 1px; }
.pal-empty { color: var(--muted-2); font-size: 12px; text-align: center; padding: 18px 6px; }

/* ============ HOME / PROJECTS ============ */
#home {
  grid-area: canvas;
  display: none;
  overflow-y: auto;
  background:
    radial-gradient(1100px 500px at 50% -8%, rgba(38, 90, 160, .35), transparent 60%),
    linear-gradient(180deg, #0a1b36 0%, #050d1c 100%);
}
#home .home-inner { max-width: 1060px; margin: 0 auto; padding: 34px 22px 60px; }
body.at-home #toolbar,
body.at-home #mobile-bar { display: none; }
body.at-home { overflow: auto; }
body.at-home #workspace { display: block; height: 100%; }
body.at-home #home { display: block; height: 100%; }
body.at-home { padding-top: 0; padding-bottom: 0; }
body.at-home #palette, body.at-home #props, body.at-home #preview,
body.at-home #canvas-wrap, body.at-home #canvas-hud, body.at-home #mobile-bar { display: none; }

.home-hero { text-align: center; padding: 18px 0 26px; }
.home-logo {
  image-rendering: pixelated;
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.08);
}
.home-banner {
  width: min(560px, 92%);
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 18px 50px rgba(0,0,0,.55));
}
.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;
}
.home-hero h1 { margin: 16px 0 4px; font-size: 34px; letter-spacing: .5px; color: #fff; }
.home-hero h1 span { color: var(--accent); }
.home-hero p { margin: 0; color: var(--muted); font-size: 14px; }
.home-hero .tagline { margin-top: 8px; font-size: 13px; color: var(--blue-300); font-style: italic; letter-spacing: .3px; }
.home-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.home-actions .btn { display: inline-flex; align-items: center; gap: 8px; }
.home-actions .btn .tb-ico { font-size: 16px; }
#btn-audio.is-on { border-color: var(--accent); color: var(--accent); }
#btn-audio.is-on .tb-ico svg { color: var(--accent); }
#btn-audio:not(.is-on) .tb-ico svg { color: var(--muted); }

.home-projects-head { display: flex; align-items: baseline; gap: 12px; margin: 8px 2px 14px; }
.home-projects-head h2 { margin: 0; font-size: 17px; color: #fff; }
#home-count { font-size: 12px; color: var(--muted-2); }

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.home-card {
  background: linear-gradient(180deg, #102340, #0c1a32);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.home-card:hover { transform: translateY(-3px); border-color: var(--blue-400); box-shadow: 0 14px 34px rgba(0,0,0,.4); }
.hc-top { display: flex; gap: 12px; align-items: center; }
.hc-ico {
  width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 11px; display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: #0e2c5c; border: 1px solid var(--line-strong);
}
.hc-name { font-weight: 700; font-size: 15px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-meta { font-size: 11.5px; color: var(--muted-2); }
.hc-actions { display: flex; gap: 6px; margin-left: auto; }
.hc-actions .mini-btn { margin-left: 0; width: 30px; height: 30px; font-size: 13px; }
.hc-mtime { font-size: 11px; color: var(--muted-2); margin-top: auto; }

.home-new {
  border: 2px dashed rgba(255,167,38,.5);
  background: rgba(255,167,38,.06);
  border-radius: 16px;
  min-height: 128px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--accent);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .12s;
}
.home-new:hover { background: rgba(255,167,38,.12); border-color: var(--accent); transform: translateY(-2px); }
.home-new .hn-plus {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(180deg, #ffb340, #f79a00);
  color: #2c2200; font-size: 30px; font-weight: 800; line-height: 52px; text-align: center;
  box-shadow: 0 8px 24px rgba(255,167,38,.4);
}
.home-new .hn-label { font-weight: 700; font-size: 13.5px; }
.home-new .hn-sub { font-size: 11px; color: var(--muted); }
.home-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 30px 10px 10px; font-size: 13px; }
.home-foot { text-align: center; margin-top: 30px; font-size: 11.5px; color: var(--muted-2); }
.home-foot a { color: var(--blue-300); }

@media (max-width: 767px) {
  .home-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .home-hero h1 { font-size: 26px; }
  .home-logo { width: 96px; height: 96px; }
}
@media (max-width: 480px) {
  .home-grid { grid-template-columns: 1fr; }
}

/* ---------- canvas (dark node-editor style) ---------- */
#canvas-wrap { grid-area: canvas; position: relative; min-width: 0; min-height: 0; background: #0b0f14; }
#canvas { position: absolute; inset: 0; overflow: hidden; cursor: default; }

#grid-layer, #wire-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
#wire-svg { overflow: visible; }
#grid-layer { pointer-events: none; }
#grid-layer {
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.09) 1px, transparent 1px);
  background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
}

#viewport {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  transform-origin: 0 0;
  transform: translate(0px, 0px) scale(1);
}

/* ---------- canvas HUD ---------- */
#canvas-hud {
  position: absolute; left: 12px; bottom: 10px; z-index: 5;
  display: flex; gap: 14px; align-items: center;
  background: rgba(10, 15, 21, .9);
  border: 1px solid #2a3542;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 11px; color: #8fa5bd;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
#hud-status, #hud-status b { color: var(--accent); font-size: 11.5px; }

/* ---------- marquee ---------- */
#marquee {
  position: absolute; border: 1px solid var(--cyan);
  background: rgba(79,216,255,.12);
  pointer-events: none; z-index: 6;
}

/* ---------- empty canvas ---------- */#canvas-empty {
  position: absolute; inset: 0; z-index: 4;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
#canvas-empty.hidden { display: none; }
.ce-card {
  pointer-events: auto;
  max-width: 430px; text-align: center;
  background: rgba(13, 18, 24, .94);
  border: 1px solid #2a3542;
  border-radius: 16px;
  padding: 26px 30px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  backdrop-filter: blur(6px);
}
.ce-ico { font-size: 40px; }
.ce-card h2 { margin: 8px 0 6px; font-size: 19px; }
.ce-card p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 16px; }
.ce-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------- NODES (dark editor cards, colored headers) ---------- */
.node {
  position: absolute;
  width: 216px;
  background: linear-gradient(180deg, #1c232c 0%, #151b22 100%);
  border: 1px solid #34414f;
  border-radius: 10px;
  color: #dbe4ee;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0,0,0,.4);
  cursor: grab;
  transition: box-shadow .12s, border-color .12s;
}
.node:hover { box-shadow: 0 12px 30px rgba(0,0,0,.65), 0 0 0 1px rgba(255,255,255,.06); }
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,167,38,.32), 0 12px 30px rgba(0,0,0,.6); }
.node.dropping { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(79,216,255,.4), 0 12px 30px rgba(0,0,0,.6); }

.node-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: 10px 10px 0 0;
  background: var(--cat, var(--blue-500));
  color: #fff;
}
.node-head .n-ico { font-size: 15px; }
.node-head .n-type {
  font-size: 9px; text-transform: uppercase; letter-spacing: 1.1px;
  opacity: .9; font-weight: 700;
  background: rgba(0,0,0,.22); padding: 2px 6px; border-radius: 6px;
}
.node-head .n-idx {
  font-size: 10px; padding: 1px 6px;
  background: rgba(0,0,0,.22); border-radius: 8px;
}
.node-head .n-title {
  flex-basis: 100%; font-size: 13px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: -2px;
}
.n-actions { display: flex; gap: 2px; margin-left: auto; }
.n-btn {
  border: 0; background: rgba(0,0,0,.18); color: #fff;
  width: 20px; height: 20px; border-radius: 5px; font-size: 11px; line-height: 1;
}
.n-btn:hover { background: rgba(0,0,0,.35); }

.node-body { padding: 8px 10px 10px; }
.n-line { font-size: 12px; display: flex; gap: 6px; align-items: baseline; min-height: 16px; }
.n-line .k { color: #8fa5bd; flex: 0 0 auto; }
.n-line .v { color: #e6eef7; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.n-line .v.muted { color: #8fa5bd; font-weight: 500; }
.n-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.n-badge {
  font-size: 10px; padding: 2px 7px; border-radius: 8px;
  background: #22303d; color: #b7cade; border: 1px solid #34414f;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.n-badge.rows { white-space: normal; }
.n-badges .n-badge.overflow { background: #3a2e12; color: #ffd28a; border-color: #6b5218; }

.node-foot {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px 7px; border-top: 1px solid #262f3a;
  font-size: 10px; color: #7e93aa;
}
.node-foot .fb-hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- ports ---------- */
.port {
  position: absolute;
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--pcat, var(--blue-500));
  z-index: 4;
  cursor: crosshair;
  transform: translateY(-50%);
  transition: box-shadow .08s;
}
.port:hover, .port.linked, .port.wiring {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pcat, var(--blue-500)) 40%, transparent);
  z-index: 5;
}
/* multi-wire badge: how many connections a port has */
.port.multi::after {
  content: attr(data-count);
  position: absolute; top: -9px; right: -9px;
  min-width: 13px; height: 13px; padding: 0 3px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent, #ffa726); color: #08131f;
  border-radius: 8px; font-size: 8.5px; font-weight: 800; line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.port.out { right: -7px; }
.port.in { left: -7px; }
.port.flow { --pcat: var(--accent); }
.port.sig { --pcat: var(--purple); }
.port.ctrl { --pcat: var(--cyan); }
.port.action { --pcat: var(--green); }
.port.extra { --pcat: var(--yellow); }
.port.bottom { right: auto; left: 50%; margin-left: -6.5px; bottom: -6.5px; transform: none; }
.port-label {
  position: absolute; font-size: 9px; color: #cfe0f4; background: #0e1620;
  padding: 1px 5px; border: 1px solid #31404f; border-radius: 6px; white-space: nowrap;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 3;
}
/* wire-mode: glowing, larger hit area + ring on valid targets */
.port.wire-source { box-shadow: 0 0 0 5px rgba(255,167,38,.35), 0 0 18px 4px rgba(255,167,38,.55); animation: port-pulse 1s ease-in-out infinite; z-index: 6; }
.port.wire-target { box-shadow: 0 0 0 5px rgba(79,216,255,.4), 0 0 20px 6px rgba(79,216,255,.6); animation: port-pulse .8s ease-in-out infinite; z-index: 6; }
@keyframes port-pulse { 0%,100% { transform: translateY(-50%) scale(1); } 50% { transform: translateY(-50%) scale(1.25); } }
.port.wire-target.bottom, .port.wire-source.bottom { animation-name: port-pulse-b; }
@keyframes port-pulse-b { 0%,100% { transform: scale(1); } 50% { transform: scale(1.25); } }
body.wiring-mode #canvas { cursor: crosshair; }
.port-label.out-label { right: -7px; transform: translate(100%, -50%); }
.port-label.in-label { left: -7px; transform: translate(-100%, -50%); }
.port-label.bottom-label { right: auto; left: 50%; transform: translate(-50%, 0); bottom: -6.5px; }

/* ---------- wires ---------- */
.wire-path { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.wire-path.hidden { display: none; }
.wire-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.wire-path.dim { opacity: .25; }
.wire-path.linked { opacity: 1; }
text.wire-label {
  font-size: 10px; fill: #b9cde5; font-family: var(--mono);
  paint-order: stroke; stroke: rgba(10,15,21,.95); stroke-width: 3px;
  pointer-events: none;
}

/* ---------- properties panel ---------- */
.props-body { overflow-y: auto; flex: 1; padding: 12px; }
.props-empty { text-align: center; color: var(--muted-2); padding: 28px 8px; font-size: 12.5px; }
.props-empty .pe-ico { font-size: 30px; display: block; margin-bottom: 10px; }
.prop-group { margin-bottom: 16px; }
.prop-group-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--muted-2); margin: 0 0 8px; padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.field input[type=text], .field input[type=number], .field select, .field textarea {
  width: 100%; padding: 7px 9px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 7px; color: var(--text); outline: none; font-size: 12.5px;
}
.field textarea { resize: vertical; min-height: 54px; font-family: var(--mono); font-size: 11.5px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue-400); box-shadow: 0 0 0 2px rgba(79,155,245,.15); }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }
.field-inline { display: flex; align-items: center; gap: 8px; }
.field-inline input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue-500); }
.field-hint { font-size: 10.5px; color: var(--muted-2); margin-top: 3px; }

.repeatable-row {
  display: flex; gap: 6px; margin-bottom: 6px;
}
.repeatable-row input, .repeatable-row select { flex: 1; min-width: 0; }
.repeatable-row .rm {
  flex: 0 0 28px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--muted); border-radius: 6px; font-size: 12px;
}
.repeatable-row .rm:hover { color: var(--red); border-color: var(--red); }
.add-row {
  width: 100%; padding: 6px; background: var(--panel-2); border: 1px dashed var(--line-strong);
  border-radius: 7px; color: var(--muted); font-size: 11.5px;
}
.add-row:hover { color: #fff; border-color: var(--blue-400); }

.props-actions { display: flex; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.props-actions .btn { flex: 1; }

/* ---------- preview (split: form | game output) ---------- */
#preview { height: 300px; flex: 0 0 300px; display: flex; flex-direction: column; min-height: 0; }
#preview .panel-head { flex: 0 0 auto; }
.preview-pages {
  display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 12px 0; flex: 0 0 auto;
}
.preview-pages[hidden] { display: none; }
.page-chip {
  font: inherit; font-size: 11px; font-weight: 700; color: #cfe0f4; cursor: pointer;
  background: #12233a; border: 1px solid #2b3b4d; border-radius: 20px; padding: 4px 11px;
  transition: border-color .12s, background .12s;
}
.page-chip:hover { border-color: var(--blue-400); }
.page-chip.is-active { background: var(--blue-500); border-color: var(--blue-400); color: #fff; }
.preview-split {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 0;
}
#preview-body {
  min-height: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(rgba(10,42,88,.6), rgba(10,42,88,.6)),
    repeating-linear-gradient(45deg, #3a5a8c 0 14px, #446699 14px 28px);
  padding: 10px;
}
.preview-output { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--line-strong); }
.preview-log-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line);
  font-size: 11px; color: var(--muted); flex: 0 0 auto;
}
.preview-log {
  flex: 1; min-height: 0; overflow-y: auto; padding: 6px 12px;
  font-family: var(--mono); font-size: 10.5px; color: #a9c4ef;
  background: #081b3a;
}
.preview-log .pl-err { color: var(--red); }
.preview-log .pl-ok { color: var(--green); }
.preview-log .pl-io { color: var(--yellow); }
@media (max-width: 767px) {
  .preview-split { grid-template-columns: 1fr; overflow-y: auto; }
  .preview-output { border-left: 0; border-top: 1px solid var(--line-strong); }
  .preview-log { min-height: 84px; }
}

/* minecraft-ish form */
.mc-form {
  width: min(420px, 100%); max-height: 100%; overflow: auto;
  background: #c6c6c6;
  border: 3px solid;
  border-color: #ffffff #555555 #555555 #ffffff;
  color: #1a1a1a;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  padding: 8px;
}
.mc-form-title {
  background: linear-gradient(180deg, #3a3a3a, #151515);
  color: #fff;
  font-weight: 700;
  margin: -8px -8px 8px;
  padding: 7px 10px;
  text-shadow: 2px 2px 0 rgba(0,0,0,.6);
}
.mc-header {
  background: linear-gradient(180deg, #4a4a4a, #222);
  color: #fff; font-weight: 700; padding: 4px 6px; margin: 2px -8px 6px;
}
.mc-label { color: #3b3b3b; padding: 2px 2px 6px; }
.mc-field { margin-bottom: 8px; }
.mc-field > span { display: block; font-size: 12px; padding: 0 1px 3px; }
.mc-btn {
  display: block; width: 100%; text-align: left;
  border: 2px solid; border-color: #ffffff #555 #555 #fff;
  background: #c6c6c6; color: #222;
  padding: 5px 8px; margin-bottom: 4px; font-size: 13px; font-weight: 600;
}
.mc-btn:hover { background: #d6d6d6; }
.mc-btn-img {
  width: 16px; height: 16px; object-fit: cover; margin-right: 7px;
  vertical-align: -3px; image-rendering: pixelated;
  border: 1px solid #555; background: #eee;
}
.mc-btn:active { border-color: #555 #fff #fff #555; padding: 6px 7px 4px 9px; }
.mc-submit {
  display: block; width: 100%; margin-top: 8px; padding: 6px 8px;
  font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #7a2f2f, #4a1818);
  border: 2px solid; border-color: #fff #3d3d3d #3d3d3d #fff;
  text-shadow: 1px 1px 0 rgba(0,0,0,.7);
}
.mc-submit:hover { filter: brightness(1.15); }
.mc-input {
  width: 100%; padding: 5px 7px; border: 2px solid #555;
  background: #fff; color: #111; font-size: 13px; outline: none;
}
.mc-input:focus { border-color: #3b3b3b; }
.mc-row { display: flex; align-items: center; gap: 8px; }
.mc-check { appearance: none; width: 18px; height: 18px; flex: 0 0 18px; cursor: pointer; border: 2px solid #555; background: #fff; position: relative; }
.mc-check:checked::after { content: "✔"; position: absolute; inset: -4px 0 0 1px; font-size: 14px; color: #222; }
.mc-range { flex: 1; accent-color: #6e6e6e; }
.mc-drop { position: relative; }
.mc-drop-list { position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 5; background: #c6c6c6; border: 2px solid #555; max-height: 120px; overflow-y: auto; }
.mc-drop-list .opt { padding: 4px 8px; cursor: pointer; }
.mc-drop-list .opt:hover, .mc-drop-list .opt.active { background: #7a9ce0; color: #fff; }
.mc-divider { height: 2px; background: #8a8a8a; margin: 9px 2px; }
.mc-preview-note { font-size: 11px; color: #666; text-align: center; margin-top: 8px; padding-top: 4px; border-top: 1px dashed #999; }

/* ---------- search results ---------- */
.search-hits {
  position: absolute; top: 46px; left: 12px; right: 12px; z-index: 40;
  max-height: 300px; overflow-y: auto;
  background: #0d2f63; border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0,0,0,.5);
}
.search-hits:empty { display: none; }
.sh-item { display: flex; gap: 10px; align-items: center; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.sh-item:hover, .sh-item.active { background: var(--panel-3); }
.sh-item .sh-type { font-size: 10px; color: var(--muted-2); min-width: 56px; }
.sh-item .sh-title { font-weight: 600; font-size: 12.5px; }
.sh-item .sh-path { font-size: 10.5px; color: var(--muted-2); }

/* ---------- MODALS ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 16, 38, .72);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(560px, 92vw); max-height: 88vh;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-wide { width: min(880px, 94vw); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { margin-left: auto; border: 1px solid var(--line); background: var(--panel-3); color: var(--muted); width: 30px; height: 30px; border-radius: 8px; font-size: 13px; }
.modal-close:hover { color: #fff; border-color: var(--line-strong); }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel-2); }

.modal-tabs { display: flex; gap: 4px; margin-left: 8px; background: var(--panel); border-radius: 9px; padding: 3px; }
.tab {
  border: 0; border-radius: 7px; padding: 7px 16px;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 600;
}
.tab.is-active { background: var(--blue-500); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); }

.export-code {
  margin: 0; padding: 14px 16px;
  background: #071a36; border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  max-height: 52vh;
  font-size: 12px; line-height: 1.55;
  color: #d6e6ff;
  tab-size: 2;
  user-select: text;
  counter-reset: line;
}
.code-line { display: block; min-height: 1.2em; }
.export-empty { text-align: center; padding: 30px 20px; color: var(--muted); }
.export-empty-ico { font-size: 44px; margin-bottom: 12px; }
.export-empty p { margin: 6px 0; }
.export-empty code { background: var(--panel-2); padding: 1px 6px; border-radius: 4px; color: var(--blue-300); }

.btn {
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--panel-2); color: var(--text);
  padding: 8px 14px; font-size: 13px;
}
.btn:hover { background: var(--panel-3); }
.btn-primary { background: var(--blue-500); border-color: var(--blue-300); font-weight: 700; }
.btn-primary:hover { background: var(--blue-400); }
.btn-danger { background: #b83a48; border-color: #e07a86; font-weight: 700; }
.btn-ghost { background: transparent; }
.btn-big { padding: 12px 22px; font-size: 14.5px; font-weight: 800; border-radius: 11px; }
.btn-ts { background: linear-gradient(180deg, #3178c6, #235a9e); border-color: #7ab0f0; }
.btn-ts:hover { background: linear-gradient(180deg, #3d8ae0, #2a68b4); }
.btn-js { background: linear-gradient(180deg, #d9a513, #b28a08); border-color: #ffe08a; color: #2c2300; }
.btn-js:hover { background: linear-gradient(180deg, #e9b91f, #c79c0d); }
.export-actions .tb-spacer { flex: 1; }

/* help */
.help-body { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.help-col h3 { font-size: 13.5px; margin: 0 0 8px; color: #fff; }
.help-col p, .help-col li { font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.help-col ol, .help-col ul { padding-left: 18px; margin: 6px 0; }
.help-col b { color: #fff; }
.p-out { color: var(--purple); font-weight: 700; }
.p-in { color: var(--cyan); font-weight: 700; }
.help-keys { margin-top: 14px; font-size: 11.5px; }

/* ================= TOUR ================= */
#tour-root { position: fixed; inset: 0; z-index: 150; pointer-events: none; }
#tour-dim {
  position: absolute; inset: 0;
  background: rgba(5, 18, 42, .68);
  opacity: 0; transition: opacity .25s;
  pointer-events: none;
}
#tour-dim.show { opacity: 1; }
#tour-spot {
  position: absolute;
  border-radius: 14px;
  box-shadow: 0 0 0 4px var(--accent), 0 0 34px rgba(255, 167, 38, .55), 0 0 110px rgba(79, 216, 255, .3);
  border: 2px solid rgba(255, 255, 255, .65);
  background: transparent;
  pointer-events: none;
  transition: left .18s ease, top .18s ease, width .18s ease, height .18s ease;
}
#tour-arrow-svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; overflow: visible; z-index: 2;
}
.tour-path {
  fill: none; stroke: var(--accent); stroke-width: 3.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(255,167,38,.9));
  stroke-dasharray: 10 7;
  animation: tour-dash 0.9s linear infinite;
}
.tour-head {
  fill: var(--accent);
  filter: drop-shadow(0 0 6px rgba(255,167,38,.9));
  animation: tour-pulse 1.1s ease-in-out infinite;
}
@keyframes tour-dash { to { stroke-dashoffset: -34; } }
@keyframes tour-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

#tour-card {
  position: absolute; z-index: 3;
  width: 340px;
  background: linear-gradient(180deg, #0e2f66, #0a2450);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 167, 38, .25);
  padding: 14px 16px 12px;
  pointer-events: auto;
  color: var(--text);
  transition: left .18s ease, top .18s ease;
}
#tour-card.tc-center { border-color: var(--accent); }
.tc-head { display: flex; align-items: center; gap: 8px; }
.tc-step {
  font-size: 10px; font-weight: 800; letter-spacing: 1px;
  color: #14305a; background: var(--accent);
  padding: 3px 8px; border-radius: 20px; text-transform: uppercase;
}
.tc-title { font-size: 15px; font-weight: 800; color: #fff; }
.tc-body { font-size: 13px; line-height: 1.55; color: var(--muted); margin: 9px 0 6px; }
.tc-hint { font-size: 12.5px; color: var(--yellow); font-weight: 600; margin: 4px 0 2px; }
.tc-foot { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.tc-btn {
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--panel-2); color: var(--text);
  padding: 7px 12px; font-size: 12.5px;
}
.tc-btn:hover { background: var(--panel-3); }
.tc-btn:disabled { opacity: .35; cursor: not-allowed; }
.tc-btn.tc-primary { background: var(--accent); border-color: #ffd28a; color: #2c2200; font-weight: 800; }
.tc-btn.tc-skip { margin-left: auto; background: transparent; color: var(--muted-2); font-size: 11.5px; }
.tc-btn.tc-skip:hover { color: #fff; }

/* ---------- settings panel ---------- */
.settings-body { display: flex; flex-direction: column; gap: 18px; }
.set-group .prop-group-title { border-bottom: 0; margin-bottom: 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; background: var(--panel); padding: 4px; border-radius: 10px; }
.seg button {
  flex: 1; min-width: 76px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--muted);
  padding: 8px 10px; font-size: 12.5px; font-weight: 600;
}
.seg button.is-active { background: var(--blue-500); color: #fff; border-color: var(--blue-300); }
.seg.pb-bg button { min-width: 96px; }
#set-saturation { width: 100%; accent-color: var(--accent); }
.set-val { text-align: right; font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }

/* ---------- export package fields + images tray ---------- */
.pkg-fields { display: flex; gap: 10px; margin-bottom: 10px; }
.pkg-fields .field { flex: 1; margin-bottom: 0; }
.images-tray { margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.images-tray-head {
  width: 100%; display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); color: var(--text);
  border: 0; padding: 9px 12px; font-size: 12.5px; font-weight: 700;
}
.images-tray-head .tr-ico { margin-left: auto; transition: transform .18s; font-size: 12px; }
.images-tray.opened .tr-ico { transform: rotate(180deg); }
.images-tray-body { padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; background: var(--panel); }
.img-thumb { position: relative; width: 70px; }
.img-thumb img { width: 70px; height: 70px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line-strong); image-rendering: pixelated; }
.img-thumb .img-del {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  border-radius: 50%; border: 1px solid var(--line-strong);
  background: #0b0f14; color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center;
}
.img-thumb .img-del svg { width: 10px; height: 10px; }
.img-add {
  width: 70px; height: 70px; border: 1px dashed var(--line-strong);
  border-radius: 8px; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 10px;
}
.img-add .tb-ico { font-size: 18px; }
.img-add:hover { border-color: var(--accent); color: var(--accent); }
.images-tray-body.pos {
  background: repeating-linear-gradient(45deg, #0e2c5c, #0e2c5c 12px, #123a75 12px, #123a75 24px);
  outline: 2px dashed var(--cyan); outline-offset: -4px;
}
.images-tray-body .drop-anywhere { width: 100%; text-align: center; font-size: 11.5px; color: var(--muted); padding: 8px 0 2px; }

/* ---------- save-as + mcaddon notice ---------- */
.saveas-label { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.saveas-label select {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 8px; font-size: 12.5px;
}
.mcaddon-notice {
  background: rgba(255,206,61,.08); border: 1px solid rgba(255,206,61,.45);
  color: var(--yellow); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
  font-size: 12.5px; line-height: 1.5;
  display: flex; gap: 10px; align-items: flex-start;
}
.mcaddon-notice .tb-ico { flex: 0 0 auto; margin-top: 2px; }
.mcaddon-notice b { color: #fff; }

/* ---------- advanced mode ---------- */
#advanced { grid-area: canvas; display: flex; flex-direction: column; height: 100%; min-height: 0; background: #0b0f14; }
#advanced[hidden] { display: none; }
.adv-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: #0d1621; border-bottom: 1px solid #2a3542;
}
.adv-title { font-weight: 800; font-size: 14px; color: #fff; letter-spacing: .5px; }
.adv-tools { display: flex; gap: 4px; margin-left: auto; }
.adv-grid {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: 1fr 1fr 1fr; gap: 10px; padding: 10px;
}
.adv-pane { display: flex; flex-direction: column; min-height: 0; background: #0d1621; border: 1px solid #2a3542; border-radius: 10px; overflow: hidden; }
.adv-pane-head {
  display: flex; align-items: center; padding: 7px 10px; background: #101b28;
  border-bottom: 1px solid #2a3542; font-size: 12px; font-weight: 700; color: #cfe0f4;
}
.adv-pane-head .tb-ico { font-size: 13px; }
.adv-lang-wrap { margin-left: auto; }
.adv-lang-wrap select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 11px; }
.adv-note { margin-left: auto; font-size: 10.5px; color: var(--muted-2); font-weight: 500; }
#adv-editor {
  flex: 1; min-height: 0; resize: none; border: 0; outline: none;
  background: #0a0f16; color: #d6e6ff; font-family: var(--mono);
  font-size: 12.5px; line-height: 1.6; padding: 12px; tab-size: 2;
}
#adv-preview {
  flex: 1; min-height: 0; overflow: auto; padding: 12px;
  display: flex; align-items: flex-start; justify-content: center;
}
#adv-console { flex: 1; min-height: 0; overflow-y: auto; font-family: var(--mono); font-size: 11.5px; padding: 10px 12px; color: #a9c4ef; }
#adv-console .aok { color: var(--green); }
#adv-console .aerr { color: var(--red); }
#adv-console .aio { color: var(--yellow); }
#adv-console .adim { color: var(--muted-2); }
#advanced .mc-form { max-height: none; width: min(380px, 100%); }

/* theme: Matrix */
body.theme-matrix { background: #020803; }
body.theme-matrix #toolbar,
body.theme-matrix #palette, body.theme-matrix #props, body.theme-matrix #preview {
  background: #04120a !important; border-color: #0f5c2e !important;
}
body.theme-matrix #canvas-wrap,
body.theme-matrix #advanced { background: #020803; }
body.theme-matrix #grid-layer {
  background-image:
    linear-gradient(rgba(0,255,102,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,255,102,.07) 1px, transparent 1px),
    linear-gradient(rgba(0,255,102,.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,255,102,.14) 1px, transparent 1px);
}
body.theme-matrix .node { background: #061008; border-color: #0f5c2e; color: #d6ffe6; }
body.theme-matrix .node-head { background: var(--cat); filter: saturate(.6); }
body.theme-matrix .node-body .n-line .v { color: #eafff2; }
body.theme-matrix .node-foot { border-color: #0c3f22; color: #57a97c; }
body.theme-matrix .panel-title, body.theme-matrix .mc-form-title { color: #d6ffe6; }
body.theme-matrix #home { background: radial-gradient(1100px 500px at 50% -8%, rgba(0,255,102,.12), transparent 60%), linear-gradient(180deg, #03130a, #01060381); }

/* theme: Minecraft (textured blocks) */
body.theme-minecraft { background: #6d6d6d; }
body.theme-minecraft #toolbar,
body.theme-minecraft #palette, body.theme-minecraft #props, body.theme-minecraft #preview {
  background: #3f3f3f !important;
  border-color: #000;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.25), inset 0 -2px 0 rgba(0,0,0,.4);
}
body.theme-minecraft .panel-head, body.theme-minecraft .preview-log-head { background: #505050; }
/* Minecraft theme — homepage wallpaper, picked for each device
   portrait phones: 1080x1920 · small/landscape: 800x450 · laptops: 1920x1080 · big monitors: 2058x1440
   (grass stripes stay as the fallback layer behind the photo) */
body.theme-minecraft #home {
  background:
    linear-gradient(rgba(6,10,6,.44), rgba(6,10,6,.44)),
    url("../img/wallpapers/mc-home-800x450.jpg") center / cover no-repeat,
    repeating-linear-gradient(0deg, #5f8f5a 0 28px, #567f52 28px 56px);
}
@media (orientation: portrait) {
  body.theme-minecraft #home {
    background:
      linear-gradient(rgba(6,10,6,.44), rgba(6,10,6,.44)),
      url("../img/wallpapers/mc-home-1080x1920.jpg") center / cover no-repeat,
      repeating-linear-gradient(0deg, #5f8f5a 0 28px, #567f52 28px 56px);
  }
}
@media (orientation: landscape) and (min-width: 1000px) and (max-width: 2100px) {
  body.theme-minecraft #home {
    background:
      linear-gradient(rgba(6,10,6,.44), rgba(6,10,6,.44)),
      url("../img/wallpapers/mc-home-1920x1080.jpg") center / cover no-repeat,
      repeating-linear-gradient(0deg, #5f8f5a 0 28px, #567f52 28px 56px);
  }
}
@media (orientation: landscape) and (min-width: 2101px) {
  body.theme-minecraft #home {
    background:
      linear-gradient(rgba(6,10,6,.44), rgba(6,10,6,.44)),
      url("../img/wallpapers/mc-home-2058x1440.jpg") center / cover no-repeat,
      repeating-linear-gradient(0deg, #5f8f5a 0 28px, #567f52 28px 56px);
  }
}
body.theme-minecraft .home-card { background: #4a4a4a; border-color: #000; box-shadow: inset 0 2px 0 rgba(255,255,255,.2), inset 0 -2px 0 rgba(0,0,0,.4); }
body.theme-minecraft .tb-btn, body.theme-minecraft .btn { border-color: #000; }
body.theme-minecraft #canvas-wrap, body.theme-minecraft #advanced { background: #6d6d6d; }
body.theme-minecraft #grid-layer { background-image:
  linear-gradient(rgba(0,0,0,.12) 1px, transparent 1px),
  linear-gradient(90deg, rgba(0,0,0,.12) 1px, transparent 1px),
  linear-gradient(rgba(0,0,0,.22) 1px, transparent 1px),
  linear-gradient(90deg, rgba(0,0,0,.22) 1px, transparent 1px); }
body.theme-minecraft .node { border-color: #000; box-shadow: inset 0 2px 0 rgba(255,255,255,.3), inset 0 -2px 0 rgba(0,0,0,.35); }
body.theme-minecraft .node-head { border-bottom: 2px solid rgba(0,0,0,.5); }

/* preview backgrounds — Minecraft scene photos (dimmed, cover) with gradient fallback */
#adv-preview.pb-overworld, #preview-body.pb-overworld {
  background:
    linear-gradient(rgba(4,10,20,.30), rgba(4,10,20,.30)),
    url("../img/previews/overworld.jpg") center / cover no-repeat,
    linear-gradient(180deg, #6fb7fa 0%, #8fd0ff 55%, #5f8f5a 56%, #4e7a4a 100%);
}
#adv-preview.pb-nether, #preview-body.pb-nether {
  background:
    linear-gradient(rgba(15,4,2,.32), rgba(15,4,2,.32)),
    url("../img/previews/nether.jpg") center / cover no-repeat,
    linear-gradient(180deg, #3a0f0a 0%, #651710 55%, #8a2a12 56%, #5a1c0c 100%);
}
#adv-preview.pb-end, #preview-body.pb-end {
  background:
    linear-gradient(rgba(2,2,10,.34), rgba(2,2,10,.34)),
    url("../img/previews/end.jpg") center / cover no-repeat,
    linear-gradient(180deg, #0a0a1c 0%, #1a1a3a 55%, #c9c9d4 56%, #a9a9b8 100%);
}
#adv-preview.pb-server, #preview-body.pb-server {
  background:
    linear-gradient(rgba(6,10,22,.32), rgba(6,10,22,.32)),
    url("../img/previews/server.jpg") center / cover no-repeat,
    linear-gradient(180deg, #101625 0%, #1c2a46 55%, #22334f 56%, #182740 100%);
}

/* settings: scene picker thumbnails */
.seg.pb-bg button {
  min-width: 96px; height: 54px; padding: 8px 10px;
  background-position: center; background-size: cover;
  border-color: rgba(255,255,255,.30);
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.95), 0 0 6px rgba(0,0,0,.85);
  font-weight: 700;
}
.seg.pb-bg button[data-val="overworld"] { background-image: url("../img/previews/overworld.jpg"); }
.seg.pb-bg button[data-val="nether"]   { background-image: url("../img/previews/nether.jpg"); }
.seg.pb-bg button[data-val="end"]      { background-image: url("../img/previews/end.jpg"); }
.seg.pb-bg button[data-val="server"]   { background-image: url("../img/previews/server.jpg"); }
.seg.pb-bg button:hover { border-color: var(--blue-300); }
.seg.pb-bg button.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--blue-400), inset 0 0 0 999px rgba(37,99,235,.30);
}

/* fonts setting */
body.font-mc,
body.font-mc *,
body.font-mc button {
  font-family: "MinecraftPixel", "Monocraft", "Courier New", monospace !important;
  font-size: 1.05em;
  letter-spacing: .5px;
  -webkit-font-smoothing: none;
  font-smooth: never;
  image-rendering: pixelated;
}
/* glyphs missing from the 110-glyph pixel font fall back to Monocraft */
body.font-mc { font-size: 103%; }
body.font-italic { font-style: italic; }
body.font-italic .tb-btn, body.font-italic .btn, body.font-italic .tc-btn { font-style: italic; }
body.font-bold { font-weight: 800; }
body.font-bold .tb-btn, body.font-bold .btn { font-weight: 800; }

/* saturation setting (scoped to app surfaces) */
body.sat-0 #toolbar, body.sat-50 #toolbar, body.sat-150 #toolbar, body.sat-200 #toolbar,
body.sat-0 #palette, body.sat-50 #palette, body.sat-150 #palette, body.sat-200 #palette,
body.sat-0 #props, body.sat-50 #props, body.sat-150 #props, body.sat-200 #props,
body.sat-0 #preview, body.sat-50 #preview, body.sat-150 #preview, body.sat-200 #preview,
body.sat-0 #home, body.sat-50 #home, body.sat-150 #home, body.sat-200 #home,
body.sat-0 #advanced, body.sat-50 #advanced, body.sat-150 #advanced, body.sat-200 #advanced {
  filter: saturate(var(--sat, 1));
}

/* mcaddon mobile fields */
@media (max-width: 767px) {
  .adv-tools .tb-lbl { display: none; }
  .pkg-fields { flex-direction: column; }
  .adv-grid { grid-template-columns: 1fr; grid-template-rows: 1.4fr 1fr 1fr; }
  .adv-head { flex-wrap: wrap; }
  .adv-tools { flex-wrap: wrap; }
  .home-actions { flex-wrap: wrap; }
}

/* toast */
.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  background: #0e2c5c; border: 1px solid var(--line-strong);
  border-left: 4px solid var(--green);
  padding: 11px 16px; border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,.5);
  font-size: 13px;
  transform: translateY(8px); opacity: 0;
  transition: transform .18s, opacity .18s;
}
.toast.show { transform: none; opacity: 1; }
.toast.err { border-left-color: var(--red); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); background-clip: content-box; }

@media (max-width: 1100px) {
  #workspace { grid-template-columns: 210px 1fr 250px; }
  .tb-lbl, .brand-sub { display: none; }
  .help-body { grid-template-columns: 1fr; }
}

/* panel toggles */
#workspace.no-preview { grid-template-rows: 1fr; grid-template-areas: "palette canvas props"; }
#workspace.no-props { grid-template-columns: 250px 1fr; grid-template-areas: "palette canvas" "preview preview"; }
#workspace.no-props.no-preview { grid-template-rows: 1fr; grid-template-areas: "palette canvas"; }

/* ============================================================
   DESKTOP POLISH (laptops & up)
   ============================================================ */
#btn-toggle-palette, #btn-toggle-props { display: none; }
#workspace.no-palette {
  grid-template-columns: 0 1fr 300px;
}
#workspace.no-palette #palette {
  width: 0; border-right: 0; opacity: 0; overflow: hidden; padding: 0;
  transition: opacity .15s;
}
#workspace.no-props { grid-template-columns: 250px 1fr 0; }
#workspace.no-props #props { width: 0; border-left: 0; opacity: 0; overflow: hidden; }
#workspace.no-palette.no-props { grid-template-columns: 0 1fr 0; }
#workspace.no-palette .panel, #workspace.no-props .panel { transition: opacity .15s; }

.node-head .n-type, .n-idx { transition: background .12s; }
.tb-btn, .btn, .tc-btn, .pal-item { transition: background .12s, border-color .12s, transform .08s, box-shadow .12s; }
#toolbar { box-shadow: 0 2px 18px rgba(0,0,0,.4); }

/* ============================================================
   TOUCH BASICS — smooth, no browser gestures fighting the app
   ============================================================ */
/* tap-to-connect hint */
.wire-hint {
  position: fixed; z-index: 210;
  left: 50%; transform: translateX(-50%);
  bottom: 86px;
  background: rgba(14, 44, 92, .96);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 13px; font-weight: 600;
  padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,.55);
  pointer-events: none;
  text-align: center;
}
@media (max-width: 767px) {
  .wire-hint { bottom: calc(var(--barbarH) + 14px + env(safe-area-inset-bottom)); left: 12px; right: 12px; transform: none; }
}

/* ============ TOOLTIPS (hover on laptop, press-and-hold on phone) ============ */
#u-tip {
  position: fixed; z-index: 500;
  max-width: 250px;
  background: #101722;
  border: 1px solid #33404e;
  color: #e6eef7;
  font-size: 12px; line-height: 1.45;
  padding: 7px 10px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .12s, transform .12s;
  text-align: left;
}
#u-tip.show { opacity: 1; transform: none; }
#u-tip::before {
  content: ""; position: absolute; left: 50%; top: -5px;
  width: 10px; height: 10px;
  background: #101722;
  border-left: 1px solid #33404e; border-top: 1px solid #33404e;
  transform: translateX(-50%) rotate(45deg);
}
#u-tip.above { transform: translateY(-4px); }
#u-tip.above::before { top: auto; bottom: -5px; border: 0; border-right: 1px solid #33404e; border-bottom: 1px solid #33404e; }
#u-tip.show.above { transform: none; }
@media (pointer: coarse) { #u-tip { font-size: 13px; max-width: 220px; } }

/* ============ DRAG & DROP ============ */
#canvas.drag-over {
  outline: 3px dashed rgba(79,216,255,.65);
  outline-offset: -8px;
  background: rgba(79,216,255,.05) !important;
}
#drop-hint {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 7; pointer-events: none;
  background: rgba(13,18,24,.95);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-size: 14px; font-weight: 700;
  padding: 12px 22px; border-radius: 12px;
  box-shadow: 0 16px 46px rgba(0,0,0,.6);
}
.ghost-node {
  position: fixed; z-index: 600;
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, #212b37, #161d26);
  border: 1px solid var(--accent);
  color: #e6eef7; font-size: 13px; font-weight: 700;
  padding: 8px 14px; border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(255,167,38,.3);
  pointer-events: none;
  opacity: .92;
  transform: translate(10px, 10px);
}
.ghost-node .gh-ico { font-size: 16px; }

body, #toolbar, #canvas, .node, .port, .pal-item, .tb-btn, .mb-btn {
  -webkit-tap-highlight-color: transparent;
}
body { touch-action: manipulation; overscroll-behavior: none; }
#canvas, .node, .port { touch-action: none; }
#canvas { -webkit-user-select: none; user-select: none; }
.node { cursor: grab; will-change: transform; }
.node:active { cursor: grabbing; }
@keyframes node-pop {
  0% { transform: scale(.86); opacity: 0; }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}
.node.new-node { animation: node-pop .28s cubic-bezier(.2,.9,.3,1.2); }
@keyframes wire-in { from { opacity: 0; } to { opacity: 1; } }
#wire-svg g[data-wire] { animation: wire-in .18s ease; }

@media (pointer: coarse) {
  .port { width: 20px; height: 20px; border-width: 3px; }
  .port.out { right: -11px; }
  .port.in { left: -11px; }
  .port.bottom { margin-left: -10px; bottom: -10px; }
  .node { border-width: 2px; }
  .pal-item { padding: 12px 12px; }
  .pal-item .p-name { font-size: 14px; }
  .n-btn { width: 28px; height: 28px; font-size: 13px; }
  .tb-btn { min-height: 40px; }
}

/* ============================================================
   MOBILE LAYOUT (<= 767px) — canvas-first + drawers
   ============================================================ */
@media (max-width: 767px) {
  :root { --toolbarH: 54px; --barbarH: 64px; }

  /* fixed top toolbar, horizontally scrollable */
  body { padding-top: var(--toolbarH); padding-bottom: calc(var(--barbarH) + env(safe-area-inset-bottom)); }
  #toolbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--toolbarH);
    padding: 0 10px; gap: 6px;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #toolbar::-webkit-scrollbar { display: none; }
  .brand { min-width: 150px; flex: 0 0 auto; }
  .brand-name { font-size: 13px; }
  .brand-sub { display: none; }
  .tb-search { width: min(210px, 42vw); flex: 0 0 auto; }
  .tb-group { flex: 0 0 auto; }
  .tb-lbl { display: none; }
  .tb-zoom-label { min-width: 38px; }
  #btn-toggle-palette, #btn-toggle-props { display: none; }
  a#btn-github .tb-lbl { display: none; }

  /* workspace = pure canvas stage */
  #workspace, #workspace.no-preview, #workspace.no-props, #workspace.no-props.no-preview {
    display: block; height: 100%;
  }
  #canvas-wrap { position: absolute; inset: 0; }
  #canvas-hud {
    left: 10px; right: auto; bottom: calc(var(--barbarH) + env(safe-area-inset-bottom) - 8px);
    max-width: calc(100vw - 20px); overflow: hidden;
    flex-wrap: nowrap; gap: 8px;
  }
  #canvas-hud span:not(#hud-status) { display: none; }
  #hud-status { white-space: nowrap; }

  .ce-card { max-width: calc(100vw - 28px); padding: 20px 18px; border-radius: 14px; }
  .ce-card p { font-size: 12.5px; }
  .ce-actions { flex-direction: column; }
  .ce-actions .btn { width: 100%; }

  /* drawers (palette / properties / preview) — slide from bottom */
  #palette, #props, #preview {
    position: fixed; left: 0; right: 0; z-index: 70;
    display: flex; flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -18px 60px rgba(0,0,0,.55);
    transform: translateY(105%);
    transition: transform .3s cubic-bezier(.22,.9,.3,1);
    pointer-events: auto;
  }
  #palette, #props { bottom: 0; height: min(62vh, 560px); }
  #preview { bottom: 0; height: min(78vh, 700px); }
  body.mobile-palette-open #palette,
  body.mobile-props-open #props,
  body.mobile-preview-open #preview { transform: translateY(0); }

  #palette::before, #props::before, #preview::before {
    content: ""; position: absolute; top: 6px; left: 50%;
    width: 44px; height: 4px; margin-left: -22px;
    background: rgba(255,255,255,.35); border-radius: 3px;
  }
  .panel-head { padding-top: 14px; }
  #preview { z-index: 75; }
  #preview-body { overflow-y: auto; }
  .mc-form { max-height: none; }

  /* backdrop */
  #panel-backdrop {
    position: fixed; inset: 0; z-index: 65;
    background: rgba(4, 14, 34, .55);
    backdrop-filter: blur(2px);
  }

  /* bottom quick bar */
  #mobile-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    display: flex; align-items: stretch; justify-content: space-around;
    height: calc(var(--barbarH) + env(safe-area-inset-bottom));
    padding: 6px 4px env(safe-area-inset-bottom);
    background: linear-gradient(180deg, #0d2f63, #0a2450);
    border-top: 1px solid var(--line-strong);
    box-shadow: 0 -6px 22px rgba(0,0,0,.4);
  }
  .mb-btn {
    flex: 1; max-width: 96px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px;
    border: 0; background: transparent; color: var(--muted);
    border-radius: 12px; font-size: 10px; font-weight: 600;
    padding: 4px 2px; min-height: 48px;
  }
  .mb-btn:active { transform: scale(.94); }
  .mb-btn.is-active { color: var(--accent); background: rgba(255,167,38,.12); }
  .mb-ico { font-size: 19px; line-height: 1.15; }
  .mb-primary {
    color: #2c2200; font-weight: 800;
    background: linear-gradient(180deg, #ffb340, #f79a00);
    border-radius: 14px; box-shadow: 0 4px 14px rgba(255,167,38,.4);
    flex: 1.5; font-size: 11px;
  }

  /* inputs: 16px so iOS doesn't zoom the page */
  .field input[type=text], .field input[type=number], .field select,
  .field textarea, .palette-search input, .props-search input,
  .tb-search input { font-size: 16px; }
  .props-body { padding-bottom: 30px; }

  /* modals go full-screen on phones */
  .modal-card, .modal-wide {
    width: 100vw; max-height: 100dvh; height: 100dvh;
    border-radius: 0; border: 0;
  }
  .modal-body { padding: 14px 14px 30px; }
  .export-code { max-height: none; flex: 1; }
  .export-actions { flex-wrap: wrap; }
  .export-actions .btn-big { flex: 1 1 100%; }
  #btn-download { flex: 1 1 100%; }
  .modal-tabs { margin-left: auto; }
  .modal-tabs .tab { padding: 7px 11px; font-size: 12px; }
  .apiWrap { display: none; }
  .help-body { grid-template-columns: 1fr; }

  /* tour card hugs the screen */
  #tour-card { width: min(340px, calc(100vw - 24px)); }
  .tc-body { font-size: 13.5px; }

  /* toast above the bottom bar */
  .toast {
    right: 12px; left: 12px; bottom: calc(var(--barbarH) + 12px + env(safe-area-inset-bottom));
    text-align: center;
  }

  /* search results constrained */
  .search-hits { left: 8px; right: 8px; top: calc(var(--toolbarH) + 4px); }
}

@media (min-width: 768px) {
  #mobile-bar, #panel-backdrop:not([hidden]) { display: none; }
  #btn-toggle-palette, #btn-toggle-props { display: inline-flex; }
}

@media (min-width: 768px) and (max-width: 1100px) {
  #workspace { grid-template-columns: 210px 1fr 250px; }
}

/* ---------- advanced experience mode ---------- */
body.adv-mode #workspace { display: none; }
#advanced { display: flex; }
#advanced[hidden] { display: none; }

/* ---------- project storage chooser ---------- */
.storage-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.store-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  background: var(--panel, #101820); color: var(--text, #e8eef6);
  border: 1px solid var(--line-strong, #2b3b4d); border-radius: 12px;
  padding: 14px; cursor: pointer; text-align: left; font: inherit; width: 100%;
  transition: border-color .15s, transform .15s;
}
.store-opt:hover { border-color: var(--accent, #ffa726); transform: translateY(-2px); }
.store-opt:disabled { opacity: .6; cursor: wait; }
.store-ico { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; background: rgba(255,255,255,.08); border-radius: 9px; color: var(--accent, #ffa726); font-size: 17px; }
.store-name { font-weight: 700; font-size: 13.5px; }
.store-name small { color: var(--muted, #8fa1b3); font-weight: 500; }
.store-sub { color: var(--muted, #8fa1b3); font-size: 11.5px; }

/* device project badge on home cards */
.hc-badge { display: inline-block; background: rgba(255,167,38,.16); color: var(--accent, #ffa726); border-radius: 6px; padding: 1px 6px; font-size: 10px; font-weight: 600; }
@media (max-width: 520px) { .storage-choice { grid-template-columns: 1fr; } }

body.adv-mode #mobile-bar { display: none; }

/* ---------- workspace guide modal ---------- */
.guide-hero {
  background: linear-gradient(135deg, rgba(37,99,235,.14), rgba(14,152,184,.10));
  border: 1px solid rgba(59,130,246,.35); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 12px; font-size: 13px; line-height: 1.55;
}
.guide-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.guide-col h3 { margin: 12px 0 6px; font-size: 12.5px; color: var(--blue-300); }
.guide-col h3:first-child { margin-top: 0; }
.guide-col ol, .guide-col ul { margin: 0 0 6px; padding-left: 20px; font-size: 12.5px; line-height: 1.6; color: #cfe0f4; }
.guide-col li { margin-bottom: 5px; }
.guide-col b { color: #fff; }
.guide-actions { gap: 10px; flex-wrap: wrap; }
@media (max-width: 767px) {
  .guide-cols { grid-template-columns: 1fr; }
  .guide-actions .btn { flex: 1 1 100%; }
}

/* ---------- sticky notes on nodes ---------- */
.n-notes {
  font-size: 9px; font-weight: 800; color: #08131f;
  background: var(--yellow, #ffd34d); border-radius: 6px;
  padding: 1px 6px; margin-left: 4px; cursor: help;
}
.n-notes[hidden] { display: none; }
.note-line .n-more { font-style: normal; color: var(--muted); font-size: 10px; }
.notes-box { margin-top: 8px; }
.notes-box .prop-group-title { background: rgba(255,211,77,.08); border-color: rgba(255,211,77,.35); color: var(--yellow); }
.notes-list { display: flex; flex-direction: column; gap: 6px; }
.note-row { display: flex; gap: 6px; align-items: flex-start; }
.note-row textarea {
  flex: 1; min-width: 0; resize: vertical; background: #0e1724; color: #e8eef6;
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 8px;
  font: inherit; font-size: 12px; line-height: 1.45;
}
.note-row textarea:focus { border-color: var(--blue-400); outline: none; }
.note-del {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 7px;
  background: rgba(255,80,80,.1); color: var(--red); border: 1px solid rgba(255,80,80,.35);
  cursor: pointer; font-size: 12px; line-height: 1;
}
.note-del:hover { background: rgba(255,80,80,.25); }

/* ---------- home tabs (Home | Images) ---------- */
.home-tabs { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.home-tab {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 13.5px; color: var(--muted);
  background: rgba(255,255,255,.04); border: 1px solid var(--line-strong);
  border-radius: 20px; padding: 8px 18px; cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.home-tab .tb-ico { font-size: 15px; }
.home-tab:hover { color: #fff; border-color: var(--blue-400); }
.home-tab.is-active { background: var(--blue-500); border-color: var(--blue-400); color: #fff; }

/* ---------- home images pane ---------- */
.home-images-head { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.home-images-head h2 { margin: 0; }
.hi-note {
  background: rgba(14,152,184,.08); border: 1px solid rgba(14,152,184,.35);
  border-radius: 10px; padding: 10px 12px; margin: 12px 0;
  font-size: 12.5px; line-height: 1.55; color: #cfe0f4;
}
.hi-note code { background: #0e1724; padding: 1px 5px; border-radius: 5px; font-size: 11.5px; }
.home-images-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px; margin-top: 4px;
}
.hi-card {
  position: relative; background: #101820; border: 1px solid var(--line-strong);
  border-radius: 12px; overflow: hidden; text-align: center;
}
.hi-card img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; background: repeating-conic-gradient(#141d28 0 25%, #0d141d 0 50%) 50%/16px 16px; }
.hi-card .hi-name { display: block; font-size: 10.5px; color: var(--muted); padding: 6px 6px 8px; word-break: break-all; }
.hi-card .hi-del {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px;
  border-radius: 7px; background: rgba(0,0,0,.65); color: var(--red);
  border: 1px solid rgba(255,80,80,.4); cursor: pointer; font-size: 12px; line-height: 1;
}
.hi-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 110px; border: 2px dashed var(--line-strong); border-radius: 12px;
  background: rgba(255,255,255,.02); color: var(--muted); cursor: pointer; font: inherit;
}
.hi-add .tb-ico { font-size: 22px; color: var(--accent); }
.hi-add:hover { border-color: var(--accent); color: #fff; }
.hi-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 26px 10px; font-size: 13px; }

/* ---------- button image slot (properties) ---------- */
.bimg-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.bimg-opt {
  position: relative; width: 54px; height: 54px; padding: 0; border-radius: 9px;
  border: 2px solid var(--line-strong); cursor: pointer; overflow: hidden; background: #0e1724;
}
.bimg-opt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bimg-opt.is-on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,167,38,.25); }
.bimg-opt.is-on::after {
  content: "✓"; position: absolute; right: 2px; top: 2px; width: 15px; height: 15px;
  background: var(--accent); color: #08131f; border-radius: 50%; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.bimg-remove { margin-top: 8px; }
.bimg-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
