:root {
  color-scheme: light dark;
  /* lorenzodalcol.com: cream paper, black ink, navy for actions, brown labels */
  --bg: light-dark(#faf8f1, #111418);
  --surface: light-dark(#fffdf8, #181c21);
  --surface-2: light-dark(#f2eee3, #20252b);
  --border: light-dark(#e5e1d6, #2d333a);
  --text: light-dark(#000000, #e7e9ec);
  --muted: light-dark(#6b665c, #98a1ab);
  --accent: light-dark(#1f4e8c, #7ea7dd);
  --accent-text: light-dark(#faf8f1, #0d1116);
  --label: light-dark(#6f4e37, #c9a27f);
  --danger: light-dark(#b3261e, #f28b82);
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
}

a { color: var(--accent); text-underline-offset: 2px; }
h1, h2 { margin: 0; }

svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  h1 { font-size: 18px; }
  p { margin: 0; color: var(--muted); font-size: 13px; }
}

.logo { width: 38px; height: 38px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: 500 14px var(--font);
  text-decoration: none;
  cursor: pointer;
  &:hover { background: var(--surface-2); }
  &:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  &.ghost { border-color: transparent; background: transparent; }
  &.wide { width: 100%; }
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
  align-items: start;
}

.stage {
  position: relative;
  container-type: inline-size;
  border-radius: 14px;
  background: #000;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: min(100cqw, calc(100dvh - 140px));
  min-height: 300px;
  cursor: grab;
  touch-action: none;
  &:active { cursor: grabbing; }
}

.error {
  position: absolute;
  inset: auto 16px 16px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #3a1210;
  color: #f28b82;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);

  h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--label); }
  h2:not(:first-child) { margin-top: 10px; }
  p { margin: 0; }
}

.layers { display: flex; flex-direction: column; gap: 2px; }

.layer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  &:hover { background: var(--surface-2); }
  input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  font: 600 12px var(--mono);
}

.hint { color: var(--muted); font-size: 13.5px; }

.footer {
  padding: 4px 20px 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  p { margin: 0; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .brand p { display: none; }
}
