:root {
  --bg: #0b0f16;
  --panel: #131a25;
  --panel-2: #182130;
  --line: #24303f;
  --text: #e6edf5;
  --muted: #93a3b8;
  --accent: #4f8cff;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* Regras como `.model-ready { display: flex }` venceriam o `hidden` do
   navegador. Isto garante que o atributo sempre esconde. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  background-image:
    radial-gradient(900px 500px at 12% -10%, #16233a 0%, transparent 60%),
    radial-gradient(700px 400px at 100% 0%, #1b1630 0%, transparent 55%);
  background-attachment: fixed;
  min-height: 100vh;
}

main { max-width: 1120px; margin: 0 auto; padding: 0 20px 64px; }

/* ------------------------------------------------------------ topbar */
.topbar {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  font-size: 24px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), #7c4dff);
  color: #fff;
}
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.2px; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.ring {
  --pct: 0%;
  width: 72px; height: 72px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background:
    conic-gradient(var(--ok) var(--pct), #223046 var(--pct));
  position: relative;
  font-size: 13px; font-weight: 600;
  transition: background .35s ease;
}
.ring::before {
  content: "";
  position: absolute; inset: 6px;
  border-radius: 50%;
  background: var(--bg);
}
.ring span { position: relative; }

/* -------------------------------------------------------------- card */
.card {
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
  margin-bottom: 18px;
  backdrop-filter: blur(6px);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.num {
  width: 26px; height: 26px; flex: none;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.check { color: var(--ok); opacity: 0; font-weight: 700; transition: opacity .2s; }
.step.done .check { opacity: 1; }
.step.done .num { background: color-mix(in srgb, var(--ok) 18%, transparent); border-color: var(--ok); color: var(--ok); }

.muted { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 5px;
  font-size: 12.5px;
}

/* ------------------------------------------------------------- forms */
label { display: block; font-size: 12.5px; color: var(--muted); }
input[type=text], input[type=number], input[type=url], select {
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
.grid3 { display: grid; grid-template-columns: 2fr 1.2fr .8fr; gap: 14px; }
.row { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; flex-wrap: wrap; }
.row > input[type=url] { flex: 1; min-width: 260px; }
.row.tight { align-items: flex-end; }
.row.tight label { min-width: 240px; }

.btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: .15s;
}
.btn:hover:not(:disabled) { border-color: #38485c; transform: translateY(-1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #6a9cff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }

/* --------------------------------------------------------------- drop */
.drop {
  border: 1.5px dashed #2f3f54;
  border-radius: 12px;
  padding: 26px;
  text-align: center;
  cursor: pointer;
  transition: .15s;
  background: color-mix(in srgb, var(--panel-2) 55%, transparent);
}
.drop:hover, .drop.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.drop strong { display: block; font-size: 14.5px; }
.drop span { color: var(--muted); font-size: 13px; }

.status { color: var(--muted); font-size: 12.5px; min-height: 18px; margin: 8px 0 0; }

/* ------------------------------------------------- modelo: 3 estados */
.model-loading { padding: 4px 0 2px; }
.ml-head { display: flex; align-items: center; gap: 9px; font-size: 13.5px; margin-bottom: 8px; }
.ml-head b { flex: 1; font-weight: 500; }
.ml-head span:last-child { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ml-head .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }
.model-loading small { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }

.model-ready {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line));
  border-radius: 11px;
  background: color-mix(in srgb, var(--ok) 7%, var(--panel-2));
}
.model-ready > div { flex: 1; min-width: 0; }
.model-ready b { display: block; font-size: 13.5px; font-weight: 600; }
.model-ready small { color: var(--muted); font-size: 12px; }
.badge-ok {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--ok) 20%, transparent);
  color: var(--ok); font-weight: 700; font-size: 13px;
}
.tag {
  flex: none;
  font-size: 11px; color: var(--muted);
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.adv { margin-top: 14px; }
.adv[hidden] { display: none; }
.adv summary {
  cursor: pointer; font-size: 12.5px; color: var(--muted);
  padding: 4px 0; list-style: none; user-select: none;
}
.adv summary::-webkit-details-marker { display: none; }
.adv summary::before { content: "▸ "; }
.adv[open] summary::before { content: "▾ "; }
.adv summary:hover { color: var(--text); }

.model-info {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 20px;
}
.model-info dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.model-info dd { margin: 2px 0 0; font-size: 13px; word-break: break-all; }

/* ------------------------------------------------------------ capture */
.capture { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; }
@media (max-width: 900px) {
  .capture { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
}

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #05070b;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.stage video, .stage canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.stage video { display: none; }
.stage.live video, .stage.live canvas { display: block; }
.stage.live .stage-empty { display: none; }
.stage.mirror video, .stage.mirror canvas { transform: scaleX(-1); }

.stage-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #56637a; font-size: 14px;
}

.hint {
  position: absolute; left: 12px; right: 12px; bottom: 16px;
  text-align: center;
  font-size: 13.5px; font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(5, 8, 14, .72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.08);
}
.stability-track { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.06); }
.stability { height: 100%; width: 0; background: var(--ok); transition: width .12s linear; }

.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .34s ease-out; }
@keyframes flash { 0% { opacity: .85; } 100% { opacity: 0; } }

