:root { --bg: #0f1419; --panel: #171d25; --panel2: #1e2631; --line: #2a3442; --text: #e6edf3; --muted: #8b98a8; --accent: #3fb950; --accent2: #58a6ff; --warn: #f0883e; --code: #c9d1d9; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent2); }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 13px; color: var(--code); }
pre { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow: auto; font-size: 13px; line-height: 1.5; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); color: var(--text); padding: 7px 12px; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #04140a; font-weight: 600; }
button.small { padding: 3px 9px; font-size: 13px; }
select, input[type=text] { font: inherit; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; max-width: 100%; }
input[type=range] { accent-color: var(--accent); width: 140px; vertical-align: middle; }
output { display: inline-block; min-width: 38px; text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: center; gap: 24px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 17px; }
.logo { color: var(--accent); margin-right: 4px; }
.sub { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 6px; }
.tabs { display: flex; gap: 4px; }
.tab { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; }
.tab.active { color: var(--text); background: var(--panel2); }
.tab:hover { color: var(--text); }

.page { display: grid; grid-template-columns: minmax(340px, 480px) 1fr; gap: 24px; padding: 22px; max-width: 1400px; margin: 0 auto; }
.page[hidden] { display: none; }
.page.prose { display: block; max-width: 860px; }
h2 { margin: 0 0 8px; font-size: 22px; }
h3 { margin: 26px 0 8px; font-size: 17px; }
.lead { color: var(--muted); margin: 0 0 16px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.card.off { opacity: .55; }
.card.src { border-color: #2d4a3a; }
.card.sink { border-color: #2d3d5a; }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head b { flex: 1; font-size: 14px; }
.badge { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.card .desc { color: var(--muted); font-size: 13px; margin: 6px 0 8px; }
.params { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.params label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.params label > input[type=text] { width: 150px; }
.tools { display: flex; gap: 4px; }
.tools button { padding: 2px 7px; font-size: 12px; line-height: 1.4; }
.switch { position: relative; width: 36px; height: 20px; border-radius: 999px; background: #3a4656; border: 0; padding: 0; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 18px; }

.adder { position: relative; margin: 6px 0 14px; }
.picker { position: absolute; z-index: 4; top: 42px; left: 0; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-height: 420px; overflow: auto; }
.picker h4 { margin: 8px 6px 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.picker button { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 6px 8px; border-radius: 6px; }
.picker button:hover { background: var(--panel2); }
.picker button small { display: block; color: var(--muted); font-size: 12px; }

.right { min-width: 0; }
.video-wrap { position: relative; background: #000; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; }
.video-wrap img { max-width: 100%; max-height: 100%; width: auto; height: auto; image-rendering: auto; }
.video-status { position: absolute; left: 10px; bottom: 8px; font-size: 12px; color: #fff; background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 999px; }
.video-status.err { background: rgba(200,50,50,.8); }
.cmd-head { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; }
.cmd-head .hint { flex: 1; color: var(--muted); font-size: 13px; }
.cmd { margin: 0; white-space: pre; }
.how { margin-top: 12px; color: var(--muted); font-size: 14px; }
.how summary { cursor: pointer; color: var(--text); }
.how ul { padding-left: 20px; }
.how li { margin: 4px 0; }

.prose p, .prose li { color: #cdd6df; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 8px 0; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--panel); }
.terms dt { font-weight: 600; margin-top: 10px; }
.terms dd { margin: 2px 0 0 0; color: #cdd6df; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(900px, 100%); max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.modal-box pre { margin: 0; border: 0; border-radius: 0 0 12px 12px; overflow: auto; font-size: 12px; }

@media (max-width: 900px) {
  .page { grid-template-columns: 1fr; }
  .right { order: -1; }
  .top { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
}

.cam-preview { position: relative; margin: 0 0 8px; border-radius: 8px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.cam-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-note { position: absolute; left: 8px; bottom: 6px; font-size: 12px; color: #fff; background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 999px; }
