/* ============================================================
   RenderMaker — workbench redesign
   ============================================================ */

:root {
  /* Surface system — warm charcoal with a very faint red tint */
  --bg-0: #0f172a;
  --bg-1: #111c30;
  --bg-2: #1e293b;
  --bg-3: #27364d;
  --bg-4: #334155;
  --line: rgba(71, 85, 105, 0.42);
  --line-strong: #475569;

  /* Ink */
  --ink-0: #f8fafc;
  --ink-1: #e2e8f0;
  --ink-2: #cbd5e1;
  --ink-3: #94a3b8;
  --ink-4: #64748b;

  /* Accent — crimson, pulled from the roster overlays */
  --accent: #6366f1;
  --accent-hot: #818cf8;
  --accent-dim: #4f46e5;
  --accent-tint: rgba(99, 102, 241, 0.14);
  --accent-ring: rgba(99, 102, 241, 0.35);

  /* Focus/utility */
  --good: #10b981;
  --warn: #f59e0b;

  /* Shadow */
  --shadow-1: 0 1px 2px rgba(2, 6, 23, 0.35);
  --shadow-2: 0 10px 30px -12px rgba(2, 6, 23, 0.58), 0 2px 6px rgba(2, 6, 23, 0.32);
  --shadow-3: 0 30px 60px -20px rgba(2, 6, 23, 0.62), 0 6px 14px rgba(2, 6, 23, 0.36);

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Type */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Metrics */
  --panel-w: 280px;
  --rail-w: 260px;
  --gap: 14px;
}

/* Light mode overrides */
.light {
  --bg-0: #f9fafb;
  --bg-1: #ffffff;
  --bg-2: #f3f4f6;
  --bg-3: #e5e7eb;
  --bg-4: #e2e8f0;
  --line: rgba(203, 213, 225, 0.64);
  --line-strong: #94a3b8;
  --ink-0: #111827;
  --ink-1: #1f2937;
  --ink-2: #4b5563;
  --ink-3: #6b7280;
  --ink-4: #94a3b8;
  --accent-tint: #dbeafe;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-2: 0 10px 30px -12px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-3: 0 30px 60px -20px rgba(15, 23, 42, 0.18), 0 6px 14px rgba(15, 23, 42, 0.08);
}

/* ===== Reset ===== */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-0);
  color: var(--ink-1);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--accent-tint), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(16, 185, 129, 0.08), transparent 60%),
    var(--bg-0);
  background-attachment: fixed;
}

h1, h2, h3, h4 {
  color: var(--ink-0);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
}

p { margin: 0; }

/* ===== Header / App chrome ===== */
header.app-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--gap);
  padding: 10px 18px;
  background: color-mix(in oklab, var(--bg-1) 80%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.Render-maker {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: block;
  flex: 0 0 auto;
  background: center / contain no-repeat url("icon.ico?v=2");
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-1);
}
.Render-maker::before,
.Render-maker::after {
  content: none;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-0);
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand-name small {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 400;
  letter-spacing: 0.04em;
}

.app-crumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 12px;
  justify-self: center;
}
.app-crumbs .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); }
.app-crumbs .sep { color: var(--ink-4); }

.app-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

/* ===== Layout: three-column workbench ===== */
main.workbench {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr var(--panel-w);
  gap: var(--gap);
  padding: var(--gap);
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
}

/* ===== Panels ===== */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel + .panel { margin-top: var(--gap); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in oklab, var(--bg-2) 80%, transparent), transparent);
}
.panel-head h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  font-weight: 600;
}
.panel-head .tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-2);
}
.panel-body { padding: 12px; }
.panel-body.tight { padding: 8px; }

/* ===== Left rail / drop area ===== */
.left-rail { min-width: 0; }

.drop-area {
  position: relative;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  background:
    repeating-linear-gradient(
      45deg,
      transparent 0 10px,
      color-mix(in oklab, var(--accent) 4%, transparent) 10px 11px
    ),
    var(--bg-2);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .18s, background .18s, color .18s, transform .18s;
}
.drop-area:hover,
.drop-area.hover {
  border-color: var(--accent);
  color: var(--ink-0);
  background:
    repeating-linear-gradient(
      45deg,
      transparent 0 10px,
      var(--accent-tint) 10px 11px
    ),
    var(--bg-2);
}
.drop-area .drop-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  color: var(--accent);
  margin-bottom: 10px;
  font-size: 18px;
}
.drop-area .drop-title {
  color: var(--ink-0);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.drop-area .drop-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}
.drop-area.compact {
  padding: 14px;
}
.drop-area.compact .drop-title { font-size: 12px; }

input[type="file"] { display: none; }

/* ===== Layer list (left rail) ===== */
.layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 10px;
}

