:root {
  --bg: #0d0907;
  --bg2: #15100c;
  --card: #1b1410;
  --card2: #231a14;
  --line: #33261c;
  --text: #f3ebe4;
  --muted: #a8968a;
  --accent: #ff7a00;
  --accent2: #ffb347;
  --ok: #3ccf4e;
  --danger: #ff4d4d;
  --warn: #ffc400;
  --r: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent2); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- кнопки / поля ---------- */
.btn { height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card2); transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: linear-gradient(180deg, var(--accent2), var(--accent)); border-color: transparent; color: #1a0a02; font-weight: 700; box-shadow: 0 0 16px rgba(255,122,0,.3); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(255,77,77,.5); color: #ff8a8a; }
.btn.danger:hover { background: rgba(255,77,77,.12); border-color: var(--danger); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 34px; padding: 0; font-size: 16px; }
.btn.wide { width: 100%; }
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld > span { font-size: 12px; color: var(--muted); }
.fld small { font-size: 11px; color: var(--muted); opacity: .8; }
input[type=text], input[type=number], input[type=password], input[type=url], input:not([type]), select, textarea {
  width: 100%; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); outline: none; transition: .15s;
}
textarea { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,122,0,.15); }
input[type=color] { width: 44px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); padding: 3px; cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.color-row { display: flex; gap: 8px; }
.color-row input[type=text] { font-family: Consolas, monospace; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row b { min-width: 46px; text-align: right; font-weight: 600; font-size: 12px; color: var(--accent2); }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; min-height: 34px; }
.toggle input { display: none; }
.toggle i { width: 38px; height: 21px; border-radius: 11px; background: #3a2d24; position: relative; flex: none; transition: .2s; }
.toggle i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { left: 20px; }

/* ---------- логин ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: radial-gradient(circle at 50% 30%, #2a1206, var(--bg) 70%); }
.login-card { width: 100%; max-width: 360px; padding: 32px 28px; border-radius: 16px; background: var(--card); border: 1px solid rgba(255,122,0,.35); box-shadow: 0 0 40px rgba(255,122,0,.15); display: flex; flex-direction: column; gap: 14px; }
.login-logo img { width: 84px; height: 68px; object-fit: contain; filter: drop-shadow(0 0 14px rgba(255,122,0,.6)); }
.login-card h1 { font-size: 22px; }
.login-err { color: #ff8a8a; font-size: 13px; min-height: 18px; }

/* ---------- каркас ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: rgba(13,9,7,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand img { width: 36px; height: 29px; object-fit: contain; filter: drop-shadow(0 0 6px rgba(255,122,0,.5)); }
.brand b { font-size: 17px; letter-spacing: 1px; font-style: italic; }
.brand span { color: var(--muted); font-size: 13px; }
.pub-state { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: rgba(60,207,78,.12); color: var(--ok); border: 1px solid rgba(60,207,78,.3); }
.pub-state.dirty { background: rgba(255,196,0,.12); color: var(--warn); border-color: rgba(255,196,0,.35); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.save-ind { font-size: 12px; color: var(--muted); }

.layout { display: grid; grid-template-columns: 210px minmax(380px, 520px) 1fr; height: calc(100vh - 56px); }
.nav { border-right: 1px solid var(--line); padding: 12px 8px; overflow-y: auto; background: var(--bg2); }
.nav button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 0; background: none; border-radius: 8px; text-align: left; color: var(--muted); transition: .15s; }
.nav button:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav button.on { color: var(--text); background: rgba(255,122,0,.14); box-shadow: inset 3px 0 0 var(--accent); }
.nav .ico { width: 20px; text-align: center; }
.nav .sep { height: 1px; background: var(--line); margin: 8px 6px; }

.editor { overflow-y: auto; padding: 20px 20px 80px; border-right: 1px solid var(--line); }
.editor h2 { font-size: 20px; margin-bottom: 4px; }
.editor .lead { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.card h3 { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card h3 .sp { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.item { background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.item.off { opacity: .55; }
.item-head { display: flex; align-items: center; gap: 6px; }
.item-head b { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-body { display: flex; flex-direction: column; gap: 10px; }
.item.collapsed .item-body { display: none; }

.media-fld .media-row { display: flex; gap: 6px; }
.media-thumb { width: 100%; max-height: 120px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #000; }
audio.media-thumb { height: 34px; max-height: none; background: none; border: 0; }
.progress-line { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; display: none; }
.progress-line.on { display: block; }
.progress-line i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.preset { height: 64px; border-radius: 8px; border: 1px solid var(--line); position: relative; overflow: hidden; text-align: left; padding: 8px 10px; display: flex; align-items: flex-end; font-weight: 700; font-size: 13px; transition: .15s; }
.preset:hover { transform: translateY(-1px); border-color: #fff4; }
.preset.on { outline: 2px solid var(--accent); outline-offset: 1px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.stat b { display: block; font-size: 24px; color: var(--accent2); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; padding-top: 10px; }
.bars div { flex: 1; background: linear-gradient(180deg, var(--accent2), var(--accent)); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px; padding: 3px 6px; background: #000; border-radius: 4px; font-size: 11px; white-space: nowrap; }
.bars-x { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.bars-x span { flex: 1; text-align: center; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--danger); }
.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.mfile { background: var(--card2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.mfile .pv { height: 86px; background: #000 center / cover; display: grid; place-items: center; font-size: 26px; color: var(--muted); }
.mfile .meta { padding: 6px 8px; font-size: 11px; word-break: break-all; display: flex; flex-direction: column; gap: 4px; }
.tag { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 10px; background: rgba(60,207,78,.15); color: var(--ok); }
.tag.unused { background: rgba(255,255,255,.08); color: var(--muted); }
.notice { padding: 10px 12px; border-radius: 8px; font-size: 13px; background: rgba(255,196,0,.1); border: 1px solid rgba(255,196,0,.35); color: #ffe08a; }
.notice.info { background: rgba(255,122,0,.08); border-color: rgba(255,122,0,.3); color: var(--text); }
code { font-family: Consolas, monospace; background: #000a; padding: 1px 5px; border-radius: 4px; font-size: 12px; user-select: all; }

/* ---------- превью ---------- */
.preview-col { display: flex; flex-direction: column; gap: 10px; padding: 16px; overflow-y: auto; min-width: 0; }
.preview-head { display: flex; align-items: center; gap: 12px; }
.preview-head b { flex: 1; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 6px 12px; font-size: 12px; color: var(--muted); }
.seg button.on { background: rgba(255,122,0,.2); color: var(--text); }
.preview-frame { position: relative; width: 100%; aspect-ratio: 1100 / 643; border-radius: 14px; overflow: hidden; background: #000; box-shadow: 0 10px 40px rgba(0,0,0,.6), 0 0 0 1px var(--line); }
.preview-frame iframe { position: absolute; left: 0; top: 0; width: 1100px; height: 643px; border: 0; transform-origin: 0 0; }
.preview-states { display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 4px 12px; font-size: 12px; color: var(--muted); }
.chips button:hover { color: var(--text); }
.chips button.on { border-color: var(--accent); color: var(--text); background: rgba(255,122,0,.15); }
.pv-note { margin-top: 2px; }

/* ---------- уведомления / диалоги ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 10px 18px; border-radius: 10px; background: #000e; border: 1px solid var(--line); opacity: 0; pointer-events: none; transition: .25s; z-index: 100; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(60,207,78,.6); }
.toast.err { border-color: rgba(255,77,77,.7); color: #ffb0b0; }
.dlg-wrap { position: fixed; inset: 0; z-index: 90; background: #000a; display: none; place-items: center; padding: 16px; }
.dlg-wrap.show { display: grid; }
.dlg { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- адаптив ---------- */
@media (max-width: 1250px) {
  .layout { grid-template-columns: 190px 1fr; height: auto; }
  .preview-col { grid-column: 1 / -1; order: -1; border-bottom: 1px solid var(--line); }
  .editor { border-right: 0; overflow: visible; }
  .nav { height: auto; }
}
.layout > * { min-width: 0; }
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .brand b { display: none; }
  .pub-state { font-size: 11px; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .editor { padding: 16px 16px 60px; }
  .nav { display: flex; overflow-x: auto; padding: 8px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav button { width: auto; white-space: nowrap; }
  .nav .sep { display: none; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .brand span, .save-ind { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  #btnDiscard { display: none; }
}
