/* Admin-only header layout. Shared player branding must not set admin geometry. */
body.newmagic > header:has(> .header-tools) {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) max-content;
  align-items: center;
  gap: 16px;
  height: 96px;
  min-height: 96px;
  max-height: none;
  padding: 4px 18px;
  overflow: visible;
}
body.newmagic > header:has(> .header-tools) > .brand {
  position: static;
  inset: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  min-width: 0;
  height: 88px;
  margin: 0;
  padding: 0;
  transform: none;
}
body.newmagic > header:has(> .header-tools) > .brand picture,
body.newmagic > header:has(> .header-tools) > .brand img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
body.newmagic > header:has(> .header-tools) > #nav {
  position: static;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  align-content: center;
  flex-wrap: nowrap;
  gap: 0;
  order: 0;
  width: auto;
  min-width: 0;
  height: 64px;
  margin: 0;
  padding: 0;
  transform: none;
  overflow: visible;
}
body.newmagic > header:has(> .header-tools) > #nav > details {
  position: relative;
  display: flex;
  align-items: center;
  height: 64px;
  flex-shrink: 0;
}
body.newmagic > header:has(> .header-tools) > #nav > button,
body.newmagic > header:has(> .header-tools) > #nav > details > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  min-height: 44px;
  padding: 0 11px;
  white-space: nowrap;
  line-height: 1.3;
}
body.newmagic > header:has(> .header-tools) > #nav details > div {
  top: 100%;
}
body.newmagic > header:has(> .header-tools) > .header-tools {
  position: static;
  inset: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: auto;
  margin: 0;
  gap: 8px;
  transform: none;
}
@media (min-width: 761px) {
  body.newmagic > header:has(> .header-tools) > .mobile-menu-toggle { display: none; }
  body.newmagic > .page-title { margin-top: 16px; }
}
@media (min-width: 761px) and (max-width: 1899px) {
  body.newmagic > header:has(> .header-tools) {
    grid-template-columns: 190px minmax(0, 1fr);
    grid-template-rows: 72px auto;
    height: auto;
    min-height: 120px;
    gap: 0 14px;
    padding: 4px 14px 8px;
  }
  body.newmagic > header:has(> .header-tools) > .brand {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 190px;
    height: 108px;
    align-self: center;
  }
  body.newmagic > header:has(> .header-tools) > .header-tools {
    grid-column: 2;
    grid-row: 1;
  }
  body.newmagic > header:has(> .header-tools) > #nav {
    grid-column: 2;
    grid-row: 2;
    height: auto;
    min-height: 44px;
    flex-wrap: wrap;
  }
  body.newmagic > header:has(> .header-tools) > #nav > details { height: 44px; }
  body.newmagic > header:has(> .header-tools) > #nav > button,
  body.newmagic > header:has(> .header-tools) > #nav > details > summary { padding: 0 9px; font-size: 12px; }
}
@media (max-width: 760px) {
  body.newmagic > header:has(> .header-tools) {
    position: fixed;
    grid-template-columns: 40px 140px minmax(0, 1fr);
    grid-template-rows: 76px;
    height: 76px;
    min-height: 76px;
    padding: 0 8px;
    gap: 4px;
  }
  body.newmagic > header:has(> .header-tools) > .mobile-menu-toggle {
    grid-column: 1;
    display: grid;
    place-items: center;
    width: 40px;
    height: 44px;
    margin: 0;
    padding: 0;
  }
  body.newmagic > header:has(> .header-tools) > .brand {
    grid-column: 2;
    width: 140px;
    height: 72px;
  }
  body.newmagic > header:has(> .header-tools) > .header-tools {
    grid-column: 3;
    gap: 4px;
    height: 64px;
  }
  body.newmagic > header:has(> .header-tools) .quota { min-width: 0; padding: 5px 8px; }
  body.newmagic > header:has(> .header-tools) .quota b { font-size: clamp(12px, 3.6vw, 14px); line-height: 20px; letter-spacing: 0; }
  /* Navigation retains the original mobile drawer and its open/close handlers. */
  body.newmagic > header:has(> .header-tools) > #nav {
    position: fixed;
    inset: 76px auto 0 0;
    display: block;
    width: 256px;
    max-width: 85vw;
    height: calc(100dvh - 76px);
    overflow-y: auto;
    padding: 10px 12px;
    transform: translateX(-105%);
  }
  body.newmagic.admin-menu-open > header:has(> .header-tools) > #nav { transform: translateX(0); }
  body.newmagic > header:has(> .header-tools) > #nav > details { display: block; height: auto; }
  body.newmagic > header:has(> .header-tools) > #nav > button,
  body.newmagic > header:has(> .header-tools) > #nav > details > summary { justify-content: flex-start; width: 100%; padding: 12px; }
  body.newmagic > header:has(> .header-tools) > #nav details > div { top: auto; }
  body.newmagic > .page-title { margin-top: 90px; }
}

