:root {
  --bg0: #0c1218;
  --bg1: #15202b;
  --accent: #4cc2ff;
  --accent-dim: #2a7fb8;
  --danger: #e81123;
  --ok: #2ecc71;
  --muted: #9aa7b5;
  --text: #f3f6f9;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.16);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font: "Outfit", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg0);
  overflow: hidden;
}

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(900px 600px at 12% 8%, #2a455c 0%, transparent 55%),
    radial-gradient(800px 500px at 88% 18%, #1a3348 0%, transparent 50%),
    linear-gradient(160deg, #0b1016, #152433 55%, #0e1620);
}
#bg::after {
  content: "";
  position: absolute;
  inset: 0;
  backdrop-filter: blur(28px) saturate(1.2);
  background: rgba(12, 18, 24, 0.25);
}

#app {
  position: relative;
  z-index: 1;
  height: 100%;
}

.mica {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(40px) saturate(1.4);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

/* Login */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  padding: 36px 32px 28px;
  text-align: center;
}
.brand {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0 0 6px;
}
.brand span { color: var(--accent); }
.login-sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 0.95rem;
}
.field {
  text-align: left;
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.28);
  color: var(--text);
  font: inherit;
  outline: none;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(76, 194, 255, 0.25);
}
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  padding: 11px 16px;
  color: #041018;
  background: linear-gradient(180deg, #6ad0ff, #3aa8e0);
  box-shadow: 0 4px 0 #1f6f99, 0 8px 20px rgba(0,0,0,0.25);
  transition: transform 80ms ease, box-shadow 80ms ease, filter 120ms ease;
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #1f6f99, 0 2px 8px rgba(0,0,0,0.3);
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-ghost {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  box-shadow: 0 3px 0 rgba(0,0,0,0.35);
}
.btn-ghost:active { box-shadow: 0 1px 0 rgba(0,0,0,0.35); }
.btn-danger {
  background: linear-gradient(180deg, #ff5a67, #c20f20);
  color: #fff;
  box-shadow: 0 4px 0 #7a0a14, 0 8px 20px rgba(0,0,0,0.25);
}
.btn-danger:active { box-shadow: 0 1px 0 #7a0a14; }
.err {
  color: #ff8f9a;
  min-height: 1.2em;
  font-size: 0.85rem;
  margin: 8px 0 0;
}

/* Hub */
.shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 18px 22px 22px;
  gap: 16px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}
.topbar .meta { color: var(--muted); font-size: 0.85rem; }
.device-grid {
  flex: 1;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  align-content: start;
  padding-right: 4px;
}
.device-card {
  position: relative;
  padding: 18px 16px 14px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
  min-height: 120px;
}
.device-card:hover {
  transform: translateY(-2px);
  border-color: rgba(76,194,255,0.45);
}
.device-card .name {
  font-weight: 650;
  font-size: 1.05rem;
  margin-bottom: 8px;
  padding-right: 28px;
  word-break: break-all;
}
.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6b7785;
  flex: none;
}
.dot.on { background: var(--ok); box-shadow: 0 0 10px rgba(46,204,113,0.55); }
.battery { margin-top: 10px; font-size: 0.82rem; color: var(--muted); }
.trash {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.trash:hover {
  background: rgba(232,17,35,0.15);
  border-color: rgba(232,17,35,0.35);
  color: #ff8f9a;
}
.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.45);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal {
  width: min(420px, 100%);
  padding: 22px;
}
.modal h2 { margin: 0 0 8px; font-size: 1.1rem; }
.modal p { margin: 0 0 18px; color: var(--muted); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Control room */
.room {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 16px 18px 18px;
}
.room-top {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.room-top .title { font-weight: 700; font-size: 1.15rem; }
.video-stage {
  position: relative;
  min-height: 280px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.video-frame {
  position: relative;
  width: min(100%, 960px);
  aspect-ratio: 9 / 16;
  max-height: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  resize: both;
  min-width: 240px;
  min-height: 180px;
}
.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
}
.video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.rec-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 6px;
  animation: blink 1s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@media (max-width: 640px) {
  .shell, .room { padding: 12px; }
  .video-frame { aspect-ratio: 9 / 16; width: 100%; }
}
