/* RPGAtlas — editor.css — GPL-3.0-or-later (see LICENSE) */
:root {
  /* atlas theme: ink navy base, chart blue actions, compass gold accents */
  --accent: #34608c;          /* chart blue — primary actions & selections */
  --accent-edge: #6c97c4;     /* chart blue border */
  --accent-text: #aeccf0;     /* headings on dark */
  --gold: #ffd86a;            /* compass gold — active tools, highlights */
  --gold-edge: #c89b4a;       /* gold border / focus ring */
  --parchment: #e8e2d4;       /* light neutral with a paper warmth */
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  font: 13px/1.45 "Segoe UI", system-ui, sans-serif;
  background: #14151c; color: #d8dae4;
  user-select: none;
}
button {
  background: #262838; color: #d8dae4; border: 1px solid #3a3d52;
  border-radius: 5px; padding: 5px 11px; cursor: pointer; font: inherit;
}
button:hover { background: #32354a; }
button.sel, button.primary { background: var(--accent); border-color: var(--accent-edge); color: #fff; }
button.accent { background: #4a3a7a; border-color: #6a5aa8; }
button.play { background: #2c6a3c; border-color: #48a060; }
button.mini { padding: 2px 8px; font-size: 12px; }
button:disabled { opacity: 0.4; cursor: default; }
input, select, textarea {
  background: #1c1e2a; color: #e8eaf2; border: 1px solid #3a3d52;
  border-radius: 4px; padding: 4px 7px; font: inherit;
}
textarea { width: 100%; resize: vertical; font-family: Consolas, monospace; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--gold-edge); }
.dim { color: #8a8da4; font-size: 11px; }

/* ---------- menu bar ---------- */
#menubar {
  display: flex; align-items: center; gap: 2px;
  padding: 2px 10px 2px 12px; background: #20222e; border-bottom: 1px solid #30334a;
  flex: 0 0 auto;
}
#logo {
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 800; font-size: 14.5px; letter-spacing: 0.4px;
  color: var(--gold); margin-right: 14px; white-space: nowrap;
}
#logo svg { width: 21px; height: 21px; flex: 0 0 auto; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5)); }
#logo .thin { font-weight: 300; letter-spacing: 0.2px; color: var(--parchment); }
#menus { display: flex; }
.menu-label {
  padding: 4px 10px; border-radius: 4px; cursor: default; color: #c8cbdc;
}
.menu-label:hover, .menu-label.open { background: #32354a; color: #fff; }
.menu-drop {
  position: absolute; z-index: 100; min-width: 220px;
  background: #232536; border: 1px solid #3e4158; border-radius: 6px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.55); padding: 4px;
}
.menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 4px; cursor: default; white-space: nowrap;
}
.menu-item:hover { background: var(--accent); color: #fff; }
.menu-item.disabled { opacity: 0.38; }
.menu-item.disabled:hover { background: none; color: inherit; }
.menu-item .mi-check { width: 14px; text-align: center; color: var(--gold); flex: 0 0 auto; }
.menu-item .mi-label { flex: 1; }
.menu-item .mi-key { color: #8a8da4; font-size: 11px; margin-left: 18px; }
.menu-item:hover .mi-key { color: #cdd6ee; }
.menu-sep { height: 1px; background: #383b52; margin: 4px 6px; }

/* ---------- toolbar ---------- */
#toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 3px;
  padding: 4px 8px; background: #1b1d28; border-bottom: 1px solid #30334a;
  flex: 0 0 auto;
}
.tbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  background: transparent; border: 1px solid transparent; border-radius: 5px;
  color: #b8bcd2;
}
.tbtn svg { width: 20px; height: 20px; display: block; }
.tbtn:hover { background: #2c2f44; border-color: #3a3d52; color: #e8eaf2; }
.tbtn.sel {
  background: #3b321f; border-color: var(--gold-edge); color: var(--gold);
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.45);
}
.tbtn:disabled { opacity: 0.32; background: transparent; border-color: transparent; }
.tbtn.play-btn { width: auto; padding: 0 12px; gap: 6px; color: #8fe0a8; font-weight: 600; }
.tbtn.play-btn:hover { background: #234a30; border-color: #48a060; color: #b8f0c8; }
.tb-sep { width: 1px; height: 24px; background: #353850; margin: 0 5px; flex: 0 0 auto; }

/* ---------- layout ---------- */
#main { flex: 1; display: flex; min-height: 0; }
#sidebar {
  width: 312px; flex: 0 0 auto; overflow-y: auto;
  background: #191b26; border-right: 1px solid #30334a; padding: 8px;
  display: flex; flex-direction: column; gap: 10px;
}
#sidebar section { background: #1f2130; border: 1px solid #2c2f44; border-radius: 8px; padding: 8px; }
.side-head { font-weight: 600; margin-bottom: 6px; color: #aeb2c8; display: flex; justify-content: space-between; align-items: center; }
.btnrow { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
#maplist { list-style: none; margin: 0; padding: 0; max-height: 150px; overflow-y: auto; }
#maplist li { padding: 4px 8px; border-radius: 4px; cursor: pointer; }
#maplist li:hover { background: #2a2d40; }
#maplist li.sel { background: var(--accent); color: #fff; }
#palettewrap { max-height: 420px; overflow-y: auto; border: 1px solid #2c2f44; border-radius: 4px; }
#palette { display: block; cursor: pointer; image-rendering: pixelated; }

#mapscroll { flex: 1; overflow: auto; background: #101018; padding: 14px; }
#mapcanvas { display: block; image-rendering: pixelated; cursor: crosshair; box-shadow: 0 0 0 1px #30334a, 0 8px 30px rgba(0,0,0,0.5); }

#status {
  flex: 0 0 auto; padding: 4px 12px; font-size: 12px; color: #9a9db4;
  background: #1b1d28; border-top: 1px solid #30334a; white-space: nowrap; overflow: hidden;
  display: flex; align-items: center; gap: 14px;
}
#status .spacer { flex: 1; }
#status-text { overflow: hidden; text-overflow: ellipsis; }
#zoom-ind { color: #8fa8d8; }
#save-ind { font-size: 11px; color: #6fc888; min-width: 70px; text-align: right; }

/* ---------- modals ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(6,8,14,0.65);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: #1f2130; border: 1px solid #3a3d52; border-radius: 10px;
  width: 560px; max-width: 94vw; max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 16px 50px rgba(0,0,0,0.6);
}
.modal.wide { width: 880px; }
.modal-title { padding: 10px 16px; font-weight: 700; border-bottom: 1px solid #30334a; color: #e8cfa0; }
.modal-body { padding: 12px 16px; overflow-y: auto; }
.modal-btns { padding: 10px 16px; border-top: 1px solid #30334a; display: flex; gap: 8px; justify-content: flex-end; }
/* Event editor footer: map position pinned left, OK/Cancel right-aligned like other dialogs. */
.modal-btns.event-footer { justify-content: space-between; align-items: center; }
.event-footer .ef-right { display: flex; gap: 8px; }
.event-pos-foot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.event-pos-foot .epf-label { color: #8a8da4; }
.event-pos-foot .epf-val { color: #cfd2e6; font-variant-numeric: tabular-nums; }

.fld { display: inline-flex; flex-direction: column; gap: 3px; margin: 4px 10px 4px 0; vertical-align: top; }
.fld > span { font-size: 11px; color: #8a8da4; }
.fld input[type=number] { width: 76px; }
.frow { display: flex; flex-wrap: wrap; align-items: flex-end; }
.subbox { background: #1a1c28; border: 1px solid #2c2f44; border-radius: 6px; padding: 8px; margin: 8px 0; }
.subhead { font-weight: 600; color: #aeb2c8; margin: 8px 0 4px; }
.minilist { display: flex; flex-direction: column; gap: 4px; }
.minirow { display: flex; gap: 6px; align-items: center; }
.chip {
  display: inline-block; background: #2c3a5a; border: 1px solid #46598a;
  border-radius: 10px; padding: 1px 9px; margin: 2px; cursor: pointer; font-size: 12px;
}
.chip:hover { background: #6a3a3a; }
.char-preview canvas, .enemy-preview canvas { image-rendering: pixelated; background: #14151c; border: 1px solid #2c2f44; border-radius: 4px; }

/* ---------- location picker ---------- */
.locpick-scroll {
  max-height: 60vh; overflow: auto; border: 1px solid #2c2f44; border-radius: 6px;
  background: #101018; padding: 8px;
}
.locpick-canvas { display: block; image-rendering: pixelated; cursor: crosshair; margin: 0 auto; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs button { padding: 4px 10px; border-radius: 5px 5px 0 0; }
.tabs button.sel { background: var(--accent); color: #fff; }
.tabs button.dragging { opacity: .45; }
.tabs button.drop-left { box-shadow: inset 3px 0 0 0 #ffd86a; }
.tabs button.drop-right { box-shadow: inset -3px 0 0 0 #ffd86a; }
.tabs input.tab-rename { padding: 4px 8px; border-radius: 5px 5px 0 0; width: 9em; font: inherit; }

/* ---------- database ---------- */
.modal.db-modal { width: 1040px; }
.dbwrap { display: flex; gap: 12px; align-items: stretch; min-height: 440px; }
.dbtabs-vert {
  display: flex; flex-direction: column; gap: 3px;
  width: 138px; flex: 0 0 auto; max-height: 560px; overflow-y: auto;
  border-right: 1px solid #30334a; padding-right: 10px;
}
.dbtabs-vert button { text-align: left; border-radius: 5px; padding: 5px 11px; }
.dbtabs-vert button.sel { background: var(--accent); color: #fff; border-color: var(--accent-edge); }
.dbbody { flex: 1; min-width: 0; }

/* Types tab — element / skill / weapon / armor / equipment categories */
.types-cols { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; align-items: flex-start; }
.types-col {
  flex: 1 1 0; min-width: 158px;
  background: #1a1c28; border: 1px solid #2c2f44; border-radius: 6px;
  padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.types-col-head { font-weight: 600; color: #aeb2c8; }
.types-rows { display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow-y: auto; }
.types-row { display: flex; align-items: center; gap: 5px; }
.types-num { color: #8a8da4; font-size: 11px; min-width: 20px; text-align: right; flex: 0 0 auto; }
.types-row input { flex: 1; min-width: 0; }
.types-row .danger { color: #f2a0a0; flex: 0 0 auto; }
.types-add { align-self: flex-start; }
@media (max-width: 1080px) {
  .types-col { flex: 0 0 168px; }
}
.dbtab { display: flex; gap: 12px; min-height: 380px; }
.dbside { width: 190px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
.dbbtns { display: flex; gap: 5px; }
.dblist { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: 420px; border: 1px solid #2c2f44; border-radius: 5px; }
.dblist li { padding: 3px 8px; cursor: pointer; display: flex; align-items: center; gap: 5px; min-height: 30px; }
.dblist li:hover { background: #2a2d40; }
.dblist li.sel { background: var(--accent); color: #fff; }
.db-entry-id { color: #8a8da4; min-width: 24px; text-align: right; }
.dblist li.sel .db-entry-id { color: #d5e1fa; }
.dbform { flex: 1; min-width: 0; }
.dbform.single { width: 100%; }
.trait-list { display: flex; flex-direction: column; gap: 6px; margin: 5px 0 10px; }
.trait-row {
  display: grid; grid-template-columns: minmax(140px, 1.1fr) minmax(140px, 1fr) minmax(130px, .9fr) auto;
  gap: 7px; align-items: end; padding: 7px 8px;
  background: #1a1c28; border: 1px solid #2c2f44; border-radius: 6px;
}
.trait-row .fld { margin: 0; }
.trait-row select { max-width: 100%; }
.trait-actions { display: flex; gap: 4px; padding-bottom: 4px; }
.trait-actions .danger { color: #f2a0a0; }
.trait-empty { padding: 8px; border: 1px dashed #34374d; border-radius: 6px; }
.trait-add { align-self: flex-start; }
@media (max-width: 760px) {
  .dbtab { flex-direction: column; }
  .dbside { width: 100%; }
  .dblist { max-height: 150px; }
  .trait-row { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .trait-actions { justify-content: flex-end; }
}
.namegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 10px; max-height: 460px; overflow-y: auto; }
.sysgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 14px; }
.rangewrap { display: inline-flex; align-items: center; gap: 8px; }
.rangewrap input[type=range] { width: 150px; }
.range-val { color: #8a8da4; font-size: 12px; min-width: 38px; }
.namegrid-add { grid-column: 1 / -1; justify-self: start; margin: 8px 0 4px; }

/* ---------- Tilesets tab ---------- */
.ts-tile-grid {
  display: flex; flex-wrap: wrap; gap: 3px; padding: 6px;
  background: #101018; border: 1px solid #2c2f44; border-radius: 6px;
  max-height: 210px; overflow-y: auto; margin: 4px 0 8px;
}
.ts-tile-btn {
  width: 38px; height: 38px; padding: 3px;
  background: #1a1c28; border: 1px solid #2c2f44; border-radius: 4px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.ts-tile-btn:hover { border-color: #6a7aaa; background: #22253a; }
.ts-tile-btn.sel { border-color: var(--accent); background: rgba(70, 100, 180, 0.28); box-shadow: 0 0 0 1px var(--accent); }
.ts-tile-detail { margin-top: 2px; border-top: 1px solid #2c2f44; padding-top: 10px; }
.ts-tile-heading { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.ts-pass-grid {
  display: grid; grid-template-columns: repeat(3, 40px); gap: 3px; margin: 6px 0 4px;
}
.ts-pass-btn {
  width: 40px; height: 40px; font-size: 17px; cursor: pointer; border-radius: 5px;
  display: flex; align-items: center; justify-content: center; border: 1px solid;
}
.ts-pass-btn.passable { background: #1c3f26; border-color: #3a8050; color: #7fe090; }
.ts-pass-btn.blocked  { background: #3f1c1c; border-color: #804040; color: #e08080; }
.ts-pass-btn.passable:hover { background: #22522e; }
.ts-pass-btn.blocked:hover  { background: #522222; }
.ts-pass-center {
  width: 40px; height: 40px; font-size: 20px;
  display: flex; align-items: center; justify-content: center; border-radius: 5px; border: 1px solid;
}
.ts-pass-center.passable { color: #7fe090; border-color: #3a8050; background: #14281a; }
.ts-pass-center.blocked  { color: #e08080; border-color: #804040; background: #281414; }
.ts-pass-actions { display: flex; gap: 5px; margin: 4px 0 10px; }
.ts-flags { display: flex; flex-direction: column; gap: 6px; margin: 5px 0 10px; }
.ts-flag-label { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; }
.ts-flag-label input[type=checkbox] { cursor: pointer; width: 14px; height: 14px; }

/* ---- Controls: author default input-bindings grid ---- */
.input-grid-wrap { margin: 4px 0 6px; }
.input-grid { display: grid; grid-template-columns: 78px 1fr 1fr; gap: 6px 12px; align-items: center; margin: 6px 0; max-width: 560px; }
.input-row { display: contents; }
.input-act { font-size: 13px; color: #cdd2e4; }
.input-head .input-act, .input-head .bind-cell { font-weight: 600; color: #8a8da4; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.gp-head { flex-direction: row; align-items: center; gap: 8px; } /* "Gamepad" + Preview on one line */
.gp-preview { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 400; }
.gp-preview > span { color: #8a8da4; font-size: 11px; }
.gp-preview select { font-size: 12px; padding: 1px 4px; }
.bind-cell { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 26px; }
.bind-chip { display: inline-flex; align-items: center; gap: 1px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.13); border-radius: 6px; padding: 1px 1px 1px 3px; }
.bind-glyph { height: 22px; width: auto; display: block; }
.bind-x { background: none; border: none; color: #b88; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 3px; }
.bind-x:hover { color: #ff6a6a; }
.bind-add { background: rgba(255,255,255,.05); border: 1px dashed rgba(255,255,255,.28); color: #9fd6b0; border-radius: 6px; cursor: pointer; width: 24px; height: 24px; line-height: 1; font-size: 15px; }
.bind-add:hover { background: rgba(255,255,255,.12); }
.input-note { color: #f2a44a; font-size: 12px; min-height: 16px; margin: 4px 0; }
.capture-note { padding: 14px 6px; font-size: 14px; color: #cdd2e4; text-align: center; }
.pad-pick { display: grid; grid-template-columns: repeat(2, minmax(190px, 1fr)); gap: 6px; }
.pad-pick-btn { display: flex; align-items: center; gap: 9px; padding: 4px 9px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.13); border-radius: 6px; cursor: pointer; color: #dde2f0; text-align: left; }
.pad-pick-btn:hover { background: rgba(255,255,255,.11); }
.pad-pick-btn img { height: 24px; width: auto; }
.icon-sprite {
  display: inline-block; width: 32px; height: 32px; flex: 0 0 32px;
  background-image: var(--icon-set-url); background-position: var(--icon-x) var(--icon-y);
  background-repeat: no-repeat; image-rendering: pixelated; vertical-align: middle;
}
.db-entry-icon { transform: scale(0.72); margin: -4px; }
.icon-pick-button { display: inline-flex; align-items: center; gap: 7px; padding: 2px 9px 2px 4px; }
.icon-preview { transform: scale(0.82); margin: -3px; }
.icon-picker-grid { display: grid; grid-template-columns: repeat(8, 44px); gap: 5px; justify-content: center; }
.icon-choice { width: 44px; height: 44px; padding: 5px; display: flex; align-items: center; justify-content: center; }
.icon-choice.sel { outline: 2px solid #ffd86a; background: var(--accent); }

/* ---------- command list ---------- */
.cmdlist-wrap { border: 1px solid #2c2f44; border-radius: 6px; overflow: hidden; }
.cmdbtns { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; box-sizing: border-box; padding: 0 8px; background: #1a1c28; border-bottom: 1px solid #2c2f44; }
.cmdbtns-actions { display: flex; gap: 5px; }
.cmdbtns-actions button { padding: 3px 9px; }
.cmdbanner-title { display: flex; align-items: baseline; gap: 5px; font-weight: 600; color: #aeb2c8; }
.cmdlist { max-height: 260px; overflow-y: auto; font-family: Consolas, monospace; font-size: 12px; background: #1a1c28; }
.cmdlist:focus { outline: none; } /* focusable for Ctrl+C/V; the selected-row highlight shows the active row */
.cmdrow { padding: 3px 8px; cursor: default; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #1a1c28; }
/* zebra striping: the panel navy plus a lighter shade of the same hue; before hover/selection so those still win */
.cmdrow:nth-child(even) { background: #232639; }
.cmdrow:hover { background: #2a2d40; }
.cmdrow.sel { background: var(--accent); color: #fff; }
.cmdrow.cmd-selected { background: rgba(52, 96, 140, .40); } /* rest of a multi-selection; focus row keeps the strong .sel */
.cmdrow.branch { color: #8fae6f; }
.cmdrow.slot { color: #6a6d84; }
.cmdrow.dragging { opacity: .45; }
/* amber (matches the icon-choice highlight) so the line reads against both dark
   rows and the accent-filled selected row */
.cmdrow.drop-before { box-shadow: inset 0 3px 0 0 #ffd86a; }
.cmdrow.drop-after { box-shadow: inset 0 -3px 0 0 #ffd86a; }
.cmdtabs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.cmdtabs button.sel { background: var(--accent); border-color: var(--accent-edge); color: #fff; }
.cmdgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cmdgrid button { text-align: left; }
.cmdgrid .cmdpreset { border-color: #536c9d; background: #263652; }
.cmdgrid .cmdaddnew { border-style: dashed; color: #9fd7ad; }
@media (max-width: 680px) {
  .cmdgrid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- event editor (3-pane IDE) ---------- */
/* The window sizes to its content (the left column of Conditions/Appearance/Behaviour is the
   tallest natural element), capped at 88vh. The command list and inspector absolute-fill their
   columns so they DON'T drive the height — instead all three columns bottom-align at the lower
   edge of the Behaviour section, and the list/inspector scroll internally only if they overflow. */
.modal.event-modal { width: 1200px; max-height: 88vh; overflow: hidden; }
.modal.event-modal .modal-body { min-height: 0; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; }
.event-head { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.event-pagebox { display: flex; min-height: 0; }
.event-ide {
  display: grid; grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 10px; align-items: stretch; min-height: 0; width: 100%;
}
.event-ide-col { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.event-ide-left { gap: 8px; padding-right: 2px; }
/* center + right contribute no intrinsic height (only absolutely-positioned children), so the
   left column anchors the row height; the boxes below stretch to it and scroll within. */
.event-ide-center, .event-ide-right { position: relative; }
.event-ide-center .cmdlist-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; }
.event-ide-center .cmdlist { max-height: none; flex: 1; min-height: 0; }
.event-inspector { position: absolute; inset: 0; overflow-y: auto; background: #1a1c28; border: 1px solid #2c2f44; border-radius: 6px; padding: 10px; }

/* left sections */
.event-ide .ev-section { background: #1a1c28; border: 1px solid #2c2f44; border-radius: 6px; }
.event-ide .ev-sec-head { display: flex; align-items: center; gap: 7px; min-height: 36px; box-sizing: border-box; padding: 0 9px; font-weight: 600; color: #aeb2c8; user-select: none; }
.event-ide .ev-sec-body { padding: 4px 9px 9px; }
.event-ide .ev-badge { margin-left: auto; font-size: 10px; color: var(--gold); background: rgba(255,216,106,.12); border: 1px solid var(--gold-edge); border-radius: 10px; padding: 0 7px; line-height: 16px; }

/* right-pane inspector */
.event-inspector { display: flex; flex-direction: column; gap: 4px; }
.ev-insp-empty { color: #6a6d84; font-size: 12px; padding: 8px 2px; line-height: 1.5; }
.ev-insp-hint { margin-top: 8px; padding: 6px 8px; font-size: 11px; color: #8fae6f; background: rgba(143,174,111,.08); border: 1px solid #3a4a32; border-radius: 5px; }
.event-ide-right .minirow { flex-wrap: wrap; }

/* stack fields full-width in the narrow left column + inspector */
.event-ide-left .frow, .event-ide-right .frow { flex-direction: column; align-items: stretch; }
.event-ide-left .fld, .event-ide-right .fld { width: 100%; margin: 4px 0; }
.event-ide-left .fld input, .event-ide-left .fld select,
.event-ide-right .fld input, .event-ide-right .fld select, .event-ide-right .fld textarea { width: 100%; }
.event-ide-left .fld input[type=number], .event-ide-right .fld input[type=number] { width: 100%; }

/* narrow-viewport fallback: stack the three panes in normal flow and let the body scroll */
@media (max-width: 900px) {
  .event-ide { grid-template-columns: 1fr; }
  .event-ide-center, .event-ide-right { position: static; }
  .event-ide-center .cmdlist-wrap, .event-inspector { position: static; inset: auto; }
  .event-ide-center .cmdlist { max-height: 240px; }
  .event-inspector { min-height: 160px; }
  .event-topbar { grid-template-columns: auto 1fr auto; }
}

/* event editor — consolidated header bar (replaces the generic modal title) */
.modal.event-modal .modal-title { display: none; }
.event-topbar { display: grid; grid-template-columns: 280px minmax(0, 1fr) auto; gap: 10px; align-items: center; margin: -10px -14px 8px; padding: 8px 14px; background: #20222e; border-bottom: 1px solid #30334a; }
.event-topbar-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.event-topbar-id .event-name-input { flex: 1; min-width: 0; }
.event-icon { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex: 0 0 auto; border-radius: 6px; background: #2c3a5a; border: 1px solid #46598a; color: #aeccf0; font-size: 12px; }
.event-icon svg { width: 18px; height: 18px; display: block; }
.event-name-input { font-weight: 600; font-size: 14px; min-width: 160px; }
/* page tabs sit in the header row, aligned over the commands column: [+ add] then pages */
.event-topbar .tabs { margin: 0; gap: 5px; flex-wrap: wrap; align-items: center; }
.event-topbar .tabs button { border-radius: 6px; padding: 3px 11px; }
.event-topbar .tabs button.tab-add { color: var(--accent-text); font-weight: 700; }
.event-topbar .tabs input.tab-rename { border-radius: 6px; }
.event-close { justify-self: end; background: transparent; border: 1px solid transparent; color: #9a9db4; font-size: 14px; line-height: 1; padding: 4px 9px; }
.event-close:hover { background: #6a3a3a; border-color: #8a4a4a; color: #fff; }

/* event editor — property rows: label left, control right (Conditions / Appearance / Behaviour) */
.prop-rows { display: flex; flex-direction: column; gap: 6px; }
.prop-row { display: flex; align-items: center; gap: 8px; }
.prop-label { flex: 0 0 auto; width: 80px; color: #aeb2c8; font-size: 12px; }
.prop-ctrl { flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px; }
.prop-ctrl > select { flex: 1; min-width: 0; }
.cond-var { flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px; }
.cond-var select { flex: 1; min-width: 0; }
.cond-var input[type=number] { flex: 0 0 auto; width: 52px; }
.cond-cmp { flex: 0 0 auto; color: #8a8da4; font-size: 12px; }

/* event editor — appearance: square sprite preview spanning the Graphic + Facing rows */
.appearance-row { display: flex; gap: 10px; align-items: stretch; }
.appearance-fields { flex: 1; min-width: 0; }
.appearance-row .char-preview { flex: 0 0 auto; align-self: stretch; aspect-ratio: 1 / 1; min-height: 60px; display: flex; align-items: center; justify-content: center; background: #14151c; border: 1px solid #2c2f44; border-radius: 6px; padding: 5px; }
.appearance-row .char-preview canvas { height: 100%; width: auto; max-width: 100%; image-rendering: pixelated; border: none; background: none; border-radius: 0; }

/* event editor — dim parenthetical command count next to the "Commands" banner title */
.ev-cmd-count { font-size: 12px; font-weight: 400; color: #71748c; }

.helpbox h3 { color: #e8cfa0; margin: 12px 0 4px; }
.helpbox ul { margin: 4px 0; padding-left: 20px; }
.helpbox li { margin: 3px 0; }
.helpbox kbd {
  background: #2a2d40; border: 1px solid #44485f; border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; font: 11px Consolas, monospace;
}
/* Collapsible message text-codes reference under Show Text / Show Choices */
.code-legend { margin: 2px 0 6px; }
.code-legend > summary { cursor: pointer; color: #8a8da4; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; user-select: none; }
.code-legend > summary:hover { color: #cdd2e4; }
.code-legend-list { margin: 6px 0 2px; padding-left: 2px; list-style: none; line-height: 1.8; }
.code-legend-list code {
  background: #2a2d40; border: 1px solid #44485f; border-radius: 4px;
  padding: 0 5px; font: 11px Consolas, monospace; color: #e8cfa0;
}
.code-legend-list .cl-desc { color: #aab0c6; font-size: 12px; }
.code-legend .cl-note { color: #7f88a6; font-size: 11px; margin-top: 4px; }
.patch-notes { display: flex; flex-direction: column; gap: 12px; }
.patch-note { background: #1a1c28; border: 1px solid #30344b; border-radius: 7px; padding: 10px 12px; }
.patch-note-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.patch-note h3 { color: #e8cfa0; margin: 0; }
.patch-note time { color: #8a8da4; font-size: 11px; white-space: nowrap; }
.patch-note p { margin: 7px 0; }
.patch-note ul { margin: 6px 0 0; padding-left: 20px; }
.patch-note li { margin: 4px 0; }

/* ---------- plugin manager ---------- */
.plug-wrap { display: flex; gap: 12px; min-height: 380px; }
.plug-side { width: 220px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
.plug-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; border: 1px solid #2c2f44; border-radius: 5px; }
.plug-list li { padding: 4px 8px; cursor: pointer; display: flex; align-items: center; gap: 7px; }
.plug-list li:hover { background: #2a2d40; }
.plug-list li.sel { background: var(--accent); color: #fff; }
.plug-list li.off .plug-name { opacity: 0.5; text-decoration: line-through; }
.plug-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.plug-badge {
  flex: 0 0 auto; font-size: 10px; letter-spacing: 0.3px; text-transform: uppercase;
  color: #8fd0ff; background: rgba(90,130,220,0.18); border: 1px solid #3e5a8a;
  border-radius: 4px; padding: 0 5px; line-height: 16px;
}
.plug-list li.sel .plug-badge { color: #fff; border-color: #cdd6ee; background: rgba(255,255,255,0.18); }
.plug-form { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.plug-form textarea { flex: 1; min-height: 260px; font-size: 12px; }

/* ---------- audio manager ---------- */
.audio-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.audio-grid button { text-align: left; }
.audio-grid button.playing { background: #2c6a3c; border-color: #48a060; color: #fff; }

/* ---------- event searcher ---------- */
.search-bar { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.search-bar input[type=text] { width: 240px; }
.search-results { max-height: 380px; overflow-y: auto; border: 1px solid #2c2f44; border-radius: 6px; }
.search-row { padding: 5px 10px; cursor: pointer; border-bottom: 1px solid #232536; }
.search-row:hover { background: #2a2d40; }
.search-row b { color: #aeccf0; }
.search-row .dim { display: block; }

/* ---------- resource manager ---------- */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; max-height: 440px; overflow-y: auto; }
.res-cell {
  background: #1a1c28; border: 1px solid #2c2f44; border-radius: 6px;
  padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center; font-size: 11px;
}
.res-cell canvas { image-rendering: pixelated; background: #14151c; border-radius: 4px; max-width: 96px; }
.res-cell .res-name { color: #aeb2c8; overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }

/* ---------- character generator ---------- */
.cg-wrap { display: flex; gap: 14px; }
.cg-side { width: 190px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
.cg-form { flex: 1; }
.cg-preview {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  background: #14151c; border: 1px solid #2c2f44; border-radius: 8px; padding: 12px; margin-top: 8px;
}
.cg-preview canvas { image-rendering: pixelated; width: 72px; height: 72px; }
.fld input[type=color] { padding: 1px 2px; width: 44px; height: 28px; }