/* One coherent purple-glass utility deck, scoped to the admin header. */
body.newmagic > header:has(> .header-tools) > .header-tools {
  padding: 7px 10px;
  gap: 10px;
  border: 1px solid #e2bc8380;
  border-radius: 17px;
  background: radial-gradient(ellipse at 30% 0, #e6b1ef26, transparent 60%), linear-gradient(145deg, #60266f99, #361443b3);
  box-shadow: inset 0 1px #ffe8f855, inset 0 -2px #200c3155, 0 3px 10px #2d123533;
}
body.newmagic > header:has(> .header-tools) .header-tools > label {
  align-items: center;
  gap: 6px;
  color: #ffefd6;
  font-size: 12px;
  font-weight: 600;
}
body.newmagic > header:has(> .header-tools) .header-tools select {
  box-sizing: border-box;
  min-height: 38px;
  height: 38px;
  min-width: 112px;
  padding: 0 9px;
  border: 1px solid #deb789;
  border-radius: 10px;
  background: linear-gradient(#91549f, #5a286f);
  box-shadow: inset 0 1px #ffe1f766, inset 0 -2px #34154144;
  color: #fff8ec;
  font: 600 12px/1.3 "Segoe UI", "Microsoft JhengHei", sans-serif;
}
body.newmagic > header:has(> .header-tools) .header-tools select option { background: #512363; color: #fff8ec; }
body.newmagic > header:has(> .header-tools) .header-tools .quota {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 208px;
  min-width: 178px;
  height: 54px;
  padding: 5px 16px;
  border: 1px solid #f5d39d;
  border-radius: 12px;
  background: radial-gradient(ellipse at 15% 0, #edb5eb55, transparent 75%), linear-gradient(120deg, #713184, #3d164e);
  box-shadow: inset 0 1px #fff3d877, inset 0 -2px #2a103f88;
  overflow: visible;
}
body.newmagic > header:has(> .header-tools) .header-tools .quota small {
  color: #eed7f0;
  font-size: 11px;
  font-weight: 600;
  line-height: 15px;
  letter-spacing: .06em;
}
body.newmagic > header:has(> .header-tools) .header-tools .quota b {
  display: block;
  color: #fff0b6;
  font-size: 23px;
  font-weight: 800;
  line-height: 28px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
  text-shadow: 0 2px 2px #2a0b3c88;
}
body.newmagic > header:has(> .header-tools) #account {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  max-width: 176px;
  padding: 5px 10px;
  border: 1px solid #ddb58599;
  border-radius: 24px;
  color: #fff2d7;
  background: linear-gradient(#9a60ab88, #532663bb);
  box-shadow: inset 0 1px #fff0e644;
}
body.newmagic > header:has(> .header-tools) #account[hidden] { display: none; }
body.newmagic > header:has(> .header-tools) #account .account-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin: 0;
  border: 1px solid #f2d197;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #d18bc6, #713785);
  color: #fff1c9;
  font-size: 19px;
}
body.newmagic > header:has(> .header-tools) #accountName { max-width: 118px; font-size: 12px; font-weight: 600; }
body.newmagic > header:has(> .header-tools) .admin-sound {
  flex-shrink: 0;
  border: 1px solid #e7c594;
  border-radius: 50%;
  color: #ffe8ad;
  background: linear-gradient(#a364b7, #613079);
  box-shadow: inset 0 1px #ffe9f777;
}
@media (max-width: 1100px) and (min-width: 761px) {
  body.newmagic > header:has(> .header-tools) { grid-template-rows: auto auto; }
  body.newmagic > header:has(> .header-tools) .header-tools { gap: 7px; flex-wrap: wrap; min-height: 58px; }
  body.newmagic > header:has(> .header-tools) .header-tools .quota { width: 188px; min-width: 164px; }
  body.newmagic > header:has(> .header-tools) .header-tools .quota b { font-size: 20px; }
}
@media (max-width: 760px) {
  body.newmagic > header:has(> .header-tools) > .header-tools {
    padding: 0;
    gap: 4px;
    border: 0;
    background: none;
    box-shadow: none;
  }
  body.newmagic > header:has(> .header-tools) .header-tools .quota {
    width: 126px;
    min-width: 0;
    height: 48px;
    padding: 4px 7px;
    border-radius: 10px;
  }
  body.newmagic > header:has(> .header-tools) .header-tools .quota small { font-size: 9px; line-height: 14px; letter-spacing: 0; }
  body.newmagic > header:has(> .header-tools) .header-tools .quota b { font-size: 14px; line-height: 20px; letter-spacing: 0; }
  body.newmagic > header:has(> .header-tools) #account { flex: 0 0 34px; width: 34px; min-height: 40px; padding: 0; border: 0; background: none; box-shadow: none; }
  body.newmagic > header:has(> .header-tools) #accountName { display: none; }
}
@media (max-width: 359px) {
  body.newmagic > header:has(> .header-tools) .header-tools .quota { display: none; }
}

/* Readable main navigation with an unmistakable active state. */
@media (min-width: 761px) {
  body.newmagic > header:has(> .header-tools) > #nav > button,
  body.newmagic > header:has(> .header-tools) > #nav > details > summary {
    font-family: "Segoe UI", "Microsoft JhengHei", sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #fffaf3;
    text-shadow: 0 1px 2px #35113e99;
    padding: 0 8px;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: 8px;
  }
  body.newmagic > header:has(> .header-tools) > #nav > button svg,
  body.newmagic > header:has(> .header-tools) > #nav > details > summary > svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: inherit;
  }
  body.newmagic > header:has(> .header-tools) > #nav > button.active,
  body.newmagic > header:has(> .header-tools) > #nav > button:hover,
  body.newmagic > header:has(> .header-tools) > #nav > details[open] > summary,
  body.newmagic > header:has(> .header-tools) > #nav > details > summary:hover {
    color: #fff1ae;
    background: linear-gradient(#c47bd7, #9349ac);
    border-color: #f4d698;
    box-shadow: inset 0 1px #ffeef777, 0 2px 5px #30103f44;
  }
}
@media (max-width: 760px) {
  body.newmagic #nav > button,
  body.newmagic #nav summary { font-size: 16px; font-weight: 700; }
}
