/* ============================================================
   MMM LEVEL EDITOR — HIGH CONTRAST MONO THEME
   Black/White/Yellow — Zero compromise
   ============================================================ */

:root {
  color-scheme: dark;

  /* Core palette: 4 values. That's it. */
  --bg:       #000000;
  --surface:  #0d0d0d;
  --line:     #2a2a2a;
  --text:     #ffffff;

  /* Single accent — the only color that matters */
  --accent:   #ffe600;

  /* Muted / dimmed text */
  --muted:    #666666;
  --muted-hi: #999999;

  /* Semantic — still mono-inspired */
  --blue:     #5599ff;     /* kept for SVG/canvas compatibility */
  --cyan:     #00c8ff;
  --yellow:   #ffe600;
  --red:      #ff3333;
  --green:    #33ff88;
  --orange:   #ff9f1c;
  --stage-black: #000000;

  /* Typography */
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "Consolas", monospace;

  /* Geometry tokens */
  --radius: 0px;        /* zero. everything is a box. */
  --border: 1px solid var(--line);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

/* ── Scrollbars ───────────────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: var(--bg); }
::-webkit-scrollbar-thumb  { background: var(--accent); }
::-webkit-scrollbar-corner { background: var(--bg); }

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

/* ── App Shell ────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(420px, 1fr) 330px;
  grid-template-rows: auto 1fr;
  width: 100vw;
  height: 100vh;
}

.app-shell.right-hidden {
  grid-template-columns: 360px minmax(420px, 1fr) 0;
}

/* ── Topbar — 3 zonas fixas, altura compacta ──────────────── */
/*
   [brand]  |  [stage-tools]  |  [file-actions]
   Botões de gestão de fase (Nova/Duplicar) foram para
   o painel esquerdo, perto das abas de fase onde fazem sentido.
   Inspetor virou toggle no stage-toolbar.
   Exportar JSON/Tudo colapsados em .cmd-dropdown.
*/
.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid #ffffff;
  background: var(--bg);
  min-height: 44px;
}

/* Zona 1: brand */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 14px;
  border-right: 1px solid var(--line);
  height: 100%;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 24px;
  border: 2px solid var(--accent);
  color: var(--bg);
  background: var(--accent);
  font: 900 10px/1 var(--mono);
  letter-spacing: -0.02em;
  flex: 0 0 auto;
}

.brand h1 {
  margin: 0;
  font-size: 12px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font: 9px/1 var(--mono);
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

/* Zona 2: stage-tools (centro, alinhado à esquerda) */
.top-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0 12px;
  height: 100%;
  min-width: 0;
}

/* Separador visual entre grupos de ações */
.top-actions .cmd-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex: 0 0 auto;
  margin: 0 4px;
}

/* Zona 3: file-actions (direita) */
.quick-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0 14px 0 12px;
  border-left: 1px solid var(--line);
  height: 100%;
}

/* ── Dropdown de exportação ───────────────────────────────── */
/*
   .cmd-dropdown: wrapper position:relative
   .cmd-dropdown > button.cmd: o botão visível
   .cmd-dropdown-menu: lista que aparece ao :focus-within
   Use tabindex="-1" nos itens do menu para manter focus
*/
.cmd-dropdown {
  position: relative;
}

.cmd-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  z-index: 20;
  min-width: 180px;
  border: 1px solid #ffffff;
  background: #050505;
  box-shadow: 0 10px 36px rgba(0,0,0,.8);
  padding: 4px;
}

.cmd-dropdown:focus-within .cmd-dropdown-menu,
.cmd-dropdown.open .cmd-dropdown-menu {
  display: block;
}

.cmd-dropdown-menu button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 16px;
  width: 100%;
  min-height: 30px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
  font: 11px/1 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 60ms;
  cursor: pointer;
}

.cmd-dropdown-menu button:hover {
  background: rgba(255,255,255,.08);
  color: var(--accent);
}

.cmd-dropdown-menu button span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.02em;
  text-transform: none;
}

.cmd-dropdown-menu .menu-sep {
  height: 1px;
  background: var(--line);
  margin: 3px 0;
}

