/* editor.css — minimal dark theme, matches the saturn-admin portal vibe */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #1a1a2e;
  color: #e0e0e0;
  font-family: -apple-system, system-ui, monospace;
  font-size: 14px;
  min-height: 100vh;
}

.topbar {
  background: #16213e;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border-bottom: 1px solid #0d1426;
}
.topbar h1 { color: #f5a623; font-size: 18px; flex-grow: 0; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar input[type=text] {
  background: #0f1a2e;
  color: #e0e0e0;
  border: 1px solid #2a3a55;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
  border-radius: 3px;
  min-width: 110px;
}

.btn {
  background: #2a3a55;
  color: #e0e0e0;
  border: 1px solid #3a4a65;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  border-radius: 3px;
}
.btn:hover { background: #3a4a65; }
.btn.primary { background: #2ecc71; color: #0a1a0a; border-color: #2ecc71; font-weight: 600; }
.btn.primary:hover { background: #4edc81; }
.btn.danger { background: #e94560; color: white; border-color: #e94560; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.admin-btn { background: #6a3a8a; border-color: #7a4a9a; }
.admin-btn:hover { background: #7a4a9a; }
.admin-btn.active { background: #2ecc71; color: #0a1a0a; border-color: #2ecc71; }
.admin-badge {
  background: #2ecc71;
  color: #0a1a0a;
  padding: 4px 8px;
  font-weight: 700;
  font-size: 11px;
  border-radius: 3px;
  letter-spacing: 1px;
}
.admin-badge.hidden { display: none; }
.del-btn.hidden { display: none; }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr 280px;
  gap: 12px;
  padding: 12px;
}

.panel {
  background: #16213e;
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 12px;
}
.panel h2 {
  color: #f5a623;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  border-bottom: 1px solid #2a3a55;
  padding-bottom: 6px;
}

.tool-row, .tile-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-bottom: 8px;
}
.tile-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #aaa;
}
.tile-row input[type=number],
.tile-row select {
  background: #0f1a2e;
  color: #e0e0e0;
  border: 1px solid #2a3a55;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 13px;
  border-radius: 3px;
  width: 80px;
}
.muted { color: #888; font-size: 11px; }

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
}
.palette > span { font-size: 12px; color: #aaa; margin-right: 4px; }
.swatch {
  border: 2px solid transparent;
  background: #555;
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 3px;
  font-family: inherit;
  text-shadow: 0 1px 1px rgba(0,0,0,0.7);
}
.swatch.active { border-color: #f5a623; }

.canvas-wrap {
  background: #16213e;
  border-radius: 4px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.view-tabs {
  display: flex;
  gap: 4px;
  align-items: center;
  border-bottom: 1px solid #2a3a55;
  padding-bottom: 8px;
}
.view-tab {
  background: transparent;
  color: #aaa;
  border: 1px solid transparent;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  border-radius: 3px 3px 0 0;
  border-bottom: none;
}
.view-tab:hover { color: #e0e0e0; }
.view-tab.active {
  background: #1d2d4a;
  color: #f5a623;
  border: 1px solid #2a3a55;
  border-bottom: 1px solid #1d2d4a;
  margin-bottom: -1px;
}
.view-help { margin-left: auto; font-size: 11px; }

.view-pane { display: none; flex-direction: column; align-items: center; gap: 10px; }
.view-pane.active { display: flex; }

#map-canvas {
  background: #0a0a14;
  border: 1px solid #2a3a55;
  cursor: crosshair;
  image-rendering: pixelated;
}
.canvas-legend { font-size: 12px; color: #aaa; }
.canvas-legend .lg-spawn { color: #2ecc71; font-size: 18px; vertical-align: middle; }
.canvas-legend .lg-model { color: #f5a623; font-size: 16px; vertical-align: middle; }
.canvas-legend .lg-crate { color: #e94560; font-size: 16px; vertical-align: middle; }

#three-mount {
  width: 640px;
  height: 640px;
  background: #0a0a14;
  border: 1px solid #2a3a55;
  position: relative;
  overflow: hidden;
}
#three-mount canvas { display: block; }
.three-overlay {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: #aaa;
  flex-wrap: wrap;
}
.three-overlay label { display: flex; gap: 4px; align-items: center; }

.texture-palette-detail summary {
  cursor: pointer;
  font-size: 13px;
  color: #f5a623;
  margin-top: 4px;
}
.texture-palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  background: #0f1a2e;
  border-radius: 3px;
  margin-top: 8px;
}
.tex-cell {
  cursor: pointer;
  border: 2px solid #2a3a55;
  border-radius: 2px;
  padding: 0;
  background: #0a0a14;
  position: relative;
  aspect-ratio: 1;
}
.tex-cell:hover { border-color: #f5a623; }
.tex-cell.active { border-color: #2ecc71; }
.tex-cell img {
  width: 100%; height: 100%; display: block;
  image-rendering: pixelated;
}
.tex-cell-label {
  position: absolute; bottom: 0; right: 0;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 9px;
  padding: 1px 3px;
  border-top-left-radius: 2px;
  font-family: monospace;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 12px;
  color: #aaa;
}
.info-grid span { color: #f5a623; font-weight: 600; margin-left: 4px; }

.validation {
  margin-top: 12px;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
}
.validation .err { color: #e94560; }
.validation .warn { color: #f5a623; }
.validation .ok  { color: #2ecc71; }

.entity-list { list-style: none; max-height: 600px; overflow-y: auto; font-size: 12px; }
.entity-list li {
  padding: 6px 8px;
  border-bottom: 1px solid #2a3a55;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.entity-list li:hover { background: #1d2d4a; }
.entity-list li.selected { background: #2a3a55; }
.entity-list .ent-tag { font-weight: 600; }
.entity-list .ent-spawn { color: #2ecc71; }
.entity-list .ent-model { color: #f5a623; }
.entity-list .ent-crate { color: #e94560; }
.entity-list .ent-empty { color: #888; }

.toast {
  position: fixed;
  top: 70px;
  right: 16px;
  background: #2ecc71;
  color: #0a1a0a;
  padding: 10px 16px;
  border-radius: 4px;
  font-weight: 600;
  z-index: 100;
  max-width: 360px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.toast.hidden { display: none; }
.toast.error { background: #e94560; color: white; }

dialog { background: #16213e; color: #e0e0e0; border: 1px solid #2a3a55; border-radius: 4px; padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,0.7); }
.dialog-content { min-width: 360px; }
.dialog-content h2 { color: #f5a623; margin-bottom: 12px; }
.load-list { list-style: none; max-height: 400px; overflow-y: auto; margin-bottom: 12px; }
.load-list li {
  padding: 8px 10px;
  border-bottom: 1px solid #2a3a55;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.load-list li:hover { background: #1d2d4a; }
.load-list .meta { font-size: 11px; color: #888; }
.load-list .del-btn {
  background: #e94560; color: white; border: none;
  padding: 2px 6px; cursor: pointer; border-radius: 3px;
  font-family: inherit; font-size: 11px;
}

/* ---- Sprites tab (CHARS.PAK display) -------------------------------- */
.view-pane.view-sprites {
  background: #0f1626;
  padding: 12px;
  overflow-y: auto;
  height: 100%;
}
.sprites-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #2a3a55;
}
.sprites-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sprites-row {
  display: grid;
  grid-template-columns: 100px repeat(var(--sprites-cols, 5), 1fr);
  gap: 8px;
  align-items: center;
}
.sprites-row-label {
  color: #f5a623;
  font-weight: 600;
  font-size: 13px;
  padding: 4px 8px;
}
.sprites-cell {
  background: #16213e;
  border: 1px solid #2a3a55;
  border-radius: 4px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
}
.sprites-cell:hover {
  background: #1d2d4a;
  border-color: #f5a623;
}
.sprites-cell img {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: repeating-conic-gradient(#222 0% 25%, #333 0% 50%) 50% / 12px 12px;
}
.sprites-cell-cap {
  font-size: 10px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sprites-detail {
  margin-top: 16px;
  padding: 12px;
  background: #16213e;
  border: 1px solid #2a3a55;
  border-radius: 4px;
}
.sprites-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.sprites-detail-label {
  font-weight: 600;
  color: #e0e0e0;
}
#sprites-detail-canvas {
  display: block;
  background: #000;
  border: 1px solid #2a3a55;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* ---- Sprites toolbar (Phase 2 buttons) ----------------------------- */
.sprites-toolbar-spacer { flex: 1; }
.sprites-toolbar #btn-sprites-download,
.sprites-toolbar #btn-sprites-import-wrap,
.sprites-toolbar #btn-sprites-help,
.sprites-toolbar #btn-sprites-refresh {
  margin-left: 6px;
}
.sprites-toolbar #btn-sprites-import-wrap {
  cursor: pointer;
}
.sprites-toolbar #btn-sprites-import-wrap input[type="file"] {
  display: none;
}

/* ---- Sprite-detail action bar + tool bar ---------------------------- */
.sprites-action-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: 12px;
}
.sprites-action-bar #sprites-status {
  margin-left: 8px;
  font-size: 11px;
}
.sprites-tool-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid #2a3a55;
  border-bottom: 1px solid #2a3a55;
  margin-bottom: 8px;
}
.sprites-tool-bar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.sprites-tool-bar input[type="color"] {
  width: 40px;
  height: 24px;
  padding: 0;
  border: 1px solid #2a3a55;
  background: #16213e;
  cursor: pointer;
}
#sprites-color-swatch {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 1px solid #2a3a55;
  border-radius: 3px;
  vertical-align: middle;
}

/* ---- Customized cell highlight ------------------------------------- */
.sprites-cell.customized {
  border-color: #f5a623;
  box-shadow: 0 0 0 1px #f5a623 inset;
}
.sprites-cell.customized::after {
  content: "★";
  position: absolute;
  top: 2px;
  right: 4px;
  color: #f5a623;
  font-size: 11px;
}
.sprites-cell { position: relative; }

/* ---- Help dialog --------------------------------------------------- */
#sprites-help-dialog {
  background: #16213e;
  color: #e0e0e0;
  border: 1px solid #2a3a55;
  border-radius: 4px;
  padding: 16px;
  max-width: 580px;
}
#sprites-help-dialog::backdrop { background: rgba(0,0,0,0.7); }
#sprites-help-dialog ul { list-style: disc; }

/* ---- Custom Characters (Phase A) ----------------------------------- */
.custom-chars-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 2px solid #2a3a55;
}
.custom-chars-header {
  color: #f5a623;
  font-size: 16px;
  margin-bottom: 8px;
}
.custom-chars-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.custom-chars-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.cc-card {
  background: #16213e;
  border: 1px solid #2a3a55;
  border-radius: 4px;
  padding: 8px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.cc-card-meta {
  flex: 0 0 160px;
  display: flex;
  flex-direction: column;
}
.cc-card-name { font-weight: 600; color: #e0e0e0; }
.cc-card-creator { font-size: 11px; color: #aaa; }
.cc-card-slug { font-size: 10px; color: #777; font-family: monospace; }
.cc-card-strip {
  flex: 1;
  display: flex;
  gap: 4px;
}
.cc-card-strip img {
  image-rendering: pixelated;
  width: 48px; height: 48px;
  background: repeating-conic-gradient(#222 0% 25%, #333 0% 50%) 50% / 12px 12px;
}
.cc-card-actions { flex: 0 0 auto; }

.custom-chars-editor {
  background: #0f1626;
  border: 1px solid #f5a623;
  border-radius: 4px;
  padding: 12px;
  margin-top: 8px;
}
.custom-chars-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.cc-edit-title { font-weight: 600; color: #f5a623; font-size: 14px; }
.custom-chars-editor-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.custom-chars-editor-meta label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.custom-chars-editor-meta input {
  background: #16213e;
  border: 1px solid #2a3a55;
  color: #e0e0e0;
  padding: 4px 8px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  width: 160px;
}
.custom-chars-editor-strip {
  margin-bottom: 8px;
}
.cc-frame-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.cc-thumb {
  background: #16213e;
  border: 1px solid #2a3a55;
  border-radius: 4px;
  padding: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.cc-thumb canvas {
  image-rendering: pixelated;
}
.cc-thumb.selected {
  border-color: #f5a623;
  box-shadow: 0 0 0 1px #f5a623 inset;
}
.cc-thumb-cap {
  font-size: 9px;
  color: #aaa;
  text-transform: uppercase;
}
.custom-chars-editor-canvas-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
#cc-edit-canvas {
  background: #000;
  border: 1px solid #2a3a55;
  image-rendering: pixelated;
}
.custom-chars-editor-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.custom-chars-editor-actions #cc-status {
  margin-left: auto;
  font-size: 11px;
}
