:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #181c20;
  --panel-2: #20262b;
  --line: #303942;
  --text: #eef3f6;
  --muted: #94a3ad;
  --accent: #3fb28f;
  --accent-2: #5c8df6;
  --danger: #e35d5d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.35 Inter, Segoe UI, Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }

.topbar {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #14181b;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-weight: 700; letter-spacing: 0; }
.topnav { display: flex; gap: 16px; color: var(--muted); }

.shell {
  width: min(1680px, calc(100vw - 20px));
  margin: 0 auto;
  padding: 12px 0 32px;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 10px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 20px; margin-bottom: 2px; }
h2 { font-size: 14px; margin-bottom: 10px; }
h3 { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
p { color: var(--muted); }

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: 1.1fr 1.4fr 1fr; }
.editor-grid { grid-template-columns: 580px 1fr; align-items: start; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.studio-layout {
  display: grid;
  grid-template-columns: 240px minmax(340px, 420px) 300px 230px;
  gap: 10px;
  align-items: start;
  margin-bottom: 10px;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.form-stack {
  display: grid;
  gap: 8px;
}

.inline-form,
.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 32px;
  color: var(--text);
  background: #111619;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}

textarea { resize: vertical; }

button {
  min-height: 32px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #07110d;
  font-weight: 700;
}

button:disabled { opacity: .55; cursor: wait; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.checkline {
  grid-template-columns: 18px 1fr;
  align-items: center;
  margin: 12px 0;
}

.checkline input { width: 16px; min-height: 16px; }

.list { display: grid; gap: 8px; }
.list.compact { gap: 6px; }

.row-link,
.task-line,
.asset-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  background: #12171a;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.row-link:hover { border-color: var(--accent-2); }
small, .muted { color: var(--muted); }
.empty { color: var(--muted); margin: 0; }
.error { color: var(--danger); }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  min-height: 0;
  padding: 10px 12px;
  color: var(--text);
  background: #111619;
  border: 1px solid var(--accent);
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 20;
}

.toast:not(:empty) { opacity: 1; }
.toast.error-toast { border-color: var(--danger); }

.task-line.done { border-color: rgba(63, 178, 143, .5); }
.task-line.failed { border-color: rgba(227, 93, 93, .65); }
.task-line.running { border-color: rgba(92, 141, 246, .65); }

.asset-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.compact-assets {
  max-height: 180px;
  overflow: auto;
}

.asset-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.thumb {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  background: #0c0f11;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.thumb.small {
  width: calc(50% - 6px);
  aspect-ratio: 9 / 16;
  object-fit: cover;
  margin: 0 6px 8px 0;
}

.video-thumb {
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #0c0f11;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 8px;
}

.editor-panel {
  display: grid;
  justify-items: center;
}

.editor-title {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#editor-canvas {
  width: min(100%, 380px);
  aspect-ratio: 9 / 16;
  background: #080a0b;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: grab;
}

#editor-canvas.dragging { cursor: grabbing; }

.asset-grid {
  grid-template-columns: minmax(360px, 1fr);
}

.final-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.final-item {
  display: grid;
  gap: 6px;
}

.final-item video {
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #0c0f11;
  border: 1px solid var(--line);
  border-radius: 6px;
}

@media (max-width: 1100px) {
  .studio-layout,
  .grid.two,
  .grid.three,
  .editor-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-head { align-items: stretch; flex-direction: column; }
  .settings-grid,
  .asset-columns { grid-template-columns: 1fr; }
}
