:root {
  --bg: #07090d;
  --panel: rgba(8, 12, 18, .78);
  --panel-strong: rgba(3, 6, 10, .88);
  --line: rgba(255, 255, 255, .12);
  --text: #f6f7fb;
  --muted: #aeb7c8;
  --red: #e5313a;
  --cyan: #45f0ff;
  --amber: #ffb84d;
  --green: #62f6a8;
  --radius: 8px;
}

@property --angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.login {
  min-height: 100%;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: clamp(20px, 4vw, 46px);
  background:
    linear-gradient(90deg, rgba(0,0,0,.78), rgba(0,0,0,.22)),
    url("./assets/bglogin.jpg") center/cover;
}
.lamp {
  position: absolute;
  inset: -26% 12% auto;
  height: 46%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(69,240,255,.36), rgba(229,49,58,.18) 36%, transparent 68%);
  filter: blur(12px);
  opacity: .9;
}
.login-orbit {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.login-orbit span {
  position: absolute;
  left: clamp(20px, 8vw, 110px);
  top: clamp(28px, 10vh, 110px);
  width: 90px;
  height: 90px;
  border: 1px solid rgba(69, 240, 255, .28);
  border-radius: 50%;
  animation: rippleWave 3.8s ease-out infinite;
}
.login-orbit span:nth-child(2) { animation-delay: .9s; }
.login-orbit span:nth-child(3) { animation-delay: 1.8s; }
.login-logo {
  width: clamp(76px, 11vw, 130px);
  position: absolute;
  top: clamp(18px, 4vw, 36px);
  left: clamp(18px, 4vw, 42px);
  filter: drop-shadow(0 0 22px rgba(69, 240, 255, .24));
}
.signal-beam {
  position: absolute;
  width: min(34vw, 420px);
  height: 2px;
  left: clamp(118px, 17vw, 190px);
  top: clamp(68px, 11vw, 96px);
  background: linear-gradient(90deg, transparent, var(--cyan), var(--red), transparent);
  transform: rotate(10deg);
  filter: drop-shadow(0 0 8px var(--cyan));
  animation: beamFlow 2.2s linear infinite;
}
.login-box {
  width: min(440px, calc(100vw - 40px));
  display: grid;
  gap: 14px;
  padding: clamp(20px, 3vw, 28px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 90px rgba(0, 0, 0, .48);
}
.eyebrow {
  width: fit-content;
  padding: 4px 8px;
  border: 1px solid rgba(69, 240, 255, .35);
  color: var(--cyan);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}
.login-box h1 {
  margin: 0 0 8px;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}
.login-box h1 span {
  display: inline-block;
  text-shadow: 0 0 26px rgba(229, 49, 58, .55);
  animation: textScan 5s ease-in-out infinite;
}
label {
  display: grid;
  gap: 6px;
  color: #c9ced9;
  font-size: 13px;
}
.cyber-input {
  width: 100%;
  border: 1px solid rgba(255,255,255,.18);
  background:
    linear-gradient(90deg, rgba(69,240,255,.10), transparent 22%),
    rgba(255,255,255,.075);
  color: #fff;
  border-radius: 6px;
  padding: 11px 12px;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
}
.cyber-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(69, 240, 255, .12);
}
.liquid-btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  padding: 12px 14px;
  color: white;
  background: linear-gradient(135deg, var(--red), #971a21);
}
.liquid-btn::before {
  content: "";
  position: absolute;
  inset: -35% -18%;
  z-index: -1;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.38), transparent 32%);
  transform: translateX(-64%) rotate(12deg);
  transition: transform .42s ease;
}
.liquid-btn:hover::before,
.liquid-btn:focus-visible::before {
  transform: translateX(0) rotate(12deg);
}
.loader {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid rgba(255,255,255,.26);
  border-top-color: white;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin .8s linear infinite;
}
.error {
  color: #ffb0b0;
  margin: 0;
}
.inline { padding: 10px 16px; }