/* Seta indicadora no botão do dropdown */
.cmd.has-arrow::after {
  content: "▾";
  margin-left: 6px;
  font-size: 10px;
  opacity: .7;
}

/* ── Botões de fase no painel esquerdo ────────────────────── */
/*
   .fase-actions: faixa de botões no topo do painel de fases.
   Fica dentro da section .tabs-section, antes do .tab-list.
   Substitui os botões "Nova Fase" e "Duplicar Fase" da topbar.
*/
.fase-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
}

/* ── Section headers ──────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.section-head h2 {
  margin: 0;
}

.section-actions {
  display: flex;
  gap: 4px;
}

/* ── Mini buttons ─────────────────────────────────────────── */
.mini-btn {
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 7px;
  font: 10px/1 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 80ms, border-color 80ms;
}

.mini-btn:hover {
  color: var(--text);
  border-color: var(--text);
}

.mini-btn.danger {
  color: var(--red);
  border-color: rgba(255, 51, 51, .4);
}

.mini-btn.danger:hover {
  border-color: var(--red);
}

/* ── Primary interactive controls ────────────────────────── */
.cmd,
.icon-btn,
.tool,
.tab-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  transition: border-color 80ms, background 80ms, transform 80ms;
}

.cmd {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cmd.compact {
  min-height: 28px;
  padding: 0 8px;
  font-size: 11px;
}

.cmd.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 900;
}

.cmd.primary:hover {
  background: #fff;
  border-color: #fff;
  color: var(--bg);
}

.cmd:disabled {
  opacity: .3;
  cursor: not-allowed;
}

.cmd:hover,
.icon-btn:hover,
.tool:hover,
.tab-item:hover {
  border-color: var(--muted-hi);
  background: rgba(255,255,255,.04);
}

.cmd:active,
.icon-btn:active,
.tool:active,
.tab-item:active {
  transform: translateY(1px);
}

/* ── Side panels ──────────────────────────────────────────── */
.left-panel,
.right-panel {
  min-width: 0;
  overflow: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--line);
  background: var(--bg);
  padding: 12px;
}

.right-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.right-hidden .right-panel {
  display: none;
}

/* ── Sections — the terminal-block signature ─────────────── */
.left-panel section,
.right-panel section {
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 10px 10px 12px;
  transition: border-left-color 120ms;
}

.left-panel section:focus-within,
.right-panel section:focus-within {
  border-left-color: var(--accent);
}

.left-panel section + section,
.right-panel section + section {
  margin-top: 8px;
}

section + section {
  margin-top: 8px;
}

section,
.tab-list,
.tool-grid,
.stats,
.warnings,
.inspector,
.layer-list {
  min-width: 0;
}

/* ── Headings ─────────────────────────────────────────────── */
h2 {
  margin: 0 0 8px;
  color: var(--muted-hi);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-family: var(--mono);
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tab-list,
.layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tab-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  text-align: left;
  font-size: 12px;
}

.tab-item.active {
  border-color: var(--accent);
  background: rgba(255, 230, 0, .07);
  box-shadow: inset 3px 0 0 var(--accent);
}

.tab-item small {
  flex: 0 0 auto;
  color: var(--muted);
  font: 10px/1 var(--mono);
}

.tab-item span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs-collapsed .tabs-section .tab-list {
  display: none;
}

.tabs-collapsed .tabs-section {
  margin-bottom: 0;
  border-left-color: var(--accent);
}

/* ── Tool grid ────────────────────────────────────────────── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tool-group-title {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  color: var(--muted);
  font: 700 9px/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.tool {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 7px 8px;
  text-align: left;
  font-size: 11px;
  min-width: 0;
  overflow: hidden;
}

.tool::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: transparent;
  transition: background 80ms;
}

.tool span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool.active {
  border-color: var(--accent);
  background: rgba(255, 230, 0, .06);
}

.tool.active::before {
  background: var(--accent);
}

.tool-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
}

/* ── Tool icons (unchanged — SVG/CSS drawing system) ──────── */
.cursor-icon::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 2px;
  width: 0;
  height: 0;
  border-left: 10px solid #fff;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transform: rotate(35deg);
}

