:root {
  --bg: #080807;
  --panel: #131211;
  --panel2: #191713;
  --line: #3b3220;
  --gold: #f0b429;
  --gold-light: #f7d264;
  --gold-dark: #c98a1b;
  --text: #efe9dc;
  --muted: #9c937f;
  --danger: #e24b4a;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

#fx { position: fixed; inset: 0; z-index: -1; }

.hide { display: none !important; }

.brand { font-size: 28px; font-weight: 700; letter-spacing: 0.5px; }
.brand span { color: var(--gold); }
.brand.small { font-size: 19px; }

.sub { color: var(--muted); margin: 4px 0 22px; }
.muted { color: var(--muted); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 18px;
}

#auth-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.auth-card { width: 360px; text-align: center; }

label { display: block; text-align: left; color: var(--muted); font-size: 13px; margin: 12px 0 4px; }

input[type="text"], input[type="password"], select {
  width: 100%;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
}
input:focus { border-color: var(--gold-dark); }

button {
  background: linear-gradient(180deg, var(--gold-light), var(--gold-dark));
  color: #1a1404;
  border: 0;
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 16px;
}
button:hover { filter: brightness(1.07); }
button.ghost {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--line);
  font-weight: 500;
  margin-top: 0;
  padding: 7px 14px;
}
.auth-card button { width: 100%; }

.err { color: var(--danger); font-size: 13px; margin-top: 12px; }

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.user-chip { color: var(--muted); display: flex; align-items: center; gap: 12px; }
.user-chip span { color: var(--gold-light); }

main { max-width: 980px; margin: 26px auto; padding: 0 20px; }

h2 { font-size: 18px; margin-bottom: 14px; }
h3 { font-size: 15px; margin: 20px 0 10px; color: var(--gold-light); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.row input[type="text"] { width: 200px; }
.row button { margin-top: 0; }
.check { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; margin: 0; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.on { background: rgba(240, 180, 41, 0.14); color: var(--gold-light); }
.pill.off { background: rgba(226, 75, 74, 0.14); color: var(--danger); }

td .ghost { padding: 4px 10px; font-size: 12.5px; }

.grid { display: flex; flex-wrap: wrap; gap: 14px; margin: 6px 0 4px; }
.char { width: 122px; text-align: center; }
.char img {
  width: 122px; height: 122px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); display: block;
}
.char.retired img { opacity: 0.35; }
.char .nm { font-size: 13px; color: var(--gold-light); margin-top: 5px; }
.char.retired .nm { color: var(--muted); text-decoration: line-through; }
.char .ghost { padding: 2px 8px; font-size: 11.5px; margin: 4px 2px 0; }
.grid .empty { color: var(--muted); font-size: 13.5px; padding: 8px 0; }

input[type="file"] { color: var(--muted); font-size: 13px; }
input[type="file"]::file-selector-button {
  background: var(--panel2); color: var(--gold);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; margin-right: 10px; cursor: pointer;
}

.layout { display: flex; align-items: flex-start; }
#side {
  width: 216px; flex-shrink: 0;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  min-height: calc(100vh - 61px);
  position: sticky; top: 0;
}
.side-label {
  color: var(--muted); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: 1px; margin: 16px 6px 7px;
}
.side-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; color: var(--text);
  border: 1.5px solid transparent; border-radius: 10px;
  padding: 10px 12px; margin: 3px 0; font-weight: 700; font-size: 14.5px;
  letter-spacing: 0.2px;
}
.side-item:hover { border-color: var(--line); filter: none; }
.side-item.active {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 14px rgba(240, 180, 41, 0.15);
}
.side-num { color: var(--gold-dark); font-size: 11px; font-weight: 700; min-width: 18px; letter-spacing: 1px; }
.side-item.active .side-num { color: var(--gold); }

