:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a;
  --text: #e8eaf0; --muted: #8b93a7; --accent: #7c8cff; --accent-ink: #0f1115;
  --danger: #ff6b6b; --ok: #4ade80; --warn: #fbbf24;
  --c-video: #4c6fff; --c-audio: #1fa37a; --c-title: #c9822b;
  --radius: 12px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f8; --panel: #ffffff; --panel2: #f0f1f5; --line: #dfe2ea;
    --text: #181b22; --muted: #667085; --accent: #4f5df0; --accent-ink: #ffffff;
    --danger: #d92d20; --ok: #15803d; --warn: #b45309;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
svg { display: block; }

/* ---------- элементы форм ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 7px; }
.btn.active { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 9px; outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 42px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; margin-bottom: 5px; font-size: 13px; color: var(--muted); }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }
.okmsg { color: var(--ok); font-size: 13px; }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; height: 100%; }
.side {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; }
.brand i { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #c084fc); display: block; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; margin-bottom: 2px;
}
.nav a:hover { background: var(--panel2); color: var(--text); }
.nav a.on { background: var(--panel2); color: var(--text); }
.nav a.on svg { color: var(--accent); }
.side .spacer { flex: 1; }
.conn { padding: 10px 12px; border-radius: 10px; background: var(--panel2); font-size: 13px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; margin-right: 7px; }
.conn .dot.on { background: var(--ok); } .conn .dot.off { background: var(--danger); }
.main { overflow: auto; padding: 26px 30px 40px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .grow { min-width: 160px; }

/* ---------- карточки и списки ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; display: flex; flex-direction: column; gap: 8px;
}
.card.link { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.card.link:hover { border-color: var(--accent); transform: translateY(-1px); }
.thumb {
  height: 96px; border-radius: 9px; margin: -2px 0 4px;
  background: linear-gradient(135deg, #232838, #1a1d27);
  display: flex; align-items: flex-end; padding: 8px; gap: 3px; overflow: hidden;
}
.thumb b { display: block; height: 14px; border-radius: 3px; opacity: .9; }
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.pill.s-edit { color: var(--accent); border-color: var(--accent); }
.pill.s-fixes { color: var(--warn); border-color: var(--warn); }
.pill.s-done, .pill.s-archive { color: var(--ok); border-color: var(--ok); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { padding: 5px 12px; border-radius: 99px; background: transparent; border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- экран проекта ---------- */
.project { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.title-input { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; font-size: 22px; font-weight: 650; width: 100%; color: var(--text); }
.title-input:hover, .title-input:focus { border-color: var(--line); outline: none; }

.player { position: relative; aspect-ratio: 16/9; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden;
  background: radial-gradient(120% 120% at 30% 20%, #232a3d, #0b0d12); }
.player .ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #8d96ad; text-align: center; padding: 20px; }
.player .tc { position: absolute; left: 12px; top: 10px; font: 13px ui-monospace, monospace; color: #fff; background: rgba(0,0,0,.45); padding: 2px 8px; border-radius: 6px; }
.player canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.player.drawing canvas { pointer-events: auto; cursor: crosshair; }
.controls { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.controls .time { font: 13px ui-monospace, monospace; color: var(--muted); white-space: nowrap; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.timeline { padding: 12px 12px 14px; user-select: none; }
.tl-wrap { position: relative; margin-left: 58px; }
.tl-ruler { position: relative; height: 22px; border-bottom: 1px solid var(--line); margin-bottom: 6px; cursor: pointer; }
.tl-ruler .tick { position: absolute; top: 8px; bottom: 0; border-left: 1px solid var(--line); font-size: 10px; color: var(--muted); padding-left: 3px; }
.tl-ruler .pin { position: absolute; top: 0; width: 12px; height: 12px; margin-left: -6px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--warn); border: 0; padding: 0; }
.tl-ruler .pin.done { background: var(--muted); }
.tl-track { position: relative; height: 34px; margin-bottom: 6px; background: var(--panel2); border-radius: 8px; cursor: pointer; }
.tl-label { position: absolute; left: -58px; width: 52px; top: 0; height: 34px; display: flex; align-items: center; font-size: 12px; color: var(--muted); }
.tl-clip { position: absolute; top: 3px; bottom: 3px; border-radius: 6px; font-size: 12px; padding: 0 8px; display: flex; align-items: center; color: #fff; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border: 1px solid rgba(255,255,255,.2); }
.tl-clip.t0 { background: var(--c-video); } .tl-clip.t1 { background: var(--c-audio); } .tl-clip.t2 { background: var(--c-title); }
.tl-clip.sel { outline: 2px solid #fff; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); pointer-events: none; z-index: 3; }
.playhead::before { content: ""; position: absolute; top: -2px; left: -5px; border: 6px solid transparent; border-top-color: var(--danger); }

.tabs { display: flex; gap: 4px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tabbody { padding: 14px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--panel2); border-radius: 10px; border: 1px solid transparent; }
.item.sel { border-color: var(--accent); }
.item.done .txt { text-decoration: line-through; color: var(--muted); }
.tcbtn { font: 12px ui-monospace, monospace; padding: 2px 7px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); color: var(--warn); }
.composer { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.chat { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 420px; position: sticky; top: 0; }
.chat-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.chat-head select { padding: 6px 10px; }
.msgs { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel2); border-bottom-left-radius: 4px; }
.msg.system { align-self: center; background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 13px; text-align: center; }
.chat-in { padding: 10px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: flex-end; }
.chat-in textarea { max-height: 140px; }

.note { padding: 12px 14px; background: var(--panel2); border-radius: 10px; color: var(--muted); font-size: 13px; }
.form-card { max-width: 460px; }
.settings { display: grid; gap: 16px; max-width: 520px; }
.settings .panel { padding: 18px; }

/* ---------- страница входа ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.login-card .brand { padding: 0 0 18px; }

/* ---------- мобильная версия ---------- */
@media (max-width: 960px) {
  .project { grid-template-columns: 1fr; }
  .chat { position: static; height: 520px; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side { grid-row: 2; flex-direction: row; padding: 6px; border-right: 0; border-top: 1px solid var(--line); justify-content: space-around; }
  .side .brand, .side .spacer, .side .conn { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 10px; margin: 0; }
  .main { padding: 16px 16px 24px; }
  .tl-wrap { margin-left: 0; } .tl-label { display: none; }
  .conn-mobile { display: block !important; }
}
.conn-mobile { display: none; }
