:root {
  color-scheme: dark;
  --page: #020710;
  --panel: #071321;
  --line: #1d3a55;
  --text: #f4f8fb;
  --muted: #9eb3c7;
  --cyan: #67d8e7;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.advanced-header {
  position: relative;
  z-index: 2;
  display: grid;
  min-height: 76px;
  padding: 9px max(18px, calc((100vw - 1580px) / 2));
  grid-template-columns: minmax(230px, 320px) minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 10, 19, 0.98);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.advanced-brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}

.advanced-brand img {
  display: block;
  width: min(100%, 300px);
  height: 54px;
  object-fit: contain;
  object-position: left center;
}

.advanced-site-nav {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: clamp(7px, 0.75vw, 14px);
}

.advanced-site-nav a {
  position: relative;
  padding: 8px 0;
  color: #c4cfdd;
  font-size: clamp(0.62rem, 0.69vw, 0.75rem);
  font-weight: 850;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.advanced-site-nav a:hover,
.advanced-site-nav a:focus-visible,
.advanced-site-nav a.active {
  color: #fff;
  outline: none;
}

.advanced-site-nav a.active::after {
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--cyan);
  content: "";
}

.advanced-site-nav a.live {
  padding: 9px 11px;
  border-radius: 6px;
  background: #ff572c;
  box-shadow: 0 0 20px rgba(255, 87, 44, 0.25);
  color: #fff;
}

.advanced-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-mode-switch {
  display: inline-grid;
  padding: 4px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.view-mode-switch a {
  min-width: 92px;
  padding: 8px 12px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.view-mode-switch a.is-active {
  background: var(--cyan);
  color: #04121b;
}

.advanced-menu-toggle {
  display: none;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0a1726;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 900;
  cursor: pointer;
}

.advanced-menu-toggle:hover,
.advanced-menu-toggle:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
  outline: none;
}

.advanced-stage {
  position: relative;
  height: calc(100vh - 76px);
}

.advanced-stage iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--page);
}

.frame-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--page);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  pointer-events: none;
}

.frame-loading span {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(103, 216, 231, 0.25);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: frame-spin 0.8s linear infinite;
}

.frame-loading[hidden] {
  display: none;
}

@keyframes frame-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .advanced-header {
    grid-template-columns: minmax(210px, 280px) minmax(0, 1fr) auto;
  }

  .advanced-site-nav {
    gap: 7px;
  }

  .advanced-site-nav a {
    font-size: 0.61rem;
  }

  .advanced-site-nav a:nth-last-child(-n + 4) {
    display: none;
  }
}

@media (max-width: 860px) {
  .advanced-header {
    min-height: 64px;
    padding: 8px 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .advanced-stage {
    height: calc(100vh - 64px);
  }

  .advanced-brand img {
    width: min(100%, 245px);
    height: 46px;
  }

  .view-mode-switch a {
    min-width: 64px;
    padding: 7px 9px;
  }

  .advanced-menu-toggle {
    display: inline-flex;
  }

  .advanced-site-nav {
    position: absolute;
    top: calc(100% + 1px);
    right: 10px;
    left: 10px;
    display: none;
    padding: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #071321;
    box-shadow: 0 18px 35px rgba(0, 0, 0, 0.5);
  }

  .advanced-header.is-menu-open .advanced-site-nav {
    display: grid;
  }

  .advanced-site-nav a,
  .advanced-site-nav a:nth-last-child(-n + 4) {
    display: flex;
    min-height: 38px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: #0a1726;
    font-size: 0.72rem;
  }

  .advanced-site-nav a.active::after {
    display: none;
  }

  .advanced-actions {
    gap: 6px;
  }
}

@media (max-width: 540px) {
  .advanced-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .advanced-brand img {
    width: 192px;
  }

  .view-mode-switch {
    position: absolute;
    top: 72px;
    right: 12px;
    z-index: 3;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  }

  .advanced-header.is-menu-open .view-mode-switch {
    display: none;
  }
}

@media (max-width: 390px) {
  .advanced-brand img {
    width: 172px;
  }
}
