:root {
   color-scheme: dark;
   --bg: #202123;
   --panel: #2a2b2e;
   --panel-2: #323337;
   --line: #44464b;
   --text: #e8e8e8;
   --muted: #a0a3a8;
   --accent: #26A69A;
   --accent-2: #EE6F73;
   --ok: #4caf50;
   --warn: #ffb74d;
   --err: #ef5350;
   --mono: ui-monospace, "Cascadia Code", "Consolas", "Menlo", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 70px; }

body {
   margin: 0;
   background: var(--bg);
   color: var(--text);
   font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

header.top {
   position: sticky;
   top: 0;
   z-index: 10;
   display: flex;
   align-items: center;
   gap: 14px;
   padding: 8px 16px;
   background: var(--accent);
   color: #fff;
}
header.top a { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 10px; font-size: 1.3rem; }
header.top img { height: 40px; border-radius: 12px; }
header.top .title { font-size: 1.05rem; opacity: .9; }

.layout { display: grid; grid-template-columns: 230px 1fr; gap: 0; }

nav.side {
   position: sticky;
   top: 56px;
   align-self: start;
   height: calc(100vh - 56px);
   overflow-y: auto;
   padding: 14px 10px;
   border-right: 1px solid var(--line);
}
nav.side h4 { margin: 14px 8px 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
nav.side a { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: .9rem; }
nav.side a:hover { background: var(--panel-2); }

main { padding: 18px 24px 60px; min-width: 0; }

@media (max-width: 900px) {
   .layout { grid-template-columns: 1fr; }
   nav.side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 2px; }
   nav.side h4 { width: 100%; }
   main { padding: 12px; }
}

section.api {
   background: var(--panel);
   border: 1px solid var(--line);
   border-radius: 10px;
   padding: 14px 18px 18px;
   margin-bottom: 22px;
}
section.api > h2 { margin: 0 0 4px; font-size: 1.35rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
section.api > h2 code { font-size: .8rem; color: var(--muted); font-weight: normal; }
section.api > p.desc { margin: 0 0 10px; color: var(--muted); font-size: .92rem; }
h3 { font-size: 1rem; margin: 16px 0 6px; color: #cfd2d6; border-bottom: 1px solid var(--line); padding-bottom: 3px; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
.dot.yes { background: var(--ok); }
.dot.no { background: var(--err); }
.dot.partial { background: var(--warn); }

.badge { font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--line); color: #fff; }
.badge.yes { background: var(--ok); }
.badge.no { background: var(--err); }
.badge.partial { background: #b7791f; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.row > label { display: inline-flex; align-items: center; gap: 5px; font-size: .88rem; color: #d0d3d7; }
.grow { flex: 1 1 220px; min-width: 0; }

button, .btn-like {
   font: inherit;
   font-size: .86rem;
   padding: 5px 12px;
   border-radius: 6px;
   border: 1px solid #3a8f86;
   background: #1f6f67;
   color: #fff;
   cursor: pointer;
}
button:hover { background: #26857b; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: var(--panel-2); border-color: var(--line); }
button.secondary:hover { background: #3c3e43; }
button.danger { background: #7a2e2e; border-color: #a33; }
button.small { padding: 2px 8px; font-size: .78rem; }

input, select, textarea {
   font: inherit;
   font-size: .88rem;
   padding: 4px 7px;
   border-radius: 5px;
   border: 1px solid var(--line);
   background: #18191b;
   color: var(--text);
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
input[type=range] { padding: 0; accent-color: var(--accent); }
input.num { width: 90px; }
input.hexin { width: 110px; font-family: var(--mono); }
textarea { width: 100%; font-family: var(--mono); min-height: 90px; resize: vertical; }

.log, .term, pre.out {
   font-family: var(--mono);
   font-size: .8rem;
   background: #141517;
   border: 1px solid var(--line);
   border-radius: 6px;
   padding: 6px 8px;
   margin: 6px 0 0;
   max-height: 260px;
   overflow: auto;
   white-space: pre-wrap;
   word-break: break-all;
}
.log { min-height: 60px; }
.log .ln { border-bottom: 1px solid #1e1f22; }
.log .ok { color: #8bd98f; }
.log .err { color: #ff8a80; }
.log .warn { color: var(--warn); }
.log .data { color: #9ecbff; }
.log .info { color: #ccc; }
.term { min-height: 160px; max-height: 360px; color: #b9f6ca; }
.logbar { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.logbar label { font-size: .78rem; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }

.note { font-size: .82rem; color: var(--muted); }
.warnbox { font-size: .85rem; background: #3a2f1a; border: 1px solid #6b5422; border-radius: 6px; padding: 6px 10px; margin: 8px 0; }

table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td code, .mono { font-family: var(--mono); font-size: .8rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.card h4 { margin: 0 0 6px; font-size: .95rem; display: flex; align-items: center; gap: 8px; }

/* bluetooth GATT tree */
.gatt-service { border: 1px solid var(--line); border-radius: 6px; margin: 8px 0; padding: 6px 10px; background: var(--panel-2); }
.gatt-service > .hd { font-weight: 600; }
.gatt-char { border-top: 1px dashed var(--line); padding: 6px 0 4px 12px; }
.gatt-char .props { font-size: .75rem; color: var(--muted); }
.gatt-char .val { font-family: var(--mono); font-size: .78rem; color: #9ecbff; white-space: pre-wrap; word-break: break-all; }

/* gamepad */
.pad-buttons { display: flex; flex-wrap: wrap; gap: 4px; }
.pad-btn { width: 38px; height: 38px; border-radius: 6px; border: 1px solid var(--line); position: relative; overflow: hidden; font-size: .7rem; display: flex; align-items: center; justify-content: center; background: #18191b; }
.pad-btn .fill { position: absolute; left: 0; bottom: 0; width: 100%; background: var(--accent); opacity: .7; }
.pad-btn span { position: relative; }
.pad-btn.pressed { border-color: var(--accent-2); }
.pad-axes { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.stick { width: 90px; height: 90px; border: 1px solid var(--line); border-radius: 50%; position: relative; background: #18191b; }
.stick .knob { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--accent-2); left: 38px; top: 38px; }
.axis-bar { width: 160px; height: 14px; background: #18191b; border: 1px solid var(--line); border-radius: 4px; position: relative; }
.axis-bar .fill { position: absolute; top: 0; bottom: 0; background: var(--accent); }

/* midi keyboard */
.keys { position: relative; height: 110px; display: flex; user-select: none; touch-action: none; margin-top: 8px; }
.key-w { flex: 1; border: 1px solid #555; background: #eee; border-radius: 0 0 5px 5px; position: relative; max-width: 44px; }
.key-b { position: absolute; width: 60%; height: 62%; left: 70%; top: 0; background: #111; border: 1px solid #555; z-index: 2; border-radius: 0 0 4px 4px; }
.key-w.on { background: #7fd3ca; }
.key-b.on { background: var(--accent); }
.key-w .lbl { position: absolute; bottom: 3px; width: 100%; text-align: center; color: #555; font-size: .65rem; }

video, canvas.viz, img.preview { max-width: 100%; border-radius: 6px; background: #000; display: block; }
canvas.spark { width: 100%; height: 60px; background: #141517; border-radius: 4px; display: block; margin-top: 6px; }
.meter { height: 12px; background: #141517; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.meter > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--warn) 70%, var(--err)); transition: width .05s; }

.dropzone { border: 2px dashed var(--line); border-radius: 8px; padding: 18px; text-align: center; color: var(--muted); margin: 8px 0; }
.dropzone.over { border-color: var(--accent); color: var(--text); }

.tree { font-family: var(--mono); font-size: .8rem; max-height: 320px; overflow: auto; background: #141517; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.tree .entry { cursor: pointer; padding: 1px 4px; border-radius: 3px; white-space: nowrap; }
.tree .entry:hover { background: var(--panel-2); }
.tree .dir { color: var(--warn); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: .85rem; }
.kv > div:nth-child(odd) { color: var(--muted); }
.kv > div:nth-child(even) { font-family: var(--mono); font-size: .8rem; word-break: break-all; }

details > summary { cursor: pointer; color: var(--muted); font-size: .88rem; margin: 6px 0; }
