:root {
  --bg: #0e0e0f; --panel: #151517; --panel2: #1c1c1f; --line: #2a2a2e; --tx: #f1ece2; --mu: #9b968c;
  --ac: #E4572E; --ac2: #ff7a52; --ok: #3fb47a; --warn: #e3a33b; --err: #e05454;
  --r: 14px; font-family: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx); font-size: 15px; line-height: 1.55; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; }
.muted { color: var(--mu); }

.app { display: grid; grid-template-columns: 250px minmax(400px, 1fr) minmax(380px, 470px); height: 100vh; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 9px 16px; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:hover { border-color: #3c3c42; background: #232327; }
.btn.primary { background: var(--ac); border-color: var(--ac); color: #fff; }
.btn.primary:hover { background: var(--ac2); border-color: var(--ac2); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 13.5px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--tx); color: var(--bg); font-size: 15px; cursor: pointer; flex: none; }

/* sidebar */
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; gap: 14px; min-height: 0; }
.brand { display: flex; gap: 11px; align-items: center; padding: 0 4px 6px; }
.brand .mark { width: 42px; height: 42px; border-radius: 11px; background: var(--ac); color: #fff; font-weight: 800; font-size: 14px; display: grid; place-items: center; letter-spacing: .5px; }
.brand b { display: block; font-size: 16px; }
.brand span { font-size: 12.5px; color: var(--mu); }
.newform { display: flex; flex-direction: column; gap: 8px; }
.newform input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.row { display: flex; gap: 8px; }
.projects { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.projects a { display: block; padding: 9px 11px; border-radius: 10px; color: var(--tx); text-decoration: none; font-size: 14px; }
.projects a:hover { background: var(--panel2); }
.projects a.on { background: #26201d; box-shadow: inset 3px 0 0 var(--ac); }
.projects a small { display: block; color: var(--mu); font-size: 12px; }
.projects .none { color: var(--mu); font-size: 13px; padding: 8px 11px; }
.status { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--mu); border-top: 1px solid var(--line); padding-top: 12px; }
.status i { width: 9px; height: 9px; border-radius: 50%; background: var(--mu); margin-top: 5px; flex: none; }
.status.ok i { background: var(--ok); }
.status.bad i { background: var(--warn); }

/* chat */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chathead { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chathead h1 { font-size: 18px; margin: 0; }
.chathead p { margin: 0; color: var(--mu); font-size: 13px; }
.team { display: flex; gap: 6px; flex-wrap: wrap; }
.team span { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--mu); }
.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 12px; max-width: 760px; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ac); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; flex: none; }
.msg.user .avatar { background: #3a3a40; }
.bubble { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; min-width: 0; overflow-wrap: anywhere; }
.msg.user .bubble { background: #2a2420; border-color: #3b302a; }
.msg.err .bubble { border-color: #5a3434; background: #221616; }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble a { color: #ffb59c; }
.bubble code { background: #000; padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.who { font-size: 12px; color: var(--mu); margin-bottom: 4px; font-weight: 600; }

.card { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 14px 16px; }
.card h3 { margin: 0 0 4px; font-size: 15.5px; }
.card h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--mu); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tag { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); }
.tag.ac { background: #3a1f16; border-color: #6b3423; color: #ffb59c; }
.hooks { display: flex; flex-direction: column; gap: 8px; }
.hook { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.hook:hover { border-color: var(--ac); }
.hook b { display: block; font-weight: 600; }
.hook small { color: var(--mu); }
.hook .n { color: var(--ac); font-weight: 800; margin-right: 6px; }
.card ol, .card ul { margin: 0; padding-left: 20px; font-size: 14px; }
.card li { margin: 3px 0; }
.card a { color: #ffb59c; }
.card .actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.warn { color: var(--warn); }

.working { border: 1px dashed #3d3d44; border-radius: var(--r); padding: 12px 16px; background: var(--panel); font-size: 13.5px; min-width: 300px; }
.working .top { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }
.working ul { list-style: none; margin: 0; padding: 0; max-height: 180px; overflow-y: auto; }
.working li { color: var(--mu); padding: 2px 0; }
.working li b { color: var(--tx); font-weight: 600; margin-right: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ac); margin-right: 8px; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.welcome { margin: auto; max-width: 560px; text-align: center; padding: 20px; }
.welcome h2 { font-size: 26px; margin: 0 0 8px; }
.welcome p { color: var(--mu); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0; text-align: left; }
.steps div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 13.5px; }
.steps b { display: block; color: var(--ac); font-size: 20px; }

.composer { border-top: 1px solid var(--line); padding: 12px 24px 18px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.thumbs:empty { display: none; }
.thumbs figure { margin: 0; width: 64px; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); display: block; }
.thumbs figcaption { font-size: 10.5px; color: var(--mu); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.box:focus-within { border-color: #4a4a52; }
.box textarea { width: 100%; resize: none; border: 0; background: transparent; outline: none; min-height: 48px; max-height: 220px; }
.tools { display: flex; gap: 8px; align-items: center; }
.tools label.btn { display: inline-block; }
.grow { flex: 1; }
.composer.off { opacity: .5; pointer-events: none; }

/* studio */
.studio { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 14px 18px; gap: 10px; overflow-y: auto; }
.studiohead { display: flex; align-items: baseline; gap: 10px; }
.studiohead h2 { margin: 0; font-size: 16px; }
.studiohead span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage { position: relative; align-self: center; height: min(58vh, 640px); aspect-ratio: 9 / 16; border-radius: 18px; overflow: hidden; background: #000; box-shadow: 0 0 0 1px var(--line); flex: none; }
.stage canvas { width: 100%; height: 100%; display: block; cursor: pointer; }
.empty, .rec { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; background: #111; color: var(--mu); font-size: 13.5px; }
.rec { background: rgba(0,0,0,.72); color: var(--tx); }
.rec span { font-size: 28px; font-weight: 800; }
.empty[hidden], .rec[hidden] { display: none; }
.controls { display: flex; align-items: center; gap: 10px; }
.controls input[type=range] { flex: 1; accent-color: var(--ac); }
.time { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--mu); white-space: nowrap; }
.subs { font-size: 12.5px; color: var(--mu); display: flex; gap: 5px; align-items: center; white-space: nowrap; }
.exports { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 8px 10px; color: var(--mu); font-weight: 600; font-size: 13.5px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--tx); border-color: var(--ac); }
.tabbody { font-size: 13.5px; }
.scene { display: grid; grid-template-columns: 30px 1fr auto; gap: 2px 10px; padding: 9px 8px; border-radius: 10px; cursor: pointer; }
.scene:hover, .scene.on { background: var(--panel2); }
.scene .i { color: var(--ac); font-weight: 800; }
.scene .t { font-weight: 600; }
.scene .d { color: var(--mu); font-size: 12px; font-variant-numeric: tabular-nums; }
.scene .v { grid-column: 2 / 4; color: var(--mu); font-size: 13px; }
.scene .k { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--mu); margin-right: 6px; }
.block { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; white-space: pre-wrap; }
.blockhead { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-weight: 600; }
.checks { list-style: none; padding: 0; margin: 6px 0 12px; }
.checks li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.checks li span.s { flex: none; width: 20px; font-weight: 800; }
.checks .y { color: var(--ok); } .checks .n { color: var(--warn); }
.checks small { color: var(--mu); display: block; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #26262b; border: 1px solid #3a3a40; padding: 11px 18px; border-radius: 12px; font-size: 14px; max-width: 640px; z-index: 10; box-shadow: 0 10px 30px rgba(0,0,0,.4); }

@media (max-width: 1180px) {
  .app { grid-template-columns: 220px 1fr; }
  .studio { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .app { height: auto; min-height: 100vh; }
  .chat { height: 100vh; }
}
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
