:root {
  color-scheme: dark;
  --bg: #070b10;
  --surface: #121b24;
  --surface-2: #17222e;
  --surface-3: #1d2a38;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e9f1f8;
  --muted: #8d9eb0;
  --faint: #64768a;
  --accent: #3ddc97;
  --accent-deep: #1f8f63;
  --danger: #ff7373;
  --warn: #ffc36b;
  --blue: #73aaff;
  --radius: 20px;
  --radius-sm: 13px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(900px 600px at 8% -10%, rgba(61, 220, 151, 0.10), transparent 60%),
    radial-gradient(800px 620px at 100% 0%, rgba(115, 170, 255, 0.09), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.7rem, 4.4vw, 2.5rem); line-height: 1.1; }
h2 { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.13em; color: var(--muted); }
h3 { font-size: 0.95rem; font-weight: 650; margin: 30px 0 8px; }

main.app { max-width: 880px; margin: 0 auto; padding: 0 18px 64px; }

/* ---------- brand ---------- */

.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.mark {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(140deg, #62f0b4, var(--accent-deep));
  color: #04170f;
  font-weight: 800; font-size: 0.86rem; letter-spacing: 0.02em;
  box-shadow: 0 8px 22px rgba(61, 220, 151, 0.22);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1rem; letter-spacing: -0.01em; white-space: nowrap; }
.brand-text small { color: var(--muted); font-size: 0.76rem; }

/* ---------- login ---------- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 390px; padding: 30px 26px 24px; }
.brand-lg { margin-bottom: 26px; }
.brand-lg .mark { width: 46px; height: 46px; border-radius: 14px; font-size: 1rem; }
.brand-lg .brand-text strong { font-size: 1.16rem; }

label { display: block; margin-bottom: 15px; }
.login label > span { display: block; font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.11em; color: var(--faint); margin-bottom: 7px; }

input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 0.98rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
input::placeholder { color: #5e7185; }
input:hover { border-color: var(--line-strong); }
input:focus { border-color: rgba(61, 220, 151, 0.55); background: rgba(255, 255, 255, 0.05); box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.11); }

button {
  font: inherit; font-weight: 650;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 17px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.06s ease, box-shadow 0.15s ease;
}
button:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--line-strong); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid rgba(61, 220, 151, 0.7); outline-offset: 2px; }

button.primary {
  background: linear-gradient(180deg, #3ddc97, #2ab679);
  border-color: rgba(0, 0, 0, 0.18);
  color: #04170f;
  box-shadow: 0 10px 24px rgba(61, 220, 151, 0.2);
}
button.primary:hover { background: linear-gradient(180deg, #4fe8a6, #31c585); }
button.ghost { background: transparent; }
button.ghost:hover { background: rgba(255, 255, 255, 0.055); }
button.small { padding: 8px 13px; font-size: 0.84rem; border-radius: 10px; }
button.danger { color: #ffd2d2; border-color: rgba(255, 115, 115, 0.28); background: rgba(255, 115, 115, 0.09); }
button.danger:hover { background: rgba(255, 115, 115, 0.16); }
button.block { width: 100%; padding: 13px; }

.error { color: var(--danger); min-height: 1.2em; margin: 12px 0 0; font-size: 0.9rem; }
.fine { color: var(--faint); font-size: 0.8rem; text-align: center; margin: 18px 0 0; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin: 0 -18px; padding: 12px 18px;
  background: rgba(7, 11, 16, 0.74);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.nav { display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; text-decoration: none;
  color: var(--muted);
  border: 1px solid transparent;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.pill:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.pill.active { color: var(--text); background: rgba(255, 255, 255, 0.07); border-color: var(--line); }

/* ---------- panels ---------- */

.panel {
  background: linear-gradient(180deg, rgba(22, 31, 42, 0.92), rgba(16, 23, 31, 0.94));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.muted { color: var(--muted); font-size: 0.88rem; }
.note { margin: 16px 0 0; }
.test-result:empty { display: none; }

/* ---------- hero ---------- */

.hero {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  padding: 24px 24px 22px;
  background:
    radial-gradient(520px 220px at 0% 0%, rgba(61, 220, 151, 0.10), transparent 70%),
    linear-gradient(180deg, rgba(24, 34, 46, 0.95), rgba(15, 22, 30, 0.96));
}
.hero-main { min-width: 0; }
.hero-meta { color: var(--muted); font-size: 0.84rem; margin-top: 10px; }
.hero-meta b { color: var(--text); font-weight: 600; }
.chips { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }

.eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--faint); margin-bottom: 10px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.live-dot.on { background: var(--accent); box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.14); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.14); }
  50% { box-shadow: 0 0 0 7px rgba(61, 220, 151, 0.06); }
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.11em;
  color: var(--faint);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.ok { color: #a9f5d2; border-color: rgba(61, 220, 151, 0.3); background: rgba(61, 220, 151, 0.09); }
.chip.warn { color: #ffdca8; border-color: rgba(255, 195, 107, 0.28); background: rgba(255, 195, 107, 0.09); }
.chip.bad { color: #ffb3b3; border-color: rgba(255, 115, 115, 0.28); background: rgba(255, 115, 115, 0.09); }

/* ---------- status banner ---------- */

.status {
  display: none;
  margin-top: 16px; padding: 12px 15px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}
.status.show { display: block; }
.status.ok { border-color: rgba(61, 220, 151, 0.26); background: rgba(61, 220, 151, 0.07); color: #a9f5d2; }
.status.locked { border-color: rgba(255, 195, 107, 0.26); background: rgba(255, 195, 107, 0.07); color: #ffdca8; }
.status.bad { border-color: rgba(255, 115, 115, 0.26); background: rgba(255, 115, 115, 0.07); color: #ffb3b3; }

/* ---------- scene grid ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 11px; }

.scene-btn {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  min-height: 66px; padding: 13px 14px;
  text-align: left; font-weight: 600; font-size: 0.95rem; line-height: 1.25;
  white-space: normal;
  background: linear-gradient(180deg, #1b2735, #141d27);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.scene-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 12px 26px rgba(0, 0, 0, 0.32); }
.scene-btn .badge {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--faint);
  font-size: 0.82rem; font-weight: 800;
}
.scene-btn .label { flex: 1; min-width: 0; word-break: break-word; }
.scene-btn .live-tag {
  display: none; position: absolute; top: 8px; right: 8px;
  padding: 2px 7px; border-radius: 999px;
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.1em;
  color: #04170f; background: var(--accent);
}
.scene-btn.active {
  border-color: rgba(61, 220, 151, 0.6);
  background: linear-gradient(180deg, #17352a, #122a22);
  box-shadow: 0 0 0 1px rgba(61, 220, 151, 0.28), 0 14px 30px rgba(61, 220, 151, 0.12);
}
.scene-btn.active .badge { background: rgba(61, 220, 151, 0.18); color: #9df6cd; }
.scene-btn.active .label { padding-right: 30px; }
.scene-btn.active .live-tag { display: inline-block; }
.scene-btn:disabled { opacity: 0.62; filter: saturate(0.7); }
.scene-btn.active:disabled { opacity: 0.92; filter: none; }

/* ---------- switches / controls ---------- */

.control-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.switch {
  flex: 1 1 300px;
  white-space: normal;
  display: flex; align-items: center; gap: 14px;
  padding: 13px 15px;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.switch:hover { background: rgba(255, 255, 255, 0.06); }
.switch .knob {
  position: relative; flex: none;
  width: 46px; height: 27px; border-radius: 999px;
  background: #2a3644;
  border: 1px solid var(--line);
  transition: background 0.18s ease;
}
.switch .knob::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #9fb0c2;
  transition: transform 0.18s ease, background 0.18s ease;
}
.switch[aria-checked="true"] .knob { background: rgba(61, 220, 151, 0.32); border-color: rgba(61, 220, 151, 0.5); }
.switch[aria-checked="true"] .knob::after { transform: translateX(19px); background: var(--accent); }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-text b { font-size: 0.94rem; font-weight: 650; }
.switch-text small { color: var(--muted); font-size: 0.8rem; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; }

.checklist {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 8px;
  margin: 12px 0 16px;
  max-height: 360px; overflow: auto;
  padding: 2px;
}
.check {
  display: flex; align-items: center; gap: 10px;
  margin: 0; padding: 10px 12px;
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.check:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.055); }
.check input { width: 17px; height: 17px; margin: 0; flex: none; accent-color: var(--accent); }
.check span { word-break: break-word; font-size: 0.9rem; font-weight: 500; color: var(--text); text-transform: none; letter-spacing: normal; }

.users { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 13px;
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 0.92rem;
}
.user-row .who { display: flex; align-items: center; gap: 10px; }
.user-row .tag {
  margin-left: 7px; padding: 2px 7px; border-radius: 999px;
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--blue); background: rgba(115, 170, 255, 0.12);
}

.avatar {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(115, 170, 255, 0.13);
  color: #bcd7ff;
  font-size: 0.74rem; font-weight: 800; letter-spacing: 0.02em;
}
.avatar.sys { background: rgba(255, 195, 107, 0.12); color: #ffdca8; }

.inline { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.inline input { flex: 1 1 180px; width: auto; }

.activity-link {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 30px; padding: 15px 17px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text); text-decoration: none; font-weight: 650;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.activity-link:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--line-strong); transform: translateY(-1px); }
.activity-link .arrow { color: var(--accent); font-size: 1.1rem; }

/* ---------- audio / camera toggles ---------- */

.toggle-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 10px; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 15px;
  text-align: left;
  white-space: normal;
  background: linear-gradient(180deg, #1b2735, #141d27);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.toggle-row:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--line-strong); box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28); }
.toggle-row:disabled { opacity: 0.55; filter: saturate(0.7); }
.toggle-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toggle-text b { font-size: 0.92rem; font-weight: 650; word-break: break-word; }
.toggle-text small { color: var(--muted); font-size: 0.78rem; }
.toggle-state {
  flex: none; padding: 5px 10px; border-radius: 999px;
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  border: 1px solid var(--line); color: var(--faint);
}
.toggle-state.on { color: #a9f5d2; border-color: rgba(61, 220, 151, 0.32); background: rgba(61, 220, 151, 0.1); }
.toggle-state.off { color: #ffc9c9; border-color: rgba(255, 115, 115, 0.3); background: rgba(255, 115, 115, 0.08); }

/* ---------- health ---------- */

.health { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.metric {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid var(--line);
}
.metric span { color: var(--faint); font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.metric strong { font-size: 1.04rem; font-variant-numeric: tabular-nums; }

/* ---------- selects / cooldowns ---------- */

select {
  font: inherit; font-size: 0.92rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
select:focus { border-color: rgba(61, 220, 151, 0.55); box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.11); }
.inline select { flex: 0 0 auto; }

.cooldowns { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 4px; }
.cooldowns label { margin: 0; width: 112px; }
.cooldowns label > span { display: block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); margin-bottom: 6px; }
.cooldowns input { padding: 9px 10px; }

.user-controls { display: flex; align-items: center; gap: 8px; }
.role-select { padding: 7px 9px; font-size: 0.82rem; border-radius: 9px; }

/* ---------- activity page ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.page-head h1 { font-size: 1.5rem; }
.filters { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0 4px; }
.filters .pill { cursor: pointer; border: 1px solid var(--line); background: transparent; font: inherit; font-size: 0.8rem; }
.filters .pill.on { color: var(--text); background: rgba(61, 220, 151, 0.12); border-color: rgba(61, 220, 151, 0.32); }

.activity { list-style: none; margin: 12px 0 0; padding: 0; }
.activity li {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center;
  gap: 13px; padding: 13px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.activity li:last-child { border-bottom: 0; }
.activity .what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.activity .what b { font-size: 0.9rem; font-weight: 650; }
.activity .what span { color: var(--muted); font-size: 0.82rem; }
.activity time { color: var(--faint); font-size: 0.78rem; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty-state { padding: 34px 10px; text-align: center; color: var(--muted); }

.foot { text-align: center; margin-top: 34px; color: var(--faint); font-size: 0.78rem; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(8px);
  padding: 11px 19px; border-radius: 999px;
  background: #1c2836; border: 1px solid var(--line-strong);
  color: var(--text); font-size: 0.9rem; font-weight: 600;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  z-index: 30; max-width: calc(100vw - 32px);
  opacity: 0; transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast:not(.hidden) { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { border-color: rgba(255, 115, 115, 0.4); color: #ffd2d2; }
.toast.good { border-color: rgba(61, 220, 151, 0.4); color: #b6f0d5; }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  main.app { padding: 0 13px 48px; }
  .topbar { margin: 0 -13px; padding: 11px 13px; }
  .brand-text strong { font-size: 0.94rem; }
  .hero { flex-direction: column; gap: 16px; padding: 20px; }
  .chips { flex-direction: row; align-items: center; }
  .grid { grid-template-columns: 1fr 1fr; }
  .scene-btn { min-height: 60px; padding: 11px; font-size: 0.88rem; }
  .scene-btn .badge { width: 30px; height: 30px; font-size: 0.74rem; }
  .panel { padding: 17px 15px; }
  .control-row { flex-direction: column; align-items: stretch; }
  .control-row .switch { flex: 1 1 auto; }
  .inline input { flex: 1 1 100%; }
  .activity li { grid-template-columns: 30px 1fr; }
  .activity time { grid-column: 2; text-align: left; }
}

@media (max-width: 480px) {
  .nav { gap: 5px; }
  .pill { padding: 7px 10px; font-size: 0.78rem; }
  button.small { padding: 7px 10px; font-size: 0.8rem; }
  .hero { padding: 18px; }
  .chips { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