.pan-icon {
  border: 1px solid #fff;
}

.pan-icon::before,
.pan-icon::after {
  content: "";
  position: absolute;
  background: #fff;
}

.pan-icon::before {
  left: 9px;
  top: 2px;
  width: 2px;
  height: 16px;
}

.pan-icon::after {
  left: 2px;
  top: 9px;
  width: 16px;
  height: 2px;
}

.platform-icon {
  border: 1px solid #fff;
  background: #000;
}

.moving-icon {
  border: 1px solid #41a2ff;
  background: #000;
}

.moving-icon::before,
.moving-icon::after {
  content: "";
  position: absolute;
  top: 9px;
  width: 5px;
  height: 5px;
  border-top: 1px solid #41a2ff;
  border-right: 1px solid #41a2ff;
}

.moving-icon::before {
  left: -2px;
  transform: rotate(-135deg);
}

.moving-icon::after {
  right: -2px;
  transform: rotate(45deg);
}

.ghost-icon {
  border: 1px dashed #41a2ff;
  background:
    linear-gradient(90deg, transparent 0 44%, rgba(65,162,255,.5) 45% 55%, transparent 56%),
    #000;
}

.ghost-icon::before,
.ghost-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 4px;
  height: 12px;
  border: 1px solid #41a2ff;
  opacity: .65;
}

.ghost-icon::before { left: -3px; }
.ghost-icon::after  { right: -3px; }

.p1-icon,
.p2-icon,
.toggle-icon,
.ice-icon,
.door-icon {
  border: 1px solid #fff;
  background: #000;
}

.p1-icon {
  border-color: #41a2ff;
  background:
    repeating-linear-gradient(90deg, rgba(65,162,255,.9) 0 2px, transparent 2px 5px),
    #000;
}

.p2-icon {
  border-color: #ffdf40;
  background:
    repeating-linear-gradient(90deg, rgba(255,223,64,.9) 0 2px, transparent 2px 5px),
    #000;
}

.toggle-icon {
  border-color: #a47cff;
  border-style: dashed;
}

.toggle-icon::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #a47cff;
}

.ice-icon {
  border-color: #83d5ff;
  background: #07141a;
}

.death-icon {
  border: 1px solid #ff3030;
  background: repeating-linear-gradient(45deg, rgba(192, 0, 0, .2), rgba(192, 0, 0, .2) 4px, transparent 4px, transparent 8px);
}

.coin-icon {
  border: 2px solid var(--yellow);
  border-radius: 50%;
  background: #000;
}

.portal-icon {
  border: 2px solid var(--cyan);
  transform: rotate(45deg) scale(.75);
}

.teleport-icon {
  border: 2px solid #a47cff;
  transform: rotate(45deg) scale(.75);
}

.teleport-icon::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid #a47cff;
}

.spring-icon {
  border-bottom: 3px solid var(--yellow);
}

.spring-icon::before {
  content: "";
  position: absolute;
  inset: 4px 2px 6px;
  background: linear-gradient(135deg, transparent 0 35%, var(--yellow) 36% 42%, transparent 43% 58%, var(--yellow) 59% 65%, transparent 66%);
}

.spring-h-icon {
  border-left: 3px solid var(--yellow);
}

.spring-h-icon::before {
  content: "";
  position: absolute;
  inset: 2px 5px 2px 4px;
  background: linear-gradient(45deg, transparent 0 35%, var(--yellow) 36% 42%, transparent 43% 58%, var(--yellow) 59% 65%, transparent 66%);
}

.spawn-icon {
  border: 2px solid var(--green);
  border-radius: 50%;
}

.spawn-p2-icon {
  border: 2px solid #41a2ff;
  border-radius: 50%;
}

.spawn-p2-icon::after {
  content: "2";
  position: absolute;
  right: -4px;
  top: -6px;
  color: #41a2ff;
  font: 700 10px/1 monospace;
}

.water-icon {
  border: 1px solid #5bbcff;
  background: rgba(41, 123, 255, .45);
}

