/* OmniGaze demo — dark, modern, self-contained. No external fonts/assets. */

:root {
  --bg:        #0c0e13;
  --bg-2:      #12151c;
  --panel:     #161a23;
  --panel-2:   #1c212d;
  --border:    #262c39;
  --border-2:  #323a4b;
  --text:      #e6e9f0;
  --text-dim:  #9aa3b5;
  --text-mut:  #6b7488;
  --accent:    #5b8cff;
  --accent-2:  #7aa2ff;
  --good:      #3ad29f;
  --warn:      #f2b347;
  --bad:       #ef5d6b;
  --radius:    10px;
  --radius-sm: 7px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; min-height: 0; }

/* ---------------------------------------------------------------- header */
.hdr {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px;
  background: linear-gradient(180deg, #141823, #11141c);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.hdr-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hdr-title h1 {
  margin: 0; font-size: 16px; font-weight: 600; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hdr-title .sep { color: var(--text-mut); margin: 0 2px; }
.hdr-title .subtitle { color: var(--text-dim); font-weight: 500; }
.logo {
  color: var(--accent); font-size: 18px; line-height: 1;
  text-shadow: 0 0 12px rgba(91,140,255,.7);
}

.hdr-right { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.weights-label { color: var(--text-mut); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
#weights-select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); padding: 6px 10px; font-size: 13px; max-width: 320px;
  cursor: pointer; outline: none;
}
#weights-select:focus { border-color: var(--accent); }

.health { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); }
.health-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-mut); box-shadow: 0 0 0 0 transparent;
}
.health-dot.loading { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.health-dot.ready   { background: var(--good); box-shadow: 0 0 8px rgba(58,210,159,.7); }
.health-dot.error   { background: var(--bad); }
@keyframes pulse {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(242,179,71,.5); }
  50%     { opacity: .5; box-shadow: 0 0 0 5px rgba(242,179,71,0); }
}

/* ---------------------------------------------------------------- body layout */
.body { display: flex; flex: 1 1 auto; min-height: 0; }

.controls {
  flex: 0 0 340px; width: 340px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 16px; overflow-y: auto; overflow-x: hidden;
}

.viewer {
  flex: 1 1 auto; min-width: 0;
  padding: 20px; overflow: auto;
  display: flex; flex-direction: column; gap: 14px; align-items: stretch;
}

/* ---------------------------------------------------------------- control blocks */
.ctl-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
}
.ctl-h {
  margin: 0 0 10px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px; color: var(--text-mut);
}

.radios { display: flex; flex-direction: column; gap: 8px; }
.radio, .check {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  font-size: 13.5px; color: var(--text); user-select: none;
}
.radio input, .check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.check input:disabled { cursor: not-allowed; }
.check:has(input:disabled) { color: var(--text-mut); cursor: not-allowed; }

.prompt {
  width: 100%; resize: vertical; min-height: 90px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 9px 10px; font-family: var(--sans); font-size: 12.5px; line-height: 1.5;
  outline: none;
}
.prompt:focus { border-color: var(--accent); }

.hint { margin: 8px 0 0; font-size: 11.5px; color: var(--text-mut); line-height: 1.4; }

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px;
}
.field .val { font-family: var(--mono); color: var(--accent-2); font-size: 12px; }
.info {
  color: var(--text-mut); cursor: help; font-size: 11px;
  border: 1px solid var(--border-2); border-radius: 50%;
  width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center;
  margin-left: 5px;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: var(--border-2); border-radius: 3px; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 15px; height: 15px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
  box-shadow: 0 0 6px rgba(91,140,255,.6); border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: none;
}

.text-input {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 7px 9px; font-size: 13px; outline: none;
}
.text-input:focus { border-color: var(--accent); }
.range-row { display: flex; gap: 10px; }
.range-row .half { flex: 1 1 0; margin-bottom: 0; }

