:root {
  --bg: #06060d;
  --panel: rgba(255,255,255,0.04);
  --panel-border: rgba(120,180,255,0.14);
  --cyan: #4fd8ff;
  --violet: #a06bff;
  --text: #d8dcf0;
  --muted: #7a80a0;
  --glow: 0 0 18px rgba(79,216,255,0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Space Grotesk', sans-serif;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(160,107,255,0.12), transparent 55%),
    radial-gradient(ellipse at 85% 90%, rgba(79,216,255,0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* subtle star specks */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 15% 25%, #fff, transparent),
    radial-gradient(1px 1px at 65% 15%, #cfe, transparent),
    radial-gradient(1px 1px at 40% 70%, #fff, transparent),
    radial-gradient(1px 1px at 80% 55%, #fff, transparent),
    radial-gradient(1px 1px at 25% 90%, #ecf, transparent),
    radial-gradient(1px 1px at 90% 30%, #fff, transparent);
  opacity: 0.5;
}

header, main, footer, #loaderPanel { position: relative; z-index: 1; }

/* ---- header ---- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: #0a0a15cc;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--panel-border);
  flex-wrap: wrap; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 30px; filter: drop-shadow(0 0 8px var(--cyan)); }
#topbar h1 {
  font-weight: 700; font-size: 24px; letter-spacing: 1px;
  color: #eaf6ff; text-shadow: var(--glow);
}
.tagline { font-size: 12px; color: var(--muted); font-weight: 300; }
#statusReadout {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--cyan); background: rgba(79,216,255,0.08);
  border: 1px solid var(--panel-border); padding: 6px 12px; border-radius: 6px;
}

/* ---- loader ---- */
#loaderPanel { padding: 16px 22px 6px; }
/* Visually hide the real input but keep it clickable/programmatically triggerable.
   We deliberately avoid the `hidden` attribute — some browsers refuse to open
   the picker for a display:none input triggered from script. */
#fileInput {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.browse-btn { width: auto; display: inline-block; margin: 10px auto 4px; padding: 10px 22px; }
#dropzone {
  border: 2px dashed rgba(120,180,255,0.3);
  border-radius: 12px; padding: 20px; text-align: center;
  cursor: pointer; transition: all .2s;
  background: rgba(120,180,255,0.03);
}
#dropzone:hover, #dropzone.drag-over {
  border-color: var(--cyan); background: rgba(79,216,255,0.08);
  box-shadow: var(--glow);
}
.dz-title { font-size: 16px; font-weight: 700; color: #eaf6ff; }
.dz-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.dz-note {
  font-size: 10px; color: var(--cyan); margin-top: 8px; opacity: 0.75;
  font-family: 'JetBrains Mono', monospace;
}

#thumbStrip {
  display: flex; gap: 10px; overflow-x: auto; padding: 12px 2px;
}
.thumb {
  position: relative; flex: 0 0 auto; width: 90px;
  border: 1px solid var(--panel-border); border-radius: 8px;
  overflow: hidden; cursor: pointer; background: #0d0d18;
  transition: all .15s;
}
.thumb:hover { border-color: var(--cyan); }
.thumb.is-ref { border-color: var(--violet); box-shadow: 0 0 12px rgba(160,107,255,0.5); }
.thumb img { width: 100%; height: 60px; object-fit: cover; display: block; }
.thumb-name {
  display: block; font-size: 9px; color: var(--muted);
  padding: 3px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: 'JetBrains Mono', monospace;
}
.ref-badge {
  position: absolute; top: 3px; left: 3px; font-size: 8px;
  background: var(--violet); color: #fff; padding: 1px 5px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
}
.thumb-x {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px;
  border: none; border-radius: 4px; background: #000a; color: #f88;
  cursor: pointer; font-size: 11px; line-height: 1;
}
.thumb-x:hover { background: #f44; color: #fff; }

/* ---- workspace layout ---- */
#workspace {
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 14px; padding: 8px 22px 22px;
  flex: 1; min-height: 0;
}
.panel { display: flex; flex-direction: column; gap: 14px; }
.section {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 14px; backdrop-filter: blur(6px);
}
.section h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--cyan); margin-bottom: 12px; font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

/* controls */
.ctrl {
  display: block; font-size: 12px; color: var(--muted);
  margin-bottom: 12px; font-family: 'JetBrains Mono', monospace;
}
.ctrl span { color: var(--cyan); }
.ctrl input[type=range] { width: 100%; margin-top: 6px; accent-color: var(--cyan); }
select, input[type=number] {
  width: 100%; margin-top: 6px; background: #0d0d18; color: var(--text);
  border: 1px solid var(--panel-border); border-radius: 6px; padding: 7px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
}

.mode-toggle { display: flex; gap: 6px; margin-bottom: 14px; }
.mode-btn {
  flex: 1; padding: 8px; border: 1px solid var(--panel-border);
  background: transparent; color: var(--muted); border-radius: 7px;
  cursor: pointer; font-family: 'Space Grotesk', sans-serif; font-size: 12px;
  transition: all .15s;
}
.mode-btn.active { background: rgba(79,216,255,0.14); color: var(--cyan); border-color: var(--cyan); }

.glow-btn {
  width: 100%; padding: 11px; margin: 4px 0 10px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: #06060d; font-weight: 700; border: none; border-radius: 8px;
  cursor: pointer; font-family: 'Space Grotesk', sans-serif; font-size: 13px;
  transition: all .2s; box-shadow: 0 0 0 rgba(79,216,255,0);
}
.glow-btn:hover:not(:disabled) { box-shadow: var(--glow); transform: translateY(-1px); }
.glow-btn:disabled { opacity: 0.4; cursor: wait; }
.ghost-btn {
  width: 100%; padding: 8px; background: transparent; color: var(--muted);
  border: 1px solid var(--panel-border); border-radius: 7px; cursor: pointer;
  font-size: 12px; font-family: 'Space Grotesk', sans-serif; transition: all .15s;
}
.ghost-btn:hover { color: var(--cyan); border-color: var(--cyan); }

.nudge-pad { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 12px 0; }
.nudge-row { display: flex; gap: 40px; }
.nudge {
  width: 40px; height: 40px; border-radius: 8px; cursor: pointer;
  background: rgba(79,216,255,0.08); color: var(--cyan);
  border: 1px solid var(--panel-border); font-size: 16px; transition: all .12s;
}
.nudge:hover { background: rgba(79,216,255,0.2); box-shadow: var(--glow); }
.offset-inputs { display: flex; gap: 10px; }
.offset-inputs label { flex: 1; font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.hint { font-size: 10px; color: var(--muted); margin-top: 10px; line-height: 1.4; }

.progress { height: 6px; background: #0d0d18; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress .bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width .15s; }
.results { max-height: 130px; overflow-y: auto; }
.result-line {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; color: #8fe;
  padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.stack-msg { font-size: 11px; color: var(--muted); min-height: 16px; font-family: 'JetBrains Mono', monospace; }
.stack-msg.flash { animation: flashIn .5s ease; color: var(--cyan); }
@keyframes flashIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- center canvas ---- */
#centerPanel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#canvasWrap {
  position: relative; flex: 1; min-height: 340px;
  background: #04040a; border: 1px solid var(--panel-border);
  border-radius: 12px; overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.6);
}
#mainCanvas { width: 100%; height: 100%; display: block; touch-action: none; outline: none; cursor: grab; }
#mainCanvas:active { cursor: grabbing; }

#emptyState {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 20px;
}
.star-field {
  width: 120px; height: 120px; margin-bottom: 18px; border-radius: 50%;
  background:
    radial-gradient(2px 2px at 30% 30%, #fff, transparent),
    radial-gradient(2px 2px at 70% 40%, #9df, transparent),
    radial-gradient(1px 1px at 50% 60%, #fff, transparent),
    radial-gradient(2px 2px at 20% 80%, #ecf, transparent),
    radial-gradient(1px 1px at 80% 75%, #fff, transparent),
    radial-gradient(circle at 50% 50%, rgba(160,107,255,0.25), transparent 70%);
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle { 0%,100% { opacity: 0.7; } 50% { opacity: 1; } }
.empty-title { font-size: 18px; color: #eaf6ff; font-weight: 700; }
.empty-sub { font-size: 13px; color: var(--muted); margin-top: 6px; max-width: 320px; }

#viewControls {
  display: flex; align-items: center; gap: 10px;
}
#viewControls .ghost-btn { width: auto; }
.zoom-info { font-size: 11px; color: var(--muted); margin-left: auto; font-family: 'JetBrains Mono', monospace; }

.privacy-note { font-size: 10px; color: var(--muted); line-height: 1.5; margin-top: 8px; }

.hidden { display: none !important; }

/* ---- footer ---- */
#footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px; border-top: 1px solid var(--panel-border);
  font-size: 12px; color: var(--muted); flex-wrap: wrap; gap: 8px;
}
#footer a { color: var(--cyan); text-decoration: none; }
#footer a:hover { text-shadow: var(--glow); }

/* ---- responsive ---- */
@media (max-width: 900px) {
  #workspace { grid-template-columns: 1fr; }
  #canvasWrap { min-height: 300px; }
  .panel { flex-direction: row; flex-wrap: wrap; }
  .section { flex: 1; min-width: 240px; }
}
@media (max-width: 560px) {
  #topbar h1 { font-size: 20px; }
  .panel { flex-direction: column; }
}
</parameter>