.jump-icon,
.speed-icon,
.big-icon,
.mini-icon,
.door-btn-icon {
  border: 1px solid #fff;
  background: #000;
}

.jump-icon::before,
.speed-icon::before,
.big-icon::before,
.mini-icon::before,
.door-btn-icon::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 700 10px/1 var(--mono);
}

.jump-icon {
  border-color: var(--yellow);
}

.jump-icon::before {
  content: "P";
  color: var(--yellow);
}

.speed-icon {
  border-color: var(--blue);
}

.speed-icon::before {
  content: "V";
  color: var(--blue);
}

.gravity-icon,
.gravity-all-icon {
  background: #000;
}

.gravity-icon::before,
.gravity-all-icon::before {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 9px;
  height: 1px;
  background: #fff;
}

.gravity-icon::after,
.gravity-all-icon::after {
  content: "";
  position: absolute;
  inset: 2px 5px;
  background:
    linear-gradient(#fff, #fff) 50% 0 / 1px 16px no-repeat,
    linear-gradient(135deg, transparent 0 42%, #fff 43% 57%, transparent 58%) 50% 0 / 9px 9px no-repeat,
    linear-gradient(315deg, transparent 0 42%, #fff 43% 57%, transparent 58%) 50% 100% / 9px 9px no-repeat;
}

.gravity-all-icon {
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.35),
    0 0 0 1px rgba(255,255,255,.2);
}

.gravity-all-icon::after {
  opacity: .85;
}

.big-icon {
  border-color: var(--orange);
}

.big-icon::before {
  content: "+";
  color: var(--orange);
}

.mini-icon {
  border-color: #8eff8e;
}

.mini-icon::before {
  content: "-";
  color: #8eff8e;
}

.door-btn-icon {
  border-color: #ff65d8;
  border-radius: 50%;
}

.door-btn-inv-icon {
  border: 1px dashed #ff65d8;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(255,101,216,.35) 0 30%, #000 31%);
}

.door-icon {
  border-color: #ff65d8;
  background:
    linear-gradient(90deg, transparent 0 38%, rgba(255,101,216,.8) 39% 61%, transparent 62%),
    #000;
}

.door-inv-icon {
  border: 1px dashed #ff65d8;
  background:
    linear-gradient(90deg, rgba(255,101,216,.28) 0 100%),
    #000;
}

/* ── Switch & range rows ──────────────────────────────────── */
.switch-row,
.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  color: var(--muted-hi);
  font-size: 12px;
}

.range-row {
  grid-template-columns: 54px minmax(0, 1fr) 28px;
}

.range-row b {
  color: var(--text);
  font: 12px/1 var(--mono);
  text-align: right;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

/* ── Stats ────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.stat {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
}

.stat span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat b {
  flex: 0 0 auto;
  color: var(--text);
  font-family: var(--mono);
}

.stat.special {
  border-color: #a47cff;
  color: #d7c8ff;
}

/* ── Warnings ─────────────────────────────────────────────── */
.warnings {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 8px;
}

.warning {
  border: 1px solid rgba(255, 159, 28, .5);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius);
  color: #ffd9a0;
  background: rgba(255, 159, 28, .06);
  padding: 7px 8px;
  font-size: 11px;
}

/* ── Stage column ─────────────────────────────────────────── */
.stage-column {
  min-width: 0;
  display: grid;
  grid-template-rows: 40px 1fr;
  background: #000;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: #000;
  padding: 0 12px;
}

.view-readout {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font: 11px/1 var(--mono);
}

.icon-btn {
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.icon-btn.danger {
  border-color: rgba(255, 48, 48, .45);
  color: var(--red);
}

.icon-btn.danger:hover {
  border-color: var(--red);
  background: rgba(255, 51, 51, .08);
}

/* ── Stage canvas area ────────────────────────────────────── */
.stage-wrap {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 18px;
  /* dot grid — tighter, dimmer */
  background:
    radial-gradient(circle, rgba(255,255,255,.08) 1px, transparent 1px),
    #000;
  background-size: 22px 22px;
}

.stage {
  display: block;
  width: min(100%, calc((100vh - 120px) * 1.777777));
  max-height: calc(100vh - 120px);
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 0;
  background: var(--stage-black);
  box-shadow:
    0 0 0 1px rgba(255,230,0,.12),
    0 20px 60px rgba(0,0,0,.8);
  touch-action: none;
  user-select: none;
}

.stage.panning {
  cursor: grab;
}

.slide-bg {
  fill: #000;
}

/* ── Objects ──────────────────────────────────────────────── */
.object {
  cursor: pointer;
}

.object.locked {
  cursor: not-allowed;
}

.object.hidden-initial .shape-main {
  opacity: .45;
  stroke-dasharray: 6 4;
}

.object.hidden-initial.selected .shape-main {
  opacity: .9;
}

.object.selected .shape-main,
.object.selected .shape-line {
  filter: drop-shadow(0 0 4px rgba(255, 230, 0, .8));
}

.shape-label {
  pointer-events: none;
  font: 9px/1 var(--mono);
  fill: rgba(255,255,255,.8);
}

/* ── Canvas overlay lines ─────────────────────────────────── */
.door-link {
  fill: none;
  stroke: #ff65d8;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 7 5;
  pointer-events: none;
}

.door-link.missing {
  stroke: #ff3030;
  stroke-dasharray: 2 5;
}

.teleport-link {
  fill: none;
  stroke: #a47cff;
  stroke-width: 1.35;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 4 4;
  pointer-events: none;
}

.teleport-link.missing {
  stroke: #ff3030;
  stroke-dasharray: 2 5;
}

.door-warning {
  pointer-events: none;
  font: 800 15px/1 var(--mono);
  fill: #ff4f4f;
  filter: drop-shadow(0 0 3px rgba(255,0,0,.6));
}

.move-path {
  stroke: #41a2ff;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 8 5;
  pointer-events: none;
}

.path-handle {
  fill: #000;
  stroke: var(--accent);
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
  cursor: ew-resize;
}

.path-handle.move-path-all {
  fill: var(--accent);
  stroke: #fff;
  cursor: grab;
}

.overlay-rect {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 6 4;
}

.selection-member-rect {
  fill: none;
  stroke: rgba(255, 230, 0, .4);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 4 4;
  pointer-events: none;
}

.selection-bounds {
  fill: rgba(255, 230, 0, .05);
  stroke: var(--accent);
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 8 5;
  pointer-events: none;
}

.marquee-rect {
  fill: rgba(255, 230, 0, .08);
  stroke: var(--accent);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 5 4;
  pointer-events: none;
}

.handle {
  fill: var(--accent);
  stroke: #000;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  cursor: nwse-resize;
}

.handle.ne,
.handle.sw {
  cursor: nesw-resize;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  font-size: 12px;
  font-family: var(--mono);
}

/* ── Inspector ────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.inspector label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted-hi);
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.inspector label.compact-hidden {
  display: none;
}

.inspector input,
.inspector select {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  padding: 0 8px;
  font-size: 12px;
  font-family: var(--mono);
  transition: border-color 80ms;
}

.inspector input:focus,
.inspector select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.prop-grid,
.moving-fields,
.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.moving-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.moving-fields,
.toggle-fields {
  border: 1px solid rgba(65, 162, 255, .2);
  border-left: 2px solid rgba(65, 162, 255, .6);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 8px;
}

.toggle-fields {
  border-color: rgba(164, 124, 255, .2);
  border-left-color: rgba(164, 124, 255, .6);
}

.inspector .move-toggle,
.toggle-fields .switch-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 28px;
}

.toggle-fields {
  display: grid;
  gap: 8px;
}

.moving-fields input:disabled,
.moving-fields select:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.color-grid input {
  padding: 0 4px;
}

/* ── Computed note ────────────────────────────────────────── */
.computed-note {
  min-height: 0;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 7px 8px;
  font: 10px/1.4 var(--mono);
}

.computed-note:empty {
  display: none;
}

/* ── Quick edit ───────────────────────────────────────────── */
.quick-edit {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 8px;
}

/* ── Layer items ──────────────────────────────────────────── */
.layer-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 0 8px;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 80ms, background 80ms;
}

.layer-item:hover {
  border-color: var(--muted-hi);
  background: rgba(255,255,255,.03);
}

.layer-item.active {
  border-color: var(--accent);
  background: rgba(255, 230, 0, .05);
  box-shadow: inset 2px 0 0 var(--accent);
}

.layer-dot {
  width: 8px;
  height: 8px;
  border: 1px solid #fff;
  border-radius: 0;
}

.layer-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-type {
  min-width: 0;
  color: var(--muted);
  font: 9px/1 var(--mono);
  white-space: nowrap;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.layer-flag {
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 0;
  color: var(--accent);
  background: rgba(255, 230, 0, .08);
  padding: 2px 5px;
  font: 8px/1 var(--mono);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ── Context menu ─────────────────────────────────────────── */
.context-menu {
  position: fixed;
  z-index: 30;
  min-width: 220px;
  border: 1px solid #ffffff;
  border-radius: var(--radius);
  background: #050505;
  box-shadow: 0 12px 40px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,.05);
  padding: 4px;
  overflow: hidden;
}

.context-menu button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 20px;
  width: 100%;
  min-height: 28px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0 9px;
  text-align: left;
  font-size: 12px;
  font-family: var(--mono);
  transition: background 60ms;
}

.context-menu button:hover {
  background: rgba(255,255,255,.08);
}

.context-menu button:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.context-menu button:disabled:hover {
  background: transparent;
}

.context-menu button span {
  justify-self: end;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.04em;
}

.context-menu button.danger {
  color: var(--red);
}

.context-menu button.danger:hover {
  background: rgba(255, 51, 51, .1);
}

/* ── Export panel ─────────────────────────────────────────── */
.export-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(260px, 42vh) auto;
  width: min(680px, calc(100vw - 40px));
  border: 1px solid #ffffff;
  border-radius: var(--radius);
  background: #030303;
  box-shadow: 0 20px 80px rgba(0,0,0,.9), 0 0 0 1px rgba(255,255,255,.08);
}

