:root {
  --bg: #f6f6f4; --card: #fff; --ink: #1b1b1a; --mute: #6b6b66; --line: #e4e3de; --acc: #3f5bd8; --ok: #1f8a5b;
  --warn: #b26b00; --bad: #c73a3a; --side: #efefeb; --sel: #e2e6fa; --field: #fff; --soft: #f1f1ee;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212; --card: #1c1c1c; --ink: #ecebe7; --mute: #9b9a94; --line: #2e2e2c; --acc: #8ea2ff; --ok: #4cc38a;
    --warn: #e0a03a; --bad: #ef6b6b; --side: #171717; --sel: #262c4a; --field: #151515; --soft: #232322;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--mute); }
.mute { color: var(--mute); }
.bad { color: var(--bad); }
.hint { color: var(--mute); font-size: 12.5px; margin: 2px 0 8px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }

input[type=text], input[type=password], input[type=number], input[type=time], textarea, select {
  width: 100%; background: var(--field); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; font: inherit;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--acc); outline-offset: -1px; border-color: transparent; }
input[type=color] { width: 54px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); padding: 2px; }
button, .upl {
  font: inherit; background: var(--soft); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
button:hover, .upl:hover { border-color: var(--mute); }
button.primary { background: var(--acc); color: #fff; border-color: var(--acc); }
button.danger { color: var(--bad); }
button.add { border-style: dashed; margin: 4px 0 8px; }
button.add.small { padding: 3px 9px; font-size: 12.5px; }
button.x { background: none; border: none; color: var(--mute); font-size: 18px; padding: 0 6px; line-height: 1; }
button.x:hover { color: var(--bad); }
.upl input { display: none; }

.login, .home { max-width: 640px; margin: 8vh auto; padding: 0 16px; }
.login { max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
.slist { display: flex; flex-direction: column; }
.srow { padding: 9px 4px; border-bottom: 1px solid var(--line); color: var(--ink); }
.srow:last-child { border-bottom: none; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
nav { background: var(--side); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
nav a { display: flex; align-items: center; gap: 8px; color: var(--ink); padding: 6px 10px; border-radius: 8px; }
nav a:hover { background: var(--sel); text-decoration: none; }
nav a.on { background: var(--sel); font-weight: 600; }
nav .brand { color: var(--mute); font-size: 12.5px; }
nav .stitle { font-weight: 700; font-size: 15px; padding: 6px 10px 12px; }
nav .n { margin-left: auto; font-size: 12px; }
nav .badge { margin-left: auto; font-size: 11px; background: var(--warn); color: #fff; border-radius: 9px; padding: 0 7px; }
nav .badge.bad { background: var(--bad); }
nav .foot { margin-top: auto; padding: 12px 10px 4px; }
.status { font-size: 12px; color: var(--ok); }
.status.busy { color: var(--mute); }
.status.bad { color: var(--bad); }
main { min-width: 0; padding: 20px 26px 80px; max-width: 1100px; height: 100vh; overflow-y: auto; }
.banner { background: var(--bad); color: #fff; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; }
.field { margin-bottom: 12px; min-width: 0; }
.lab { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.count { font-weight: 400; color: var(--ok); font-size: 12px; }
.count.low { color: var(--warn); }
.count.high { color: var(--bad); }
.checkrow { display: flex; align-items: center; gap: 8px; margin: 6px 0; cursor: pointer; }
.checkrow .hint { margin: 0; }
.grid2, .grid3, .grid4 { display: grid; gap: 0 14px; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: 1fr 1fr 1fr; }
.grid4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input[type=text] { flex: 1; min-width: 160px; width: auto; }
input.short { width: 70px; }
input.short2 { width: 140px; flex: 0 0 140px; }
ul.tight { margin: 0 0 8px; padding-left: 18px; }
ul.tight li { margin: 3px 0; }
.empty { color: var(--mute); padding: 40px 10px; text-align: center; }
.sub { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin: 8px 0; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--ink); border: 1px solid var(--line); background: var(--card); }
.tabs a.on { background: var(--sel); border-color: var(--acc); font-weight: 600; }

.ava { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; object-fit: cover; flex: none; vertical-align: middle; }
.ava.me { width: 22px; height: 22px; background: var(--acc); font-size: 12px; }
.split { display: grid; grid-template-columns: 230px 1fr; gap: 18px; align-items: start; }
.plist { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.prow { display: flex; gap: 9px; align-items: center; padding: 6px 8px; border-radius: 9px; color: var(--ink); }
.prow:hover { background: var(--sel); text-decoration: none; }
.prow.on { background: var(--sel); }
.pn { display: flex; flex-direction: column; min-width: 0; }
.pn b, .pn small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pn small { color: var(--mute); }
.phead { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }

.mapedit .maprow { display: grid; grid-template-columns: 180px 1fr auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-radius: 16px; padding: 3px 11px; font-size: 13px; }
.chip.on { background: var(--acc); color: #fff; border-color: var(--acc); }

.mwrap { overflow-x: auto; margin-bottom: 14px; }
table.matrix { border-collapse: collapse; font-size: 12px; }
.matrix th, .matrix td { border: 1px solid var(--line); }
.matrix th { background: var(--card); font-weight: 600; }
.matrix th .vert { writing-mode: vertical-rl; transform: rotate(180deg); padding: 6px 2px; white-space: nowrap; }
.matrix .rowh { text-align: left; padding: 4px 8px; white-space: nowrap; }
.matrix td { width: 64px; height: 32px; text-align: center; cursor: pointer; color: var(--mute); font-size: 11px; overflow: hidden; max-width: 64px; white-space: nowrap; text-overflow: ellipsis; padding: 0 3px; }
.matrix td:hover { outline: 2px solid var(--acc); outline-offset: -2px; }
.matrix td.kind { background: var(--soft); }
.matrix td.full { background: var(--sel); color: var(--ink); }
.matrix td.self { background: repeating-linear-gradient(45deg, transparent 0 4px, var(--line) 4px 5px); cursor: default; }
.matrix tr.on th { color: var(--acc); }
details.tie, details.thread { border-top: 1px solid var(--line); padding: 8px 0; }
details > summary { cursor: pointer; display: flex; align-items: center; gap: 4px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.side { display: flex; flex-direction: column; gap: 6px; }
.side.hint { justify-content: center; }

.cover { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.cv { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 3px 10px 3px 4px; font-size: 12.5px; }
.cv small { color: var(--mute); }
.cv.low { border-color: var(--warn); }
.facthead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.holders { display: flex; flex-direction: column; gap: 6px; }
.holder { display: grid; grid-template-columns: 22px 130px 190px 1fr auto; gap: 8px; align-items: center; }
.hold { font-size: 11px; border-radius: 6px; padding: 1px 6px; color: #fff; background: var(--ok); }
.hold.piece { background: var(--warn); }
.hold.wrong { background: var(--bad); }

.force { margin-bottom: 14px; }
.fnum { font-weight: 700; color: var(--mute); width: 18px; }
.time { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.time input.day { width: 62px; }
.time input[type=time] { width: 120px; }
.cond { display: flex; flex-direction: column; gap: 6px; }
.calrow { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.calrow > input[type=text]:not(.short2) { flex: 1; min-width: 160px; width: auto; }

.msg { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px; margin: 6px 0; align-items: start; }
.msg.mine textarea { border-color: var(--acc); }

.map { position: relative; height: 260px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.pin { position: absolute; transform: translate(-50%, -50%); text-align: center; font-size: 18px; }
.pin small { display: block; font-size: 10.5px; color: var(--mute); white-space: nowrap; }
.pin.home small { color: var(--acc); font-weight: 700; }

.apick { display: flex; gap: 10px; align-items: center; }
.apick > div { display: flex; gap: 8px; align-items: center; flex: 1; }
.apreview { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--soft); border: 1px solid var(--line); flex: none; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; color: var(--mute); }
.drop.over { border-color: var(--acc); background: var(--sel); }
.drop select { width: auto; display: inline-block; }
.agrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.asset { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; position: relative; }
.athumb { height: 140px; background: var(--soft); display: flex; align-items: center; justify-content: center; }
.athumb img, .athumb video { width: 100%; height: 100%; object-fit: cover; }
.athumb audio { width: 92%; }
.ameta { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.ameta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ameta small { color: var(--mute); }
.ameta code { cursor: copy; color: var(--mute); font-size: 11px; }
.asset button.x { position: absolute; top: 4px; right: 4px; background: var(--card); border-radius: 50%; }
.wallprev { border-radius: 12px; color: #fff; font-weight: 700; display: flex; align-items: flex-end; padding: 12px; min-height: 70px; margin-bottom: 12px; }

ul.findings { list-style: none; padding: 0; margin: 0; }
ul.findings li { padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.findings li:last-child { border-bottom: none; }
.findings .lvl { font-size: 11px; border-radius: 6px; padding: 1px 7px; color: #fff; background: var(--warn); }
.findings .bad .lvl { background: var(--bad); }
textarea.json { min-height: 70vh; margin-top: 10px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--line); }
  nav .foot { margin: 0; }
  main { height: auto; padding: 16px; }
  .split, .pair, .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .plist { position: static; flex-direction: row; flex-wrap: wrap; }
  .holder { grid-template-columns: 22px 1fr; }
  .mapedit .maprow, .msg { grid-template-columns: 1fr; }
}
.pub { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.pubinfo { font-size: 11.5px; }
