@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=IBM+Plex+Sans:wght@400;600&display=swap");

:root {
  --bg: #0e1114;
  --panel: #171b20;
  --border: #2a323a;
  --text: #e6ebe8;
  --muted: #8a9690;
  --accent: #3d9a6a;
  --accent-dim: #2a6b4a;
  --warn: #c9a227;
  --danger: #c45c4a;
  --grid: #1c2228;
  --pixel-on: #d8f0e0;
  --pixel-sel: #5ecf8e;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 13px;
}

#app {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 420px);
  grid-template-rows: 48px 1fr;
  height: 100%;
}

header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
header h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
header .meta { color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 12px; }
header .actions { margin-left: auto; display: flex; gap: 8px; }

button, select, input[type="number"] {
  background: #222830;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}
button.primary { background: var(--accent-dim); border-color: var(--accent); }
button.danger { border-color: var(--danger); color: #f0c4bc; }
button:hover { filter: brightness(1.08); }

.workspace {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  background:
    radial-gradient(ellipse at 30% 20%, #152018 0%, transparent 50%),
    var(--bg);
  overflow: auto;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.zoom-group { display: flex; gap: 4px; }
.zoom-group button.active {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.canvas-wrap {
  position: relative;
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  background: #000;
  line-height: 0;
}

#screen {
  display: block;
  width: auto;
  height: auto;
  cursor: crosshair;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  max-width: 520px;
  text-align: center;
}

.sidebar {
  border-left: 1px solid var(--border);
  background: var(--panel);
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar h2 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.el-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  background: #12161a;
}
.el-card.active { border-color: var(--accent); }
.el-card .row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.el-card label { color: var(--muted); font-size: 12px; min-width: 52px; }
.el-card .title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.el-card input[type="number"] { width: 56px; }

.reticle-tools {
  /* Keep painter from being crushed by narrow sidebar */
  min-width: 0;
}
.reticle-tools .pix-scroll {
  margin-top: 8px;
  max-width: 100%;
  max-height: min(70vh, 520px);
  overflow: auto;
  border: 1px solid var(--border);
  background: #0a0c0e;
  border-radius: 4px;
  /* Prefer horizontal scroll over squashing cells */
  overscroll-behavior: contain;
}
.reticle-tools .pix-scroll canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  /* Never let CSS shrink the paint surface */
  flex-shrink: 0;
}

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a2420;
  border: 1px solid var(--accent);
  padding: 8px 14px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 20;
}
.toast.show { opacity: 1; }
