/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #1a1b1e;
  --bg2:       #25262b;
  --bg3:       #2c2e33;
  --border:    #3a3c42;
  --accent:    #4c9eff;
  --accent2:   #3d7fd6;
  --danger:    #e05252;
  --text:      #d4d8e2;
  --text-dim:  #6c7280;
  --success:   #52c47a;
  --warn:      #f0a030;

  --panel-w:   220px;
  --menubar-h: 30px;
  --toolbar-h: 38px;
  --status-h:  26px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
}

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== MENU BAR ===== */
#menubar {
  height: var(--menubar-h);
  background: #111315;
  border-bottom: 1px solid #222;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 2px;
  flex-shrink: 0;
  user-select: none;
  z-index: 200;
  position: relative;
}

.menubar-brand {
  font-weight: 800;
  font-size: 12px;
  color: var(--accent);
  padding: 0 8px 0 2px;
  letter-spacing: 0.5px;
}
.menubar-spacer { flex: 1; }
#menubar .tb-btn-primary {
  font-size: 12px !important;
  padding: 3px 12px !important;
  height: 22px !important;
}

/* Menu items */
.menu-item {
  position: relative;
}
.menu-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 9px;
  cursor: pointer;
  border-radius: 3px;
  height: var(--menubar-h);
  transition: background 0.1s, color 0.1s;
}
.menu-btn:hover,
.menu-item.open .menu-btn {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

/* Dropdown */
.menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  background: #1e1f24;
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  padding: 4px 0;
  z-index: 999;
}
.menu-item:hover .menu-dropdown,
.menu-item.open .menu-dropdown { display: block; }

.menu-drop-item {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 12px;
  padding: 5px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  text-align: left;
  transition: background 0.1s;
}
.menu-drop-item:hover { background: var(--accent2); color: #fff; }
.menu-drop-item kbd {
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.07);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid #444;
  white-space: nowrap;
  font-family: inherit;
}
.menu-drop-item:hover kbd { color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.1); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== TOOLBAR ===== */
#toolbar {
  height: var(--toolbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  flex-shrink: 0;
  user-select: none;
}

