:root { color-scheme: dark; --bg: #111; --panel: #1c1c1c; --line: #2c2c2c; --fg: #e8e8e8; --muted: #9a9a9a; --accent: #4ea1ff; --warn: #e0a030; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
/* Everything wraps instead of disappearing: no control is ever cut off in a small window. */
header { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--panel); border-bottom: 1px solid var(--line); }
header .tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
h1 { font-size: 16px; margin: 0; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
button, select, input[type=number], input[type=text] { background: #2a2a2a; color: var(--fg); border: 1px solid #3a3a3a; border-radius: 6px; padding: 6px 10px; font: inherit; min-height: 32px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: #1d4f86; border-color: #2f6db3; }
button.source { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #666; display: inline-block; }
.dot.on { background: #3c3; }
#banner[hidden] { display: none; }
#banner { padding: 10px 12px; background: #2a2414; border-bottom: 1px solid #4a3d1a; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

#grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 44vw), 1fr)); gap: 8px; padding: 12px; }
.tile { position: relative; aspect-ratio: 16 / 10; background: #000; border-radius: 6px; overflow: hidden; cursor: pointer; border: 2px solid transparent; }
.tile:hover, .tile:focus-visible { border-color: var(--accent); outline: none; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; font-size: 12px; background: linear-gradient(transparent, rgba(0,0,0,.8)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .badge { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: #3c3; box-shadow: 0 0 0 2px rgba(0,0,0,.5); }
.tile:not(.offline) .badge { display: none; }
#empty { padding: 24px; }

#viewer { position: fixed; inset: 0; z-index: 5; background: #000; display: flex; flex-direction: column; }
#viewer[hidden] { display: none; }
#stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; touch-action: pan-y; }
#stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
#stage .msg { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.7); padding: 4px 10px; border-radius: 6px; color: var(--muted); max-width: 90%; }
#hud { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: rgba(20,20,20,.95); border-top: 1px solid var(--line); transition: opacity .3s; }
#hud .group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
#v-info { flex: 1 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#viewer.idle #hud { opacity: 0; }
#viewer.idle { cursor: none; }

dialog { background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; width: min(680px, 94vw); max-height: 90vh; overflow: auto; padding: 16px; }
dialog h2 { margin-top: 0; font-size: 16px; }
dialog h3 { font-size: 14px; margin: 0 0 6px; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.card.active { border-color: var(--accent); }
.card p { margin: 4px 0 8px; }
textarea { width: 100%; background: #0d0d0d; color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font: 13px/1.4 ui-monospace, Consolas, monospace; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row.wrap { flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chips button { font-size: 12px; }
.field { display: block; margin: 8px 0; }
.field input { width: 7em; }
input[type=text] { width: 100%; }
code { background: #0d0d0d; padding: 1px 4px; border-radius: 4px; word-break: break-all; }
