:root {
  --bg: #f5f3ee; --panel: #ffffff; --ink: #17213b; --soft: #55607d; --line: #e3ded2; --chip: #f1ece0;
  --accent: #0F1B2D; --accent-ink: #fff; --blue: #2f6fd1; --ok: #1f7a4d; --warn: #9a5b00; --err: #b3261e;
  --radius: 12px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11172a; --panel: #19213a; --ink: #e9edf8; --soft: #a3aecb; --line: #2b3657; --chip: #222c4a; --accent: #E2B33C; --accent-ink: #0F1B2D; --blue: #7aa7ff; --ok: #57c48c; --warn: #f0b555; --err: #ff8a80; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { font-family: system-ui, sans-serif; font-weight: 600; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; } h2 { font-size: 17px; margin-bottom: 10px; } h3 { font-size: 16px; margin: 14px 0 8px; }
a { color: var(--blue); }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--chip); padding: 1px 5px; border-radius: 5px; }
.boot { padding: 40px; color: var(--soft); }
.muted { color: var(--soft); } .small { font-size: 13px; } .strong { font-weight: 650; text-decoration: none; color: var(--ink); }
p { margin: 6px 0; }

/* layout */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side a { display: block; padding: 9px 12px; border-radius: 9px; color: var(--ink); text-decoration: none; font-weight: 550; }
.side a:hover { background: var(--chip); }
.side a.on { background: var(--accent); color: var(--accent-ink); }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.brand b { display: block; font-family: system-ui, sans-serif; font-size: 18px; line-height: 1; }
.brand small { color: var(--soft); }
.logo { width: 36px; height: 36px; border-radius: 50%; background: #B23A2E; box-shadow: 0 0 0 3px #8E2C23; color: #F6EBD7; display: grid; place-items: center; font: 800 14px system-ui, sans-serif; }
.navfoot { margin-top: auto; display: grid; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.navfoot a { padding: 4px 0; }
.menu { display: none; }
.main { padding: 24px 28px 60px; min-width: 0; }
.page { max-width: 1400px; display: grid; gap: 16px; }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.navopen .side { transform: none; }
  .menu { display: block; position: fixed; z-index: 21; top: 10px; left: 10px; width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 20px; }
  .main { padding: 64px 14px 40px; }
}

/* panels, grids */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid2 > div { display: grid; gap: 16px; }
@media (max-width: 1100px) { .grid2 { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1 1 120px; }
.row.wrap { align-items: center; margin-top: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; }
.stat span { color: var(--soft); font-size: 13px; } .stat b { font: 600 28px system-ui, sans-serif; } .stat small { color: var(--soft); }
.bars { display: flex; gap: 6px; align-items: flex-end; height: 160px; }
.barcol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.barcol i { display: block; width: 100%; min-height: 2px; background: #C9962A; border-radius: 4px 4px 0 0; }
.barcol span { font-size: 11px; color: var(--soft); }
.rank { margin: 0; padding-left: 20px; } .rank li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin-bottom: 8px; }
.kv span { color: var(--soft); } .kv b { text-align: right; font-variant-numeric: tabular-nums; }

/* forms */
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field label { font-weight: 600; font-size: 13.5px; }
.field small { color: var(--soft); font-size: 12.5px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-height: 38px; width: 100%; }
input[type=color] { padding: 2px; width: 46px; height: 38px; }
input[type=checkbox] { width: auto; min-height: 0; }
input[type=range] { padding: 0; }
input[type=file] { width: auto; }
.filters input, .filters select { width: auto; }
textarea.json { font: 12.5px ui-monospace, Menlo, monospace; width: 100%; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 550; margin: 6px 14px 6px 0; cursor: pointer; }
.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #ffc83d; outline-offset: 2px; }
.colorlist { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cl { position: relative; }
.cl .x { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: var(--ink); color: var(--panel); font-size: 12px; line-height: 18px; padding: 0; cursor: pointer; }

/* buttons */
.btn { appearance: none; border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); font: 600 14.5px system-ui, sans-serif; padding: 9px 16px; border-radius: 10px; cursor: pointer; min-height: 40px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--chip); }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: 13.5px; }
.btn.danger { background: var(--err); color: #fff; }
.btn.ghost.danger { background: transparent; color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.icon { appearance: none; border: 0; background: var(--chip); color: var(--ink); width: 36px; height: 36px; border-radius: 50%; font-size: 20px; cursor: pointer; }
.link { appearance: none; border: 0; background: none; color: var(--blue); cursor: pointer; padding: 0; font: inherit; text-align: left; }
.x { appearance: none; border: 0; background: none; color: var(--soft); cursor: pointer; font-size: 18px; }
.seg { display: flex; gap: 4px; background: var(--chip); padding: 4px; border-radius: 11px; flex-wrap: wrap; }
.seg button { flex: 1; appearance: none; border: 0; background: transparent; color: var(--ink); font: 600 13.5px system-ui, sans-serif; padding: 8px 6px; border-radius: 8px; cursor: pointer; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* tables */
.tblwrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--soft); font-weight: 650; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.compact td, .tbl.compact th { padding: 5px 6px; }
.tbl td.actions { white-space: nowrap; text-align: right; }
.tbl td.actions .btn { margin-left: 4px; }
.tbl.tracks canvas { width: 72px; height: 48px; border-radius: 8px; display: block; }
.tbl select { width: auto; }
tr.banned td { opacity: .55; } tr.warnrow td { color: var(--warn); }
.filters { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.filters label { font-weight: 600; }
select.st-published { border-color: var(--ok); color: var(--ok); font-weight: 600; }
select.st-draft { border-color: #8f5de2; color: #8f5de2; font-weight: 600; }
select.st-disabled { color: var(--soft); }
.pill { display: inline-block; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; margin-left: 6px; background: var(--chip); }
.pill.st-published { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.st-draft { background: color-mix(in srgb, #8f5de2 18%, transparent); color: #8f5de2; }

/* validation */
.validation { display: grid; gap: 4px; }
.err { color: var(--err); font-weight: 600; } .warn { color: var(--warn); } .ok { color: var(--ok); font-weight: 600; }
p.err:empty { display: none; }
.report { display: grid; gap: 12px; margin-top: 10px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px; display: grid; gap: 4px; }
.login h1 { margin: 8px 0 10px; }
.login .btn { margin-top: 8px; }

/* dialogs, toast, qr */
dialog.modal { border: 1px solid var(--line); border-radius: 16px; padding: 20px; background: var(--panel); color: var(--ink); width: min(440px, calc(100vw - 32px)); }
dialog.modal.wide { width: min(640px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 16, 30, .45); }
.mhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.totp { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.qr svg { display: block; border-radius: 8px; }
.key { display: inline-block; font-size: 15px; padding: 6px 10px; margin-top: 6px; user-select: all; }
#toast { position: fixed; z-index: 50; right: 20px; bottom: 20px; max-width: min(460px, calc(100vw - 40px)); padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--panel); font-weight: 600; opacity: 0; transform: translateY(12px); transition: opacity .2s, transform .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }
#toast.err { background: var(--err); color: #fff; }
@media (prefers-reduced-motion: reduce) { #toast, .side { transition: none; } }

/* settings tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { appearance: none; border: 0; background: transparent; color: var(--soft); font: 600 14.5px system-ui, sans-serif; padding: 10px 14px; border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabbody { display: grid; gap: 16px; }


/* box editor */
.editorpage { max-width: none; }
.chips { display: flex; flex-wrap: wrap; gap: 0 4px; }
.check.sym { gap: 6px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; margin: 3px 4px 3px 0; }
.dialpv { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.dialpv span { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: #0F1B2D; color: #E2B33C; }
.dialpv.small span { width: 32px; height: 32px; }
.imgfield { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.imgfield img { width: 150px; max-height: 110px; object-fit: contain; border-radius: 8px; background: var(--chip); border: 1px solid var(--line); }
.imgfield .noimg, .sceneed .noimg { display: grid; place-items: center; width: 150px; height: 100px; border-radius: 8px; border: 1px dashed var(--line); color: var(--soft); font-size: 13px; text-align: center; padding: 8px; }
.edlayout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .edlayout { grid-template-columns: 1fr; } }
.roomlist { position: sticky; top: 12px; display: grid; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.roomitem { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; }
.roomitem.on { background: var(--chip); }
.roomitem .link { color: var(--ink); }
.roomed { display: grid; gap: 16px; min-width: 0; }
.sceneed { position: relative; width: 100%; aspect-ratio: 3 / 2; border-radius: 10px; overflow: hidden; user-select: none; touch-action: none; cursor: crosshair; margin: 8px 0 12px; }
.sceneed > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: auto; }
.sceneed > .noimg { position: absolute; inset: 0; width: auto; height: auto; border: 0; color: #C9D3E0; }
.hs { position: absolute; border: 2px solid #E2B33C; background: rgba(226, 179, 60, .14); border-radius: 6px; cursor: pointer; }
.hs.req { border-style: dashed; border-color: #9FB3CC; background: rgba(159, 179, 204, .14); }
.hs.sel { border-color: #6FC3BC; background: rgba(111, 195, 188, .22); cursor: move; z-index: 2; }
.hs span { position: absolute; left: 4px; top: 2px; font: 600 11.5px system-ui; color: #fff; text-shadow: 0 1px 2px #000; white-space: nowrap; pointer-events: none; }
.hs .handle { display: none; position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 3px; background: #6FC3BC; cursor: nwse-resize; }
.hs.sel .handle { display: block; }
.hsform { border-top: 1px solid var(--line); padding-top: 12px; }
details.item { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; background: var(--bg); }
details.item[open] { padding-bottom: 12px; }
details.item.exit { border-color: color-mix(in srgb, var(--ok) 60%, var(--line)); }
details.item summary { cursor: pointer; padding: 4px 0; }
details.item .grid2 { margin-top: 10px; }
textarea { resize: vertical; }
ol.walk { margin: 4px 0 12px; padding-left: 22px; } ol.walk li { margin: 3px 0; }
.phead select { width: auto; }