.shell {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(178px, 220px) minmax(380px, 1fr) minmax(320px, 420px);
  background:
    linear-gradient(180deg, rgba(0,0,0,.50), rgba(0,0,0,.86)),
    url("./assets/bgmenu.jpg") center/cover;
}
.nav {
  min-width: 0;
  padding: 18px 12px;
  background: rgba(0,0,0,.46);
  border-right: 1px solid var(--line);
}
.brand {
  width: 100%;
  max-height: 72px;
  object-fit: contain;
  margin-bottom: 18px;
}
.nav-track {
  position: relative;
  display: grid;
  gap: 8px;
}
.nav-btn {
  width: 100%;
  min-height: 50px;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: #e8ebf4;
  background: rgba(255,255,255,.055);
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: left;
  padding: 0 12px;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.nav-btn:hover { transform: translateX(3px); }
.nav-btn img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.nav-btn span,
.card span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.nav-btn.active, .cats button.active {
  border-color: rgba(69, 240, 255, .62);
  background: linear-gradient(90deg, rgba(69,240,255,.16), rgba(229,49,58,.14));
  box-shadow: inset 3px 0 0 var(--red), 0 0 26px rgba(69,240,255,.10);
}
.content {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(0,0,0,.32);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.topbar strong {
  display: block;
  font-size: clamp(20px, 2.5vw, 28px);
  line-height: 1.05;
  letter-spacing: 0;
}
.morph-title {
  animation: titleIn .28s ease both;
}
.topbar span {
  color: var(--muted);
  font-size: 13px;
}
.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: min(360px, 52%);
}
.top-actions input { min-width: 0; }
.command-btn,
.player-head button,
.player-actions button,
.command-head button {
  border: 1px solid rgba(255,255,255,.18);
  color: #fff;
  background: rgba(255,255,255,.08);
  border-radius: 6px;
  padding: 9px 11px;
}
.columns {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
}
.cats {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  border-right: 1px solid rgba(255,255,255,.08);
}
.cats button {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 11px 10px;
  text-align: left;
  color: #e8ebf4;
  background: rgba(255,255,255,.055);
  border: 1px solid transparent;
  border-radius: 6px;
}
.grid {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(116px, 13vw, 158px), 1fr));
  grid-auto-rows: minmax(146px, auto);
  gap: 12px;
  align-content: start;
}
.card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(86px, 1fr) auto;
  gap: 8px;
  min-height: 146px;
  padding: 10px;
  color: #fff;
  border: 1px solid rgba(255,255,255,.10);
  background:
    linear-gradient(145deg, rgba(255,255,255,.08), transparent 42%),
    rgba(0,0,0,.42);
  border-radius: 8px;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card::after {
  content: "01001100 101101";
  position: absolute;
  inset: 0;
  z-index: -1;
  color: rgba(69, 240, 255, .10);
  font-size: 10px;
  line-height: 1.6;
  word-break: break-all;
  opacity: 0;
  transition: opacity .18s ease;
}
.card:hover,
.card:focus {
  transform: translateY(-2px);
  border-color: rgba(69,240,255,.55);
  box-shadow: 0 14px 34px rgba(0,0,0,.28);
}
.card:hover::after,
.card:focus::after {
  opacity: 1;
}
.card.active {
  border-color: rgba(255,184,77,.72);
}
.card img, .no-logo {
  width: 100%;
  height: 100%;
  min-height: 88px;
  max-height: 118px;
  object-fit: contain;
  background: rgba(255,255,255,.05);
  border-radius: 6px;
}
.no-logo {
  display: grid;
  place-items: center;
  font-size: 24px;
  color: #cdd3df;
  text-transform: uppercase;
}
.card span {
  font-size: 13px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.player {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  padding: 18px;
  background: var(--panel-strong);
  border-left: 1px solid var(--line);
}
.player-empty, .empty {
  display: grid;
  place-items: center;
  color: #c9ced9;
  min-height: 180px;
  text-align: center;
  padding: 18px;
}
.span-grid {
  grid-column: 1 / -1;
  min-height: auto;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.24);
  border-radius: 8px;
}
.player-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.player-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}
.player-status {
  min-height: 20px;
  margin: 0;
  color: #b9c4d6;
  font-size: 13px;
}
.video-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  align-self: start;
  background: #000;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-container video {
  box-shadow: none;
  border-radius: 0;
  transition: transform 0.2s ease;
}
.settings {
  padding: 24px;
  max-width: 740px;
  color: #d8deea;
}
.settings p {
  overflow-wrap: anywhere;
}

