:root {
  --bg: #11161d; --panel: #171e27ee; --line: #2a3441; --text: #e6edf5; --dim: #92a0b1; --accent: #4aa3ff; --ok: #3aa36d; --warn: #d9a33f; --bad: #d0564b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
#view { position: fixed; inset: 0; }
#view canvas { display: block; }
button, select, input, textarea { font: inherit; color: var(--text); }
button { background: #263140; border: 1px solid #344255; border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
button:hover:not(:disabled) { background: #30405a; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: #2b67b5; border-color: #3a7ad0; }
button.primary:hover:not(:disabled) { background: #3477cf; }
button.small { padding: 4px 10px; min-height: 32px; font-size: 13px; }
button.danger { background: #6b2e2a; border-color: #8a3a34; }
button.on { background: #2b67b5; border-color: #4a8be0; }
input, select, textarea { background: #0d1218; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
textarea { width: 100%; resize: vertical; }
label { display: block; margin: 10px 0; color: var(--dim); }
label input:not([type=checkbox]), label select { display: block; width: 100%; margin-top: 4px; color: var(--text); }
label.check { display: flex; gap: 8px; align-items: center; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 14px 0; padding: 8px 12px 12px; }
legend { color: var(--dim); padding: 0 6px; }
.dim { color: var(--dim); } .small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; } .row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

#bar { position: fixed; top: 0; left: 0; right: 0; height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: linear-gradient(#11161df2, #11161dcc); border-bottom: 1px solid var(--line); z-index: 5; }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 600; white-space: nowrap; }
.brand img { width: 28px; height: 28px; }
.brand img.a3 { width: auto; height: 50px; aspect-ratio: 528 / 423; object-fit: contain; filter: invert(1); }   /* black logo -> white on the dark bar */
.title { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.peers { display: flex; gap: 4px; }
.peers span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; border: 2px solid #0008; }

#tabs { position: fixed; top: 64px; left: 12px; width: 380px; display: flex; gap: 4px; z-index: 5; }
#tabs button { flex: 1; padding: 6px 4px; min-height: 36px; font-size: 13px; background: #1b2430; }
#tabs button.on { background: #2b67b5; }
#tabs #btnHide { flex: 0 0 40px; }
body.collapsed #side, body.collapsed #tabs button:not(#btnHide) { display: none; }
body.collapsed #tabs { width: auto; }
.badge { background: #0006; border-radius: 9px; padding: 0 6px; font-size: 11px; }
.badge:empty { display: none; }

#side { position: fixed; top: 108px; left: 12px; width: 380px; bottom: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; overflow: auto; z-index: 4; backdrop-filter: blur(6px); }
.tab { display: none; } .tab.on { display: block; }
.list .item { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 6px 0; background: #0f151c; }
.list .item.active { border-color: var(--accent); }
.list .item .name { font-weight: 600; word-break: break-word; }
.list .item .sub { color: var(--dim); font-size: 12.5px; }
.list .item .acts { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.list .folder { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 2px; }
.list .navitem { cursor: pointer; display: flex; gap: 8px; align-items: center; }
.list .navitem:hover { border-color: #3a4a60; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: #2a3646; color: var(--dim); text-transform: uppercase; }
.tag.cloud { background: #3b2f12; color: #e8c06a; } .tag.ready { background: #143322; color: #7bd6a2; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; font-size: 13px; }
.crumbs a { color: var(--accent); cursor: pointer; } .crumbs span { color: var(--dim); }
.filebtn { display: inline-block; margin: 0; padding: 8px 12px; border-radius: 8px; background: #263140; border: 1px solid #344255; color: var(--text); cursor: pointer; }
.filebtn input { display: none; }
.job { border-left: 3px solid var(--warn); padding: 6px 10px; margin: 8px 0; background: #1d1a12; border-radius: 6px; font-size: 13px; }
.job.done { border-color: var(--ok); background: #122019; } .job.error { border-color: var(--bad); background: #24120f; }
.job .bar { height: 4px; background: #0006; border-radius: 2px; margin-top: 4px; } .job .bar i { display: block; height: 100%; background: var(--warn); border-radius: 2px; }
.cnum { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 12px; font-size: 12px; font-weight: 700; color: #fff; margin-right: 6px; padding: 0 6px; }
.resolved .cnum { background: #3aa36d !important; }
.reply { border-left: 2px solid var(--line); padding-left: 8px; margin: 6px 0; font-size: 13.5px; }
#commentDetail .item { border-color: var(--accent); }

#tools { position: fixed; right: 12px; top: 64px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
#tools button { min-width: 96px; }
#tools input[type=range] { writing-mode: vertical-lr; direction: rtl; height: 160px; width: 40px; margin: 0 auto; }

#progress { position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; min-width: 320px; z-index: 9; text-align: center; }
.pbar { height: 6px; background: #0008; border-radius: 3px; margin-top: 10px; overflow: hidden; } .pbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2a38f2; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; z-index: 9; max-width: 80vw; }

dialog { background: #171e27; color: var(--text); border: 1px solid var(--line); border-radius: 14px; width: min(520px, 92vw); padding: 18px 20px; }
dialog::backdrop { background: #0009; }
dialog h3 { margin: 0 0 6px; }

@media (max-width: 760px) {
  #tabs, #side { width: calc(100vw - 24px); }
  #side { bottom: auto; max-height: 50vh; }
  #tools { top: auto; bottom: 12px; flex-direction: row; right: 12px; left: 12px; flex-wrap: wrap; }
  #tools input[type=range] { writing-mode: horizontal-tb; direction: ltr; height: 40px; width: 140px; }
  .brand span { display: none; }
}

#crosshair { position: fixed; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; z-index: 6; pointer-events: none; opacity: .55; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: #fff; box-shadow: 0 0 2px #000; }
#crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }
#crosshair::after { top: 10px; left: 0; height: 2px; width: 22px; }
#crosshair.locked { opacity: .95; }

/* file pickers hidden inside their button label (beats "label input" above) */
.filebtn input[type=file] { display: none !important; }
.filebtn { display: inline-block; }

/* tabs may wrap to two rows; the panel follows them (see placeSide in app.js) */
#tabs { flex-wrap: wrap; }
#tabs button { flex: 1 1 auto; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.cards div { background: #0f151c; border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; }
.cards b { display: block; font-size: 18px; } .cards span { color: var(--dim); font-size: 11.5px; }
.adh { margin: 14px 0 4px; font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.ev { display: grid; grid-template-columns: 74px 1fr; gap: 6px; font-size: 12.5px; padding: 4px 2px; border-bottom: 1px solid #222b36; }
.ev .when { color: var(--dim); } .ev .what b { color: var(--text); } .ev .bad { color: #ff8a80; }
.kv2 { font-size: 12.5px; color: var(--dim); }
#tabs button { padding: 6px 5px; font-size: 12.5px; min-width: 0; }
#tabs #btnHide { flex: 0 0 30px; }

#treePanel { position: fixed; right: 124px; top: 64px; width: 360px; max-height: calc(100vh - 80px); display: flex; flex-direction: column; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; z-index: 6; backdrop-filter: blur(6px); }
#treePanel .row { margin: 0; }
#treeList { overflow: auto; flex: 1; font-size: 13px; min-height: 120px; }
.tn { display: flex; align-items: center; gap: 4px; padding: 2px 0; white-space: nowrap; }
.tn .tw { width: 18px; text-align: center; cursor: pointer; color: var(--dim); flex: none; }
.tn input { flex: none; width: 15px; height: 15px; margin: 0; }
.tn .nm { overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tn .nm:hover { color: var(--accent); }
.tn .ct { color: var(--dim); font-size: 11px; flex: none; }
.tn.off .nm { color: var(--dim); text-decoration: line-through; }
.tn.sel .nm { color: #fff; background: #2b67b5; border-radius: 4px; padding: 0 4px; }
#sectionBox { display: flex; flex-direction: column; gap: 4px; align-items: center; }
#sectionBox[hidden] { display: none; }
@media (max-width: 760px) { #treePanel { right: 12px; left: 12px; width: auto; top: auto; bottom: 70px; max-height: 50vh; } }
#treePanel[hidden] { display: none; }

.hist { margin: 6px 0; } .hist summary { cursor: pointer; }
