:root {
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-solid: #0e152a; /* solid counterpart for opaque cards */
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #e6ecf2;
  --muted: #98a2b3;
  --accent: #7dd3fc;
  --primary: #16a34a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg); /* solid background to avoid gradient bleed */
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  backdrop-filter: saturate(140%) blur(6px);
  position: sticky; top: 0; z-index: 10;
}

.app-header h1 { font-size: 18px; margin: 0; letter-spacing: 0.4px; }
.app-header .status { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }

.app-main {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  padding: 18px; /* align with header side padding */
  height: calc(100% - 64px);
}

.controls {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0; /* prevent grid-min-content overflow */
  overflow: hidden; /* ensure content does not bleed out */
}

.control-group { display: flex; flex-direction: column; gap: 6px; width: 100%; min-width: 0; }
.control-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.control-group label { font-size: 12px; color: var(--muted); }
.control-group input[type="text"],
.control-group select {
  background: #0e152a;
  color: var(--text);
  border: 1px solid #1f2a44;
  border-radius: 8px;
  padding: 8px 10px;
}

.control-group input.invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.18) inset;
}

/* Narrow slider styling for clarity */
input[type="range"] {
  accent-color: var(--primary);
}

input[type="range"] { width: 100%; }

.toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px 12px; align-items: center; width: 100%; }
.toggles label { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }

.buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
button { white-space: nowrap; }
button {
  background: #0e152a;
  color: var(--text);
  border: 1px solid #1f2a44;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
button.primary { background: linear-gradient(180deg, #1a2b49, #12213d); border-color: #294168; }
button:hover { filter: brightness(1.1); }

.stage {
  position: relative;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
}

canvas#canvas { width: 100%; height: 100%; display: block; }

.hint {
  position: absolute;
  right: 12px; bottom: 12px;
  font-size: 12px; color: var(--muted);
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 6px 8px;
  border-radius: 8px;
}

.app-footer { padding: 8px 18px; color: var(--muted); border-top: 1px solid var(--panel-border); }

@media (max-width: 900px) {
  .app-main { grid-template-columns: 1fr; height: auto; padding: 12px; }
  .stage { min-height: 56vh; }
  .app-header .status { display: none; }
}

/* Inline help and tooltips */
.help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 6px;
  font-size: 11px; color: var(--accent);
  border: 1px solid #1f2a44; border-radius: 50%;
  background: #0e152a; cursor: help;
}
.inline-help { margin-top: 4px; }
.inline-help summary { cursor: pointer; color: var(--muted); }
.inline-help summary:hover { color: var(--text); }
.inline-help .help-content { color: var(--muted); font-size: 12px; padding: 6px 0 0; }

/* Info section below the main area */
.info {
  margin: 12px 18px 18px; /* align with main/header sides */
  background: var(--panel-solid); /* opaque background to block page gradient */
  border: 0; /* avoid any outside bleed */
  border-radius: 12px;
  padding: 16px;
  /* Removed gradients/blur for a clean card */
  background-clip: padding-box; /* prevent background under the border */
  overflow: hidden; /* clip children to rounded corners */
  box-shadow: inset 0 0 0 1px var(--panel-border); /* crisp inner stroke */
}
.info h2 { margin: 0 0 8px; font-size: 16px; letter-spacing: 0.2px; }
.info h3 { margin: 14px 0 6px; font-size: 14px; color: var(--text); }
.info p { color: var(--muted); margin: 0 0 8px; }
.info ul { margin: 0; padding-left: 18px; color: var(--muted); }
.info code { background: #0e152a; border: 1px solid #1f2a44; padding: 0 4px; border-radius: 4px; }
.info-grid {
  display: grid; gap: 12px; grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 1200px) { .info-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .info-grid { grid-template-columns: 1fr; } }
