:root {
  --panel: rgba(20, 22, 34, 0.72);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e9e9f2;
  --muted: #9a9cb5;
  --accent: #ff4d7e;
  --accent-2: #ffb36b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #11121b;
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#app, #app canvas { position: fixed; inset: 0; display: block; }
#app canvas { outline: none; }

.panel-like {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#title {
  position: fixed;
  top: 16px;
  left: 18px;
  pointer-events: none;
}
#title h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
#title h1 span {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#title p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

/* tools */
#tools {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}
#tools button {
  position: relative;
  width: 64px;
  height: 60px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
#tools button span { font-size: 22px; line-height: 1; }
#tools button em { font-style: normal; font-size: 11px; color: var(--muted); }
#tools button kbd {
  position: absolute; top: 4px; right: 6px;
  font: 9px ui-monospace, monospace; color: #666a88;
}
#tools button:hover { background: rgba(255, 255, 255, 0.06); }
#tools button:active { transform: scale(0.96); }
#tools button.active {
  background: rgba(255, 77, 126, 0.16);
  border-color: rgba(255, 77, 126, 0.55);
}
#tools button.active em { color: #ffd0dc; }

/* actions */
#actions {
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100vw - 340px);
}
#actions button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}
#actions button:hover { background: rgba(255, 255, 255, 0.12); }
#actions button:active { transform: scale(0.95); }
#actions button.on { background: rgba(255, 179, 107, 0.25); border-color: rgba(255, 179, 107, 0.6); }
#actions .sep { width: 1px; height: 24px; background: rgba(255, 255, 255, 0.12); margin: 0 4px; }

#hud {
  position: fixed;
  left: 18px;
  bottom: 14px;
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  pointer-events: none;
  white-space: pre;
}

#hint {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  font-size: 11.5px;
  color: var(--muted);
  pointer-events: none;
  white-space: nowrap;
}
#hint b { color: #c9cbe0; font-weight: 600; }
kbd {
  font: 10px ui-monospace, monospace;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #c9cbe0;
}

#toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate(-50%, -20px);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(20, 22, 34, 0.85);
  border: 1px solid var(--panel-border);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* lil-gui theme */
.lil-gui.root {
  --background-color: rgba(20, 22, 34, 0.82);
  --widget-color: rgba(255, 255, 255, 0.07);
  --hover-color: rgba(255, 255, 255, 0.12);
  --focus-color: rgba(255, 255, 255, 0.16);
  --number-color: #ffb36b;
  --string-color: #9fe3b0;
  --title-background-color: rgba(255, 255, 255, 0.04);
  --font-size: 11.5px;
  --input-font-size: 11.5px;
  --widget-height: 21px;
  --name-width: 44%;
  --folder-indent: 6px;
  position: fixed !important;
  top: 12px !important;
  right: 12px !important;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.lil-gui.root > .title { font-weight: 700; letter-spacing: 0.3px; }
.lil-gui .controller.boolean input:checked { background: var(--accent); }

body.hide-ui #tools, body.hide-ui #actions, body.hide-ui #hint, body.hide-ui #hud,
body.hide-ui #title, body.hide-ui .lil-gui.root { display: none !important; }

@media (max-width: 800px) {
  #hint { display: none; }
  #actions { bottom: 12px; max-width: calc(100vw - 24px); }
  #tools { top: auto; bottom: 120px; transform: none; }
  #tools button { width: 52px; height: 50px; }
  .lil-gui.root { max-height: 45vh; }
}
