/* ==========================================================================
   VIDONIA ENHANCE — UI only (no processing engine)
   Grid overlay matches enhancer.py (_draw_grid)
   ========================================================================== */

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

:root {
  --bg: #070b10;
  --bg-2: #05080d;
  --panel: #080d13;
  --panel-2: #0b121a;
  --line: #1a2632;
  --line-2: #273847;
  --text: #e8eef5;
  --muted: #7c8b9d;
  --muted-2: #566b7f;
  --cyan: #66ecff;
  --cyan-2: #72f5d8;
  --violet: #b899ff;
  --red: #ff728c;
}

html, body {
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

/* ---------- TOP BAR ---------- */
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: #111923;
  border-bottom: 1px solid #2a3b4b;
  flex-shrink: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 850;
  letter-spacing: .12em;
  color: #eefaff;
  text-decoration: none;
  padding-right: 12px;
}
.brand-mark {
  font-size: 18px;
  color: var(--cyan-2);
  text-shadow: 0 0 12px var(--cyan);
}
.brand-text em {
  font-style: normal;
  color: var(--cyan-2);
  font-size: 11px;
  letter-spacing: .18em;
  margin-left: 4px;
}

.compare-gadget {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: #0a1119;
  border: 1px solid #314353;
  border-radius: 11px;
}
.compare-title {
  color: #5f7487;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.1px;
  padding: 0 6px;
}
.vmode {
  background: transparent;
  color: #74869a;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 9.5px;
  font-weight: 850;
  letter-spacing: .5px;
  cursor: pointer;
  transition: all .18s ease;
}
.vmode:hover { color: #e4f3fb; background: #14202b; border-color: #365161; }
.vmode.active { color: #8df2ff; background: #12313b; border-color: #3a8294; }

.zoom-controls { display: flex; gap: 4px; }
.btn-icon {
  min-width: 40px;
  height: 34px;
  padding: 0 10px;
  background: #101922;
  color: #c3cfdb;
  border: 1px solid #304352;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .4px;
  cursor: pointer;
  transition: all .18s ease;
}
.btn-icon:hover { background: #16232e; border-color: #5a8393; color: #f2fdff; }

.btn-quit {
  margin-left: auto;
  padding: 8px 16px;
  background: #241219;
  border: 1px solid #713949;
  color: #ff9bad;
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: .5px;
  text-decoration: none;
  cursor: pointer;
  transition: all .18s ease;
}
.btn-quit:hover { background: #34151f; border-color: #a34c63; color: #ffc1cb; }

/* ---------- WORKSPACE ---------- */
.workspace {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: calc(100vh - 58px - 42px);
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  background: #080d13;
  border-right: 1px solid #1d2a37;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #2a3e4e; border-radius: 4px; }

.row { display: flex; gap: 6px; }
.row > * { flex: 1 1 0; min-width: 0; }

.btn-side {
  height: 38px;
  padding: 0 10px;
  background: #0f171f;
  color: #c5d1dc;
  border: 1px solid #2a3a49;
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: .4px;
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}
.btn-side:hover:not(:disabled) {
  background: #15212c;
  border-color: #54869a;
  color: #f2fdff;
  transform: translateY(-1px);
}
.btn-side:disabled { opacity: .4; cursor: not-allowed; }

.btn-enhance {
  flex: 5;
  background: #12372f;
  border-color: #3d9e8a;
  color: #86f7d8;
  height: 44px;
  font-size: 11px;
}
.btn-enhance:hover:not(:disabled) {
  background: #17463b;
  border-color: #67d5bc;
  color: #c4fff0;
  box-shadow: 0 0 22px rgba(102, 236, 255, .25);
}

.btn-pause {
  flex: 3;
  background: #101b24;
  border-color: #355064;
  color: #8bd7e8;
  height: 44px;
}
.btn-pause:hover:not(:disabled) { background: #152935; border-color: #63b8cf; }

.btn-stop {
  flex: 2;
  background: #241219;
  border-color: #713949;
  color: #ff9bad;
  height: 44px;
}
.btn-stop:hover:not(:disabled) { background: #34151f; border-color: #a34c63; }

.btn-toggle {
  background: #102d29;
  border: 1px solid #3a8d7d;
  color: #78f4d5;
  border-radius: 9px;
  height: 40px;
  font-size: 10.5px;
  font-weight: 850;
  cursor: pointer;
  transition: all .18s ease;
}
.btn-toggle:hover { background: #143a32; border-color: #5bc6ad; }
.btn-toggle.on { background: #12382f; border-color: #55bba3; color: #a8ffe9; }

.btn-scale {
  flex: 1;
  height: 40px;
  background: #0f171f;
  border: 1px solid #2a3a49;
  color: #8799aa;
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 900;
  cursor: pointer;
  transition: all .18s ease;
}
.btn-scale:hover { background: #142531; border-color: #4e8da3; color: #dff9ff; }
.btn-scale.on {
  background: #10323b;
  border-color: #58b8ca;
  color: #8ff3ff;
  box-shadow: 0 0 16px rgba(102, 236, 255, .2);
}

.btn-batch { background: #101922; border-color: #304352; }

.section-label {
  margin-top: 8px;
  color: #607488;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 1.6px;
  padding-top: 3px;
}

.input-select {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  background: #0d151e;
  color: #d4dfe9;
  border: 1px solid #273948;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}
.input-select:hover { border-color: #4c7083; }
.input-select option { background: #0d141c; }

.model-hint {
  color: #566b7f;
  font-size: 9px;
  line-height: 1.35;
  padding: 2px 4px 0;
}

.adj-panel {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: #0b1219;
  border: 1px solid #182735;
  border-radius: 8px;
}
.adj-panel.open { display: flex; }

.adj-row {
  display: grid;
  grid-template-columns: 70px 1fr 28px;
  align-items: center;
  gap: 6px;
  color: #b4c2d1;
  font-size: 10.5px;
  font-weight: 700;
}
.adj-row input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #1a2633;
  border-radius: 2px;
  outline: none;
}
.adj-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: #76efff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px #76efff;
}
.adj-row input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px;
  background: #76efff;
  border: none; border-radius: 50%;
  cursor: pointer;
}
.adj-row b { color: #70ebff; font-size: 10.5px; text-align: right; }

.source-card {
  margin-top: 6px;
  padding: 9px 10px;
  background: #0b121a;
  border: 1px solid #1a2937;
  border-radius: 9px;
}
.source-name {
  color: #d8e3ed;
  font-size: 11px;
  font-weight: 650;
  word-break: break-all;
}
.source-info {
  color: #71869a;
  font-size: 9.5px;
  margin-top: 4px;
  white-space: pre-line;
  line-height: 1.4;
}

/* ---------- STUDIO ----------
   Technical grid overlay — reproduces enhancer.py _draw_grid():
   - minor grid every 32px  (#101923)
   - major grid every 160px (#182532)
   The grid is painted directly on the studio background so the
   image (canvas) stays above it and remains the focus.
   ------------------------------------------------------------ */
.studio {
  position: relative;
  background-color: #05080d;
  background-image:
    /* Major grid lines */
    linear-gradient(to right,  #182532 1px, transparent 1px),
    linear-gradient(to bottom, #182532 1px, transparent 1px),
    /* Minor grid lines */
    linear-gradient(to right,  #101923 1px, transparent 1px),
    linear-gradient(to bottom, #101923 1px, transparent 1px);
  background-size:
    160px 160px,
    160px 160px,
    32px  32px,
    32px  32px;
  background-position: center center;
  overflow: hidden;
  border: 1px solid #1a2632;
  margin: 8px;
  border-radius: 9px;
}

/* Soft vignette so edges of the grid fade a bit — same feel as enhancer.py */
.studio::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%,
              transparent 0%,
              transparent 55%,
              rgba(0, 0, 0, .28) 100%);
  z-index: 1;
}

.studio-canvas {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  display: none;
  z-index: 2;
}
.studio-canvas.visible { display: block; }

.split-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: #fff;
  left: 50%;
  cursor: ew-resize;
  display: none;
  z-index: 5;
}
.split-handle::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 34px; height: 34px;
  transform: translate(-50%, -50%);
  background: #f9fdff;
  border: 2px solid #14202b;
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(102,236,255,.5);
}
.split-handle::after {
  content: "⇄";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #14202b;
  font-size: 15px;
  font-weight: 900;
  z-index: 1;
}

.label {
  position: absolute;
  top: 18px;
  padding: 7px 14px;
  background: rgba(7, 11, 18, .92);
  border: 1px solid #1a2632;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .16em;
  z-index: 6;
  display: none;
}
.label-original { left: 18px; color: #d2d9e2; }
.label-enhanced { right: 18px; color: #75efff; }
.label.visible { display: block; }

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #8391a3;
  gap: 8px;
  pointer-events: none;
  z-index: 3;
}
.empty-icon {
  font-size: 44px;
  color: #2a3e4e;
  margin-bottom: 8px;
}
.empty-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .12em;
  color: #8391a3;
}
.empty-sub {
  font-size: 12px;
  color: #566b7f;
  letter-spacing: .08em;
}
.empty-state.hidden { display: none; }

.studio-status {
  position: absolute;
  bottom: 12px;
  left: 18px;
  color: #8392a4;
  font-size: 10px;
  letter-spacing: .06em;
  z-index: 6;
}

.studio.dragging::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(102, 236, 255, .06);
  border: 2px dashed #66ecff;
  border-radius: 9px;
  z-index: 10;
  pointer-events: none;
}

/* ---------- FOOTER ---------- */
.footer {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: #080c11;
  border-top: 1px solid #18232e;
}
.progress-track {
  width: 260px;
  height: 7px;
  background: #101923;
  border: 1px solid #253543;
  border-radius: 5px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #21b9cf, #75efff, #4d75e5);
  border-radius: 5px;
  transition: width .3s ease;
}
.footer-label {
  color: #71f0d2;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .7px;
  min-width: 150px;
}
.footer-spacer { flex: 1; }
.footer-zoom {
  color: #70ebff;
  font-size: 10px;
  font-weight: 850;
  min-width: 48px;
}
.footer-model {
  color: #8c9eaf;
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: .5px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .compare-gadget { display: none; }
}