:root {
  --bg: #0c0d13;
  --panel: #151720;
  --panel-2: #1c1f2b;
  --panel-3: #242838;
  --line: #303548;
  --text: #f6f7fb;
  --muted: #9aa2b8;
  --primary: #8b5cf6;
  --primary-2: #c084fc;
  --accent: #ff8c42;
  --good: #2dd4bf;
  --danger: #fb7185;
  --warning: #fbbf24;
  --shadow: 0 18px 55px rgba(0,0,0,.38);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, video { max-width: 100%; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, .9fr) minmax(500px, 1.35fr); background: radial-gradient(circle at 70% 20%, rgba(139,92,246,.25), transparent 35%), var(--bg); }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 42px; }
.auth-card { width: min(460px, 100%); background: rgba(21,23,32,.93); border: 1px solid var(--line); border-radius: 28px; padding: 38px; box-shadow: var(--shadow); }
.auth-art { position: relative; overflow: hidden; display: flex; align-items: flex-end; padding: 70px; background: linear-gradient(145deg, #261c45, #111827 55%, #2a1721); }
.auth-art::before, .auth-art::after { content: ""; position: absolute; border-radius: 50%; filter: blur(2px); }
.auth-art::before { width: 420px; height: 420px; top: 8%; left: 18%; background: linear-gradient(145deg, #8b5cf6, #f472b6); opacity: .6; }
.auth-art::after { width: 260px; height: 260px; top: 36%; right: 12%; background: linear-gradient(145deg, #ff8c42, #fbbf24); opacity: .55; }
.art-copy { position: relative; z-index: 2; max-width: 700px; }
.art-copy h1 { font-size: clamp(48px, 6vw, 92px); line-height: .95; margin: 0 0 24px; letter-spacing: -.06em; }
.art-copy p { font-size: 21px; color: #e6e2f2; line-height: 1.55; max-width: 630px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -.03em; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; background: linear-gradient(145deg, var(--primary), var(--accent)); box-shadow: 0 8px 22px rgba(139,92,246,.35); }
.auth-card .brand { margin-bottom: 36px; font-size: 21px; }
.auth-card h2 { font-size: 30px; letter-spacing: -.04em; margin: 0 0 8px; }
.auth-card > p { margin: 0 0 28px; color: var(--muted); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0,1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; background: #101118; border-right: 1px solid #242735; padding: 22px 16px; display: flex; flex-direction: column; z-index: 40; }
.sidebar .brand { padding: 6px 10px 24px; font-size: 20px; }
.nav { display: grid; gap: 5px; }
.nav-btn { border: 0; background: transparent; color: var(--muted); text-align: left; padding: 12px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; font-weight: 650; }
.nav-btn:hover { background: var(--panel-2); color: var(--text); }
.nav-btn.active { color: white; background: linear-gradient(100deg, rgba(139,92,246,.28), rgba(139,92,246,.08)); box-shadow: inset 3px 0 var(--primary); }
.nav-icon { width: 22px; text-align: center; font-size: 18px; }
.sidebar-bottom { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--line); }
.user-chip { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; padding: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(145deg, var(--primary), #ec4899); display: grid; place-items: center; font-weight: 800; }
.user-chip strong, .user-chip small { display: block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { color: var(--muted); margin-top: 2px; }
.main { grid-column: 2; min-width: 0; }
.topbar { height: 76px; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 30px; background: rgba(12,13,19,.88); backdrop-filter: blur(18px); border-bottom: 1px solid rgba(48,53,72,.7); }
.topbar-title { font-weight: 780; font-size: 18px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.page { padding: 30px; max-width: 1680px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 28px; }
.page-head h1 { font-size: clamp(30px, 4vw, 48px); letter-spacing: -.055em; margin: 0 0 8px; }
.page-head p { color: var(--muted); margin: 0; max-width: 780px; line-height: 1.55; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

.btn { border: 1px solid var(--line); color: var(--text); background: var(--panel-2); border-radius: 12px; padding: 10px 15px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; }
.btn:hover { transform: translateY(-1px); border-color: #4b526b; }
.btn-primary { border: 0; background: linear-gradient(135deg, var(--primary), #a855f7); box-shadow: 0 10px 28px rgba(139,92,246,.25); }
.btn-accent { border: 0; background: linear-gradient(135deg, #f97316, var(--accent)); }
.btn-good { border-color: rgba(45,212,191,.4); color: #9ff8e9; background: rgba(45,212,191,.1); }
.btn-danger { border-color: rgba(251,113,133,.35); color: #fecdd3; background: rgba(251,113,133,.09); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-sm { min-height: 34px; padding: 7px 10px; font-size: 13px; border-radius: 9px; }
.btn-icon { width: 42px; padding: 0; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

.grid { display: grid; gap: 18px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0,1fr)); margin-bottom: 28px; }
.stat-card { background: linear-gradient(145deg, var(--panel), #181b27); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; min-height: 135px; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; width: 90px; height: 90px; border-radius: 50%; right: -20px; top: -20px; background: var(--glow, var(--primary)); opacity: .12; }
.stat-card span { color: var(--muted); font-weight: 650; }
.stat-card strong { display: block; font-size: 36px; letter-spacing: -.04em; margin-top: 14px; }
.two-col { grid-template-columns: minmax(0,1.6fr) minmax(300px,.8fr); }
.three-col { grid-template-columns: repeat(3,minmax(0,1fr)); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 17px; }
.panel-body { padding: 20px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 32px 0 16px; }
.section-title h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); gap: 18px; }
.project-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; transition: .2s ease; min-height: 245px; display: flex; flex-direction: column; }
.project-card:hover { transform: translateY(-3px); border-color: #555d79; box-shadow: 0 15px 40px rgba(0,0,0,.25); }
.card-cover { height: 138px; background: radial-gradient(circle at 75% 25%, rgba(255,140,66,.8), transparent 22%), radial-gradient(circle at 30% 55%, rgba(139,92,246,.8), transparent 30%), linear-gradient(145deg,#20243a,#151720); position: relative; overflow: hidden; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-cover .cover-letter { position: absolute; inset: 0; display: grid; place-items: center; font-size: 54px; font-weight: 900; opacity: .4; }
.card-body { padding: 17px; flex: 1; }
.card-body h3 { margin: 0 0 7px; font-size: 18px; }
.card-body p { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; gap: 8px; align-items: center; margin-top: 14px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-3); border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; color: #c8cee0; font-size: 12px; font-weight: 700; }
.status { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 750; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-draft, .status-queued { color: #c4b5fd; background: rgba(139,92,246,.12); }
.status-active, .status-rendering { color: #fde68a; background: rgba(251,191,36,.12); }
.status-completed, .status-ready { color: #99f6e4; background: rgba(45,212,191,.12); }
.status-failed { color: #fecdd3; background: rgba(251,113,133,.12); }
.status-cancelled, .status-archived { color: #cbd5e1; background: rgba(148,163,184,.1); }

.list { display: grid; gap: 10px; }
.list-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 18px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.015); }
.list-row:hover { background: rgba(255,255,255,.028); }
.list-row h4 { margin: 0 0 4px; font-size: 15px; }
.list-row p, .list-row small { margin: 0; color: var(--muted); }
.row-actions { display: flex; align-items: center; gap: 8px; }
.empty { border: 1px dashed #3d4358; border-radius: 16px; padding: 45px 24px; text-align: center; color: var(--muted); }
.empty strong { color: var(--text); font-size: 18px; display: block; margin-bottom: 7px; }

.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.field { display: grid; gap: 7px; }
.field-full { grid-column: 1/-1; }
.field label { color: #c7ccda; font-size: 13px; font-weight: 700; }
.field small { color: var(--muted); line-height: 1.4; }
.input, .textarea, .select { width: 100%; border: 1px solid var(--line); background: #10121a; color: var(--text); border-radius: 11px; padding: 11px 12px; outline: none; }
.textarea { min-height: 104px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139,92,246,.14); }
.check { display: flex; align-items: center; gap: 9px; color: #d9dcea; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.help { padding: 13px 15px; border-radius: 11px; background: rgba(139,92,246,.1); border: 1px solid rgba(139,92,246,.22); color: #ddd6fe; font-size: 13px; line-height: 1.5; }

.asset-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(190px,1fr)); gap: 14px; }
.asset-card { border: 1px solid var(--line); background: var(--panel-2); border-radius: 14px; overflow: hidden; }
.asset-preview { height: 150px; display: grid; place-items: center; background: repeating-conic-gradient(#222635 0 25%, #191c27 0 50%) 50%/20px 20px; overflow: hidden; }
.asset-preview img, .asset-preview video { width: 100%; height: 100%; object-fit: contain; }
.asset-preview audio { width: 90%; }
.asset-info { padding: 12px; }
.asset-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-info small { color: var(--muted); }
.asset-actions { display: flex; gap: 6px; margin-top: 10px; }

.progress { height: 7px; border-radius: 999px; background: #282c3a; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg,var(--primary),var(--accent)); transition: width .3s ease; }
.job-row { padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.job-top { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.job-error { color: #fecdd3; white-space: pre-wrap; font-size: 12px; max-height: 90px; overflow: auto; margin-top: 10px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(3,4,8,.72); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 24px; }
.modal { width: min(720px,100%); max-height: calc(100vh - 48px); overflow: auto; background: #171923; border: 1px solid #3a3f53; border-radius: 22px; box-shadow: var(--shadow); }
.modal-lg { width: min(980px,100%); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0 0 5px; font-size: 22px; }
.modal-head p { margin: 0; color: var(--muted); }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px; border-top: 1px solid var(--line); }

.toast-root { position: fixed; z-index: 200; right: 24px; bottom: 24px; display: grid; gap: 10px; width: min(390px,calc(100vw - 48px)); }
.toast { background: #1d202b; border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 12px; padding: 13px 15px; box-shadow: var(--shadow); animation: toast-in .25s ease; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--good); }
.toast strong { display: block; margin-bottom: 3px; }
.toast p { color: var(--muted); margin: 0; font-size: 13px; line-height: 1.4; }
@keyframes toast-in { from { opacity: 0; transform: translateY(15px); } }

.loading { display: grid; place-items: center; min-height: 280px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid #363b4e; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Editor */
.editor-shell { position: fixed; inset: 0; z-index: 80; background: #0c0d13; display: grid; grid-template-rows: 66px minmax(0,1fr) 220px; }
.editor-top { display: grid; grid-template-columns: minmax(260px,1fr) auto minmax(260px,1fr); align-items: center; gap: 16px; padding: 0 18px; border-bottom: 1px solid var(--line); background: #11131b; }
.editor-top .center-tools { display: flex; align-items: center; gap: 7px; }
.editor-top .right-tools { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.editor-main { min-height: 0; display: grid; grid-template-columns: 230px minmax(420px,1fr) 285px; }
.editor-left, .editor-right { background: #13151e; overflow: auto; }
.editor-left { border-right: 1px solid var(--line); }
.editor-right { border-left: 1px solid var(--line); }
.editor-pane-head { position: sticky; top: 0; z-index: 2; background: #13151e; padding: 13px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.layer-list { padding: 9px; display: grid; gap: 5px; }
.layer-row { padding: 9px; border: 1px solid transparent; border-radius: 9px; display: grid; grid-template-columns: 22px minmax(0,1fr) auto; align-items: center; gap: 7px; color: var(--muted); }
.layer-row:hover { background: var(--panel-2); color: white; }
.layer-row.selected { border-color: var(--primary); background: rgba(139,92,246,.14); color: white; }
.layer-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.stage-workspace { min-width: 0; min-height: 0; overflow: auto; padding: 34px; display: grid; place-items: center; background-color: #090a0f; background-image: radial-gradient(#262a38 1px, transparent 1px); background-size: 22px 22px; }
.stage-frame { position: relative; width: min(100%,1100px); aspect-ratio: 16/9; box-shadow: 0 30px 80px rgba(0,0,0,.55); overflow: hidden; background: #111827; user-select: none; }
.stage-layer { position: absolute; transform-origin: center; }
.stage-layer img { width: 100%; height: 100%; pointer-events: none; display: block; }
.stage-layer.text-layer { display: flex; align-items: flex-start; white-space: pre-wrap; overflow: hidden; }
.stage-layer.selected { outline: 2px solid #a78bfa; box-shadow: 0 0 0 1px #fff; }
.stage-layer.selected::after { content: ""; position: absolute; width: 12px; height: 12px; right: -7px; bottom: -7px; border-radius: 3px; background: white; border: 2px solid var(--primary); }
.stage-subtitle { position: absolute; left: 10%; right: 10%; bottom: 5%; text-align: center; font-weight: 800; font-size: clamp(13px,2vw,32px); text-shadow: 0 2px 5px #000; }
.stage-subtitle span { background: rgba(0,0,0,.65); padding: .25em .5em; border-radius: .3em; box-decoration-break: clone; }
.property-form { padding: 13px; display: grid; gap: 12px; }
.property-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.property-form .input, .property-form .select { padding: 8px 9px; font-size: 13px; }
.property-form .field label { font-size: 11px; }
.editor-timeline { min-height: 0; background: #11131b; border-top: 1px solid var(--line); display: grid; grid-template-columns: 230px minmax(0,1fr); grid-template-rows: 42px minmax(0,1fr); }
.timeline-corner { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 14px; color: var(--muted); font-size: 12px; }
.timeline-ruler { position: relative; border-bottom: 1px solid var(--line); overflow: hidden; }
.ruler-mark { position: absolute; bottom: 6px; font-size: 10px; color: var(--muted); transform: translateX(-50%); }
.timeline-labels { overflow: auto; border-right: 1px solid var(--line); }
.timeline-label { height: 34px; border-bottom: 1px solid #242735; padding: 8px 12px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-tracks { position: relative; overflow: auto; }
.timeline-track { height: 34px; border-bottom: 1px solid #242735; position: relative; background-image: linear-gradient(90deg,transparent 99%,rgba(255,255,255,.04) 100%); background-size: 10% 100%; }
.timeline-block { position: absolute; top: 5px; bottom: 5px; border-radius: 6px; background: linear-gradient(90deg,rgba(139,92,246,.78),rgba(192,132,252,.68)); border: 1px solid rgba(255,255,255,.16); min-width: 6px; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); pointer-events: none; z-index: 5; }
.playhead::before { content: ""; position: absolute; top: 0; left: -5px; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid var(--accent); }

.breadcrumbs { display: flex; gap: 7px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 15px; }
.breadcrumbs a:hover { color: white; }
.hero-panel { position: relative; overflow: hidden; padding: 28px; border: 1px solid var(--line); background: linear-gradient(135deg,rgba(139,92,246,.17),rgba(255,140,66,.07)),var(--panel); border-radius: 22px; margin-bottom: 24px; }
.hero-panel::after { content:""; position:absolute; right:-70px; top:-100px; width:260px; height:260px; border-radius:50%; background:var(--primary); filter:blur(15px); opacity:.12; }
.hero-panel h1 { margin: 0 0 9px; font-size: 38px; letter-spacing: -.045em; }
.hero-panel p { max-width: 850px; color: #bdc4d8; line-height: 1.55; }
.kpi-inline { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .two-col { grid-template-columns: 1fr; }
  .editor-main { grid-template-columns: 190px minmax(360px,1fr); }
  .editor-right { position: fixed; right: 0; top: 66px; bottom: 220px; width: 285px; z-index: 10; box-shadow: var(--shadow); }
}
@media (max-width: 820px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .app-shell { grid-template-columns: 76px minmax(0,1fr); }
  .sidebar { width: 76px; padding: 18px 10px; }
  .sidebar .brand span:last-child, .nav-btn span:last-child, .user-chip > div:nth-child(2) { display: none; }
  .sidebar .brand { justify-content: center; padding-inline: 0; }
  .nav-btn { justify-content: center; padding-inline: 8px; }
  .main { grid-column: 2; }
  .topbar { padding: 0 17px; }
  .page { padding: 20px 16px; }
  .page-head { flex-direction: column; }
  .page-actions { justify-content: flex-start; }
  .three-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .editor-main { grid-template-columns: 1fr; }
  .editor-left, .editor-right { display: none; }
  .editor-timeline { grid-template-columns: 120px minmax(0,1fr); }
  .editor-top { grid-template-columns: 1fr auto; }
  .editor-top .center-tools { display: none; }
}
@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 34px; }
  .topbar-title { display: none; }
  .auth-panel { padding: 18px; }
  .auth-card { padding: 26px; }
  .modal-backdrop { padding: 8px; }
  .modal { max-height: calc(100vh - 16px); border-radius: 16px; }
}