.beam-card {
  position: relative;
  overflow: hidden;
}
.beam-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(from var(--angle, 0deg), transparent 0 58%, var(--cyan), var(--red), transparent 72%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  animation: borderBeam 4s linear infinite;
}
.ripple {
  position: relative;
  overflow: hidden;
}
.ripple::after {
  content: "";
  position: absolute;
  left: var(--rx, 50%);
  top: var(--ry, 50%);
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(69, 240, 255, .24);
  opacity: 0;
  pointer-events: none;
}
.ripple.rippling::after {
  animation: tapRipple .48s ease-out;
}
.command-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: start center;
  padding: min(9vh, 70px) 18px 18px;
  background: rgba(0,0,0,.58);
  backdrop-filter: blur(10px);
}
.command-box {
  width: min(520px, 100%);
  max-height: min(620px, calc(100vh - 44px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: rgba(8, 12, 18, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 90px rgba(0,0,0,.58);
  animation: pop .18s ease-out both;
}
.command-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.command-list {
  overflow: auto;
  display: grid;
  gap: 8px;
  padding: 12px;
}
.command-list button {
  min-height: 48px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 6px;
  color: #fff;
  background: rgba(255,255,255,.06);
  text-align: left;
  padding: 8px 10px;
}
.command-list img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

@keyframes borderBeam {
  to { --angle: 360deg; }
}
@keyframes beamFlow {
  0% { opacity: .3; background-position: 0 0; }
  50% { opacity: 1; }
  100% { opacity: .3; background-position: 420px 0; }
}
@keyframes rippleWave {
  from { transform: scale(.22); opacity: .56; }
  to { transform: scale(4.2); opacity: 0; }
}
@keyframes tapRipple {
  0% { width: 0; height: 0; opacity: .8; }
  100% { width: 240px; height: 240px; opacity: 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes textScan {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(35deg); }
}
@keyframes titleIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  from { opacity: 0; transform: translateY(-10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 184px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .player {
    grid-column: 1 / -1;
    grid-row: 2;
    border-left: 0;
    border-top: 1px solid var(--line);
    grid-template-columns: minmax(240px, 360px) 1fr;
    grid-template-rows: auto auto;
    align-items: start;
  }
  .player video,
  .player-empty {
    grid-column: 1;
    grid-row: 1 / span 2;
  }
}

@media (max-width: 820px) {
  body { overflow: auto; }
  html, body, #app { min-height: 100%; height: auto; }
  .shell {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .nav {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
  }
  .brand {
    max-height: 42px;
    margin-bottom: 10px;
  }
  .nav-track {
    grid-auto-flow: column;
    grid-auto-columns: minmax(86px, 1fr);
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 2px;
  }
  .nav-btn {
    min-height: 64px;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 8px;
  }
  .nav-btn:hover { transform: none; }
  .nav-btn img { width: 24px; height: 24px; }
  .nav-btn span { font-size: 12px; }
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
  .top-actions {
    min-width: 0;
    width: 100%;
  }
  .columns {
    grid-template-columns: 1fr;
  }
  .cats {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .cats button {
    width: auto;
    min-width: 120px;
    margin-bottom: 0;
    white-space: nowrap;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
    overflow: visible;
  }
  .player {
    grid-column: auto;
    grid-row: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .player video,
  .player-empty {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 540px) {
  .login {
    place-items: end center;
    padding: 120px 14px 18px;
  }
  .signal-beam { display: none; }
  .login-box {
    width: 100%;
  }
  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 10px;
  }
  .card {
    min-height: 136px;
  }
  .player-head {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}
