.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: env(safe-area-inset-top, 0) 18px 0;
  padding-left: calc(18px + env(safe-area-inset-left, 0));
  padding-right: calc(18px + env(safe-area-inset-right, 0));
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.76), rgba(0, 18, 18, 0.56) 52%, rgba(0, 0, 0, 0.72)),
    url('/assets/metal-header.png') center center / cover no-repeat,
    rgba(0, 0, 0, 0.72);
  border-bottom: 1px solid rgba(57, 255, 20, 0.10);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.04), 0 10px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.topbar-icon-button {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  box-sizing: border-box;
}

.topbar-icon-button:hover,
.topbar-icon-button:focus-visible {
  outline: none;
  background: var(--panel-soft);
}

.hamburger-button {
  flex-direction: column;
  gap: 5px;
  flex: 0 0 52px;
}

.hamburger-button img {
  width: 41px;
  height: 41px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}


.topbar-back-button {
  width: 43px;
  height: 43px;
  padding: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.topbar-back-button[hidden] {
  display: none;
}

.topbar-back-button img {
  width: 41px;
  height: 41px;
  object-fit: contain;
  display: block;
}

.topbar-back-button:hover,
.topbar-back-button:focus-visible {
  outline: none;
  opacity: 0.86;
}

.topbar-home-button {
  width: 43px;
  height: 43px;
  padding: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.topbar-home-button img {
  width: 41px;
  height: 41px;
  object-fit: contain;
  display: block;
}

.topbar-home-button:hover,
.topbar-home-button:focus-visible {
  outline: none;
  opacity: 0.86;
}


.topbar-search-button,
.topbar-sync-dojo-button {
  width: 43px;
  height: 43px;
  padding: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.topbar-search-button img,
.topbar-sync-dojo-button img {
  width: 41px;
  height: 41px;
  object-fit: contain;
  display: block;
}

.topbar-search-button:hover,
.topbar-search-button:focus-visible,
.topbar-sync-dojo-button:hover,
.topbar-sync-dojo-button:focus-visible {
  outline: none;
  opacity: 0.86;
}

.topbar-sync-dojo-button img {
  filter: drop-shadow(0 0 8px rgba(57,255,20,.12));
}

.topbar-search-wrap {
  flex: 1 1 420px;
  max-width: 720px;
  min-width: 220px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 14px;
  border: 1px solid rgba(57, 255, 20, 0.34);
  background: rgba(0, 0, 0, 0.42);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.topbar-search-wrap[hidden] {
  display: none;
}

.topbar-search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 21px;
  line-height: 1;
}

.topbar-search-input::placeholder {
  color: rgba(235, 255, 238, 0.46);
}

.topbar-search-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 30px;
  line-height: 30px;
  cursor: pointer;
}

.topbar-search-close:hover,
.topbar-search-close:focus-visible {
  outline: none;
  color: #D946EF;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  opacity: 0.96;
}

.brand-title {
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-subtitle {
  display: none;
}

.top-spacer { flex: 1; }

.mode-pill {
  min-width: 74px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.top-bar[data-device="phone"] {
  gap: 3px;
  padding-left: calc(6px + env(safe-area-inset-left, 0));
  padding-right: calc(6px + env(safe-area-inset-right, 0));
}

.top-bar[data-device="phone"] .brand-logo {
  width: 41px;
  height: 41px;
}

.top-bar[data-device="phone"] .brand-title {
  font-size: 18px;
}

.top-bar[data-device="phone"] .brand-text {
  display: none;
}

.top-bar[data-device="phone"] .brand-block {
  gap: 0;
}

.top-bar[data-device="phone"] .brand-subtitle {
  display: none;
}

.top-bar[data-device="phone"] .mode-pill {
  min-width: 62px;
  padding: 7px 9px;
}

.top-bar[data-device="phone"] .topbar-search-button,
.top-bar[data-device="phone"] .topbar-home-button,
.top-bar[data-device="phone"] .topbar-back-button {
  width: 41px;
  height: 41px;
}

.top-bar[data-device="phone"] .topbar-search-button img,
.top-bar[data-device="phone"] .topbar-home-button img,
.top-bar[data-device="phone"] .topbar-back-button img {
  width: 31px;
  height: 31px;
}

.top-bar[data-device="phone"].is-searching .brand-text,
.top-bar[data-device="phone"].is-searching .top-spacer,
.top-bar[data-device="phone"].is-searching .mode-pill {
  display: none;
}

.top-bar[data-device="phone"] .topbar-search-wrap {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding-left: 10px;
}

.top-bar[data-device="phone"] .topbar-search-input {
  font-size: 20px;
}

.top-bar[data-device="phone"] .topbar-search-close {
  width: 36px;
  height: 36px;
}

.top-bar[data-device="phone"] .topbar-search-close img {
  width: 31px;
  height: 31px;
}

.top-bar[data-device="tv"] .topbar-icon-button {
  width: 56px;
  height: 56px;
}

.top-bar[data-device="tv"] .brand-logo {
  width: 42px;
  height: 42px;
}

.topbar-search-input::-webkit-search-decoration,
.topbar-search-input::-webkit-search-cancel-button,
.topbar-search-input::-webkit-search-results-button,
.topbar-search-input::-webkit-search-results-decoration {
  display: none;
}

.topbar-search-input[type="search"]::-ms-clear,
.topbar-search-input[type="search"]::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}

/* v0.0.171 — whole hamburger icon hitbox */

/* v0.0.184: actually smaller search close icon */
.topbar-search-close {
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.topbar-search-close img {
  width: 18px;
  height: 18px;
}
.top-bar[data-device="phone"] .topbar-search-close {
  width: 32px;
  height: 32px;
  min-width: 32px;
}
.top-bar[data-device="phone"] .topbar-search-close img {
  width: 18px;
  height: 18px;
}

/* v0.0.294 — header avatar opens User Area */
.mode-pill.topbar-user-avatar-button {
  width: 48px;
  min-width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  font-weight: 700;
}

.mode-pill.topbar-user-avatar-button.has-avatar {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

.mode-pill.topbar-user-avatar-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mode-pill.topbar-user-avatar-button span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.mode-pill.topbar-user-avatar-button:hover,
.mode-pill.topbar-user-avatar-button:focus-visible {
  outline: none;
  border-color: rgba(255, 204, 0, 0.72);
  box-shadow: 0 0 0 3px rgba(255, 204, 0, 0.14);
}

.top-bar[data-device="phone"] .mode-pill.topbar-user-avatar-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
}

.top-bar[data-device="phone"].is-searching .mode-pill.topbar-user-avatar-button {
  display: none;
}

.top-bar[data-device="tv"] .mode-pill.topbar-user-avatar-button {
  width: 56px;
  min-width: 56px;
  height: 56px;
}

/* v0.0.440: desktop keeps full Ninja Media wordmark; phone swaps to compact app icon. */
.brand-logo-picture {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.brand-logo {
  width: clamp(106px, 11.7vw, 160px);
  height: 36px;
  object-fit: contain;
  object-position: left center;
}

.top-bar[data-device="phone"] .brand-logo-picture {
  width: 40px;
  height: 40px;
}

.top-bar[data-device="phone"] .brand-logo {
  width: 40px;
  height: 40px;
}

.top-bar[data-device="tv"] .brand-logo {
  width: 171px;
  height: 40px;
}


/* v0.0.441: phone header is icon-only; section name moves below the header. */
.phone-section-title {
  display: none;
}

body.shell-device-phone .phone-section-title {
  position: fixed;
  left: calc(18px + env(safe-area-inset-left, 0));
  top: calc(var(--topbar-height) + 9px);
  z-index: 24;
  display: block;
  max-width: calc(100vw - 36px - env(safe-area-inset-left, 0) - env(safe-area-inset-right, 0));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(244, 255, 244, 0.94);
  font-size: 22px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.2px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72);
  pointer-events: none;
}

body.shell-device-phone .main-content {
  padding-top: calc(var(--topbar-height) + 56px);
}

/* v0.0.563 — header size chooser beside search */
.topbar-size-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.topbar-size-button {
  width: 43px;
  height: 43px;
  padding: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.topbar-size-button img {
  width: 41px;
  height: 41px;
  object-fit: contain;
  display: block;
}

.topbar-size-button:hover,
.topbar-size-button:focus-visible {
  outline: none;
  opacity: 0.86;
}

.topbar-size-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 80;
  min-width: 144px;
  padding: 8px;
  border: 1px solid rgba(57, 255, 20, 0.28);
  border-radius: 14px;
  background: rgba(4, 13, 18, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px);
}

.topbar-size-menu[hidden] {
  display: none;
}

.topbar-size-menu button {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(244, 255, 244, 0.88);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.topbar-size-menu button:hover,
.topbar-size-menu button:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
}

.topbar-size-menu button.is-active {
  background: rgba(57, 255, 20, 0.16);
  color: #39ff14;
}

.top-bar[data-device="phone"] .topbar-size-wrap {
  display: none;
}

.top-bar[data-device="tv"] .topbar-size-button {
  width: 56px;
  height: 56px;
}

.top-bar[data-device="tv"] .topbar-size-button img {
  width: 50px;
  height: 50px;
}

/* v0.0.564 — Size menu applies to Web/TV header controls without touching phone. */
body:not(.shell-device-phone) .topbar-search-button,
body:not(.shell-device-phone) .topbar-sync-dojo-button,
body:not(.shell-device-phone) .topbar-home-button,
body:not(.shell-device-phone) .topbar-back-button,
body:not(.shell-device-phone) .topbar-size-button {
  width: var(--ninja-topbar-control-size, 43px);
  height: var(--ninja-topbar-control-size, 43px);
}

body:not(.shell-device-phone) .topbar-search-button img,
body:not(.shell-device-phone) .topbar-sync-dojo-button img,
body:not(.shell-device-phone) .topbar-home-button img,
body:not(.shell-device-phone) .topbar-back-button img,
body:not(.shell-device-phone) .topbar-size-button img {
  width: var(--ninja-topbar-control-img, 41px);
  height: var(--ninja-topbar-control-img, 41px);
}

body:not(.shell-device-phone) .mode-pill.topbar-user-avatar-button {
  width: var(--ninja-topbar-avatar-size, 48px);
  min-width: var(--ninja-topbar-avatar-size, 48px);
  height: var(--ninja-topbar-avatar-size, 48px);
}

body:not(.shell-device-phone) .topbar-size-menu button {
  min-height: var(--ninja-size-menu-button-height, 36px);
  font-size: var(--ninja-size-menu-font, 13px);
}

/* v0.0.564 — valid fixed tokens for Size menu choices. */
body:not(.shell-device-phone) .topbar-size-menu button {
  min-height: var(--ninja-size-menu-button-height, 36px);
  font-size: var(--ninja-size-menu-font, 13px);
}
