:root {
    --bg: #0a0a0a;
    --panel: #141414;
    --panel-2: #1b1b1b;
    --border: #262626;
    --text: #e8e8e8;
    --text-dim: #888;
    --accent: #4ade80;
    --accent-dim: #166534;
    --danger: #ef4444;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
}

.app {
    max-width: 640px;
    margin: 0 auto;
    padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 16px) 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: lowercase;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: background 0.2s;
}

.dot.live { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.dot.error { background: var(--danger); }

.role {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stage {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.video-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.6) 100%);
    pointer-events: none;
    transition: opacity 0.2s;
}

.overlay.hidden { opacity: 0; }

.overlay-text {
    color: var(--text-dim);
    font-size: 13px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 10px 16px;
    border: 1px dashed var(--border);
    border-radius: 999px;
    background: rgba(0,0,0,0.4);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

select {
    appearance: none;
    width: 100%;
    padding: 12px 14px;
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%23888' d='M6 8L2 4h8z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

select:disabled { opacity: 0.5; }

.buttons {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.btn {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.05s, background 0.15s, border-color 0.15s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: #04120a;
    border-color: var(--accent);
}

.btn-primary:disabled { background: var(--accent-dim); border-color: var(--accent-dim); color: #a7f3d0; }

.status {
    padding: 10px 12px;
    background: var(--panel-2);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-dim);
    border-left: 2px solid var(--border);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    word-break: break-word;
}

.status.ok { color: var(--accent); border-left-color: var(--accent); }
.status.err { color: var(--danger); border-left-color: var(--danger); }

.info {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.info-row > span:first-child { color: var(--text-dim); }

.footer {
    margin-top: auto;
    padding: 12px 4px;
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
}

.muted { color: #555; }

.viewer-link {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
}

.viewer-link-head {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.viewer-link code {
    display: block;
    padding: 10px 12px;
    background: var(--panel-2);
    border-radius: 8px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 13px;
    color: var(--accent);
    word-break: break-all;
    border-left: 2px solid var(--accent);
}

/* viewer page: no gutters, video fills the viewport for OBS capture */
body.viewer-page { padding: 0; }
.viewer-app .stage { border-radius: 0; border: none; }
.viewer-app .video-wrap { aspect-ratio: auto; height: 56vh; }
.viewer-app video { background: #000; }

/* clean mode (?clean=1) — hide every piece of chrome so OBS Browser Source
   captures only the raw stream. The <video> fills the window. */
html.clean-mode,
html.clean-mode body { margin: 0; padding: 0; background: #000; overflow: hidden; }
html.clean-mode .header,
html.clean-mode .info,
html.clean-mode .status,
html.clean-mode .footer,
html.clean-mode .overlay { display: none !important; }
html.clean-mode .app      { max-width: none; padding: 0; min-height: 100vh; gap: 0; }
html.clean-mode .stage    { border: none; border-radius: 0; background: #000; height: 100vh; }
html.clean-mode .video-wrap { aspect-ratio: auto; height: 100vh; }
html.clean-mode video     { width: 100%; height: 100%; object-fit: cover; background: #000; }
