:root {
  color-scheme: dark;
  --bg: #0a0f1c;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-border: rgba(255, 255, 255, 0.09);
  --accent: #5b8cff;
  --accent-soft: rgba(80, 130, 255, 0.14);
  --text: #e6edf6;
  --muted: #97a3b6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 25% 10%, #16223d, var(--bg) 70%);
  color: var(--text);
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid var(--panel-border);
  gap: 1rem;
}
.brand { display: flex; align-items: baseline; gap: 0.6rem; }
.brand h1 { font-size: 1.15rem; margin: 0; letter-spacing: -0.01em; }
.brand .tag {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: #8fb4ff; background: var(--accent-soft); padding: 0.18rem 0.5rem; border-radius: 999px;
}
.brand small { color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.2rem;
  padding: 1.2rem;
  align-items: start;
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1rem;
}
.panel h2 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); margin: 0 0 0.7rem;
}
.panel + .panel { margin-top: 1rem; }

.tool-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

button, .btn, label.btn {
  font: inherit;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 0.5rem 0.8rem;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover, .btn:hover, label.btn:hover { background: rgba(255, 255, 255, 0.1); }
button:disabled { opacity: 0.5; cursor: default; }

button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
  width: 100%; padding: 0.7rem; margin-top: 0.4rem;
}
button.primary:hover { background: #6f9bff; }

.field { margin-bottom: 0.7rem; }
.field label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.3rem; }
.field input[type="color"] { width: 100%; height: 34px; padding: 2px; border-radius: 8px; background: none; border: 1px solid var(--panel-border); }
.field select { width: 100%; padding: 0.45rem; border-radius: 8px; background: rgba(255,255,255,0.05); color: var(--text); border: 1px solid var(--panel-border); }
.checkbox { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--muted); }

.editor { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }

.side-tabs { display: flex; gap: 0.4rem; }
.side-tab {
  padding: 0.5rem 1.3rem; border-radius: 999px; font-weight: 600;
}
.side-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.stage-wrap {
  display: grid;
  place-items: center;
  padding: 1.4rem;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.03) 75%),
    linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.03) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
}
#stage { position: relative; }
#stage .canvas-container { position: absolute !important; top: 0; left: 0; }
#guide-overlay { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 5; }

.note {
  font-size: 0.78rem; color: #ffc98a; background: rgba(255, 180, 80, 0.1);
  border: 1px solid rgba(255, 180, 80, 0.25); padding: 0.5rem 0.7rem; border-radius: 9px;
  max-width: 540px; text-align: center;
}
.dims { font-size: 0.78rem; color: var(--muted); }
#status { min-height: 1.1em; font-size: 0.82rem; color: var(--muted); }

/* modal */
.modal {
  position: fixed; inset: 0; display: none; place-items: center;
  background: rgba(5, 8, 16, 0.7); backdrop-filter: blur(4px); z-index: 100;
}
.modal.open { display: grid; }
.modal .box {
  background: #131c30; border: 1px solid var(--panel-border); border-radius: 16px;
  padding: 2rem; text-align: center; max-width: 26rem; width: 90%;
}
.modal h3 { margin: 0 0 0.4rem; }
.modal .code {
  font-size: 2rem; font-weight: 700; letter-spacing: 0.08em; color: #8fb4ff;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; margin: 1rem 0;
  user-select: all;
}
.modal p { color: var(--muted); line-height: 1.5; }
.modal .actions { display: flex; gap: 0.6rem; justify-content: center; margin-top: 1.2rem; }