/* ------------------------------------------------------------- panel */
.panel { display: flex; flex-direction: column; gap: 14px; }
.meter-head { display: flex; justify-content: space-between; font-size: 13px; }
.meter-head b { font-variant-numeric: tabular-nums; }
.track { height: 9px; background: #1d2836; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.track.sm { height: 6px; margin-top: 3px; }
.track .fill { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .1s linear, background .2s; }
.fill.ok { background: var(--ok); }
.fill.bad { background: var(--warn); }
.sub .fill { background: var(--ok); }
.sub .fill.low { background: var(--warn); }

.thr { display: flex; align-items: center; gap: 8px; font-size: 11.5px; margin-top: 6px; }
.thr input[type=range] { flex: 1; accent-color: var(--accent); }
.thr b { font-variant-numeric: tabular-nums; color: var(--text); }

.sub { display: grid; gap: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.sub > div > span { font-size: 11.5px; color: var(--muted); }

.raw { flex: 1; font-size: 11px; color: #6d7c92; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin: 0; min-height: 30px; line-height: 1.5; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.switch { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.switch input { accent-color: var(--accent); }

/* -------------------------------------------------------------- shots */
.shots { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 0; padding: 0; }
@media (max-width: 620px) { .shots { grid-template-columns: 1fr; } }
.shot {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  min-height: 86px;
}
.shot.filled { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.shot img { width: 64px; height: 64px; border-radius: 9px; object-fit: cover; flex: none; }
.shot .ph {
  width: 64px; height: 64px; flex: none;
  border-radius: 9px;
  border: 1.5px dashed #2f3f54;
  display: grid; place-items: center;
  color: #4a586d; font-size: 20px; font-weight: 600;
}
.shot-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.shot-meta strong { font-size: 13px; }
.shot-meta small { font-size: 10.5px; color: var(--muted); }
.shot-meta .ts { font-family: ui-monospace, Menlo, monospace; font-size: 9.5px; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 999px; width: fit-content; }
.pill.ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.redo {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer; font-size: 13px;
}
.redo:hover { color: var(--text); border-color: #3a4a5f; }

.foot { color: #5c6a80; font-size: 12px; text-align: center; padding-top: 8px; }

/* ------------------------------------------------------- loader/toast */
.loader {
  position: fixed; inset: 0;
  background: rgba(6, 9, 14, .72);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; gap: 14px;
  align-content: center;
  z-index: 50;
}
.loader[hidden] { display: none; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid #2a3648;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader p { font-size: 13.5px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 26px;
  transform: translate(-50%, 140%);
  max-width: min(640px, calc(100vw - 40px));
  padding: 12px 18px;
  border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13.5px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  transition: transform .3s cubic-bezier(.2,.9,.3,1);
  z-index: 60;
}
.toast.show { transform: translate(-50%, 0); }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); }
.toast.warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.toast.err { border-color: color-mix(in srgb, var(--err) 55%, var(--line)); }