.layer-row {
  position: relative;
  display: grid;
  grid-template-columns: 14px 26px minmax(0,1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  cursor: default;
  color: var(--ink-1);
  font-size: 12.5px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .12s;
}
.layer-row:hover {
  background: var(--bg-3);
  border-color: var(--line-strong);
}
.layer-row.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-ring);
}
.layer-row.dragging {
  opacity: 0.6;
  transform: scale(0.985);
}
.layer-row.drag-over-top { box-shadow: inset 0 2px 0 var(--accent); }
.layer-row.drag-over-bot { box-shadow: inset 0 -2px 0 var(--accent); }

.layer-row .layer-drag {
  width: 18px; height: 22px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  cursor: grab;
  font-size: 14px;
  line-height: 1;
  user-select: none;
  transition: color .15s;
}
.layer-row .layer-drag:hover { color: var(--ink-0); }
.layer-row .layer-drag:active { cursor: grabbing; }
.layer-row.dragging .layer-drag { cursor: grabbing; }

.layer-row .layer-swatch {
  width: 26px; height: 26px;
  border-radius: 5px;
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  display: grid; place-items: center;
  font-size: 11px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 600;
  overflow: hidden;
  background-image:
    conic-gradient(var(--bg-4) 0 25%, transparent 0 50%, var(--bg-4) 0 75%, transparent 0);
  background-size: 8px 8px;
}
.layer-row .layer-swatch img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.layer-row .layer-swatch.is-base {
  background: linear-gradient(135deg, var(--bg-3), var(--bg-0));
  color: var(--accent);
  background-image: none;
}

.layer-row .layer-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.layer-row .layer-name {
  font-size: 12.5px;
  color: var(--ink-0);
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  width: 100%;
  font-family: inherit;
  min-width: 0;
}
.layer-row .layer-name:focus {
  color: var(--accent);
}
.layer-row .layer-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
}

.layer-row .layer-actions {
  display: flex;
  gap: 2px;
  align-items: center;
}

.layer-row .lbtn {
  width: 24px; height: 24px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--ink-2);
  display: grid; place-items: center;
  transition: background .15s, color .15s, border-color .15s;
}
.layer-row .lbtn:hover {
  background: var(--bg-4);
  color: var(--ink-0);
  border-color: var(--line-strong);
}
.layer-row .lbtn.danger:hover {
  color: var(--accent-hot);
  border-color: var(--accent);
  background: var(--accent-tint);
}
.layer-row.hidden .lbtn.vis { color: var(--ink-4); }
.layer-row.hidden .layer-swatch { opacity: 0.35; }
.layer-row.hidden .layer-name { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-4); text-decoration-thickness: 1px; }

/* Inline opacity slider inside each layer row */
.layer-row .layer-opacity {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px dashed var(--line);
}
.layer-row .layer-opacity .oicon {
  color: var(--ink-3);
  display: grid;
  place-items: center;
}
.layer-row .layer-opacity .oval {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  min-width: 36px;
  text-align: right;
}
.layer-row .layer-opacity input[type="range"] {
  height: 3px;
}

/* Add-layer button at the bottom of the list */
.layer-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  width: 100%;
  border-radius: var(--r-sm);
  border: 1.5px dashed var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  margin-top: 4px;
  transition: border-color .15s, color .15s, background .15s;
}
.layer-add:hover {
  border-color: var(--accent);
  color: var(--ink-0);
  background: var(--accent-tint);
}

.layer-empty {
  text-align: center;
  padding: 18px 8px;
  color: var(--ink-3);
  font-size: 12px;
  font-family: var(--font-mono);
}

/* ===== Canvas stage ===== */
.stage {
  position: relative;
  background:
    linear-gradient(180deg, var(--bg-1), var(--bg-1)),
    var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.stage-toolbar .title {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-1);
  font-family: var(--font-mono);
  font-size: 12px;
}
.stage-toolbar .title b { color: var(--ink-0); font-weight: 500; }
.stage-toolbar .title .chip {
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  font-size: 10.5px;
}

.stage-toolbar .group {
  display: flex; gap: 6px; align-items: center;
}

/* The checkered transparency bg behind canvas */
.canvas-wrapper {
  position: relative;
  padding: 16px;
  display: grid;
  place-items: center;
  background:
    conic-gradient(var(--bg-3) 0 25%, transparent 0 50%, var(--bg-3) 0 75%, transparent 0)
      0 0 / 18px 18px,
    var(--bg-2);
  transition: background .18s, box-shadow .18s;
}

.canvas-wrapper.drag-hover {
  background:
    conic-gradient(var(--bg-3) 0 25%, transparent 0 50%, var(--bg-3) 0 75%, transparent 0)
      0 0 / 18px 18px,
    color-mix(in oklab, var(--accent) 16%, var(--bg-2));
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* Keep your canvas rules but retheme it */
#canvas {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  max-width: min(560px, 100%);
  aspect-ratio: 1 / 1;
  background: transparent;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-3);
  image-rendering: auto;
}

