:root {
  --bg: #0b0e12;
  --panel: #12161c;
  --panel-2: #181d25;
  --line: #262d38;
  --text: #e7ecf2;
  --muted: #8b95a5;
  --accent: #32e6a0;
  --accent-ink: #04140d;
  --danger: #ff5d6c;
  --warn: #ffbf47;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #142028 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

.screen { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }

.card {
  width: 100%; max-width: 360px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.card.wide { max-width: 520px; }

.brand { font-weight: 700; font-size: 20px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.byline { font-size: 11px; font-weight: 500; letter-spacing: .08em; color: var(--muted); opacity: .85; }
.logo {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--panel-2); color: var(--accent); font-size: 13px; border: 1px solid var(--line);
}
.muted { color: var(--muted); margin: 0 0 8px; }
.hint { color: var(--muted); font-size: 13px; margin: -2px 0 6px; }

label { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; justify-content: space-between; align-items: baseline; }
label output { color: var(--text); font-family: var(--mono); font-size: 13px; }

input[type=password], input[type=text], select {
  width: 100%; height: 42px; padding: 0 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; font: inherit; outline: none;
}
input[type=password]:focus, input[type=text]:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(50,230,160,.15); }
input[type=range] { width: 100%; accent-color: var(--accent); }

.check { flex-direction: row; justify-content: flex-start; gap: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.checks { display: flex; align-items: flex-end; padding-bottom: 10px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid > div { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 480px) { .grid { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; gap: 10px; }
.row.space { justify-content: space-between; margin-bottom: 8px; }

button { font: inherit; cursor: pointer; }
button.primary {
  height: 44px; margin-top: 8px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 650;
}
button.primary:disabled { opacity: .4; cursor: not-allowed; }
button.primary:not(:disabled):hover { filter: brightness(1.08); }
button.link { background: none; border: 0; color: var(--muted); align-self: center; padding: 6px; }
button.link:hover { color: var(--text); }

.error { color: var(--danger); min-height: 1.2em; margin: 2px 0 0; font-size: 14px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 11px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.on .dot { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.pill.on { color: var(--text); }
.pill.off .dot { background: var(--danger); }

.keys { margin-top: 10px; color: var(--muted); font-size: 13px; }
.keys summary { cursor: pointer; }
.keys dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 10px 0 0; }
.keys dt { font-family: var(--mono); color: var(--text); font-size: 12px; }
.keys dd { margin: 0; }

/* Stream */
#stream { position: fixed; inset: 0; background: #000; overflow: hidden; }
#video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; outline: none; }
#stream.locked { cursor: none; }

.stats {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  background: rgba(8,10,14,.82); border: 1px solid rgba(255,255,255,.08); border-radius: 10px;
  padding: 10px 12px; font: 12px/1.6 var(--mono); color: #cfd6df;
  display: grid; grid-template-columns: auto auto; gap: 0 14px; pointer-events: none;
  backdrop-filter: blur(6px);
}
.stats b { color: var(--muted); font-weight: 400; }
.stats .good { color: var(--accent); }
.stats .warn { color: var(--warn); }
.stats .bad { color: var(--danger); }

.capture { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); z-index: 4; }
.capture button {
  background: rgba(18,22,28,.92); color: var(--text); border: 1px solid var(--line);
  padding: 14px 22px; border-radius: 12px; font-weight: 600;
}

.status, .toast {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 6;
  background: rgba(18,22,28,.92); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; font-size: 14px; max-width: calc(100% - 32px); text-align: center;
}
.status { top: 45%; }
.toast { bottom: 24px; }

.bar {
  position: absolute; top: 10px; left: 50%; transform: translate(-50%, -140%); z-index: 7;
  display: flex; gap: 4px; padding: 5px; border-radius: 12px;
  background: rgba(18,22,28,.92); border: 1px solid var(--line);
  transition: transform .18s ease; flex-wrap: wrap; justify-content: center; max-width: calc(100% - 32px);
}
.bar.show { transform: translate(-50%, 0); }
.bar button {
  background: transparent; color: var(--text); border: 0; padding: 7px 11px; border-radius: 8px; font-size: 13px;
}
.bar button:hover { background: var(--panel-2); }
.bar button.danger { color: var(--danger); }

.pc-label { align-self: center; padding: 0 10px 0 8px; font-size: 13px; color: var(--muted); border-right: 1px solid var(--line); margin-right: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; }
#code { font-family: var(--mono); letter-spacing: .2em; font-size: 17px; }
.check.dim { opacity: .4; }
.badge {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: rgba(255,191,71,.12); color: var(--warn); border: 1px solid rgba(255,191,71,.35);
}
.bar .badge { align-self: center; margin-right: 4px; }

/* watch party (owner) */
.party { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); display: flex; flex-direction: column; gap: 10px; }
.party.live { border-color: rgba(50,230,160,.45); box-shadow: 0 0 0 3px rgba(50,230,160,.08); }
.hint.inline { margin: 0 0 0 6px; }
.viewers { min-height: 42px; display: flex; align-items: center; font-size: 14px; color: var(--text); }
.switch { flex-direction: row; gap: 8px; align-items: center; color: var(--text); font-size: 14px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
button.secondary { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-weight: 600; }
button.secondary:hover { border-color: var(--accent); }
.viewers-badge { background: rgba(50,230,160,.12); color: var(--accent); border-color: rgba(50,230,160,.35); }

/* touch devices */
#video { touch-action: none; }
.touch-cursor {
  position: absolute; z-index: 6; width: 22px; height: 22px; pointer-events: none; transform: translate(-2px, -2px);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M2 2l0 16 4.5-4.2 3 6.5 2.6-1.2-3-6.3 6.1-.3z' fill='%23fff' stroke='%23000' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat;
}
.touch-cursor.down { filter: drop-shadow(0 0 4px var(--accent)); }
.menu-btn {
  position: absolute; z-index: 8; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(18,22,28,.75); color: var(--text); border: 1px solid var(--line); font-size: 20px; line-height: 1;
}
.kbd-input { position: absolute; left: -1000px; top: 0; width: 10px; height: 10px; opacity: 0; }
.party-status { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 13px; color: var(--accent); background: rgba(50,230,160,.08); border: 1px solid rgba(50,230,160,.3); }