.export-head,
.export-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
}

.export-head {
  border-bottom: 1px solid var(--line);
}

.export-head strong {
  font: 700 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent);
}

.export-panel textarea {
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: 0;
  background: #000000;
  color: #e8e8e8;
  padding: 12px;
  font: 11px/1.5 var(--mono);
}

.export-actions {
  justify-content: flex-end;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 50;
  transform: translateX(-50%);
  border: 1px solid var(--accent);
  border-radius: 0;
  background: var(--bg);
  color: var(--accent);
  padding: 8px 16px;
  font: 700 11px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 8px 32px rgba(0,0,0,.7), 0 0 0 1px rgba(255,230,0,.15);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 300px minmax(340px, 1fr) 280px;
  }

  .app-shell.right-hidden {
    grid-template-columns: 300px minmax(340px, 1fr) 0;
  }

  /* Esconde texto da brand, mantém o mark */
  .brand p {
    display: none;
  }

  .cmd {
    padding: 0 9px;
    font-size: 11px;
  }
}

@media (max-width: 860px) {
  body {
    overflow: auto;
    overflow-x: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    min-height: auto;
    padding-bottom: 8px;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 8px 14px;
  }

  .top-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 6px 10px;
    flex-wrap: wrap;
    border: 0;
  }

  .quick-actions {
    grid-column: 2;
    grid-row: 1;
    border-left: 1px solid var(--line);
    padding: 0 10px;
  }

  .topbar,
  .left-panel,
  .right-panel,
  .stage-column {
    grid-column: 1;
  }

  .stage-column { order: 2; }
  .left-panel   { order: 3; }
  .right-panel  { order: 4; }

  .left-panel,
  .right-panel {
    max-height: none;
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage-wrap {
    min-height: 56vw;
    padding: 10px;
  }

  .export-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    grid-template-rows: auto minmax(220px, 48vh) auto;
  }

  /* Dropdown abre pra cima em mobile */
  .cmd-dropdown-menu {
    top: auto;
    bottom: calc(100% + 2px);
    right: 0;
  }
}
