:root {
  --bg: #0f1218; --panel: #171b23; --panel2: #1e2330; --line: #2a3040; --text: #e7eaf0; --muted: #8b93a7;
  --accent: #4f8cff; --accent2: #3a74e6; --danger: #e5484d; --ok: #30a46c; --radius: 10px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 18px; font-weight: 650; }
h2 { font-size: 16px; margin: 24px 0 10px; font-weight: 600; }
h3 { font-size: 12px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }

button, .btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px;
  font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: #3d4560; background: #242a39; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: var(--accent2); }
button.danger { color: #ff8a8d; }
button.danger:hover { border-color: var(--danger); }
button.small { padding: 4px 9px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: #0d1016; color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px;
  font: inherit; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=color] { padding: 0; width: 34px; height: 32px; border-radius: 7px; cursor: pointer; flex: none; }
textarea { resize: vertical; min-height: 70px; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* Layout */
.shell { display: flex; height: 100%; }
nav.side { width: 210px; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; flex: none; }
nav.side .brand { font-weight: 750; font-size: 17px; padding: 0 10px 18px; letter-spacing: .02em; }
nav.side .brand span { color: var(--accent); }
nav.side a { color: var(--text); padding: 9px 10px; border-radius: 8px; opacity: .8; }
nav.side a:hover { background: var(--panel2); opacity: 1; }
nav.side a.on { background: var(--panel2); opacity: 1; color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
nav.side .sep { height: 1px; background: var(--line); margin: 10px 4px; }
nav.side .who { margin-top: auto; padding: 10px; font-size: 12px; color: var(--muted); word-break: break-all; }
main { flex: 1; overflow: auto; padding: 28px 32px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.head h1 { margin: 0; flex: 1; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; }
.login .card { width: 340px; padding: 28px; }

/* Listor */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.thumb { aspect-ratio: 16/9; background: #000; border-radius: 8px; overflow: hidden; position: relative; margin-bottom: 12px; cursor: pointer; }
.thumb.portrait { aspect-ratio: 9/16; max-height: 300px; margin-inline: auto; }
.card .title { font-weight: 600; margin-bottom: 4px; }
.card .actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #555; margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.tag.admin { color: #ffcf6b; border-color: #5a4a20; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.media-item { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.media-item .pv { aspect-ratio: 4/3; background: #000 center/contain no-repeat; display: grid; place-items: center; font-size: 30px; overflow: hidden; }
.media-item .pv video, .media-item .pv img { width: 100%; height: 100%; object-fit: cover; }
.media-item .meta { padding: 8px; font-size: 12px; display: flex; gap: 6px; align-items: center; }
.media-item .meta span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); margin-bottom: 18px; }
.drop.over { border-color: var(--accent); color: var(--text); }
.tree .user { margin-bottom: 14px; }
.tree ul { margin: 8px 0 0; padding-left: 20px; }
.tree li { margin: 4px 0; }

/* Editor */
.editor { display: grid; grid-template-columns: 230px 1fr 320px; grid-template-rows: auto 1fr; height: 100vh; }
.editor .top { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.editor .top input.name { max-width: 280px; font-weight: 600; }
.editor .left, .editor .right { background: var(--panel); overflow: auto; padding: 12px 14px; }
.editor .left { border-right: 1px solid var(--line); }
.editor .right { border-left: 1px solid var(--line); }
.editor .center { position: relative; background: repeating-conic-gradient(#151922 0 25%, #11141b 0 50%) 0 0/24px 24px; overflow: hidden; }
#canvas { position: absolute; inset: 24px; }
.addbar { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.addbar button { justify-content: center; }
.layers { list-style: none; padding: 0; margin: 0; }
.layers li { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.layers li:hover { background: var(--panel2); }
.layers li.on { background: #22304d; }
.layers li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layers li button { padding: 2px 6px; font-size: 11px; border: none; background: transparent; opacity: .6; }
.layers li button:hover { opacity: 1; }
.sel-box { position: absolute; outline: 2px solid var(--accent); pointer-events: none; z-index: 9999; }
.sel-box .h { position: absolute; width: 22px; height: 22px; right: -11px; bottom: -11px; background: var(--accent); border: 3px solid #fff; border-radius: 4px; pointer-events: auto; cursor: nwse-resize; }
.sign-stage .sign-el { cursor: move; }
.sign-stage .sign-el:hover { outline: 2px dashed rgba(79,140,255,.6); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.colorf { display: flex; gap: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 10px; }
.checks label { display: flex; gap: 5px; align-items: center; font-size: 13px; cursor: pointer; }
details.grp { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; background: #141820; }
details.grp > summary { cursor: pointer; font-weight: 600; font-size: 13px; }
details.grp[open] > summary { margin-bottom: 10px; }
.items .it { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; background: #141820; }
.items .it .row { margin-bottom: 6px; }
.items .it .tools { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.items .it .tools label { margin-right: auto; display: flex; gap: 4px; font-size: 12px; align-items: center; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.saved { font-size: 12px; color: var(--muted); margin-right: 6px; }
.saved.dirty { color: #ffcf6b; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2b3245; padding: 10px 18px; border-radius: 8px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 99999; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
#toast.show { opacity: 1; }
#toast.err { background: #5b2226; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: 420px; max-width: 92vw; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin-top: 0; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 50vh; overflow: auto; }
.picker div { aspect-ratio: 4/3; background: #000 center/cover no-repeat; border-radius: 6px; cursor: pointer; border: 2px solid transparent; overflow: hidden; }
.picker div:hover { border-color: var(--accent); }
.picker video { width: 100%; height: 100%; object-fit: cover; }
.imgf { display: flex; gap: 6px; align-items: center; }
.imgf .sw { width: 54px; height: 34px; border-radius: 6px; background: #000 center/cover no-repeat; border: 1px solid var(--line); flex: none; }
