:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #1b1f24; --muted: #5d6570; --line: #d8dce1; --accent: #0f62fe;
  --err: #b4141f; --warn: #8a5300; --review: #5b3ea6; --ok: #1a7f37; --info: #2d5f8a; --code: #f6f8fa;
  --font: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; --mono: Consolas, "Cascadia Mono", "Courier New", monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15181c; --panel: #1d2126; --ink: #e3e6ea; --muted: #9aa3ad; --line: #343a42; --accent: #5b9bff; --err: #ff6b74; --warn: #e3a33b; --review: #b39cff; --ok: #4cc06a; --info: #7fb2e5; --code: #23282e; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
.topbar { display: flex; align-items: center; gap: 18px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 600; font-size: 16px; }
.ver { color: var(--muted); font-weight: 400; font-size: 12px; }
.barpick { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 240px; }
.route { color: var(--muted); font-size: 13px; }
.layout { display: flex; height: calc(100vh - 52px - 34px); }
body.logopen .layout { height: calc(100vh - 52px - 220px); }
.sidenav { width: 210px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 8px 0; overflow: auto; display: flex; flex-direction: column; }
.sidenav a { display: block; padding: 7px 16px; color: var(--ink); text-decoration: none; cursor: pointer; border-left: 3px solid transparent; }
.sidenav a:hover { background: var(--bg); }
.sidenav a.active { border-left-color: var(--accent); background: var(--bg); font-weight: 600; }
.navfoot { margin-top: auto; padding: 8px 0; border-top: 1px solid var(--line); }
.view { flex: 1; overflow: auto; padding: 16px 20px 40px; }
h1 { font-size: 20px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 22px 0 8px; } h3 { font-size: 14px; margin: 16px 0 6px; }
.lead { color: var(--muted); margin: 0 0 14px; max-width: 980px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; margin: 10px 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.stat .n { font-size: 22px; font-weight: 600; } .stat .l { color: var(--muted); font-size: 12px; }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 5px 12px; border-radius: 4px; cursor: pointer; font: inherit; font-size: 13px; }
.btn:hover:not([disabled]) { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--err); }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
table.grid { border-collapse: collapse; width: 100%; background: var(--panel); font-size: 13px; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 4px 7px; text-align: left; vertical-align: top; }
table.grid th { background: var(--bg); position: sticky; top: 0; z-index: 1; }
table.grid tr.sel td { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { max-height: 60vh; overflow: auto; border: 1px solid var(--line); }
code, pre, .mono { font-family: var(--mono); font-size: 12px; }
pre { background: var(--code); padding: 8px; border-radius: 4px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 6px 0; }
.sev { font-weight: 600; white-space: nowrap; }
.sev-Error, .st-fail { color: var(--err); } .sev-Warning, .st-attention { color: var(--warn); } .sev-Manual { color: var(--review); }
.sev-Information, .st-info { color: var(--info); } .st-pass { color: var(--ok); } .st-toolkit { color: var(--review); } .st-unknown { color: var(--muted); }
.tag { display: inline-block; padding: 0 6px; border-radius: 9px; font-size: 11px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.source { color: var(--ok); border-color: var(--ok); } .tag.binary { color: var(--err); border-color: var(--err); }
.tag.library { color: var(--review); border-color: var(--review); } .tag.metadata { color: var(--info); border-color: var(--info); }
.tag.archive { color: var(--warn); border-color: var(--warn); } .tag.config { color: var(--info); } .tag.security { color: var(--err); }
.tag.decompiled { color: var(--review); border-color: var(--review); } .tag.generated { color: var(--warn); border-color: var(--warn); }
.banner { padding: 8px 12px; border-radius: 5px; border: 1px solid var(--line); margin: 8px 0; background: var(--panel); }
.banner.err { border-color: var(--err); color: var(--err); } .banner.warn { border-color: var(--warn); } .banner.ok { border-color: var(--ok); }
.split { display: flex; gap: 12px; min-height: 60vh; }
.split > .left { width: 38%; min-width: 260px; overflow: auto; max-height: 72vh; border: 1px solid var(--line); background: var(--panel); }
.split > .right { flex: 1; min-width: 0; }
.tree { font-family: var(--mono); font-size: 12px; }
.tree div { padding: 1px 6px; cursor: pointer; white-space: nowrap; }
.tree div:hover { background: var(--bg); } .tree div.sel { background: color-mix(in srgb, var(--accent) 15%, var(--panel)); }
.tree .dir { font-weight: 600; cursor: default; }
textarea.editor { width: 100%; min-height: 58vh; font: 12px/1.5 var(--mono); background: var(--code); color: var(--ink); border: 1px solid var(--line); padding: 8px; tab-size: 4; white-space: pre; }
textarea.editor[readonly] { opacity: .92; }
.diff { font: 12px/1.45 var(--mono); background: var(--code); border: 1px solid var(--line); max-height: 50vh; overflow: auto; }
.diff div { white-space: pre; padding: 0 6px; } .diff .add { background: color-mix(in srgb, var(--ok) 18%, transparent); } .diff .del { background: color-mix(in srgb, var(--err) 18%, transparent); }
.diff .gap { color: var(--muted); }
input[type=text], input[type=number], select, textarea.plain { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--ink); }
input[type=text].wide { width: 520px; max-width: 100%; }
label.inline { display: inline-flex; gap: 6px; align-items: center; }
.formgrid { display: grid; grid-template-columns: 220px 1fr; gap: 6px 12px; align-items: center; max-width: 1000px; }
.logdock { position: fixed; bottom: 0; left: 0; right: 0; background: var(--panel); border-top: 1px solid var(--line); z-index: 5; }
.logbar { display: flex; align-items: center; gap: 8px; padding: 4px 10px; height: 34px; }
.progress { position: relative; flex: 1; height: 20px; background: var(--bg); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.progress-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: color-mix(in srgb, var(--accent) 35%, transparent); transition: width .15s; }
.progress span { position: relative; font-size: 12px; padding-left: 8px; line-height: 18px; white-space: nowrap; }
.counts { font-size: 12px; color: var(--muted); }
.logpanel { display: none; height: 186px; overflow: auto; font: 12px/1.4 var(--mono); padding: 4px 10px; border-top: 1px solid var(--line); }
body.logopen .logpanel { display: block; }
.log-error { color: var(--err); } .log-warn { color: var(--warn); } .log-ok { color: var(--ok); } .log-debug { color: var(--muted); }
details > summary { cursor: pointer; }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 2px 10px; font-size: 13px; }
.kv > div:nth-child(odd) { color: var(--muted); }
@media (max-width: 800px) { .sidenav { width: 150px; } .split { flex-direction: column; } .split > .left { width: 100%; } .formgrid { grid-template-columns: 1fr; } }

