:root {
  --bg: #0b0d14;
  --panel: #12151f;
  --panel-2: #181c28;
  --line: #262b3a;
  --line-2: #323848;
  --text: #e8eaf2;
  --muted: #9aa1b5;
  --faint: #6b7287;
  --accent: #8b5cf6;
  --accent-2: #6366f1;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, sans-serif; }
body { min-height: 100vh; background: radial-gradient(1200px 600px at 80% -10%, rgba(99, 102, 241, 0.12), transparent 60%), var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: #a78bfa; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

/* ---------- header ---------- */
header.top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: rgba(11, 13, 20, 0.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; }
.brand small { color: var(--faint); font-weight: 500; font-size: 12px; }
nav.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin: 0 auto; }
nav.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 7px; color: var(--muted); cursor: pointer; font-weight: 600; white-space: nowrap; }
nav.tabs button.active { background: var(--accent-soft); color: #fff; box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.5); }
.top-right { display: flex; align-items: center; gap: 10px; }
.spend { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.key-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); display: inline-block; margin-right: 6px; }
.key-dot.ok { background: var(--good); }

/* ---------- layout ---------- */
main { max-width: 1440px; margin: 0 auto; padding: 22px 20px 60px; }
.split { display: grid; grid-template-columns: minmax(340px, 460px) 1fr; gap: 22px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card > .card-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; font-weight: 600; cursor: default; }
.card > .card-b { padding: 0 14px 14px; }
details.card > summary { list-style: none; padding: 12px 14px; font-weight: 600; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: '▾'; color: var(--faint); transition: transform 0.2s; }
details.card[open] > summary::after { transform: rotate(180deg); }
details.card > .card-b { padding: 0 14px 14px; }
.sticky-col { position: sticky; top: 76px; }
h2.step { font-size: 18px; margin: 0 0 2px; }
p.sub { margin: 0 0 6px; color: var(--muted); font-size: 13px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

/* ---------- fields ---------- */
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.f .lbl { display: flex; align-items: center; gap: 5px; }
select, input[type=text], input[type=password], input[type=number], textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.tip { position: relative; display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line-2); color: var(--faint); font-size: 10px; cursor: help; }
.tip:hover::after {
  content: attr(data-tip); position: absolute; bottom: 140%; left: 50%; transform: translateX(-50%); width: 240px; padding: 8px 10px;
  background: #222738; border: 1px solid var(--line-2); border-radius: 8px; color: var(--text); font-size: 12px; font-weight: 400; z-index: 50; box-shadow: var(--shadow);
}
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 0 auto; min-width: 46px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600; }
.seg button.on { border-color: var(--accent); background: var(--accent-soft); color: #fff; }
.seg button:disabled { opacity: 0.35; cursor: not-allowed; }
.aspects { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.aspects button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px 7px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--muted); cursor: pointer; text-align: center; }
.aspects button.on { border-color: var(--accent); background: var(--accent-soft); color: #fff; }
.aspects button:disabled { opacity: 0.35; cursor: not-allowed; }
.aspects .shape { height: 46px; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 2px; }
.aspects .shape svg { overflow: hidden; }
.aspects .frame { fill: var(--panel); stroke: currentColor; stroke-width: 1.5; }
.aspects .fig { fill: currentColor; opacity: 0.45; }
.aspects button.on .fig { opacity: 0.8; }
.aspects .a-name { font-size: 12px; font-weight: 700; }
.aspects .a-ratio { font-weight: 500; opacity: 0.7; }
.aspects .a-use { font-size: 10.5px; line-height: 1.25; opacity: 0.8; }
@media (max-width: 520px) { .aspects { grid-template-columns: repeat(2, 1fr); } }
.toggle { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; cursor: pointer; }
.toggle input { appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--line-2); position: relative; flex: none; cursor: pointer; transition: 0.2s; margin-top: 1px; }
.toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: 0.2s; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { left: 17px; }
.toggle .t-title { font-weight: 600; font-size: 13px; }
.toggle .t-desc { color: var(--faint); font-size: 12px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: #4a5168; background: #1e2331; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn.big { padding: 13px 18px; font-size: 15px; border-radius: 11px; width: 100%; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: 7px; }
.cost { font-size: 11px; font-family: ui-monospace, Menlo, monospace; padding: 2px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.chip:hover { color: var(--text); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: #fff; }
.group-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin: 10px 0 6px; font-weight: 700; }

/* ---------- prompt hint ---------- */
.hint { font-size: 12px; margin-top: 6px; }
.hint.good { color: var(--good); } .hint.warning { color: var(--warn); } .hint.info { color: #93c5fd; }

/* ---------- result viewer ---------- */
.viewer { min-height: 520px; display: flex; flex-direction: column; }
.stage { position: relative; flex: 1; display: grid; place-items: center; background: repeating-conic-gradient(#121520 0% 25%, #0f121b 0% 50%) 50% / 22px 22px; border-radius: 10px; margin: 0 14px; min-height: 460px; overflow: hidden; }
.stage img { max-height: 72vh; object-fit: contain; border-radius: 6px; cursor: zoom-in; }
.empty { text-align: center; color: var(--faint); padding: 40px; }
.empty .big-ic { font-size: 40px; margin-bottom: 8px; opacity: 0.7; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(11, 13, 20, 0.72); backdrop-filter: blur(3px); z-index: 2; text-align: center; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin 0.9s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading .msg { font-weight: 600; } .loading .msg2 { font-size: 12px; color: var(--muted); margin-top: 4px; }
.thumbs { display: flex; gap: 8px; padding: 12px 14px 0; overflow-x: auto; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; cursor: pointer; flex: none; }
.thumbs img.on { border-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 14px; }

/* ---------- QC badge / report ---------- */
.qc { position: absolute; top: 10px; left: 10px; z-index: 1; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgba(0, 0, 0, 0.65); border: 1px solid var(--line-2); }
.qc.good { color: var(--good); border-color: rgba(52, 211, 153, 0.5); }
.qc.mid { color: var(--warn); border-color: rgba(251, 191, 36, 0.5); }
.qc.bad { color: var(--bad); border-color: rgba(248, 113, 113, 0.5); }
.report { margin: 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); font-size: 12px; }
.report ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }
.report .sev-high { color: var(--bad); font-weight: 600; } .report .sev-medium { color: var(--warn); font-weight: 600; } .report .sev-low { color: var(--muted); font-weight: 600; }
.report .log { color: var(--faint); margin-top: 6px; }

/* ---------- galleries ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; aspect-ratio: 4 / 5; }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s; }
.tile:hover img { transform: scale(1.03); }
.tile .meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 8px 7px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.85)); font-size: 11px; display: flex; justify-content: space-between; gap: 6px; }
.tile .meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .qc { top: 6px; left: 6px; font-size: 11px; padding: 2px 8px; }
.tile.pending { display: grid; place-items: center; cursor: default; }
.tile.pending .spinner { width: 28px; height: 28px; margin: 0; }
.tile.failed { display: grid; place-items: center; text-align: center; padding: 12px; color: var(--bad); font-size: 12px; cursor: default; }

/* ---------- avatar refs ---------- */
.refs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ref { position: relative; aspect-ratio: 1; border-radius: 9px; overflow: hidden; border: 1px solid var(--line-2); }
.ref img { width: 100%; height: 100%; object-fit: cover; }
.ref .x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.7); color: #fff; cursor: pointer; font-size: 12px; }
.ref .tag { position: absolute; bottom: 4px; left: 4px; font-size: 10px; padding: 1px 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.7); }
.drop { aspect-ratio: 1; border: 1.5px dashed var(--line-2); border-radius: 9px; display: grid; place-items: center; text-align: center; color: var(--faint); font-size: 12px; cursor: pointer; padding: 8px; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.drop.wide { aspect-ratio: auto; min-height: 140px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(4, 5, 10, 0.78); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; }
.modal .box { width: min(640px, 100%); max-height: 92vh; overflow: auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow); padding: 22px; }
.modal .box.wide { width: min(1180px, 100%); }
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal .close { float: right; }
.lightbox { display: grid; grid-template-columns: 1fr 340px; gap: 18px; }
.lightbox img { max-height: 80vh; width: 100%; object-fit: contain; border-radius: 10px; background: #000; }
.lightbox .side { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.lightbox .prompt-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 260px; overflow: auto; white-space: pre-wrap; color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 12px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 600; }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast { padding: 11px 14px; border-radius: 10px; background: #1d2130; border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 13px; animation: pop 0.2s ease-out; }
.toast.err { border-color: rgba(248, 113, 113, 0.6); }
.toast.ok { border-color: rgba(52, 211, 153, 0.6); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.banner { padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(139, 92, 246, 0.5); background: var(--accent-soft); display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }

@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .sticky-col { position: static; }
  .lightbox { grid-template-columns: 1fr; }
  header.top { flex-wrap: wrap; }
  nav.tabs { order: 3; width: 100%; overflow-x: auto; }
}
@media (max-width: 520px) {
  main { padding: 14px 12px 40px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .brand small { display: none; }
}

/* ---------- member sign-in ---------- */
.signin { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 16px; overflow: auto;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(139, 92, 246, 0.22), transparent 60%), var(--bg); transition: opacity 0.25s; }
.signin.out { opacity: 0; }
.si-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); padding: 30px 26px 22px; text-align: center; }
.si-logo { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.si-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.01em; }
.si-sub { margin: 0 0 22px; color: var(--muted); }
.si-form { text-align: left; display: grid; gap: 10px; }
.si-form input { font-size: 15px; padding: 12px 14px; }
.si-form .btn { width: 100%; justify-content: center; }
.si-err { color: var(--bad); font-size: 12.5px; min-height: 0; }
.si-err:empty { display: none; }
.si-steps { list-style: none; margin: 4px 0 0; padding: 0; text-align: left; display: grid; gap: 12px; }
.si-steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); animation: si-in 0.25s ease-out; }
.si-steps li.ok { color: var(--text); }
.si-steps li.final { color: var(--good); font-weight: 600; word-break: break-all; }
.si-ic { width: 18px; height: 18px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.si-steps li.run .si-ic { border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.si-steps li.ok .si-ic { background: var(--good); color: #062; }
.si-steps li.ok .si-ic::after { content: '✓'; }
.si-fine { margin: 20px 0 0; font-size: 12px; color: var(--faint); }
@keyframes si-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); font-size: 13px; word-break: break-all; }
.badge-ok { color: var(--good); font-weight: 600; margin-right: 4px; }
