:root {
  --bg: #0d111a; --bg2: #121827; --panel: #151c2b; --panel2: #1b2436; --line: #28344a; --line2: #34425c;
  --text: #e8edf6; --dim: #95a3b8; --accent: #a78bfa; --accent2: #f08ab6; --ok: #4cc38a; --warn: #f0a33a;
  --bad: #f06a6a; --radius: 10px; --glow: #1d1838;
  --font: Inter, 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; }
.dim { color: var(--dim); } .small { font-size: 12px; } .mono { font-family: var(--mono); }
.error { color: var(--bad); }
button, .btn { font: 600 13px var(--font); color: var(--text); background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 8px; padding: 7px 13px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #140f26; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; color: var(--dim); }
button.ghost:hover, .btn.ghost:hover { color: var(--text); border-color: var(--line2); }
input, select, textarea { font: 13px var(--font); color: var(--text); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; width: 100%; }
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: 12px; min-height: 420px; white-space: pre; tab-size: 2; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--dim); }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
label.inline input { width: auto; }

/* layout */
header.top { display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--line);
  background: var(--bg2); position: sticky; top: 0; z-index: 10; }
.logo { font: 800 18px var(--font); letter-spacing: -.02em; }
.logo b { color: var(--accent); } .logo span { color: var(--accent2); font-weight: 600; }
header.top nav { display: flex; gap: 6px; margin-left: 12px; }
header.top .spacer { flex: 1; }
main { max-width: 1240px; margin: 0 auto; padding: 24px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } main { padding: 16px; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.stack > * + * { margin-top: 14px; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--line2); color: var(--dim); text-transform: uppercase; letter-spacing: .04em; }
.chip.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.chip.working { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.chip.scripted { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* project cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; color: var(--text); }
.card:hover { border-color: var(--accent); text-decoration: none; }
.card .thumb { aspect-ratio: 16/9; background: linear-gradient(135deg, var(--glow), var(--bg)); display: flex; align-items: center;
  justify-content: center; color: var(--dim); font-size: 12px; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.card .title { font-weight: 650; }

/* project page */
.phead { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0 18px; flex-wrap: wrap; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 9px 14px; color: var(--dim); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.jobbar { display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-radius: 8px; margin-top: 14px;
  background: color-mix(in srgb, var(--warn) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
.jobbar.failed { background: color-mix(in srgb, var(--bad) 10%, var(--panel)); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.jobbar .last { flex: 1; font-family: var(--mono); font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--warn); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
pre.log { background: #080b12; border: 1px solid var(--line); border-radius: 8px; padding: 14px; max-height: 560px; overflow: auto;
  font: 12px/1.55 var(--mono); color: #c8d2e0; white-space: pre-wrap; margin: 0; }

/* scenes */
.scene { display: grid; grid-template-columns: 220px 1fr; gap: 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; }
.scene + .scene { margin-top: 12px; }
.scene .pic { background: #080b12; border-radius: 8px; aspect-ratio: 16/9; overflow: hidden; display: flex; align-items: center;
  justify-content: center; color: var(--dim); font-size: 11px; text-align: center; padding: 4px; }
.scene .pic.tall { aspect-ratio: 9/16; max-height: 300px; }
.scene .pic img { width: 100%; height: 100%; object-fit: contain; }
.scene .fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.scene .fields .wide { grid-column: span 4; } .scene .fields .half { grid-column: span 2; }
.scene .meta { display: flex; gap: 8px; align-items: center; color: var(--dim); font-size: 12px; }
@media (max-width: 900px) { .scene { grid-template-columns: 1fr; } .scene .fields { grid-template-columns: 1fr 1fr; } }
.player { width: 100%; max-height: 72vh; background: #000; border-radius: var(--radius); }
.player.tall { max-height: 80vh; width: auto; display: block; margin: 0 auto; }
.sheets img, .gallery img { width: 100%; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; } .gallery figcaption { font-size: 11px; color: var(--dim); margin-top: 4px; }
.filelist { list-style: none; padding: 0; margin: 0; }
.filelist li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.filelist li span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.note { border-left: 3px solid var(--line2); padding: 6px 12px; margin: 8px 0; }
.note.blocking { border-color: var(--bad); } .note.major { border-color: var(--warn); } .note.minor { border-color: var(--line2); }
.hint { font-size: 12px; color: var(--dim); font-weight: 400; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line2);
  padding: 10px 18px; border-radius: 8px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.toast.err { border-color: var(--bad); color: #ffd0d0; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: transparent; }
.seg button.on { background: var(--accent); color: #140f26; }
.empty { text-align: center; padding: 50px 20px; color: var(--dim); }

/* login */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(ellipse at 30% 20%, var(--glow), var(--bg) 60%); }
.login-card { width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px;
  display: flex; flex-direction: column; gap: 14px; }
.login-card .logo { font-size: 24px; }

.grid4 > * { align-self: start; }

/* kind chooser + spec-driven forms */
.kinds { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 16px 0 18px; }
.kind { flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; white-space: normal; text-align: left;
  background: var(--panel); border-color: var(--line); height: 100%; }
.kind b { font-size: 14px; } .kind span { font-weight: 400; font-size: 12px; color: var(--dim); line-height: 1.4; }
.kind.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.fgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; align-items: start; }
.fgrid > .w-full { grid-column: span 6; } .fgrid > .w-half { grid-column: span 3; }
.fgrid > .w-third { grid-column: span 2; } .fgrid > .w-two-thirds { grid-column: span 4; }
@media (max-width: 900px) { .kinds { grid-template-columns: 1fr 1fr; } .fgrid > * { grid-column: span 6 !important; } }
.req { color: var(--accent2); font-weight: 700; }
.invalid { border-color: var(--bad) !important; }
details.more { border-top: 1px solid var(--line); padding-top: 12px; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--dim); }
details.more summary .hint { margin-left: 8px; }
input[type=file] { padding: 5px; }

button.ghost.danger { color: var(--bad); }
button.ghost.danger:hover:not(:disabled) { border-color: var(--bad); }
[hidden] { display: none !important; }
