@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&display=swap');

:root {
  --nc: #00fff9;
  --nm: #ff00ff;
  --ny: #ffff00;
  --nr: #ff003c;
  --ng: #00ff41;
  --bg: #030303;
  --bg2: #0a0a0f;
  --bg3: #0f0f1a;
  --panel: #0d0d18;
  --bdr: #1a1a2e;
  --txt: #c0c0d0;
  --dim: #555570;
}

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


body {
  background: var(--bg);
  color: var(--txt);
  font-family: 'Share Tech Mono', monospace;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}


header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--nc);
  background: var(--bg2);
  box-shadow: 0 0 20px rgba(0, 255, 249, .15);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.top-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--bdr);
  padding: 6px 20px;
  display: flex;
  justify-content: center;
  z-index: 90;
  flex-shrink: 0;
  min-height: 38px;
}

.logo {
  font-family: 'Orbitron', monospace;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--nc);
  text-shadow: 0 0 10px var(--nc), 0 0 30px rgba(0, 255, 249, .4);
}

.logo span {
  color: var(--nm);
  text-shadow: 0 0 10px var(--nm);
}

.hst {
  font-size: 11px;
  color: var(--ng);
  text-shadow: 0 0 8px var(--ng);
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: .3;
  }
}

.app {
  display: grid;
  grid-template-columns: 255px 1fr 285px;
  grid-template-rows: minmax(0, 1fr);
  flex: 1;
  overflow: hidden;
  min-height: 0;
}


.pl, .pr {
  background: var(--panel);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
  height: 100%;
}


.pl {
  border-right: 1px solid var(--bdr);
}

.pr {
  border-left: 1px solid var(--bdr);
}

.stitle {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--nc);
  padding: 4px 0;
  border-bottom: 1px solid var(--bdr);
  margin-bottom: 2px;
  text-transform: uppercase;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.effects-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.effects-grid.live-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.effects-grid.live-mode .ecard {
  padding: 6px;
}

.effects-grid.live-mode .ename {
  font-size: 8px;
  margin-bottom: 0;
}

.effects-grid.live-mode .edesc {
  display: none;
}

.ecard {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  border-radius: 2px;
  padding: 7px 10px;
  cursor: pointer;
  transition: .15s;
  position: relative;
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
}

.ecard:hover {
  border-color: var(--nc);
  background: rgba(0, 255, 249, .03);
}

.ename {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ddd;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.edesc {
  font-size: 10px;
  color: var(--dim);
  line-height: 1.4;
}

.ecard-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  margin-top: 6px;
  border-radius: 1px;
  overflow: hidden;
  display: none;
  border: 1px solid var(--bdr);
  position: relative;
}

.ecard.has-preview .ecard-preview {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ecard-preview canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  opacity: 0.8;
}

.ecard:hover .ecard-preview canvas {
  opacity: 1;
}

.ecard:hover .add-btn {
  opacity: 0.6;
}

/* Chain */
.chain-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 36px;
  flex-shrink: 0;
}


.chain-item {
  background: var(--bg3);
  border: 1px solid var(--nm);
  border-radius: 2px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: grab;
  position: relative;
  font-size: 10px;
  user-select: none;
}

.chain-item:active {
  cursor: grabbing;
  opacity: .8;
}

.chain-item.drag-over {
  border-color: var(--nc);
  box-shadow: 0 2px 0 var(--nc);
}

.chain-num {
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  color: var(--nm);
  min-width: 12px;
  text-shadow: 0 0 4px var(--nm);
}

.chain-name {
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  color: #ccc;
  flex: 1;
}

.chain-drag {
  color: var(--dim);
  font-size: 10px;
  cursor: grab;
}

.chain-del {
  color: var(--nr);
  cursor: pointer;
  font-size: 13px;
  opacity: .6;
  transition: .15s;
  line-height: 1;
  padding: 0 2px;
}

.chain-del:hover {
  opacity: 1;
  text-shadow: 0 0 6px var(--nr);
}