/* Overlays sit over the 1536x1536 canvas - critical to keep 1:1 */
.overlay-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  border-radius: var(--r-md);
}

.canvas-wrapper > div {
  position: relative;
  width: min(560px, 100%);
  aspect-ratio: 1 / 1;
}

/* ===== Actions under stage ===== */
.stage-actions {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  flex-wrap: wrap;
  justify-content: center;
}

#preview {
  display: block;
  max-width: min(480px, 100%);
  margin: 14px auto 0;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: #000;
}

/* ===== Buttons ===== */
.btn {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
  color: var(--ink-1);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  user-select: none;
}
.btn:hover {
  background: var(--bg-3);
  color: var(--ink-0);
  border-color: var(--line-strong);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

.btn.icon { padding: 8px; width: 34px; height: 34px; }
.btn.tiny { padding: 4px 8px; font-size: 11px; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-2); border-color: var(--line); }

.btn.primary {
  background: linear-gradient(180deg, var(--accent-hot), var(--accent));
  border-color: color-mix(in oklab, var(--accent) 70%, black);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 6px 16px -6px var(--accent);
  font-weight: 600;
}
.btn.primary:hover {
  background: linear-gradient(180deg, var(--accent-hot), var(--accent-dim));
  color: #fff;
}

.btn.ok {
  border-color: color-mix(in oklab, var(--good) 30%, var(--line-strong));
  color: var(--good);
}
.btn.ok:hover { background: color-mix(in oklab, var(--good) 10%, var(--bg-2)); color: var(--good); }

.btn-active {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--ink-0);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

/* Legacy compat so the JS that toggles .btn-glass / .btn-primary classes keeps working */
.btn-glass { @apply; }
.btn-glass, .btn-primary {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  user-select: none;
}
.btn-glass {
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
  color: var(--ink-1);
}
.btn-glass:hover {
  background: var(--bg-3);
  color: var(--ink-0);
}
.btn-primary {
  border: 1px solid color-mix(in oklab, var(--accent) 70%, black);
  background: linear-gradient(180deg, var(--accent-hot), var(--accent));
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 6px 16px -6px var(--accent);
  font-weight: 600;
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent-hot), var(--accent-dim));
}
.btn-bubble { position: relative; overflow: hidden; }

/* ===== Right panel controls ===== */
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  font-weight: 600;
  margin: 0 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.section-title .hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  text-transform: none;
  letter-spacing: 0.01em;
  font-weight: 400;
}

/* Control pad (dpad) */
.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 12px;
}
.pad .btn {
  width: 100%;
  height: 34px;
  padding: 0;
  font-size: 14px;
}
.pad .btn.center {
  background: var(--bg-3);
  color: var(--ink-0);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

/* Two-up grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.grid-2 .btn {
  width: 100%;
  font-size: 12px;
  padding: 8px 10px;
}

/* Small labeled row */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
}
.row + .row { border-top: 1px dashed var(--line); }
.row .label {
  font-size: 13px;
  color: var(--ink-1);
  display: flex;
  align-items: center;
  gap: 8px;
}
.row .value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  min-width: 36px;
  text-align: right;
}

/* Slider */
.slider-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}
.slider-row .slabel {
  font-size: 12px;
  color: var(--ink-1);
  min-width: 68px;
  display: flex; align-items: center; gap: 6px;
}
.slider-row .slabel .dot {
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--accent);
}
.slider-row .slabel .dot.a { background: var(--accent); }
.slider-row .slabel .dot.b { background: var(--warn); }
.slider-row .slabel .dot.c { background: #38bdf8; }
.slider-row .slabel .dot.d { background: var(--good); }

.slider-row .sval {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  min-width: 34px;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-3);
  border-radius: 999px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ink-0);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-1);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ink-0);
  border: 1px solid var(--line-strong);
  cursor: pointer;
}

/* Checkbox / switch rows */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-1);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.toggle:hover { border-color: var(--line-strong); }
.toggle input { display: none; }
.toggle .sw {
  position: relative;
  width: 32px; height: 18px;
  border-radius: 999px;
  background: var(--bg-4);
  border: 1px solid var(--line-strong);
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.toggle .sw::after {
  content: "";
  position: absolute;
  top: 1px; left: 1px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ink-1);
  transition: left .15s, background .15s;
}
.toggle input:checked + .sw {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle input:checked + .sw::after {
  left: 15px;
  background: #fff;
}
.toggle .tlabel {
  display: flex; align-items: center; gap: 8px;
  flex: 1;
}
.toggle .tsub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
}

.toggles-stack { display: flex; flex-direction: column; gap: 6px; }