#studio-title { display: flex; align-items: center; gap: 10px; }
#studio-title::before {
  content: '＋';
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold-dark));
  color: #1a1404; font-size: 17px; font-weight: 800;
}
#content { flex: 1; min-width: 0; }
#content main, #content .view { max-width: 1020px; margin: 26px auto; padding: 0 20px; }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  #side { width: 100%; min-height: 0; position: static; display: flex; flex-wrap: wrap; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-item { width: auto; }
  .side-label { width: 100%; margin: 6px 6px 2px; }
}

.slots-row { display: flex; gap: 22px; flex-wrap: wrap; align-items: flex-start; }
.cslot { min-width: 240px; }
.lbl { color: var(--muted); font-size: 13px; margin: 10px 0 4px; }
.char.small { width: 92px; }
.char.small img { width: 92px; height: 92px; }
.noimg {
  width: 122px; height: 122px; border-radius: 10px; border: 1px dashed var(--line);
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px;
}
.noimg.small { width: 92px; height: 92px; cursor: pointer; color: var(--gold); font-size: 14px; }
.addtile:hover .noimg { border-color: var(--gold); }
#own-model-images.drag { outline: 2px dashed var(--gold); outline-offset: 6px; border-radius: 10px; }
.slot-drop.wide { max-width: 560px; }
#face-refs .char.small { position: relative; }

.emp-card { border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; background: var(--panel2); }
.emp-card.terminated { opacity: 0.75; }
.emp-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; }
.emp-name { font-weight: 700; font-size: 15.5px; color: var(--gold-light); }
.emp-head .chev { margin-left: auto; color: var(--muted); }
.pill.role { background: rgba(240, 180, 41, 0.08); color: var(--muted); }
.emp-body { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.emp-stats { display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--muted); font-size: 13.5px; margin: 10px 0; }
.emp-stats b { color: var(--text); font-weight: 600; }
.sess-list { line-height: 1.9; }
button.ghost.danger { color: var(--danger); border-color: rgba(226, 75, 74, 0.4); }

.view h2 { margin-bottom: 6px; }

#log-toggle {
  position: fixed; bottom: 14px; left: 14px; z-index: 70;
  background: var(--panel2); color: var(--gold);
  border: 1px solid var(--line); border-radius: 99px;
  padding: 7px 14px; font-size: 12.5px; margin: 0;
}
#console {
  position: fixed; bottom: 56px; left: 14px;
  width: min(560px, 92vw); max-height: 46vh;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  z-index: 70; display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.c-head {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  color: var(--gold-light); font-size: 13px; font-weight: 700;
}
.c-head .ghost { padding: 3px 10px; font-size: 12px; }
#console-body { overflow-y: auto; padding: 8px 12px; font: 12px/1.7 ui-monospace, Menlo, monospace; }
#console-body .l-error { color: var(--danger); }
#console-body .l-ok { color: #8ff0b8; }
#console-body .l-dim { color: var(--muted); }
#console-body .l-info { color: var(--text); }

.cal-head { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.cal-month { color: var(--gold-light); font-weight: 700; font-size: 14px; min-width: 140px; text-align: center; }
.cal-head .ghost { padding: 3px 12px; }
.cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(52px, 1fr)) minmax(64px, auto);
  gap: 4px; max-width: 640px;
}
.cal-h { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; padding: 2px 4px; }
.cal-d {
  border: 1px solid var(--line); border-radius: 8px;
  min-height: 46px; padding: 4px 6px; cursor: pointer;
  background: var(--panel2);
}
.cal-d:hover { border-color: var(--gold-dark); }
.cal-d.out { opacity: 0.32; }
.cal-d.today { border-color: var(--gold); }
.cal-d.sel { outline: 2px solid var(--gold); outline-offset: -1px; }
.cal-n { font-size: 11.5px; color: var(--muted); }
.cal-hrs { font-size: 12.5px; font-weight: 700; color: var(--gold-light); margin-top: 2px; }
.cal-w {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 4px 8px; color: var(--gold-light); font-size: 12.5px; font-weight: 600;
}
.cal-detail { margin-top: 10px; line-height: 1.9; }

