:root {
  --bg: #ffffff;
  --grid: #f1f1f4;
  --panel: #ffffff;
  --panel-border: #e4e4e9;
  --text: #1e1e1e;
  --muted: #6b6b78;
  --accent: #6965db;
  --accent-bg: #ece9ff;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; color: var(--text); background: var(--bg); }

#canvas { position: absolute; inset: 0; display: block; touch-action: none; cursor: crosshair; }

/* ===== top toolbar ===== */
.toolbar {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px; background: var(--panel);
  border: 1px solid var(--panel-border); border-radius: 12px;
  box-shadow: var(--shadow); z-index: 10;
}
.tool {
  position: relative;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 8px;
  color: var(--text); cursor: pointer; padding: 0;
}
.tool svg { width: 20px; height: 20px; }
.tool:hover { background: #f3f3f7; }
.tool.active { background: var(--accent-bg); color: var(--accent); }
.tool[data-key]::after {
  content: attr(data-key);
  position: absolute; right: 3px; bottom: 2px;
  font-size: 9px; color: var(--muted); pointer-events: none;
}
.tool-sep { width: 1px; height: 22px; background: var(--panel-border); margin: 0 6px; }

.hint {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  color: var(--muted); font-size: 12px; z-index: 5;
}
.hint kbd {
  font-family: inherit; font-size: 11px; padding: 1px 6px;
  border: 1px solid var(--panel-border); border-radius: 4px; background: #fafafc;
}

/* ===== side panel ===== */
.side-panel {
  position: fixed; top: 16px; left: 16px; bottom: 16px;
  width: 220px; background: var(--panel);
  border: 1px solid var(--panel-border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 14px 14px 18px;
  overflow-y: auto; z-index: 8;
}
.side-panel h4 {
  margin: 0 0 8px 0; font-size: 12px; font-weight: 500;
  color: var(--text); letter-spacing: 0.01em;
}
.side-panel section { margin-bottom: 14px; }
.side-panel .row {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap;
}
.side-panel .row.wrap { flex-wrap: wrap; }
.side-panel .row.between { justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 2px; }

.swatch {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--panel-border);
  background: #fff; cursor: pointer; padding: 0; position: relative;
  display: inline-flex; align-items: center; justify-content: center;
}
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.swatch svg { width: 22px; height: 22px; }
.swatch.custom { background: #1e1e1e; overflow: hidden; }
.swatch.custom input[type="color"] {
  width: 100%; height: 100%; border: 0; padding: 0; background: transparent; cursor: pointer;
}
.divider { width: 1px; height: 22px; background: var(--panel-border); margin: 0 2px; }

.pill {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px;
  background: #f5f5f8; border: 0; color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.pill:hover { background: #ececf2; }
.pill.active { background: var(--accent-bg); color: var(--accent); }
.pill svg { width: 18px; height: 14px; display: block; }

.line { display: inline-block; width: 18px; height: 0; border-top: 1.5px solid currentColor; }
.line.w1 { border-top-width: 1.5px; }
.line.w2 { border-top-width: 2.5px; }
.line.w3 { border-top-width: 4px; }
.line.dashed { border-top-style: dashed; }
.line.dotted { border-top-style: dotted; }

input[type="range"] {
  width: 100%; accent-color: var(--accent);
}

/* ===== topbar (scene selector) ===== */
.topbar {
  position: fixed; top: 16px; right: 16px; z-index: 11;
  display: flex; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 6px 10px; box-shadow: var(--shadow);
}
.topbar select, .topbar input[type="text"] {
  font: inherit; font-size: 13px; padding: 6px 8px;
  border: 1px solid var(--panel-border); border-radius: 8px; background: #fff; outline: none;
}
.topbar input[type="text"] { width: 200px; }
.topbar .status { font-size: 12px; color: var(--muted); margin-left: 6px; min-width: 120px; }
.topbar .folder-path { font-size: 12px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar a.pill { text-decoration: none; display: inline-flex; }
.topbar-sep { width: 1px; height: 22px; background: var(--panel-border); margin: 0 4px; }
.topbar-avatar { width: 26px; height: 26px; border-radius: 50%; background: #ddd; }

/* floating text editor */
#textInput {
  position: absolute; display: none; z-index: 20;
  background: transparent; border: 1px dashed var(--accent);
  outline: none; resize: none; overflow: hidden; padding: 2px 4px;
  color: inherit;
  font-family: "Virgil", "Comic Sans MS", cursive;
}