.toolbar-brand {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.brand-icon { font-size: 16px; }

.toolbar-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.toolbar-spacer { flex: 1; }
.toolbar-group { display: flex; align-items: center; gap: 3px; }

.tb-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background 0.1s, border-color 0.1s;
}
.tb-btn:hover { background: #3a3c44; border-color: #555; }
.tb-btn:active { background: #2a2c34; }
.tb-btn.active { background: var(--accent2); border-color: var(--accent); color: #fff; }
.tb-btn-primary { background: var(--accent2) !important; border-color: var(--accent) !important; color: #fff !important; font-weight: 600; }
.tb-btn-primary:hover { background: var(--accent) !important; }

.tools-group .tool-btn { padding: 3px 8px; font-size: 15px; }

#zoom-label { font-size: 12px; color: var(--text-dim); min-width: 38px; text-align: center; }

.tb-toggle { display: flex; align-items: center; gap: 5px; cursor: pointer; color: var(--text-dim); }
.tb-toggle input { cursor: pointer; accent-color: var(--accent); }

/* ===== MAIN LAYOUT ===== */
#main-layout {
  display: flex;
  height: calc(100vh - var(--menubar-h) - var(--toolbar-h));
  overflow: hidden;
}

/* ===== PANELS ===== */
#left-panel, #right-panel {
  width: var(--panel-w);
  min-width: var(--panel-w);
  background: var(--bg2);
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
#right-panel { border-right: none; border-left: 1px solid var(--border); }

.panel-section { border-bottom: 1px solid var(--border); }

.panel-header {
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header.collapsible { cursor: pointer; user-select: none; }
.panel-header.collapsible:hover { background: #303238; }
.collapse-arrow { font-size: 10px; transition: transform 0.2s; }
.collapse-arrow.closed { transform: rotate(-90deg); }

.hdr-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 18px; height: 18px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.hdr-btn:hover { background: var(--accent2); border-color: var(--accent); }

.panel-body { padding: 8px 10px; }

/* ===== LEVELS LIST ===== */
#levels-list { padding: 4px; }

.level-item {
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.level-item:hover { background: var(--bg3); color: var(--text); }
.level-item.active { background: var(--accent2); color: #fff; }
.level-item .level-num { font-size: 10px; background: rgba(0,0,0,0.2); padding: 1px 4px; border-radius: 3px; }
.level-item .level-del { margin-left: auto; opacity: 0; font-size: 11px; cursor: pointer; }
.level-item:hover .level-del { opacity: 0.6; }
.level-item .level-del:hover { opacity: 1; color: var(--danger); }

/* ===== LAYERS ===== */
#layers-list { padding: 4px; }
.layer-item {
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 6px;
}
.layer-item:hover { background: var(--bg3); color: var(--text); }
.layer-item.active { background: var(--accent2); color: #fff; }
.layer-item::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--border); }
.layer-item[data-layer="0"]::before { background: #4a6e4a; }
.layer-item[data-layer="1"]::before { background: #6e4a4a; }
.layer-item[data-layer="2"]::before { background: #4a4a6e; }

/* ===== PALETTE ===== */
.palette-section { flex: 1; display: flex; flex-direction: column; }
.palette-tabs { display: flex; border-bottom: 1px solid var(--border); }
.pal-tab {
  flex: 1;
  padding: 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: color 0.15s, border-color 0.15s;
}
.pal-tab:hover { color: var(--text); }
.pal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.palette-content { padding: 6px; overflow-y: auto; flex: 1; }
.hidden { display: none !important; }

#tile-palette, #custom-tile-palette, #entity-palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.pal-item {
  aspect-ratio: 1;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.1s, transform 0.1s;
  background: var(--bg3);
}
.pal-item:hover { border-color: #666; transform: scale(1.05); }
.pal-item.active { border-color: var(--accent) !important; }
.pal-item .pal-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  font-size: 8px;
  text-align: center;
  background: rgba(0,0,0,0.6);
  padding: 1px;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pal-item.checkerboard { background: repeating-conic-gradient(#333 0% 25%, #444 0% 50%) 0 0 / 8px 8px; }
.pal-item.pal-entity { background: var(--bg3); font-size: 20px; }

.pal-divider { font-size: 10px; color: var(--text-dim); margin: 6px 0 3px; text-transform: uppercase; letter-spacing: 0.5px; }

.full-btn {
  width: 100%;
  padding: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin-bottom: 4px;
  transition: background 0.1s;
}
.full-btn:hover { background: #3a3c44; }

/* ===== CANVAS AREA ===== */
#canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #111;
  position: relative;
}

#canvas-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: crosshair;
}

#editor-canvas {
  position: absolute;
  top: 0; left: 0;
  image-rendering: pixelated;
}

#canvas-statusbar {
  height: var(--status-h);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 20px;
  font-size: 11px;
  color: var(--text-dim);
}
#canvas-hint { margin-left: auto; }

/* ===== RIGHT PANEL PROPS ===== */
.prop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.prop-row input[type="text"],
.prop-row input[type="number"],
.prop-row select {
  flex: 1;
  max-width: 110px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.prop-row input[type="color"] {
  flex: 1;
  max-width: 80px;
  height: 26px;
  padding: 1px 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.prop-row input:focus, .prop-row select:focus {
  outline: none;
  border-color: var(--accent);
}

.prop-row-range { margin-bottom: 8px; font-size: 12px; }
.prop-row-range label { display: flex; justify-content: space-between; margin-bottom: 3px; color: var(--text-dim); }
.prop-row-range span { color: var(--accent); font-weight: 600; }
.prop-row-range input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.prop-row-checkboxes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.prop-row-checkboxes label {
  display: flex; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; color: var(--text-dim);
}
.prop-row-checkboxes input { accent-color: var(--accent); cursor: pointer; }

.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 12px; }
.info-grid > *:nth-child(odd) { color: var(--text-dim); }
.info-grid > *:nth-child(even) { color: var(--text); font-weight: 500; }

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
}

.modal-window {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  max-height: 92vh;
  overflow: hidden;
}

.modal-header {
  padding: 10px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  flex-shrink: 0;
}

.modal-hdr-btns { display: flex; align-items: center; gap: 6px; }
.modal-hdr-btns button {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.modal-hdr-btns button:hover { background: var(--bg3); }
#btn-close-play { color: var(--danger); }
#play-level-name { font-size: 12px; color: var(--text-dim); min-width: 60px; text-align: center; }

#game-canvas-wrap {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#game-canvas { image-rendering: pixelated; display: block; }

.modal-footer {
  padding: 8px 14px;
  background: var(--bg3);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}
#game-status { color: var(--accent); font-weight: 600; }

.modal-sm { width: 320px; }
.modal-body { padding: 12px 14px; overflow-y: auto; }
.modal-body .prop-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.modal-body .prop-row input,
.modal-body .prop-row select {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.modal-body .prop-row input:focus, .modal-body .prop-row select:focus { outline: none; border-color: var(--accent); }
.modal-footer .full-btn { margin-bottom: 4px; }
.btn-danger { background: var(--danger) !important; border-color: #c03030 !important; color: #fff !important; }
.btn-danger:hover { background: #c03030 !important; }

#ct-image-preview { margin-top: 6px; text-align: center; }
#ct-image-preview img { max-width: 80px; max-height: 80px; border-radius: 4px; border: 1px solid var(--border); }

/* ===== ENTITY PROPS ===== */
#entity-props-body .prop-row { margin-bottom: 8px; }

/* ===== SELECTION HIGHLIGHT ===== */
#sec-selection { border: 1px solid var(--accent); }

/* ===== RESPONSIVE HELP TEXT ===== */
.help-text { font-size: 11px; color: var(--text-dim); line-height: 1.5; padding: 6px 0; }

/* ===== KBD BASE ===== */
kbd {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', monospace;
  font-size: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid #555;
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ===== SHORTCUTS MODAL ===== */
.modal-md { width: 580px; }

.shortcuts-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
  padding: 16px 18px;
  font-size: 12px;
}

.shortcuts-col { display: flex; flex-direction: column; }

.sc-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  margin-bottom: 6px;
}

.sc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.sc-row kbd { min-width: 50px; text-align: center; flex-shrink: 0; }
.sc-row span { color: var(--text); }

/* ===================================================================
   WINDOW SYSTEM
   =================================================================== */

#wm-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 800;
}

/* ── Window  (FL Studio style) ───────────────────────────────────── */
.wm-window {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: #161618;
  border: 1px solid #3a3c42;
  border-radius: 3px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.85), 0 2px 6px rgba(0,0,0,0.6),
              inset 0 1px 0 rgba(255,255,255,0.04);
  min-width: 280px;
  min-height: 120px;
  pointer-events: all;
  overflow: hidden;
  opacity: 0.92;
  transition: opacity 0.1s, transform 0.1s;
  transform-origin: center top;
}
.wm-window.wm-closing {
  opacity: 0;
  transform: scale(0.98);
  pointer-events: none;
}
.wm-window:not(.wm-focused) { opacity: 0.82; filter: brightness(0.9); }
.wm-window.wm-focused {
  opacity: 1;
  filter: none;
  border-color: #555860;
  box-shadow: 0 14px 50px rgba(0,0,0,0.9), 0 0 0 1px rgba(100,120,180,0.15),
              inset 0 1px 0 rgba(255,255,255,0.05);
}

/* ── Title bar  (thin, FL Studio style) ──────────────────────────── */
.wm-titlebar {
  height: 22px;
  background: linear-gradient(180deg, #2e3038 0%, #252730 55%, #1e2028 100%);
  border-bottom: 1px solid #111216;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3px 0 7px;
  cursor: default;
  flex-shrink: 0;
  user-select: none;
}
.wm-window.wm-focused .wm-titlebar {
  background: linear-gradient(180deg, #33363f 0%, #2a2d36 55%, #22252e 100%);
}
/* subtle grip dots on left */
.wm-titlebar::before {
  content: '⋮⋮';
  font-size: 9px;
  letter-spacing: -3px;
  color: rgba(255,255,255,0.15);
  margin-right: 5px;
  flex-shrink: 0;
  line-height: 1;
}

.wm-titlebar-left {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.wm-icon { font-size: 11px; flex-shrink: 0; line-height: 1; }

.wm-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7a7e8a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wm-window.wm-focused .wm-title { color: #b8bccb; }

/* ── Window control buttons  [− □ ✕] FL-style ───────────────────── */
.wm-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  margin-left: 6px;
}

.wm-ctrl {
  width: 18px;
  height: 16px;
  border-radius: 2px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.08s, border-color 0.08s, color 0.08s;
  color: #555860;
  background: rgba(255,255,255,0.05);
}
.wm-window.wm-focused .wm-ctrl { color: #8a8e9a; background: rgba(255,255,255,0.07); }
.wm-ctrl:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.12); }
.wm-ctrl:active { background: rgba(255,255,255,0.06); }

.wm-ctrl-min:hover   { background: rgba(200,160,30,0.25); border-color: rgba(200,160,30,0.4); color: #c8a01e; }
.wm-ctrl-max:hover   { background: rgba(50,160,80,0.25);  border-color: rgba(50,160,80,0.4);  color: #32a050; }
.wm-ctrl-close:hover { background: rgba(210,50,50,0.35);  border-color: rgba(210,50,50,0.5);  color: #ff6060; }

/* ── Body ────────────────────────────────────────────────────────── */
.wm-body {
  flex: 1;
  overflow: auto;
  padding: 0;
  position: relative;
  background: #141416;
}

/* ── Resize handle (subtle corner dots) ─────────────────────────── */
.wm-resize-br {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 2;
}
.wm-resize-br::after {
  content: '···';
  position: absolute;
  bottom: 2px;
  right: 1px;
  font-size: 8px;
  letter-spacing: -1px;
  color: rgba(255,255,255,0.2);
  line-height: 1;
  transform: rotate(-45deg);
  transform-origin: center;
}

/* ── Dialog backdrop ─────────────────────────────────────────────── */
.wm-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  pointer-events: all;
  backdrop-filter: blur(2px);
}

/* ── Dialog window tweaks ────────────────────────────────────────── */
.wm-dialog { border-color: rgba(76,158,255,0.35) !important; border-radius: 3px !important; }
.wm-dialog .wm-body { padding: 16px 18px 12px; display: flex; flex-direction: column; gap: 12px; }

.wm-dlg-msg {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.wm-dlg-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 13px;
}
.wm-dlg-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(76,158,255,0.15); }

.wm-dlg-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: auto; }
.wm-dlg-btn {
  padding: 6px 18px;
  border-radius: 5px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.1s;
}
.wm-dlg-cancel { background: var(--bg3); color: var(--text); }
.wm-dlg-cancel:hover { background: #3a3c44; }
.wm-dlg-ok { background: var(--accent2); border-color: var(--accent); color: #fff; }
.wm-dlg-ok:hover { background: var(--accent); }

/* ── Tab system inside windows  (FL Studio compact) ─────────────── */
.wm-tabs {
  display: flex;
  border-bottom: 1px solid #111216;
  background: #11121a;
  padding: 0 4px;
  flex-shrink: 0;
  overflow-x: auto;
}
.wm-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #5a5e6a;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.1s, border-color 0.1s;
  flex-shrink: 0;
}
.wm-tab:hover { color: #9aa0b0; }
.wm-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.wm-pane { display: none; padding: 14px 16px; overflow-y: auto; height: 100%; }
.wm-pane.active { display: block; }

/* ── Settings window form styles ─────────────────────────────────── */
.wm-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-dim);
}
.wm-field > label { flex-shrink: 0; min-width: 120px; }
.wm-field input[type="text"],
.wm-field input[type="number"],
.wm-field select {
  flex: 1;
  background: #0e0f13;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12px;
  min-width: 0;
}
.wm-field input:focus,
.wm-field select:focus { outline: none; border-color: var(--accent); }
.wm-field input[type="color"] {
  width: 44px; height: 28px;
  padding: 2px 3px;
  border-radius: 4px;
  background: #0e0f13;
  border: 1px solid var(--border);
  cursor: pointer;
}
.wm-field input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.wm-range-row { margin-bottom: 12px; font-size: 12px; }
.wm-range-row > div { display: flex; justify-content: space-between; margin-bottom: 4px; color: var(--text-dim); }
.wm-range-row > div span { color: var(--accent); font-weight: 700; font-size: 13px; }
.wm-range-row input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }

.wm-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.wm-section-title:first-child { margin-top: 0; }

.wm-btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.wm-action-btn {
  flex: 1;
  min-width: 120px;
  padding: 8px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  transition: background 0.1s, border-color 0.1s;
}
.wm-action-btn:hover { background: #3a3c44; border-color: #666; }
.wm-action-btn.primary { background: var(--accent2); border-color: var(--accent); color: #fff; }
.wm-action-btn.primary:hover { background: var(--accent); }
.wm-action-btn.danger { background: rgba(224,82,82,0.15); border-color: var(--danger); color: var(--danger); }
.wm-action-btn.danger:hover { background: var(--danger); color: #fff; }

/* ── Asset Manager ───────────────────────────────────────────────── */
.am-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}
.am-sidebar {
  width: 180px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px;
}
.am-main {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}
.am-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 5px;
  margin-bottom: 12px;
}
.am-tile {
  aspect-ratio: 1;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: border-color 0.1s, transform 0.1s;
}
.am-tile:hover { border-color: #666; transform: scale(1.05); }
.am-tile.selected { border-color: var(--accent); }
.am-tile .am-tile-del {
  position: absolute; top: 1px; right: 1px;
  background: rgba(224,82,82,0.85);
  color: #fff; font-size: 9px;
  padding: 1px 3px; border-radius: 2px;
  cursor: pointer; opacity: 0;
  font-weight: 700;
}
.am-tile:hover .am-tile-del { opacity: 1; }

.am-empty { color: var(--text-dim); font-size: 12px; text-align: center; padding: 20px 0; }

.am-edit-form { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.am-preview-tile {
  width: 64px; height: 64px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  overflow: hidden;
  margin-bottom: 12px;
}
.am-preview-tile img { width: 100%; height: 100%; object-fit: cover; }

/* Export window */
.export-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.export-option:hover { border-color: var(--accent2); background: rgba(76,158,255,0.05); }
.export-option-icon { font-size: 28px; flex-shrink: 0; }
.export-option-text h3 { font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.export-option-text p  { font-size: 11px; color: var(--text-dim); line-height: 1.4; }

.html-export-opts { padding: 10px 12px; background: #0e0f13; border-radius: 5px; margin-bottom: 10px; }
.html-export-opts label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-dim); cursor: pointer; padding: 3px 0;
}
.html-export-opts input { accent-color: var(--accent); }

/* ── Asset manager – sidebar tile list ───────────────────────── */
.am-sidebar-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--accent);
  margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.am-tile-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 5px; cursor: pointer;
  font-size: 12px; color: var(--text); transition: background 0.1s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 32px;
}
.am-tile-item:hover { background: rgba(255,255,255,0.07); }
.am-tile-item > img { width: 22px; height: 22px; border-radius: 3px; flex-shrink: 0; object-fit: cover; }
.am-tile-item > span { overflow: hidden; text-overflow: ellipsis; }

.am-flags {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin: 10px 0 12px; font-size: 12px; color: var(--text-dim);
}
.am-flags label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.am-flags input  { accent-color: var(--accent); }

.am-actions { display: flex; gap: 8px; margin-top: 4px; }

.am-empty-state {
  color: var(--text-dim); font-size: 13px;
  text-align: center; padding: 40px 20px; line-height: 1.7;
}

/* ── wm-pane flex (tabbed windows: tabs fixed, pane scrolls) ── */
.wm-pane { flex: 1; overflow-y: auto; }
.wm-pane.active { display: flex; flex-direction: column; }

/* ── Script Editor ───────────────────────────────────────────── */
.se-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: #111216;
  border-bottom: 1px solid #1e2028;
  flex-shrink: 0;
}

.se-editor-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
  background: #0d0e12;
}

.se-gutter {
  width: 38px;
  flex-shrink: 0;
  padding: 10px 6px 10px 0;
  background: #0a0b0e;
  border-right: 1px solid #1e2028;
  overflow: hidden;
  user-select: none;
  font: 11px/1.55 'Consolas', 'Monaco', 'Courier New', monospace;
  color: #3a3e4a;
  text-align: right;
}
.se-gutter div { height: 1.55em; }

.se-code {
  flex: 1;
  background: transparent;
  border: none;
  color: #c8ccd8;
  font: 12px/1.55 'Consolas', 'Monaco', 'Courier New', monospace;
  padding: 10px 12px;
  resize: none;
  outline: none;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  tab-size: 2;
  caret-color: var(--accent);
}
.se-code::selection { background: rgba(76,158,255,0.25); }

.se-console {
  height: 26px;
  background: #090a0d;
  border-top: 1px solid #1e2028;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  flex-shrink: 0;
  overflow: hidden;
}
.se-console-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #3a9a3a;
  flex-shrink: 0;
  font-family: 'Consolas', 'Monaco', monospace;
}
.se-console-out {
  font-size: 11px;
  font-family: 'Consolas', 'Monaco', monospace;
  color: #5a8a5a;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.se-console.se-console-error .se-console-badge { color: #c04040; }
.se-console.se-console-error .se-console-out   { color: #e06060; }

/* ── Script Console Window ───────────────────────────────────── */
.scon-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: #111216;
  border-bottom: 1px solid #1e2028;
  flex-shrink: 0;
}
.scon-status {
  flex: 1;
  font-size: 10px;
  color: #4a8a4a;
  font-family: 'Consolas', 'Monaco', monospace;
  letter-spacing: 0.3px;
}
.scon-log {
  flex: 1;
  overflow-y: auto;
  background: #0a0b0e;
  padding: 4px 0;
}
.scon-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 1px 10px;
  font-size: 11px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  line-height: 1.55;
  border-bottom: 1px solid rgba(255,255,255,0.025);
}
.scon-line:hover { background: rgba(255,255,255,0.03); }
.scon-ts {
  color: #3a3e4e;
  flex-shrink: 0;
  font-size: 10px;
  user-select: none;
}
.scon-msg { color: #8abf8a; word-break: break-all; }
.scon-err .scon-msg { color: #e06060; }
.scon-err .scon-ts  { color: #6a3a3a; }
