/* Web Streamer shared design system (server dashboard + client UI). */
:root {
  --bg: #08090d;
  --bg-2: #0d0f15;
  --panel: #12141c;
  --panel-2: #171a24;
  --panel-3: #1d2130;
  --border: rgba(255, 255, 255, .07);
  --border-2: rgba(255, 255, 255, .12);
  --text: #e9ebf3;
  --muted: #9095a8;
  --dim: #626779;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(124, 92, 255, .14);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, .13);
  --red: #f43f5e;
  --red-soft: rgba(244, 63, 94, .13);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, .13);
  --brand: linear-gradient(135deg, #7c5cff 0%, #22d3ee 100%);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .6);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 10% -10%, rgba(124, 92, 255, .10), transparent 60%),
    radial-gradient(800px 500px at 110% 0%, rgba(34, 211, 238, .07), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(124, 92, 255, .35); }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.grad-text { background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: #2a2e3d transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #2a2e3d; border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

/* brand mark */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; text-decoration: none; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--brand);
  display: grid; place-items: center; box-shadow: 0 6px 20px -6px rgba(124, 92, 255, .7);
}
.logo-mark svg { width: 17px; height: 17px; color: #fff; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s, opacity .15s;
}
.btn:hover { background: var(--panel-3); border-color: rgba(255, 255, 255, .18); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--brand); border-color: transparent; color: #fff; box-shadow: 0 8px 24px -10px rgba(124, 92, 255, .8); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.btn.danger { color: #fda4af; border-color: rgba(244, 63, 94, .3); background: var(--red-soft); }
.btn.danger:hover { background: rgba(244, 63, 94, .22); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.block { width: 100%; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--dim); }
.input, select.input, textarea.input {
  height: 40px; width: 100%; padding: 0 12px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border-2); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: rgba(124, 92, 255, .7); box-shadow: 0 0 0 3px rgba(124, 92, 255, .18); }
.input::placeholder { color: var(--dim); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .full { grid-column: 1 / -1; }

/* segmented control */
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 11px; }
.seg button {
  flex: 1; min-width: max-content; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 12px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 550; font-size: 13px;
}
.seg button svg { width: 15px; height: 15px; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-2); }

/* toggle */
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 22px; background: #2a2e3d; cursor: pointer; transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }

/* cards */
.card { background: linear-gradient(180deg, rgba(255,255,255,.025), transparent 40%), var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }

/* status pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap;
  background: rgba(255, 255, 255, .06); color: var(--muted);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.live { background: var(--green-soft); color: #4ade80; }
.pill.live .dot { animation: pulse 1.6s infinite; }
.pill.rec { background: rgba(244, 63, 94, .9); color: #fff; }
.pill.connecting { background: var(--amber-soft); color: #fbbf24; }
.pill.connecting .dot { animation: blink 1s infinite; }
.pill.error { background: var(--red-soft); color: #fb7185; }
.pill.offline { background: rgba(255, 255, 255, .05); color: var(--dim); }
.pill.accent { background: var(--accent-soft); color: #b4a3ff; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .7); } 70% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }
@keyframes blink { 50% { opacity: .3; } }

.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; background: rgba(255,255,255,.05); border: 1px solid var(--border); color: var(--muted); font-size: 12px; font-family: var(--mono); }

/* copy box */
.copybox { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm); font-family: var(--mono); font-size: 13px; }
.copybox .val { flex: 1; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.copybox .val::-webkit-scrollbar { display: none; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(4, 5, 8, .72); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 80; padding: 20px; animation: fade .15s; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--panel); border: 1px solid var(--border-2); border-radius: 18px; box-shadow: var(--shadow); animation: pop .18s ease-out; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: rgba(0,0,0,.15); border-radius: 0 0 18px 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { min-width: 240px; max-width: 380px; padding: 12px 16px; border-radius: 12px; background: var(--panel-3); border: 1px solid var(--border-2); box-shadow: var(--shadow); animation: pop .2s; font-size: 13.5px; }
.toast.ok { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }

/* empty states */
.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty .empty-icon { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: #b4a3ff; }
.empty .empty-icon svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); font-size: 17px; margin-bottom: 6px; }
.empty p { margin: 0 auto 18px; max-width: 420px; }

/* auth / center layout */
.center-page { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(400px, 100%); padding: 32px; }
.auth-card .logo { justify-content: center; margin-bottom: 26px; font-size: 18px; }
.auth-card .logo-mark { width: 40px; height: 40px; border-radius: 12px; }
.auth-card .logo-mark svg { width: 22px; height: 22px; }
.auth-card h1 { font-size: 20px; text-align: center; }
.auth-card .sub { text-align: center; color: var(--muted); margin: 6px 0 24px; }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }
.alert.err { background: var(--red-soft); color: #fda4af; border: 1px solid rgba(244, 63, 94, .25); }
.alert.info { background: var(--accent-soft); color: #c4b8ff; border: 1px solid rgba(124, 92, 255, .25); }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}
