:root {
  --bg: #0c0c0f; --panel: #141418; --panel2: #1b1b21; --panel3: #23232b; --line: #2a2a33; --line2: #383844;
  --text: #ececf1; --muted: #8b8b98; --accent: #6d7cff; --accent2: #b86dff; --danger: #ff5c7a; --ok: #3ddc97;
  --tl-name: 210px;
  font-family: "Inter", "Noto Sans Georgian", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; overflow: hidden; }
[hidden] { display: none !important; }
button, select, input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.full { width: 100%; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 7px 13px; white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--line2); background: var(--panel3); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; font-weight: 600; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.icon { width: 34px; height: 34px; padding: 0; }
.btn.big { padding: 12px; font-size: 15px; margin-top: 12px; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }
select, input[type=text], input[type=number], input[type=password], input:not([type]), textarea {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; outline: none; min-width: 0;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); }
textarea { width: 100%; resize: vertical; line-height: 1.5; }
input[type=range] { accent-color: var(--accent); }
input[type=color] { width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; flex: none; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 6px; }
.check { display: flex; align-items: center; gap: 7px; cursor: pointer; margin-top: 10px; }

.view { height: 100vh; display: flex; flex-direction: column; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); gap: 10px; background: var(--panel); flex: none; }
.top-left, .top-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 9px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: conic-gradient(var(--accent), var(--accent2), #ff7ab6, var(--accent)); flex: none; }
.proj-name { background: transparent !important; border-color: transparent !important; font-weight: 600; font-size: 15px; width: 240px; }
.proj-name:hover, .proj-name:focus { border-color: var(--line) !important; }

/* ---------- dashboard ---------- */
.dash { overflow-y: auto; padding: 32px max(24px, 6vw) 60px; }
.dash-hero { max-width: 860px; margin: 0 auto 40px; text-align: center; }
.dash-hero h1 { font-size: clamp(26px, 4vw, 40px); margin: 10px 0 22px; letter-spacing: -0.02em; }
.dash-prompt { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px; text-align: left; }
.dash-prompt textarea { background: transparent; border: none; font-size: 16px; padding: 6px; }
.dash-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.dash-row .muted { margin-right: auto; }
.dash-quick { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.dash h2 { font-size: 16px; color: var(--muted); font-weight: 600; max-width: 1200px; margin: 0 auto 14px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; max-width: 1200px; margin: 0 auto; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s; }
.pcard:hover { transform: translateY(-2px); border-color: var(--line2); }
.pcard .th { aspect-ratio: 16/9; background: #222 center/contain no-repeat; }
.pcard .meta { padding: 10px 12px; display: flex; align-items: center; gap: 6px; }
.pcard .meta div { flex: 1; min-width: 0; }
.pcard .meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.pcard .meta button { padding: 4px 7px; font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 30px; border: 1px dashed var(--line); border-radius: 14px; grid-column: 1 / -1; }

/* ---------- editor layout ---------- */
.workspace { flex: 1; display: grid; grid-template-columns: 300px 1fr 300px; min-height: 0; }
.left, .right { background: var(--panel); overflow-y: auto; min-height: 0; }
.left { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.right { border-left: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; padding: 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; background: var(--panel); z-index: 2; }
.tabs button { flex: 1; background: none; border: none; padding: 7px 4px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 12px; white-space: nowrap; }
.tabs button.active { background: var(--panel3); color: var(--text); }
.pane { padding: 14px; }
.lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 7px; font-weight: 600; }
.pane > .lbl:first-child { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.chips button { font-size: 11px; padding: 4px 9px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); cursor: pointer; }
.keybox { margin-top: 8px; }
.keybox input { width: 100%; }
.keybox a { color: var(--accent); }

.chat-pane { display: flex; flex-direction: column; gap: 10px; min-height: calc(100% - 50px); }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 160px; max-height: 52vh; padding-right: 2px; }
.chat-empty { color: var(--muted); font-size: 13px; line-height: 1.55; }
.chat-empty b { color: var(--text); font-size: 14px; }
.chat-empty p { margin: 6px 0 10px; }
.msg { padding: 9px 12px; border-radius: 14px; font-size: 13px; line-height: 1.5; max-width: 92%; white-space: normal; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--panel2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.ai .btn { margin-top: 6px; }
.msg.typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); margin-right: 3px; animation: blink 1.2s infinite; }
.msg.typing span:nth-child(2) { animation-delay: .2s; } .msg.typing span:nth-child(3) { animation-delay: .4s; }
.msg.typing em { color: var(--muted); font-style: normal; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-box { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.chat-box:focus-within { border-color: var(--accent); }
.chat-box textarea { background: transparent; border: none; padding: 4px; font-size: 14px; }
.chat-actions { display: flex; align-items: center; gap: 6px; }
.ai-banner { background: linear-gradient(135deg, rgba(109,124,255,.16), rgba(184,109,255,.16)); border: 1px solid rgba(109,124,255,.4); border-radius: 12px; padding: 10px 12px; font-size: 12.5px; line-height: 1.5; }
.ai-banner .btn { margin-top: 8px; }
.ai-settings { font-size: 13px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.ai-settings summary { cursor: pointer; color: var(--muted); }
.ai-settings select, .ai-settings input { margin-top: 8px; }
.ai-settings ol { padding-left: 18px; margin: 8px 0; }
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tpl { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; padding: 0; overflow: hidden; text-align: left; transition: border-color .15s; }
.tpl:hover { border-color: var(--accent); }
.tpl canvas { width: 100%; aspect-ratio: 16/9; display: block; background: #222; }
.tpl span { display: block; padding: 6px 8px; font-size: 12px; }
.el-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.el { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.el:hover { border-color: var(--accent); color: var(--text); }
.el b, .el span { font-size: 18px; color: var(--text); }
.el .pill-demo { font-size: 11px; background: var(--accent); padding: 2px 8px; border-radius: 99px; }

.drop { display: block; border: 1.5px dashed var(--line2); border-radius: 14px; padding: 20px 12px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.drop.over, .drop:hover { border-color: var(--accent); color: var(--text); background: rgba(109,124,255,.06); }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 10px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: repeating-conic-gradient(#2a2a30 0 25%, #222228 0 50%) 0 0/16px 16px; border: 1px solid var(--line); cursor: pointer; }
.thumb:hover { border-color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.thumb .x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; font-size: 10px; background: rgba(0,0,0,.75); border: none; cursor: pointer; }
.thumb .idx { position: absolute; left: 4px; bottom: 3px; font-size: 10px; background: rgba(0,0,0,.75); padding: 1px 6px; border-radius: 6px; }
.music { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.music span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pack-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pack { border: 2px solid transparent; border-radius: 12px; cursor: pointer; padding: 0; overflow: hidden; background: var(--panel2); text-align: left; }
.pack.active { border-color: var(--accent); }
.pack .sw { height: 46px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.pack span { display: block; padding: 5px 8px; font-size: 12px; }
.colors { display: flex; gap: 6px; margin-top: 8px; }
.field-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.field-row > span { width: 80px; color: var(--muted); font-size: 12px; flex: none; }
.field-row > input[type=range], .field-row > select { flex: 1; }

/* ---------- stage ---------- */
.center { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #09090b; }
.viewport { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; position: relative;
  background: radial-gradient(circle at 50% 50%, #15151b, #09090b); }
.stagebox { position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.55); }
.stagebox canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#canvas { border-radius: 4px; }
#overlay { cursor: default; touch-action: none; }

/* ---------- inspector ---------- */
.insp { padding: 12px 14px 40px; }
.insp h4 { margin: 18px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.insp h4:first-child { margin-top: 0; }
.insp .f { display: grid; grid-template-columns: 78px 1fr auto; align-items: center; gap: 6px; margin-bottom: 6px; }
.insp .f > label { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp .f > .ctl { display: flex; gap: 5px; align-items: center; min-width: 0; }
.insp .f > .ctl > input:not([type=color]):not([type=checkbox]), .insp .f > .ctl > select, .insp .f > .ctl > textarea { flex: 1; width: 100%; padding: 5px 7px; font-size: 13px; }
.insp .f.wide { grid-template-columns: 1fr; }
.kfb { width: 22px; height: 22px; border: none; background: none; cursor: pointer; color: var(--line2); font-size: 13px; padding: 0; }
.kfb.has { color: var(--accent); }
.kfb.on { color: #ffd43b; }
.insp .row-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.insp .row-btns .btn { flex: 1; padding: 6px 8px; font-size: 12px; }
.insp .empty-state { color: var(--muted); text-align: center; padding: 40px 10px; line-height: 1.6; }
.insp .badge { font-size: 10px; background: var(--panel3); padding: 2px 7px; border-radius: 99px; color: var(--muted); text-transform: none; letter-spacing: 0; }
.kbd { display: inline-block; background: var(--panel3); border: 1px solid var(--line2); border-radius: 5px; padding: 0 5px; font-size: 11px; }

/* ---------- timeline ---------- */
.timeline { height: 250px; border-top: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; flex: none; resize: vertical; overflow: hidden; min-height: 140px; max-height: 60vh; }
.tl-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex: none; }
.time { font-variant-numeric: tabular-nums; font-size: 13px; min-width: 110px; }
#zoom { width: 110px; }
.tl-scroll { flex: 1; overflow: auto; position: relative; }
.tl-content { position: relative; min-width: 100%; }
.tl-row { display: flex; height: 30px; border-bottom: 1px solid rgba(255,255,255,0.035); }
.tl-row.sel { background: rgba(109,124,255,0.09); }
.tl-name { width: var(--tl-name); flex: none; position: sticky; left: 0; z-index: 3; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; align-items: center; gap: 4px; padding: 0 6px; font-size: 12px; cursor: pointer; white-space: nowrap; overflow: hidden; }
.tl-row.sel .tl-name { background: #1a1a26; }
.tl-name .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.tl-name .tg, .tl-name .eye { width: 16px; text-align: center; color: var(--muted); cursor: pointer; flex: none; font-size: 11px; }
.tl-name .ty { font-size: 10px; color: var(--muted); width: 14px; text-align: center; flex: none; }
.tl-track { position: relative; flex: 1; }
.tl-clip { position: absolute; top: 5px; height: 20px; border-radius: 6px; cursor: grab; display: flex; align-items: center; padding: 0 7px; font-size: 11px; overflow: hidden; white-space: nowrap; color: #fff; }
.tl-clip::before, .tl-clip::after { content: ''; position: absolute; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }
.tl-clip::before { left: 0; } .tl-clip::after { right: 0; }
.tl-clip.group { background: rgba(109,124,255,0.35); border: 1px solid rgba(109,124,255,0.7); }
.tl-clip.text { background: rgba(61,220,151,0.28); border: 1px solid rgba(61,220,151,0.6); }
.tl-clip.image { background: rgba(255,170,60,0.28); border: 1px solid rgba(255,170,60,0.6); }
.tl-clip.shape { background: rgba(184,109,255,0.28); border: 1px solid rgba(184,109,255,0.6); }
.tl-row.sel .tl-clip { box-shadow: 0 0 0 1.5px #fff inset; }
.tl-row.hid .tl-clip { opacity: .35; }
.kf { position: absolute; top: 9px; width: 11px; height: 11px; margin-left: -5.5px; transform: rotate(45deg); background: #ffd43b; border: 1.5px solid #0c0c0f; cursor: ew-resize; z-index: 2; border-radius: 2px; }
.tl-ruler { position: sticky; top: 0; z-index: 5; height: 26px; display: flex; background: var(--panel2); border-bottom: 1px solid var(--line); }
.tl-ruler .tl-name { background: var(--panel2); z-index: 6; color: var(--muted); }
.tl-ruler .ticks { position: relative; flex: 1; cursor: text; }
.tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line2); font-size: 10px; color: var(--muted); padding: 3px 0 0 4px; pointer-events: none; }
.tick.minor { top: 18px; }
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1.5px solid #ff4d6d; z-index: 4; pointer-events: none; }
.tl-playhead::before { content: ''; position: absolute; top: 0; left: -6px; border: 6px solid transparent; border-top: 8px solid #ff4d6d; }
.tl-end { position: absolute; top: 0; bottom: 0; background: rgba(0,0,0,0.25); pointer-events: none; }

/* ---------- modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(4px); }
.modal { background: var(--panel); border: 1px solid var(--line); padding: 22px 24px; border-radius: 18px; width: min(420px, 92vw); }
.modal h3 { margin: 0 0 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.bar { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; margin-top: 10px; }
.bar div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .1s; }
.toast { position: fixed; bottom: 270px; left: 50%; transform: translateX(-50%); background: var(--panel3); border: 1px solid var(--line2); padding: 10px 16px; border-radius: 12px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 90vw; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 260px 1fr; }
  .right { display: none; }
  .right.mobile-open { display: block; position: fixed; right: 0; top: 51px; bottom: 250px; width: 300px; z-index: 20; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .view#editor { height: auto; min-height: 100vh; }
  .workspace { grid-template-columns: 1fr; }
  .center { height: 56vw; min-height: 240px; order: -1; }
  .left { max-height: none; border-right: none; }
  .hide-sm { display: none; }
  .proj-name { width: 120px; }
  :root { --tl-name: 130px; }
}