/* ---------- Project Explorer (Toolkit style) ---------- */
.ptree { font: 13px/1.2 var(--font); padding: 4px 0; user-select: none; outline: none; }
.ptree .tn { display: flex; align-items: center; gap: 4px; height: 22px; padding-right: 8px; cursor: default; white-space: nowrap; border: 1px solid transparent; }
.ptree .tn:hover { background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.ptree .tn.sel { background: color-mix(in srgb, var(--accent) 18%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.ptree .tw { width: 12px; flex: none; text-align: center; color: var(--muted); cursor: pointer; font-size: 11px; }
.ptree .ic { flex: none; }
.ptree .tl { overflow: hidden; text-overflow: ellipsis; }
.ptree .tl.unsaved::after { content: " ●"; color: var(--warn); }
.tbadge { display: inline-block; font-size: 10px; line-height: 14px; padding: 0 5px; border-radius: 7px; border: 1px solid var(--line); color: var(--muted); }
.tbadge.mod { color: var(--warn); border-color: var(--warn); }
.tbadge.dirty { color: var(--warn); border-color: var(--warn); font-weight: 600; }
.tbadge.warn { color: var(--err); border-color: var(--err); }
.tbadge.gen { color: var(--review); border-color: var(--review); }
.tbadge.dec { color: var(--review); border-color: var(--review); }
.pxbar { margin: 4px 0; }
.ctxmenu { position: absolute; z-index: 50; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.18); border-radius: 4px; padding: 3px 0; min-width: 190px; font-size: 13px; }
.ctxmenu div { padding: 5px 14px; cursor: pointer; }
.ctxmenu div:hover { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.ic text { pointer-events: none; }
.split > .right { overflow: auto; }
.split > .right .kv > div { overflow-wrap: anywhere; }

/* in-page dialog (replaces the browser's confirm/alert, which embedded browsers may suppress) */
.dlg-back { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dlg { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: 620px; width: 100%; max-height: 80vh; overflow: auto; padding: 16px 18px; }
.dlg-msg { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; }
.dlg-btns { justify-content: flex-end; margin-top: 14px; }

/* the hidden attribute must win over component display rules (e.g. .tbadge) */
[hidden] { display: none !important; }