/* tab segments */
.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.seg button {
  background: transparent;
  border: none;
  color: var(--ink-2);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.seg button.active {
  background: var(--bg-4);
  color: var(--ink-0);
}

/* Tiny stat cards */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.stat {
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.stat .k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  font-weight: 500;
}
.stat .v {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink-0);
  margin-top: 2px;
}

/* Tip list */
.tips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tips li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
}
.tips li::before {
  content: "›";
  color: var(--accent);
  font-weight: 600;
}

/* Kbd */
kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-1);
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  line-height: 1.5;
}

/* ===== Canvas fullscreen adjustments (keep JS compat) ===== */
.canvas-container:fullscreen,
.canvas-container:-webkit-full-screen {
  display: grid;
  place-items: center;
  background: var(--bg-0);
  width: 100%;
  height: 100%;
  padding: 10px;
  margin: 0;
}
.canvas-container:fullscreen .stage-toolbar,
.canvas-container:-webkit-full-screen .stage-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 110;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--bg-1) 82%, transparent);
  backdrop-filter: blur(10px);
}
.canvas-container:fullscreen .canvas-wrapper,
.canvas-container:-webkit-full-screen .canvas-wrapper {
  width: min(calc(100vw - 20px), calc(100vh - 20px));
  height: min(calc(100vw - 20px), calc(100vh - 20px));
  padding: 0;
  background: transparent;
}
.canvas-container:fullscreen .canvas-wrapper > div,
.canvas-container:-webkit-full-screen .canvas-wrapper > div {
  width: 100%;
  height: 100%;
  max-width: none;
}
.canvas-container:fullscreen #canvas,
.canvas-container:-webkit-full-screen #canvas {
  width: 100%;
  height: 100%;
  max-width: none;
  min-height: 0 !important;
}
.canvas-container:fullscreen #fullscreen-btn {
  position: absolute;
  bottom: 20px; right: 20px;
  z-index: 100;
  opacity: 0.7;
}
.canvas-container:fullscreen #fullscreen-btn:hover { opacity: 1; }

.fs-controls {
  position: absolute;
  top: 20px; right: 20px;
  display: none;
  gap: 8px;
  z-index: 101;
}
.canvas-container.fs-active #fullscreen-btn { display: none; }
.canvas-container.fs-active .fs-controls { display: flex; }
#control-panel.fs-overlay {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 420px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  display: none;
  z-index: 102;
  background: color-mix(in oklab, var(--bg-1) 90%, transparent);
  backdrop-filter: blur(12px);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  padding: 14px;
}
.canvas-container.fs-show-controls #control-panel.fs-overlay { display: block; }
.canvas-container.fs-moving-controls #control-panel.fs-overlay { cursor: move; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg-3);
  color: var(--ink-0);
  border: 1px solid var(--line-strong);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-family: var(--font-mono);
  z-index: 1000;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  box-shadow: var(--shadow-2);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Loading screen ===== */
#loading-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(600px 400px at 50% 50%, var(--accent-tint), transparent 70%),
    var(--bg-0);
  z-index: 10000;
  transition: opacity .5s;
}
#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}
#loading-screen .loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
#loading-screen .load-mark {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  position: relative;
  background: center / contain no-repeat url("icon.ico?v=2");
}
#loading-screen .load-mark::before {
  content: none;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(0.92); opacity: 0.6; }
}
#loading-screen .loader-bar {
  width: 240px;
  height: 3px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
}
#loading-screen .loader-progress {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-hot));
  box-shadow: 0 0 12px -2px var(--accent);
  transition: width .2s linear;
}
#loading-screen .progress-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  padding: 24px 16px 32px;
  letter-spacing: 0.04em;
}
.site-footer span { color: var(--accent); }

/* ===== Page-load animation ===== */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: no-preference) {
  body { opacity: 0; }
  body.page-loaded { animation: rise .6s ease-out forwards; }
  body.page-loaded .left-rail  { animation: rise .6s .05s ease-out both; }
  body.page-loaded .stage      { animation: rise .6s .12s ease-out both; }
  body.page-loaded .right-panel { animation: rise .6s .18s ease-out both; }
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  main.workbench {
    grid-template-columns: 1fr var(--panel-w);
  }
  .left-rail { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: start; }
  .left-rail .panel + .panel { margin-top: 0; }
}
@media (max-width: 780px) {
  main.workbench {
    grid-template-columns: 1fr;
  }
  :root { --panel-w: 100%; --rail-w: 100%; }
  .left-rail { grid-template-columns: 1fr; }
  header.app-bar { grid-template-columns: 1fr auto; }
  .app-crumbs { display: none; }
}

/* Hide legacy backgrounds inherited from old style.css */
.drop-area:focus, .drop-area:active { outline: none; }

/* Canvas border override - keep 1536x1536 intrinsic, dark bg so overlays pop */
