:root {
  --bg:#17181b; --panel:#202226; --panel2:#2a2c31; --line:#36383e; --text:#e6e8ec; --muted:#9aa0aa;
  --accent:#ff6b4a; --accent2:#e9553a; --ok:#3ba55d; --bad:#ed4245;
  --chat:#1b1c20; --embed:#25272c; --r:10px;
}
@media (prefers-color-scheme: light) {
  :root { --bg:#f3f4f6; --panel:#fff; --panel2:#f0f1f4; --line:#d9dce2; --text:#1f2329; --muted:#5d6470; --chat:#fff; --embed:#f4f5f7; }
}
* { box-sizing:border-box; }
html, body { margin:0; }
body { background:var(--bg); color:var(--text); font:15px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif; }
[hidden] { display:none !important; }
button, input, select, textarea { font:inherit; color:inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }

.top { position:sticky; top:0; z-index:20; display:flex; align-items:center; gap:10px; padding:10px 16px; background:var(--panel); border-bottom:1px solid var(--line); flex-wrap:wrap; }
.brand { font-weight:700; font-size:18px; display:flex; align-items:center; gap:8px; }
.logo { display:inline-grid; place-items:center; width:30px; height:30px; border-radius:9px; background:var(--accent); color:#fff; font-weight:800; }
.spacer { flex:1; }
.targets { display:flex; gap:8px; }
select, input[type=text], input:not([type]), input[type=url], textarea {
  background:var(--bg); border:1px solid var(--line); border-radius:8px; padding:8px 10px; width:100%;
}
.targets select { width:auto; max-width:200px; }
textarea { min-height:90px; resize:vertical; }
.btn { display:inline-block; text-decoration:none; color:var(--text); border:1px solid var(--line); background:var(--panel2); border-radius:8px; padding:8px 14px; cursor:pointer; }
.btn:hover { border-color:var(--muted); }
.btn.primary { background:var(--accent); border-color:var(--accent); color:#fff; font-weight:600; }
.btn.primary:hover { background:var(--accent2); }
.btn.ghost { background:transparent; }
.btn.small { padding:4px 9px; font-size:13px; }
.btn.danger:hover { border-color:var(--bad); color:var(--bad); }
.btn:disabled { opacity:.5; cursor:not-allowed; }
.chip { display:inline-flex; align-items:center; gap:8px; padding:4px 10px 4px 4px; border:1px solid var(--line); border-radius:99px; background:var(--panel2); cursor:pointer; }
.chip img { width:26px; height:26px; border-radius:50%; }
.chip .ph { width:26px; height:26px; border-radius:50%; background:var(--accent); display:grid; place-items:center; color:#fff; font-size:13px; }

.menu { position:fixed; top:56px; right:150px; z-index:30; background:var(--panel); border:1px solid var(--line); border-radius:var(--r); padding:6px; display:flex; flex-direction:column; min-width:280px; box-shadow:0 10px 30px #0006; }
.menu button { text-align:left; background:none; border:0; padding:9px 12px; border-radius:6px; cursor:pointer; }
.menu button:hover { background:var(--panel2); }

.layout { display:grid; grid-template-columns:minmax(0,1.05fr) minmax(0,1fr); gap:16px; padding:16px; max-width:1400px; margin:0 auto; align-items:start; }
@media (max-width:960px) { .layout { grid-template-columns:1fr; } .preview { position:static !important; } }

.editor { background:var(--panel); border:1px solid var(--line); border-radius:var(--r); padding:14px; }
.tabs { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:12px; }
.tab { display:flex; align-items:center; border:1px solid var(--line); border-radius:8px; overflow:hidden; background:var(--panel2); }
.tab button { background:none; border:0; padding:6px 10px; cursor:pointer; }
.tab.on { border-color:var(--accent); }
.tab.on > button:first-child { color:var(--accent); font-weight:600; }
.tab .x { color:var(--muted); padding:6px 8px; }
.modes { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:14px; }
.mode { text-align:left; padding:10px 12px; border:1px solid var(--line); border-radius:var(--r); background:var(--panel2); cursor:pointer; display:flex; flex-direction:column; font-weight:600; }
.mode small { font-weight:400; color:var(--muted); }
.mode.on { border-color:var(--accent); box-shadow:inset 0 0 0 1px var(--accent); }

.field { margin:10px 0; }
.field > label { display:flex; justify-content:space-between; font-size:12px; color:var(--muted); margin-bottom:4px; }
.row { display:flex; gap:8px; } .row > * { flex:1; min-width:0; }
.toolbar { display:flex; gap:4px; flex-wrap:wrap; margin-bottom:4px; }
.toolbar button { border:1px solid var(--line); background:var(--panel2); border-radius:6px; min-width:30px; padding:2px 7px; cursor:pointer; font-size:13px; }
.toolbar button:hover { border-color:var(--accent); }
.toolbar select { width:auto; padding:2px 6px; font-size:13px; }

details.card { border:1px solid var(--line); border-radius:var(--r); margin:12px 0; background:var(--bg); }
details.card > summary { cursor:pointer; padding:10px 12px; font-weight:600; display:flex; gap:8px; align-items:center; list-style:none; }
details.card > summary::before { content:"\25B8"; color:var(--muted); }
details.card[open] > summary::before { content:"\25BE"; }
details.card .body { padding:0 12px 12px; }
.swatches { display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.sw { width:24px; height:24px; border-radius:50%; border:2px solid transparent; cursor:pointer; padding:0; }
.sw.on { border-color:var(--text); }
input[type=color] { width:34px; height:28px; padding:0; border:1px solid var(--line); border-radius:6px; background:none; }
.blocks .blk { border:1px solid var(--line); border-radius:var(--r); padding:10px; margin:10px 0; background:var(--bg); }
.blk .bh { display:flex; align-items:center; gap:6px; margin-bottom:6px; font-weight:600; font-size:13px; }
.blk .bh .sp { flex:1; }
.adds { display:flex; gap:6px; flex-wrap:wrap; margin-top:10px; }
.fieldrow { display:grid; grid-template-columns:1fr 1.4fr auto auto; gap:6px; align-items:center; margin-top:6px; }
.fieldrow label { display:flex; gap:4px; align-items:center; font-size:13px; }
.fieldrow input[type=checkbox] { width:auto; }
.warn { color:#e8a13a; font-size:13px; margin:8px 0; }
.hint { color:var(--muted); font-size:12px; }

.preview { position:sticky; top:70px; background:var(--panel); border:1px solid var(--line); border-radius:var(--r); overflow:hidden; }
.phead { display:flex; justify-content:space-between; padding:10px 14px; border-bottom:1px solid var(--line); font-size:12px; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); }
.chat { background:var(--chat); padding:16px; max-height:calc(100vh - 150px); overflow:auto; }
.pmsg { display:flex; gap:12px; margin-bottom:18px; }
.pav { width:40px; height:40px; border-radius:50%; background:var(--accent); display:grid; place-items:center; color:#fff; font-weight:700; flex:none; }
.pbody { min-width:0; flex:1; }
.pname { font-weight:600; } .pname .tag { font-size:10px; background:var(--accent); color:#fff; border-radius:4px; padding:1px 5px; margin-left:6px; vertical-align:middle; }
.md { white-space:pre-wrap; word-break:break-word; }
.md h1 { font-size:1.5em; margin:.3em 0; } .md h2 { font-size:1.25em; margin:.3em 0; } .md h3 { font-size:1.1em; margin:.3em 0; }
.md .sub { font-size:.8em; color:var(--muted); display:block; }
.md code { background:var(--embed); border-radius:4px; padding:1px 5px; font-family:ui-monospace,monospace; font-size:.9em; }
.md pre { background:var(--embed); border:1px solid var(--line); border-radius:6px; padding:8px; margin:6px 0; white-space:pre-wrap; }
.md a { color:#5aa9ff; }
.md .men { background:#5865f233; color:#8f9bff; border-radius:4px; padding:0 3px; }
.emb { background:var(--embed); border-left:4px solid var(--line); border-radius:6px; padding:10px 14px 14px; margin-top:6px; max-width:520px; }
.emb .au { display:flex; align-items:center; gap:6px; font-size:13px; font-weight:600; margin-bottom:4px; }
.emb .au img { width:22px; height:22px; border-radius:50%; }
.emb .top2 { display:flex; gap:12px; justify-content:space-between; }
.emb .ti { font-weight:700; margin-bottom:4px; }
.emb .fs { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:8px; }
.emb .f { grid-column:span 3; } .emb .f.in { grid-column:span 1; }
.emb .f b { display:block; font-size:13px; }
.emb img.big { max-width:100%; border-radius:6px; margin-top:10px; display:block; }
.emb img.th { width:80px; height:80px; border-radius:6px; object-fit:cover; flex:none; }
.emb .ft { margin-top:10px; font-size:12px; color:var(--muted); display:flex; gap:6px; align-items:center; }
.emb .ft img { width:18px; height:18px; border-radius:50%; }
.btns { display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }
.pbtn { background:#4f545c; color:#fff; border-radius:6px; padding:6px 14px; font-size:14px; text-decoration:none; display:inline-block; }
.cont { background:var(--embed); border:1px solid var(--line); border-left-width:4px; border-radius:10px; padding:12px 14px; max-width:560px; }
.cont > * + * { margin-top:10px; }
.cont hr { border:0; border-top:1px solid var(--line); margin:12px 0; } .cont hr.big { margin:20px 0; } .cont hr.noline { border-top-color:transparent; }
.sec { display:flex; gap:12px; align-items:center; justify-content:space-between; }
.sec img { width:80px; height:80px; border-radius:8px; object-fit:cover; flex:none; }
.gal { display:grid; gap:4px; grid-template-columns:repeat(2,1fr); }
.gal img { width:100%; border-radius:8px; display:block; object-fit:cover; max-height:240px; }
.gal img:first-child:nth-last-child(odd) { grid-column:span 2; }
.empty { color:var(--muted); text-align:center; padding:30px 0; }

.modal { position:fixed; inset:0; z-index:50; background:#000a; display:grid; place-items:center; padding:16px; }
.box { background:var(--panel); border:1px solid var(--line); border-radius:12px; width:min(720px,100%); max-height:90vh; overflow:auto; padding:16px; }
.mhead { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.mhead h2 { margin:0; font-size:18px; }
.tpls { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:10px; }
.tpl { text-align:left; border:1px solid var(--line); border-radius:var(--r); background:var(--panel2); padding:12px; cursor:pointer; }
.tpl:hover { border-color:var(--accent); }
.tpl b { display:block; } .tpl span { color:var(--muted); font-size:13px; }
.toast { position:fixed; left:50%; bottom:24px; transform:translateX(-50%); background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:10px 16px; opacity:0; pointer-events:none; transition:opacity .2s; z-index:60; max-width:90vw; }
.toast.show { opacity:1; } .toast.err { border-color:var(--bad); } .toast.ok { border-color:var(--ok); }