.chain-empty {
  font-size: 9px;
  color: var(--dim);
  text-align: center;
  padding: 8px;
  border: 1px dashed var(--bdr);
  border-radius: 2px;
}

.chain-arrow {
  text-align: center;
  color: var(--dim);
  font-size: 9px;
  line-height: 1;
  padding: 0;
}

/* Canvas */
.ca {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #050508;
  position: relative;
  overflow: hidden;
  padding: 20px;
  min-height: 0;
}

.ca::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 255, 249, .02) 1px, transparent 1px) 0 0/40px 40px, linear-gradient(0deg, rgba(0, 255, 249, .02) 1px, transparent 1px) 0 0/40px 40px;
  pointer-events: none;
}

#drop-zone {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.cwrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#main-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  image-rendering: auto; /* Smoother scaling for large images */
  box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

#original-canvas {
  display: none;
}

.drop-ph {
  border: 2px dashed rgba(0, 255, 249, .3);
  border-radius: 4px;
  padding: 48px 40px;
  text-align: center;
  cursor: pointer;
  transition: .2s;
  width: 100%;
}

.drop-ph:hover, .drop-ph.drag-over {
  border-color: var(--nc);
  background: rgba(0, 255, 249, .03);
}

.drop-icon {
  font-size: 34px;
  margin-bottom: 10px;
  display: block;
  opacity: .5;
}

.drop-text {
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--nc);
  text-shadow: 0 0 8px var(--nc);
  margin-bottom: 4px;
}

.drop-sub {
  font-size: 10px;
  color: var(--dim);
}

.toolbar {
  display: flex;
  gap: 8px;
  position: relative;
  z-index: 10;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 5px 10px;
  border: 1px solid;
  border-radius: 1px;
  cursor: pointer;
  background: transparent;
  transition: .15s;
  text-transform: uppercase;
  white-space: nowrap;
}

.btn-c {
  color: var(--nc);
  border-color: var(--nc);
}

.btn-c:hover {
  background: rgba(0, 255, 249, .1);
  box-shadow: 0 0 8px rgba(0, 255, 249, .2);
}

.btn-m {
  color: var(--nm);
  border-color: var(--nm);
}

.btn-m:hover {
  background: rgba(255, 0, 255, .1);
}

.btn-g {
  color: var(--ng);
  border-color: var(--ng);
}

.btn-g:hover {
  background: rgba(0, 255, 65, .1);
}

.btn-r {
  color: var(--nr);
  border-color: var(--nr);
}

.btn-r:hover {
  background: rgba(255, 0, 60, .1);
}

.btn-y {
  color: var(--ny);
  border-color: var(--ny);
}

.btn-y:hover {
  background: rgba(255, 255, 0, .1);
}

#export-progress {
  display: none;
  width: 100%;
  max-width: 580px;
  position: relative;
  z-index: 10;
  padding: 0 8px;
}

.prog-bar {
  height: 5px;
  background: var(--bdr);
  border-radius: 1px;
  overflow: hidden;
  margin-bottom: 3px;
}

.prog-fill {
  height: 100%;
  background: var(--nm);
  width: 0%;
  box-shadow: 0 0 8px var(--nm);
}

.prog-text {
  font-size: 10px;
  color: var(--nm);
  text-align: center;
  letter-spacing: 1px;
}

/* Params */
.param-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
}

.param-label {
  font-size: 10px;
  color: var(--dim);
  min-width: 82px;
  letter-spacing: .5px;
}

.param-val {
  font-size: 11px;
  color: var(--ny);
  min-width: 28px;
  text-align: right;
}

input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  height: 2px;
  background: var(--bdr);
  outline: none;
  cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 0;
  background: var(--nc);
  box-shadow: 0 0 5px var(--nc);
  cursor: pointer;
}

input[type=range]::-webkit-slider-thumb:hover {
  background: var(--nm);
}

select {
  background: var(--bg3);
  color: var(--txt);
  border: 1px solid var(--bdr);
  padding: 4px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  cursor: pointer;
  width: 100%;
}