/* ---------------------------------------------------------------- source picker */
.source-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1 1 0; padding: 7px 0; font-size: 12.5px; cursor: pointer;
  background: var(--panel-2); color: var(--text-dim);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  transition: background .12s, color .12s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.gallery {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  max-height: 320px; overflow-y: auto; overflow-x: hidden;
}
.thumb {
  position: relative; cursor: pointer; border-radius: var(--radius-sm);
  overflow: hidden; border: 2px solid transparent; background: var(--bg);
  aspect-ratio: 4 / 3;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.thumb.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.thumb-label {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 10.5px; padding: 3px 6px; color: #fff;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.82));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dropzone {
  border: 2px dashed var(--border-2); border-radius: var(--radius);
  padding: 26px 14px; text-align: center; cursor: pointer;
  background: var(--bg); transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone:focus { border-color: var(--accent); outline: none; }
.dropzone.dragover { border-color: var(--accent); background: rgba(91,140,255,.08); }
.dz-icon { font-size: 24px; color: var(--accent); margin-bottom: 8px; }
.dz-text { font-size: 12.5px; color: var(--text-dim); }
.dz-text span { color: var(--text-mut); font-size: 11.5px; }

/* ---------------------------------------------------------------- run button */
.run-btn {
  width: 100%; padding: 12px; font-size: 14px; font-weight: 600;
  color: #fff; background: linear-gradient(180deg, var(--accent), #4877e6);
  border: none; border-radius: var(--radius); cursor: pointer;
  transition: filter .12s, opacity .12s;
}
.run-btn:hover:not(:disabled) { filter: brightness(1.08); }
.run-btn:disabled { opacity: .45; cursor: not-allowed; }
.run-btn.running { background: var(--panel-2); color: var(--text-dim); cursor: progress; }
.stop-btn {
  width: 100%; margin-top: 8px; padding: 11px; font-size: 14px; font-weight: 600;
  color: #fff; background: linear-gradient(180deg, #e0564e, #c5403a);
  border: none; border-radius: var(--radius); cursor: pointer; transition: filter .12s;
}
.stop-btn:hover { filter: brightness(1.08); }
.run-hint { margin: 8px 0 0; font-size: 11.5px; color: var(--text-mut); text-align: center; min-height: 1em; }

/* ---------------------------------------------------------------- viewer */
.viewer-empty {
  margin: auto; text-align: center; color: var(--text-mut);
}
.ve-icon { font-size: 40px; margin-bottom: 12px; opacity: .6; }
.viewer-empty p { margin: 0; font-size: 13.5px; }

.error-banner {
  background: rgba(239,93,107,.12); border: 1px solid rgba(239,93,107,.5);
  color: #ffb3bb; border-radius: var(--radius); padding: 11px 14px;
  font-size: 13px; white-space: pre-wrap; word-break: break-word;
}

.result-image { width: 100%; display: flex; justify-content: center; }
.result-image img {
  max-width: 100%; height: auto; border-radius: var(--radius);
  border: 1px solid var(--border); background: #000;
}

.result-video { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.frame-wrap {
  width: 100%; display: flex; justify-content: center;
  background: #000; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; min-height: 120px;
}
.frame-wrap img { max-width: 100%; height: auto; display: block; }
/* GT overlay layer stacked exactly over the frame/result image (same native size -> aligns) */
.img-stack { position: relative; display: inline-block; line-height: 0; max-width: 100%; }
.img-stack img.gt-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.progress { width: 100%; height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar {
  height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--good));
  transition: width .15s linear;
}
.vid-meta { font-size: 12px; color: var(--text-dim); font-family: var(--mono); }

.player { display: flex; align-items: center; gap: 12px; }
.play-btn {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-2);
  font-size: 14px; cursor: pointer; line-height: 1;
}
.play-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-2); }
.play-btn:disabled { opacity: .4; cursor: not-allowed; }
.scrubber { flex: 1 1 auto; }
.frame-idx { flex: 0 0 auto; font-family: var(--mono); font-size: 12px; color: var(--text-dim); min-width: 36px; text-align: right; }

.dl-btn {
  align-self: flex-start; padding: 9px 16px; font-size: 13px; font-weight: 600;
  color: #fff; background: var(--panel-2); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); text-decoration: none; cursor: pointer;
}
.dl-btn:hover { border-color: var(--good); color: var(--good); }

.status-line {
  font-size: 12px; color: var(--text-mut); font-family: var(--mono);
  border-top: 1px solid var(--border); padding-top: 10px;
}

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .body { flex-direction: column; }
  .controls { flex: 0 0 auto; width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: none; }
  .hdr { flex-wrap: wrap; gap: 10px; }
  .hdr-right { flex-wrap: wrap; }
}
