:root {
  --bg-0: #0b0d12;
  --bg-1: #11141b;
  --bg-2: #171b24;
  --bg-3: #1f2532;
  --line: #262d3b;
  --text: #e6ebf2;
  --text-dim: #98a2b3;
  --text-mute: #6b7383;
  --accent: #f5a524;
  --accent-2: #fbbf24;
  --danger: #ef4444;
  --ok: #10b981;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(245,165,36,.08), transparent 60%), var(--bg-0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,13,18,.7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px;
  background:
    linear-gradient(var(--accent), var(--accent)) center / 2px 14px no-repeat,
    linear-gradient(var(--accent), var(--accent)) center / 14px 2px no-repeat,
    radial-gradient(circle at center, var(--accent) 1px, transparent 2px);
}
.brand-name { font-weight: 700; letter-spacing: .02em; text-transform: lowercase; }
.header-actions { display: flex; gap: 8px; }

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 18px;
  padding: 18px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 20px;
  box-shadow: var(--shadow);
}
.panel-title { margin: 2px 0 14px; font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-dim); }
.panel-subtitle { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-mute); }

.controls { max-height: calc(100vh - 100px); overflow-y: auto; position: sticky; top: 78px; }
.controls::-webkit-scrollbar { width: 8px; }
.controls::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { display: flex; justify-content: space-between; align-items: baseline; color: var(--text-dim); font-size: 12px; }
.field output { color: var(--text); font-family: var(--mono); font-size: 12px; }
.field.tight { margin-bottom: 8px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.row.triple { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; user-select: none; font-size: 12px; }
.check input { accent-color: var(--accent); }

input[type="text"], input[type="number"], select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 13px;
  width: 100%;
}
textarea { font-size: 12px; resize: vertical; }
input[type="text"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(245,165,36,.18);
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; background: var(--bg-3); border-radius: 999px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--bg-0);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--bg-0);
}

input[type="color"] { width: 100%; height: 38px; border: 1px solid var(--line); background: var(--bg-2); border-radius: 6px; cursor: pointer; padding: 4px; }

.btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--bg-3); border-color: #354056; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #1a1308; border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; }

.preview-panel { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.preview-stage {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  aspect-ratio: 16 / 10;
  width: 100%;
}
.preview-stage canvas { display: block; width: 100%; height: 100%; }
.bg-toggle { position: absolute; top: 10px; left: 10px; display: flex; gap: 4px; z-index: 2; }
.bg-btn {
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.15);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.bg-btn.active { color: var(--accent); border-color: var(--accent); }

.output-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .output-grid { grid-template-columns: 1fr; } }

.output-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.output-head { display: flex; justify-content: space-between; align-items: center; }
.output-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-dim); font-weight: 600; }
.muted { color: var(--text-mute); font-weight: 400; text-transform: none; letter-spacing: 0; }
.msg { color: var(--text-mute); font-size: 11px; min-height: 14px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }

.lib-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.lib-list:empty::before { content: "No saved crosshairs yet."; color: var(--text-mute); font-size: 12px; }
.lib-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-bottom: 1px solid var(--line);
}
.lib-list li:last-child { border-bottom: none; }
.lib-list .lib-name { flex: 1; font-size: 13px; cursor: pointer; }
.lib-list .lib-name:hover { color: var(--accent); }
.lib-list .lib-code { font-family: var(--mono); font-size: 10px; color: var(--text-mute); }
.lib-list .lib-actions { display: flex; gap: 4px; }
.lib-list .lib-actions button { font-size: 11px; padding: 4px 8px; }
