:root {
  --bg: #1e1e1e;
  --panel: #2d2d2d;
  --panel-2: #333333;
  --line: #1a1a1a;
  --line-soft: #3d3d3d;
  --text: #cfcfcf;
  --muted: #8f8f8f;
  --hover: #3a3a3a;
  --active: #454545;
  --accent: #f0b232;
  --accent-text: #201503;
  --danger: #c05b52;
  --viewport: #191919;
}

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

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #454545; border-radius: 5px; border: 2px solid var(--panel); }
::-webkit-scrollbar-thumb:hover { background: #555; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
kbd {
  font: 10px/1 "Consolas", monospace;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 1px 4px 2px;
  background: #262626;
}

/* ---------- layout ---------- */

body { display: flex; flex-direction: column; }

#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 44px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.brand { font-size: 12px; font-weight: 700; letter-spacing: .12em; color: #e6e6e6; }
.brand span { color: var(--muted); font-weight: 400; margin-left: 4px; }

.top-group { display: flex; align-items: center; gap: 8px; }
.top-group.push { margin-left: auto; }

#main { display: flex; flex: 1; min-height: 0; }

#left, #right {
  background: var(--panel);
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#left { width: 216px; border-right: 1px solid var(--line); }
#right { width: 216px; border-left: 1px solid var(--line); }

#left section, #right section { padding: 12px; border-bottom: 1px solid var(--line); }
#left section.grow, #right section.grow { flex: 1; min-height: 0; }
#left section.grow, #right section.scroll { overflow-y: auto; }

h2 {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { font-size: 11px; color: var(--muted); margin-top: 6px; white-space: nowrap; }
.hint:first-child { margin-top: 0; }

/* ---------- buttons ---------- */

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 5px 11px;
  font-size: 12.5px;
  transition: background .1s;
}
.btn:hover { background: var(--hover); }
.btn:active { background: var(--active); }
.btn.icon { width: 26px; padding: 5px 0; text-align: center; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.btn.primary:hover { background: #f7c14f; }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.zoom-group { display: flex; align-items: center; gap: 6px; margin-right: 8px; }
#zoomPct { font-size: 12px; color: var(--muted); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- tools ---------- */

.tools { display: flex; flex-direction: column; gap: 4px; }
.tool {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 12.5px;
  text-align: left;
}
.tool svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
.tool kbd { margin-left: auto; }
.tool:hover { background: var(--hover); }
.tool.on { background: var(--active); border-color: var(--line-soft); }
.tool.on svg { color: var(--accent); }

/* ---------- palette ---------- */

.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.asset-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px 6px;
  background: #272727;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  transition: background .1s;
}
.asset-tile:hover { background: var(--hover); }
.asset-tile.on { border-color: var(--accent); background: #3a3324; }
.asset-tile .thumb {
  height: 44px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.asset-tile img {
  image-rendering: pixelated;
  max-width: 74px;
  max-height: 44px;
}
.asset-tile span {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.2;
  text-align: center;
}
.asset-tile.on span { color: var(--text); }

/* ---------- viewport ---------- */

#viewport { flex: 1; min-width: 0; position: relative; background: var(--viewport); }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- inspector ---------- */

.kv { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.kv span:first-child { color: var(--muted); }
.kv:last-child { margin-bottom: 0; }

.row2 { display: flex; gap: 8px; margin: 10px 0 2px; }
.row2 label { flex: 1; font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
input[type="number"] {
  width: 100%;
  background: #262626;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  color: var(--text);
  font: 12px "Segoe UI", system-ui, sans-serif;
  padding: 4px 6px;
}
input[type="number"]:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

.slider-row { display: block; font-size: 11px; color: var(--muted); margin: 10px 0 4px; }
.slider-row span { float: right; }
input[type="range"] { width: 100%; margin-top: 6px; accent-color: var(--accent); }

.btn-row { display: flex; gap: 6px; margin-top: 8px; }
.btn-row .btn { flex: 1; padding: 5px 0; font-size: 12px; }

textarea {
  width: 100%;
  background: #262626;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  color: var(--text);
  font: 12px/1.5 "Segoe UI", system-ui, sans-serif;
  padding: 7px 8px;
  resize: vertical;
  min-height: 70px;
}
textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
textarea::placeholder { color: #6e6e6e; }
.tiny { font-size: 11px; margin-top: 6px; line-height: 1.4; }

.ins-tip {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
  margin: 6px 0 2px;
}

/* ---------- shortcuts ---------- */

.short-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 12px;
  align-items: center;
  font-size: 12px;
  color: #b9b9b9;
}
.short-grid kbd { justify-self: start; white-space: nowrap; }

/* ---------- tooltip ---------- */

#tooltip {
  position: fixed;
  z-index: 60;
  max-width: 240px;
  background: #232323;
  border: 1px solid #464646;
  border-radius: 5px;
  padding: 8px 11px;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
#tooltip strong { font-size: 12.5px; color: #e4e4e4; }
#tooltip p { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin-top: 3px; }
#tooltip[hidden] { display: none; }

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 20px;
  width: 560px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.modal-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }

.size-cards { display: flex; gap: 10px; margin-top: 16px; }
.size-card {
  flex: 1;
  background: #272727;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: border-color .1s, background .1s;
}
.size-card:hover { border-color: var(--accent); background: #2e2b22; }
.size-card strong { font-size: 13px; margin-top: 8px; }

.size-diagram {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  width: 64px;
  height: 36px;
}
.size-diagram.wide { grid-template-columns: 1fr 1fr; width: 92px; }
.size-diagram.large { grid-template-columns: 1fr 1fr; width: 92px; height: 52px; }
.size-diagram i { background: #4a3a68; border: 1px solid #6a5494; border-radius: 2px; }

.modal-foot { display: flex; justify-content: flex-end; margin-top: 16px; }
