: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); }

.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-grid .slot, #active-grid .errslot {
  width: 148px; height: 196px; 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; }

#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;
}
.lb-box { max-width: min(92vw, 900px); max-height: 92vh; display: flex; flex-direction: column; gap: 10px; }
#lb-img { max-width: 100%; max-height: 74vh; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); }
.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%; }
}