.speed-display {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  color: var(--nc);
  text-align: center;
  text-shadow: 0 0 6px var(--nc);
  letter-spacing: 2px;
  margin: 2px 0;
}

.sw-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.sw {
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  cursor: pointer;
  border-radius: 1px;
  transition: .1s;
}

.sw.sel {
  border-color: #fff;
}

.pgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.pbtn {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  letter-spacing: 1px;
  padding: 6px 4px;
  border: 1px solid var(--bdr);
  background: var(--bg3);
  color: var(--dim);
  cursor: pointer;
  text-align: center;
  transition: .15s;
  text-transform: uppercase;
}

.pbtn:hover {
  border-color: var(--nc);
  color: var(--nc);
  text-shadow: 0 0 5px var(--nc);
  background: rgba(0, 255, 249, .03);
}

.divider {
  height: 1px;
  background: var(--bdr);
  margin: 1px 0;
  flex-shrink: 0;
}

.info-bar {
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 1px;
}

#animate-btn.running {
  color: var(--nr);
  border-color: var(--nr);
  animation: blink .8s infinite;
}

.pblock-title {
  font-family: 'Orbitron', monospace;
  font-size: 8px;
  color: var(--nm);
  letter-spacing: 1px;
  margin-bottom: 5px;
}

/* Export Section */
.export-section {
  border: 1px solid var(--bdr);
  border-radius: 2px;
  background: rgba(0, 255, 249, 0.02);
  margin-top: 5px;
}

.export-section[open] {
  background: rgba(0, 255, 249, 0.05);
  border-color: var(--nc);
}

.export-section summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 10px;
  user-select: none;
}

.export-section summary::-webkit-details-marker {
  display: none;
}

.export-section .stitle {
  border-bottom: none;
  margin-bottom: 0;
  padding: 0;
}

.export-section .toggle-icon {
  font-size: 10px;
  color: var(--nc);
  transition: transform .2s;
}

.export-section[open] .toggle-icon {
  transform: rotate(45deg);
  color: var(--nm);
}

.export-content {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--bdr);
}


::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--bdr);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--nc);
}

#file-input {
  display: none;
}

.gallery-hint {
  pointer-events: auto;
}
.gallery-grid {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.gitem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: .15s;
}
.gitem img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border: 1px solid var(--bdr);
  border-radius: 2px;
}
.gitem span {
  font-size: 8px;
  color: var(--dim);
}
.gitem:hover img {
  border-color: var(--nc);
  box-shadow: 0 0 10px rgba(0, 255, 249, .3);
}
.ecard:hover .reset-btn {
  opacity: 1;
}

.fx-reset-btn {
  font-size: 11px;
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  opacity: 0;
  transition: all .15s ease;
  cursor: pointer;
  line-height: 1;
  position: relative;
}

.ecard:hover .fx-reset-btn, .pcard:hover .fx-reset-btn {
  opacity: 0.6;
}

.fx-reset-btn:hover {
  opacity: 1 !important;
  color: var(--nr);
  background: rgba(255, 0, 60, 0.1);
  border-color: var(--nr);
  box-shadow: 0 0 8px rgba(255, 0, 60, 0.2);
}

.fx-reset-btn::after {
  content: 'RESET';
  position: absolute;
  top: -18px;
  right: 0;
  font-size: 7px;
  background: var(--nr);
  color: #fff;
  padding: 1px 3px;
  border-radius: 1px;
  pointer-events: none;
  opacity: 0;
  transition: .1s;
}

.fx-reset-btn:hover::after {
  opacity: 1;
}

.pgrid.live-mode {
  grid-template-columns: 1fr 1fr;
}

.pcard {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  border-radius: 2px;
  padding: 6px;
  cursor: pointer;
  transition: .15s;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pcard:hover { border-color: var(--nc); }

.pcard.has-preview .pcard-preview {
  display: flex;
  width: 100%;
  aspect-ratio: 1/1;
  margin-top: 5px;
  border: 1px solid var(--bdr);
  background: #000;
}

.pcard-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.8;
}

.pcard:hover .pcard-preview canvas { opacity: 1; }
