/* Default theme — dark. Chrome themes via CSS vars; the canvas stage
   stays dark in every theme because effects need contrast to read. */
:root,
:root[data-theme="dark"] {
  --bg: #0b0d12;
  --panel: #14171f;
  --panel-2: #1b1f2a;
  --border: #2a2f3d;
  --text: #e5e7eb;
  --muted: #8a91a3;
  --accent: #3b82f6;
  --accent-2: #8b5cf6;
  --hover: #20242f;
  --active-bg: #1f3454;
  --modal-pre-bg: #0a0c11;
  --modal-pre-text: #cbd5e1;
}

:root[data-theme="light"] {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #eef1f6;
  --border: #d6dbe4;
  --text: #161a23;
  --muted: #6a7283;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --hover: #e3e8f0;
  --active-bg: #dbeafe;
  --modal-pre-bg: #f7f8fb;
  --modal-pre-text: #1f2937;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overflow: hidden;
}
[x-cloak] { display: none !important; }

.layout {
  display: grid;
  grid-template-columns: 220px 1fr 340px;
  grid-template-rows: 48px 1fr 32px;
  grid-template-areas:
    "top  top   top"
    "left stage side"
    "foot foot  foot";
  height: 100vh;
}

/* Left sidebar — effect picker */
.left-sidebar {
  grid-area: left;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 8px;
}
.left-sidebar > .cat-title { margin: 0 4px 10px; }
.effect-group { margin-bottom: 14px; }
.effect-group-title {
  margin: 0 4px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.effect-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 8px 10px;
  margin-bottom: 4px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.effect-item:hover { background: var(--hover); border-color: var(--border); }
.effect-item.active {
  background: var(--active-bg);
  border-color: var(--accent);
  color: var(--accent);
}
.effect-item-name { display: block; font-weight: 600; font-size: 13px; }
.effect-item-desc {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}
.effect-item.active .effect-item-desc { color: rgba(59, 130, 246, 0.7); }

.sitefoot {
  grid-area: foot;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 11px;
  color: var(--muted);
}
.sitefoot a {
  color: var(--text);
  text-decoration: none;
}
.sitefoot a:hover { color: var(--accent); }

.bmc-link {
  background: #FFDD00;
  color: #0a0c11 !important;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
  transition: background .15s, transform .1s;
}
.bmc-link:hover {
  background: #ffe833;
  color: #0a0c11 !important;
  transform: translateY(-1px);
}

.btn.bmc-btn {
  background: #FFDD00;
  color: #0a0c11;
  border-color: #e6c700;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn.bmc-btn:hover { background: #ffe833; color: #0a0c11; }

.topbar {
  grid-area: top;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  /* 3-column grid: left | centered home button | right actions.
     Side columns are 1fr each so the centre column stays exactly centred
     regardless of how much content sits in the sides. */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.topbar-center {
  display: flex;
  justify-content: center;
}
.brand { font-weight: 600; color: var(--text); }
.brand-link { text-decoration: none; }
.brand-link:hover { color: var(--accent); }

/* "Back to home" button — solid success green so it's instantly visible
   and reads as a positive/safe navigation action distinct from the
   Export button (accent blue). White text enforced with !important so
   neither theme nor base .btn color rule can override it. */
.btn.home-btn {
  background: #16a34a;
  border-color: #15803d;
  color: #ffffff !important;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 16px;
  display: inline-flex;
  align-items: center;
}
.btn.home-btn:hover {
  background: #15803d;
  color: #ffffff !important;
  text-decoration: none;
}
.effect-name { color: var(--muted); }
.actions { display: flex; gap: 8px; justify-content: flex-end; }

.stage {
  grid-area: stage;
  background:
    linear-gradient(45deg, #0d0f15 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(-45deg, #0d0f15 25%, transparent 25%) 0 8px/16px 16px,
    linear-gradient(45deg, transparent 75%, #0d0f15 75%) 8px -8px/16px 16px,
    linear-gradient(-45deg, transparent 75%, #0d0f15 75%) -8px 0/16px 16px,
    #06080d;
  display: grid;
  place-items: center;
  overflow: hidden;
}
#stage {
  display: block;
  /* Driven by the Canvas BG dropdown — see app.js setCanvasBg(). */
  background: var(--canvas-bg, #000);
  /* width/height set inline by JS to match the active preview viewport */
}

.sidebar {
  grid-area: side;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}

.cat { margin-bottom: 16px; }
.cat-title {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.ctrl {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.ctrl-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text);
}
.ctrl-value {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.ctrl-desc {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.ctrl input[type="range"] { width: 100%; accent-color: var(--accent); }
.ctrl input[type="color"] { width: 100%; height: 28px; border: 1px solid var(--border); background: transparent; border-radius: 4px; }
.ctrl select {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 6px;
}
.ctrl-text {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit;
}
.ctrl-text:focus { outline: none; border-color: var(--accent); }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-knob {
  position: absolute;
  inset: 0;
  background: #2f3543;
  border-radius: 20px;
  transition: background .15s;
  cursor: pointer;
}
.slider-knob::before {
  content: "";
  position: absolute;
  height: 14px; width: 14px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s;
}
.switch input:checked + .slider-knob { background: var(--accent); }
.switch input:checked + .slider-knob::before { transform: translateX(16px); }

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
}
.btn:hover { background: var(--hover); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.btn.primary:hover { background: #2563eb; color: #ffffff; }

/* Export dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 200px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  padding: 4px;
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.dropdown-item {
  background: transparent;
  border: 0;
  text-align: left;
  padding: 8px 12px;
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--hover); }
.dropdown-item.active { background: var(--active-bg); color: var(--accent); }
.dropdown-item .dropdown-hint {
  float: right;
  margin-left: 12px;
  color: var(--muted);
  font-size: 11px;
}
.dropdown-item.active .dropdown-hint { color: var(--accent); opacity: 0.8; }
.dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: grid;
  place-items: center;
  z-index: 50;
}
.modal-card {
  width: min(900px, 92vw);
  max-height: 86vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}
.modal-card header {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-card header h2 {
  margin: 0;
  font-size: 14px;
  flex: 1;
}
.modal-card pre {
  margin: 0;
  padding: 14px;
  overflow: auto;
  background: var(--modal-pre-bg);
  color: var(--modal-pre-text);
  font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace;
}