/* instant-delete ✕ on result tiles (owner) */
.char, #active-grid .slot { position: relative; }
.del-x {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 26px; height: 26px; padding: 0; margin: 0;
  border-radius: 99px; border: 1px solid rgba(226, 75, 74, 0.55);
  background: rgba(8, 8, 7, 0.72); color: var(--danger);
  font-size: 13px; font-weight: 700; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity 0.12s;
}
.char:hover .del-x, #active-grid .slot:hover .del-x { opacity: 1; }
.del-x:hover { background: rgba(226, 75, 74, 0.25); filter: none; }
.del-x:disabled { opacity: 0.4; }

.char.pick { cursor: pointer; }
.char.pick img { border-width: 2px; }
.char.pick.sel img { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.char.pick.sel .nm { color: var(--gold); font-weight: 700; }

.mode-panel { margin: 10px 0; }
.ctl { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; margin: 0; }
.ctl select { min-width: 150px; }
.tiny { font-size: 12.5px; }

textarea {
  width: 100%;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); padding: 10px 12px; font-size: 14px; outline: none; resize: vertical;
  margin: 8px 0;
}
textarea:focus { border-color: var(--gold-dark); }

.slot-drop {
  border: 1.5px dashed var(--line); border-radius: 12px;
  min-height: 130px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; margin: 10px 0; position: relative; overflow: hidden;
  color: var(--muted); background: var(--panel2);
  max-width: 340px;
}
.slot-drop.drag { border-color: var(--gold); color: var(--gold); }
.slot-inner { text-align: center; width: 100%; }
.slot-inner img { max-width: 100%; max-height: 260px; display: block; margin: 0 auto; }
.cx {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.65); color: #fff; border: 0; border-radius: 99px;
  width: 26px; height: 26px; padding: 0; margin: 0; font-weight: 700; cursor: pointer;
}

.gen-row { margin-top: 14px; align-items: flex-end; }
.gen-row button { min-width: 140px; }

/* active batch — extension-sized slots (3:4 tiles, ≥180px, like the app's active grid) */
#active-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
#active-grid .slot, #active-grid .errslot {
  aspect-ratio: 3/4; border-radius: 10px;
  background: var(--panel2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12.5px; text-align: center; padding: 6px; overflow: hidden;
}
#active-grid .slot img { width: 100%; height: 100%; object-fit: cover; }
#active-grid .errslot { color: var(--danger); }

#vr-extra video { width: 100%; max-width: 340px; border-radius: 10px; border: 1px solid var(--line); display: block; margin: 8px 0; }
pre#vr-ontext { white-space: pre-wrap; font-size: 13px; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }

.vr-prog { margin: 8px 0 6px; max-width: 340px; }
.vr-prog-bar { height: 9px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#vr-prog-fill { height: 100%; width: 0%; border-radius: 6px; background: linear-gradient(90deg, var(--gold, #f5b64a), #ffe49b); transition: width .5s ease; }
#vr-prog-label { margin-top: 5px; }

#lb {
  position: fixed; inset: 0; background: rgba(0,0,0,0.82);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
/* extension-sized viewing: the app shows results at up to 88vh/60vw — never smaller than the source needs */
.lb-box { max-width: 96vw; max-height: 96vh; display: flex; flex-direction: column; gap: 10px; align-items: center; }
#lb-img { max-width: min(80vw, 100%); max-height: 82vh; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); }
.lb-meta { align-self: flex-start; }
.lb-meta { color: var(--gold-light); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

@media (max-width: 640px) {
  .row input[type="text"] { width: 100%; }
}

/* ---------- rating system (Tinder / Winners-Losers) — ported from the extension ---------- */
.chip {
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 99px; padding: 6px 14px; cursor: pointer; font-size: 12px; font-weight: 500; margin-top: 0;
}
.chip.active, .chip:hover { color: var(--text); border-color: var(--gold); filter: none; }
.chip.solid { background: linear-gradient(135deg, var(--gold), var(--gold-dark)); color: #1a1404; border: 0; font-weight: 700; }

.char { position: relative; }
.char .verdict-mark { position: absolute; top: 6px; right: 6px; font-size: 15px; text-shadow: 0 1px 4px rgba(0,0,0,0.7); }
.char.winner img { outline: 2px solid #34d17d; }
.char.super img { outline: 2px solid #ffd24a; }
.char.loser img { opacity: 0.55; }

#lb-img.zoomable { cursor: zoom-in; transition: transform 0.12s ease; will-change: transform; }
#lb-img.zoomed { cursor: grab; transition: none; border-radius: 6px; }
#lb-img.grabbing { cursor: grabbing; }
.lb-nav {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: rgba(0,0,0,0.55); color: #fff; border: 0; font-size: 24px; cursor: pointer; margin: 0 8px;
}
#lb { gap: 6px; }
.lb-v.win.on { background: #0f2a1a; color: #8ff0b8; border-color: #34d17d; }
.lb-v.lose.on { background: #3a0f22; color: #ffb4d6; border-color: var(--gold); }

.lb-close-x {
  position: absolute; top: 18px; right: 20px; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: 0; font-size: 16px; cursor: pointer; z-index: 90; margin: 0; padding: 0;
}
.lb-close-x.static { position: static; }

#tinder {
  position: fixed; inset: 0; background: rgba(4,2,7,0.96); z-index: 80;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px;
}
.tinder-head { color: var(--muted); font-size: 13px; }
.tinder-card {
  width: min(420px, 86vw); aspect-ratio: 3/4; border-radius: 20px; overflow: hidden;
  border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,0.6); background: var(--panel2);
  transition: transform 0.18s, opacity 0.18s;
}
.tinder-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tinder-card.swipe-win { transform: translateX(60vw) rotate(18deg); opacity: 0; }
.tinder-card.swipe-lose { transform: translateX(-60vw) rotate(-18deg); opacity: 0; }
.tinder-actions { display: flex; gap: 16px; }
.tinder-actions button { border: 0; border-radius: 14px; padding: 14px 26px; font-weight: 800; cursor: pointer; font-size: 15px; margin: 0; }
.t-lose { background: #3a0f22; color: #ffb4d6; }
.t-win { background: linear-gradient(135deg, #34d17d, #12a25a); color: #04120b; }
.t-skip { background: var(--panel2); color: var(--muted); }
.tinder-hint { color: var(--muted); font-size: 12px; }
.tinder-done { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; font-size: 40px; text-align: center; padding: 20px; }
.tinder-done .genlike { background: linear-gradient(135deg, var(--gold), var(--gold-dark)); color: #1a1404; border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 700; cursor: pointer; margin: 0; font-size: 14px; }
.tinder-done .ghostlike { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 9px 16px; cursor: pointer; margin: 0; font-size: 14px; }

.modal { position: fixed; inset: 0; background: rgba(4,2,7,0.9); z-index: 85; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.wl-box { width: min(900px, 94vw); max-height: 88vh; overflow: auto; }
.wl-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wl-head h3 { margin: 0; }
.wl-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.wl-sect { color: var(--gold-light); font-weight: 700; margin: 14px 0 8px; }
.wl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.wl-grid img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }
.wl-grid img:hover { border-color: var(--gold); }
.wl-empty { color: var(--muted); font-size: 13.5px; padding: 8px 0; }

/* result galleries — extension-sized tiles (3:4, ≥180px; the app's .tile look) instead of 122px squares */
.grid.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.grid.results .char { width: auto; }
.grid.results .char img { width: 100%; height: auto; aspect-ratio: 3/4; object-fit: cover; }

/* Motion Control pipeline: WaveSpeed edit → RunningHub video */
#mc-extra { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.mc-s1 { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.mc-thumb { width: 132px; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.mc-pick { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; max-width: 140px; }
.mc-pick img { width: 30px; height: 40px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); cursor: pointer; opacity: .65; }
.mc-pick img.sel { border-color: var(--gold); opacity: 1; }
.mc-s1-controls { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 8px; }
.mc-card {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px;
}
.mc-card .mc-imgs { display: flex; gap: 8px; }
.mc-card .mc-imgs img { width: 84px; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.mc-chain { flex: 1; min-width: 250px; display: flex; flex-direction: column; gap: 8px; }
.mc-steps { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.mc-step {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); font-size: 12px; color: var(--gold-light);
}
.mc-step.ok { border-color: var(--gold); }
.mc-step.err { border-color: var(--danger); color: var(--danger); }
.mc-step .mc-n5 { background: linear-gradient(135deg, var(--gold), var(--gold-dark)); color: #1a1404; border-radius: 999px; padding: 1px 7px; font-weight: 700; font-size: 11px; }
.mc-arrow { color: var(--gold-dark); font-size: 13px; }
.mc-bar { height: 8px; width: 88px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.mc-bar > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold, #f5b64a), #ffe49b); transition: width .6s ease; }
.mc-card video { max-width: 240px; max-height: 320px; border-radius: 10px; border: 1px solid var(--line); }
#mc-done .mc-card video { max-width: 300px; max-height: 400px; }
.mc-err-text { color: var(--danger); font-size: 12px; }
#mcwf-list { display: flex; flex-direction: column; gap: 8px; }
.mcwf-row { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.mcwf-row .muted { flex: 1; }
#mcwf .modal-box { max-width: 620px; width: 100%; max-height: 88vh; overflow-y: auto; }
.mc-thumbwrap { display: flex; flex-direction: column; gap: 3px; align-items: center; max-width: 90px; text-align: center; }
.mc-thumbwrap.sent img { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.mc-thumbwrap.sent .muted { color: var(--gold); }
/* finished-video cards: the whole pipeline left → right */
.mc-donecard { flex-direction: column; align-items: stretch; }
.mc-strip { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mc-stage { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; max-width: 170px; }
.mc-stage img { width: 96px; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }
.mc-stage video.mc-mini { width: 130px; max-height: 230px; border-radius: 8px; border: 1px solid var(--line); }
.mc-stage video.mc-final { width: 170px; max-height: 300px; border-radius: 10px; border: 1px solid var(--gold); }

/* lightweight stand-ins for list videos — the real player mounts on click (lag fix) */
.mc-vfacade { position: relative; cursor: pointer; overflow: hidden; background: var(--panel2); display: flex; align-items: center; justify-content: center; }
.mc-vfacade.mc-mini { width: 130px; aspect-ratio: 9/16; max-height: 230px; border-radius: 8px; border: 1px solid var(--line); }
.mc-vfacade.mc-final { width: 170px; aspect-ratio: 9/16; max-height: 300px; border-radius: 10px; border: 1px solid var(--gold); }
.mc-vfacade img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mc-vfacade .mc-play {
  position: relative; z-index: 1;
  width: 44px; height: 44px; border-radius: 99px;
  background: rgba(8, 8, 7, 0.72); border: 1px solid var(--gold);
  color: var(--gold); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.mc-vfacade:hover .mc-play { background: rgba(240, 180, 41, 0.25); }

/* don't render off-screen cards/tiles until scrolled into view */
.mc-donecard { content-visibility: auto; contain-intrinsic-size: 340px; }
#emp-gallery .char, #owner-gallery .char { content-visibility: auto; contain-intrinsic-size: 190px; }
.mc-stage.final .muted { color: var(--gold); }
/* video lightbox (click a pipeline video → big player + info + download) */
.mclb-box { max-width: min(600px, 94vw); width: 100%; }
#mclb-video { width: 100%; max-height: 68vh; border-radius: 10px; border: 1px solid var(--line); background: #000; }
#mclb-meta { display: flex; flex-direction: column; gap: 4px; }

/* ================= Phone Farm =================
   Dense device-management layout: checklist rail + compact phone cards.
   Deliberately flatter and darker than the rest of GatesGen: near-black
   surface, hairline borders, no orbs (hidden while this view is open).
   Gold stays the accent — selection, actions, brand. */
#fx.pf-hidden { display: none; }
#view-phones { --pf-bg: #050505; --pf-card: #0b0b0c; --pf-line: #232326; --pf-line2: #2e2e33; }
#view-phones.pf-active { max-width: 1560px; padding-left: 14px; padding-right: 14px; }
body.pf-mode { background: var(--pf-bg, #050505); }

/* ---- page skeleton: checklist rail + flexible device area ---- */
.pf-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; align-items: start; }
.pf-main { min-width: 0; }

.pf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 0 0 16px; }
.pf-head-l { display: flex; align-items: flex-start; gap: 12px; }
.pf-title { font-size: 24px; font-weight: 700; color: #fff; letter-spacing: -0.3px; margin: 0 0 5px; }
.pf-counts { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #8b8b93; }
.pf-counts .pf-total { color: #5f5f66; }
.pf-counts .pf-dot.checking { background: #6f6f77; box-shadow: none; animation: pf-pulse 1.1s ease-in-out infinite; }
@keyframes pf-pulse { 50% { opacity: 0.35; } }
.pf-mockchip {
  font-size: 10px; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--gold); border: 1px solid rgba(240,180,41,0.35);
  border-radius: 99px; padding: 3px 9px; white-space: nowrap;
}
.pf-cl-toggle { display: none; margin: 0; padding: 6px 10px; font-size: 12px; }

/* status dots */
.pf-dot { width: 7px; height: 7px; border-radius: 99px; display: inline-block; flex: 0 0 auto; }
.pf-dot.online   { background: #35d07f; box-shadow: 0 0 8px rgba(53,208,127,0.5); }
.pf-dot.sleeping { background: #e8b33c; }
.pf-dot.offline  { background: #5a5a60; }
.pf-dot.busy     { background: #e8b33c; }

/* ---- Daily checklist rail ---- */
.pf-checklist {
  background: var(--pf-card); border: 1px solid var(--pf-line); border-radius: 14px;
  padding: 14px 12px 12px; position: sticky; top: 12px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; gap: 10px;
}
.pf-cl-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pf-cl-title { margin: 0; font-size: 14px; font-weight: 700; color: #fff; letter-spacing: -0.2px; }
.pf-cl-count { font-size: 11.5px; color: #7b7b84; margin-top: 3px; }
.pf-cl-count span { color: #c9c9d0; }
.pf-cl-head-r { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.pf-cl-reset {
  background: none; border: 0; margin: 0; padding: 2px 0; cursor: pointer;
  color: #7b7b84; font-size: 11px; font-weight: 500; letter-spacing: 0.2px;
  text-decoration: underline; text-underline-offset: 2px;
}
.pf-cl-reset:hover { color: var(--gold); filter: none; }
.pf-cl-x { display: none; background: none; border: 0; color: #6f6f77; font-size: 13px; cursor: pointer; padding: 2px 4px; margin: 0; }
.pf-cl-bar { height: 3px; border-radius: 99px; background: #1a1a1d; overflow: hidden; }
.pf-cl-bar i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 99px; transition: width .25s ease; }
.pf-cl-chip { align-self: flex-start; }
.pf-cl-groups { overflow-y: auto; margin: 0 -4px; padding: 0 4px; display: flex; flex-direction: column; gap: 6px; }
.pf-cl-groups::-webkit-scrollbar { width: 6px; }
.pf-cl-groups::-webkit-scrollbar-thumb { background: #232326; border-radius: 99px; }

.pf-cl-group { border: 1px solid var(--pf-line); border-radius: 10px; overflow: hidden; background: #08080a; }
.pf-cl-gh {
  display: flex; align-items: center; gap: 7px; width: 100%; text-align: left;
  background: none; border: 0; margin: 0; padding: 8px 9px; cursor: pointer; color: #d6d6da;
  font-size: 12.5px; font-weight: 600;
}
.pf-cl-gh:hover { background: #101013; }
.pf-cl-caret { color: #5f5f66; font-size: 9px; width: 9px; transition: transform .15s; }
.pf-cl-group.open .pf-cl-caret { transform: rotate(90deg); }
.pf-cl-gname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-cl-gcount { font-size: 10.5px; color: #6f6f77; font-weight: 500; }
.pf-cl-group.done .pf-cl-gcount { color: #35d07f; }
.pf-cl-body { display: none; padding: 2px 9px 9px; }
.pf-cl-group.open .pf-cl-body { display: block; }

.pf-cl-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12px; color: #b6b6bd; cursor: pointer; }
.pf-cl-item input { accent-color: var(--gold); width: 13px; height: 13px; margin: 0; cursor: pointer; flex: 0 0 auto; }
.pf-cl-item .pf-cl-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-cl-item.done .pf-cl-t { color: #55555d; text-decoration: line-through; }
.pf-cl-add { display: flex; gap: 5px; margin-top: 7px; }
.pf-cl-add input[type="text"] {
  flex: 1; min-width: 0; margin: 0; padding: 5px 8px; font-size: 11.5px;
  background: #0d0d10; border: 1px solid var(--pf-line); border-radius: 7px; color: #d6d6da;
}
.pf-cl-add input::placeholder { color: #4f4f57; }
.pf-cl-add button { margin: 0; padding: 4px 9px; font-size: 13px; line-height: 1; border-radius: 7px; }

/* ---- device grid: compact iPhone cards ---- */
.pf-grid {
  /* Columns are CAPPED, so a card never stretches into a thin sliver: it stays
     220-240px whatever the width, the row simply fits fewer phones. Left-aligned
     with even gaps rather than justified across the panel. */
  display: grid; gap: 16px; justify-content: start;
  grid-template-columns: repeat(auto-fill, minmax(220px, 240px));
}
.pf-card {
  background: var(--pf-card); border: 1px solid var(--pf-line); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
  transition: border-color .14s, transform .14s;
  /* intrinsic size must match the real card (phone box + footer), otherwise an
     off-screen card is laid out short and the phone gets squashed when shown */
  content-visibility: auto; contain-intrinsic-size: 230px 590px;
}
.pf-card.clickable { cursor: pointer; }
.pf-card.clickable:hover { border-color: var(--pf-line2); transform: translateY(-2px); }
.pf-card.mine { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(240,180,41,0.25), 0 0 22px rgba(240,180,41,0.10); }
.pf-card.busy { opacity: 0.82; }
.pf-card.offline { opacity: 0.62; }

/* the phone itself — real handset proportions, subtle bezel */
.pf-shot {
  position: relative; aspect-ratio: 390 / 844; margin: 12px 12px 0; flex: 0 0 auto;
  background: #000; border-radius: 22px; overflow: hidden;
  /* visible handset bezel: dark band, then a lighter edge highlight */
  box-shadow: 0 0 0 4px #101013, 0 0 0 5px #303038, 0 8px 18px rgba(0,0,0,0.55);
}
.pf-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-shot::after {                       /* notch / dynamic island */
  content: ''; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 32%; height: 9px; border-radius: 99px; background: #000; z-index: 3; opacity: 0.9;
}
.pf-shot .pf-skeleton {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, #0d0d0f 30%, #17171a 50%, #0d0d0f 70%);
  background-size: 220% 100%; animation: pf-sheen 1.5s linear infinite;
}
@keyframes pf-sheen { to { background-position: -220% 0; } }
/* styled stand-in whenever no frame has EVER loaded — never a blank rectangle */
.pf-shot .pf-placeholder {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  color: #4a4a52; font-size: 11px; letter-spacing: 0.3px; text-align: center;
  background:
    radial-gradient(120% 80% at 50% 0%, #131317 0%, #0a0a0c 60%, #08080a 100%);
}
.pf-shot .pf-placeholder::before {      /* little phone glyph */
  content: ''; width: 26px; height: 46px; border-radius: 6px;
  border: 1.5px solid #2b2b31; background: #0d0d10;
  box-shadow: inset 0 6px 0 -4px #2b2b31, inset 0 -6px 0 -4px #2b2b31;
}
.pf-badge {
  position: absolute; top: 7px; left: 7px; z-index: 4;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(0,0,0,0.66); backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.10); border-radius: 99px;
  padding: 2.5px 8px; font-size: 10px; color: #d6d6da; letter-spacing: 0.3px;
}
.pf-badge.mine { border-color: rgba(240,180,41,0.5); color: var(--gold-light); }

/* footer sits directly under the phone — no dead vertical space */
.pf-foot { padding: 10px 13px 13px; }
.pf-name { font-size: 13.5px; font-weight: 600; color: #fff; line-height: 1.3; }
.pf-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pf-tag {
  font-size: 9.5px; color: #9a9aa2; border: 1px solid var(--pf-line2);
  border-radius: 5px; padding: 1px 5px;
}
.pf-status { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11.5px; color: #8b8b93; }
.pf-status.mine { color: var(--gold-light); }
.pf-actions { display: flex; gap: 6px; margin-top: 9px; }
.pf-actions button { margin: 0; padding: 5px 9px; font-size: 11.5px; flex: 1; }
.pf-actions .ghost { border-color: var(--pf-line2); }

/* sleeping keeps the last frame, visibly dimmed; a lost connection greys it */
.pf-card.sleeping .pf-shot img { opacity: 0.42; filter: saturate(0.55) brightness(0.8); }
.pf-card.stale .pf-shot img { opacity: 0.45; filter: grayscale(0.35); }
.pf-card.stale { border-color: rgba(232, 179, 60, 0.35); }

/* ---- detail: the selected phone is the focus ---- */
.pf-detail-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--pf-line);
}
.pf-detail-head .row { margin-left: auto; }
.pf-detail-id { display: flex; align-items: center; gap: 10px; }
.pf-detail-name { font-size: 16px; font-weight: 700; color: #fff; }
.pf-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #8b8b93; }
.pf-frame-slot {
  border: 1px solid var(--pf-line); border-radius: 14px; overflow: hidden;
  background: #000; height: calc(100vh - 190px); min-height: 420px; max-height: 900px;
  display: flex; align-items: center; justify-content: center;
}
.pf-frame-slot iframe { width: 100%; height: 100%; border: 0; display: block; }
.pf-frame-ph { color: #4a4a52; font-size: 13px; text-align: center; line-height: 1.7; }
.pf-frame-ph b { color: var(--gold); font-weight: 600; }
#pf-fallback { margin-top: 7px; }

/* ---- responsive: collapse the rail rather than crush the grid ---- */
/* GatesGen's own 216px nav sits outside this view, so the rail has to fold at a
   wider VIEWPORT than 1100 to leave the device grid ~1100px of usable width */
@media (max-width: 1320px) {
  .pf-layout { grid-template-columns: minmax(0, 1fr); }
  .pf-checklist {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; width: 260px;
    border-radius: 0; max-height: none; transform: translateX(-102%);
    transition: transform .18s ease; box-shadow: 24px 0 40px rgba(0,0,0,0.5);
  }
  .pf-layout.cl-open .pf-checklist { transform: none; }
  .pf-cl-x, .pf-cl-toggle { display: inline-flex; align-items: center; }
  .pf-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 240px)); gap: 14px; }
}
@media (max-width: 700px) {
  .pf-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .pf-title { font-size: 20px; }
}
