:root {
  --bg: #131316;
  --panel: #1c1c21;
  --border: #2e2e36;
  --text: #e8e6e1;
  --text-dim: #a09d96;
  --accent: #e8472b;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* ---------- viewer column ---------- */

.viewer-col { min-width: 0; }

.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.chip {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
}

.engine-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

.viewer-frame {
  position: relative;
  background: #0b0b0d;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#viewer-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.viewer-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(11, 11, 13, 0.75);
  pointer-events: none;
  transition: opacity 0.2s;
}

.viewer-overlay.hidden { opacity: 0; }

.viewer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color 0.15s, background 0.15s;
}

.btn:hover { border-color: #45454f; }

.btn-ghost:active { background: #26262c; }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-accent:hover { background: #f25a3e; border-color: #f25a3e; }

.btn-small { font-size: 12px; padding: 5px 10px; }

/* ---------- source panel ---------- */

.source-panel {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.panel-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel-title-row .panel-title { margin-bottom: 0; }

.thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.thumb {
  flex: 0 0 auto;
  width: 96px;
  height: 54px;
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 0;
  background: #000;
  cursor: pointer;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb.active { border-color: var(--accent); }

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 14px;
  color: var(--text-dim);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(232, 71, 43, 0.06);
}

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

.privacy-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- inspector ---------- */

.inspector {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

select {
  width: 100%;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  background: #131317;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

.hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

/* look list */

.look-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.look-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #131317;
  cursor: pointer;
  transition: border-color 0.15s;
}

.look-item:hover { border-color: #45454f; }

.look-item.active {
  border-color: var(--accent);
  color: #fff;
}

.look-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.look-item .spin {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
}

/* sliders */

.slider-row { margin-bottom: 10px; }

.slider-row:last-child { margin-bottom: 0; }

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}

.slider-label .val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #2e2e36;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  cursor: pointer;
}

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

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  .inspector { order: 2; }
  .look-list { grid-template-columns: 1fr 1fr; }
}

/* empty state — la drop zone È la demo finché non carichi */
.empty-state{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  text-align:center;color:var(--mut);font-size:15px;line-height:1.7;padding:24px;
  background:repeating-linear-gradient(45deg,transparent 0 14px,rgba(255,255,255,.012) 14px 28px)}
.empty-state b{color:var(--txt);font-size:18px}
.viewer-frame.has-source .empty-state{display:none}
