.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px) saturate(1.2);
  background: rgba(24, 24, 27, 0.72);
  border-bottom: 1px solid var(--line);
}

.header__inner {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.7rem 1.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 1.25rem;
  width: 100%;
  box-sizing: border-box;
}

.header__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
  justify-self: start;
}

.header__mark {
  width: 0.55rem;
  height: 1.2rem;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-glow) 100%);
  box-shadow: 0 0 12px rgba(204, 28, 57, 0.28);
}

.header__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.14em;
  line-height: 1;
}

.header__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 1.15rem;
  min-width: 0;
  flex: none;
}

.header__nav-mobile {
  display: none !important;
}

.header__nav a {
  position: relative;
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.header__nav a:hover,
.header__nav a.active {
  color: var(--text);
}

.header__nav a.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.55rem;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
}

.header__auth {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 2.15rem;
  padding: 0.35rem 0.95rem !important;
  border: 1px solid rgba(204, 28, 57, 0.55) !important;
  border-radius: 999px;
  background: transparent !important;
  color: #fff !important;
  font-family: var(--font-display) !important;
  font-weight: 700 !important;
  font-size: 0.84rem !important;
  letter-spacing: 0.05em;
  text-decoration: none !important;
  box-shadow: none !important;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease,
    color 0.2s ease;
}

.header__auth:hover {
  color: #fff !important;
  border-color: rgba(204, 28, 57, 0.85) !important;
  background: rgba(204, 28, 57, 0.12) !important;
  box-shadow: none !important;
  transform: translateY(-1px);
}

.header__auth:active {
  transform: translateY(0);
}

.header__user {
  display: inline-flex !important;
  align-items: center;
  gap: 0.4rem;
}

.header__user img {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  object-fit: cover;
}

.header__tools {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
  justify-self: end;
  margin-left: 0;
}

.header__tools-link {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.header__tools-link:hover,
.header__tools-link.active {
  color: var(--text);
}

.header__tools-name {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

/* Account hover menu */
.header__account {
  position: relative;
  z-index: 90;
}

.header__account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  padding: 0.2rem 0.15rem;
  border-radius: 999px;
}

.header__account-trigger img {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.12);
}

.header__account-fallback {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(145deg, #334155, #0f172a);
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 700;
}

.header__account-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid rgba(228, 228, 231, 0.55);
  margin-left: 0.05rem;
  transition: transform 0.2s ease;
}

.header__account.is-open .header__account-caret,
.header__account:hover .header__account-caret {
  transform: rotate(180deg);
}

.header__account-menu {
  position: absolute;
  top: 100%;
  right: 0;
  padding-top: 0.55rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.2s ease;
}

.header__account:hover .header__account-menu,
.header__account.is-open .header__account-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

.header__account-panel {
  min-width: 11.5rem;
  padding: 0.4rem;
  display: grid;
  gap: 0.1rem;
  border-radius: 4px 12px 12px 12px;
  background:
    linear-gradient(165deg, rgba(44, 44, 48, 0.98), rgba(24, 24, 27, 0.98));
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
}

.header__account-sep {
  height: 1px;
  margin: 0.3rem 0.45rem;
  background: var(--line);
}

.account-chip {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 0;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: transparent;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.account-chip:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.account-chip--logout {
  color: rgba(255, 255, 255, 0.72);
}

.account-chip--logout:hover {
  color: #fecdd3;
  background: rgba(204, 28, 57, 0.12);
}


.notif-bell {
  position: relative;
}

.notif-bell__btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.notif-bell.is-open .notif-bell__btn,
.notif-bell__btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.notif-bell__badge {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.05rem;
  text-align: center;
}

.notif-bell__drop {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 80;
  width: 22rem;
  max-width: min(22rem, calc(100vw - 1.5rem));
  max-height: min(70vh, 26rem);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #141416;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.notif-bell__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.notif-bell__head strong {
  font-size: 0.9rem;
}

.notif-bell__read-all {
  border: 0;
  background: transparent;
  color: var(--rose-strong);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
}

.notif-bell__read-all:disabled {
  opacity: 0.4;
  cursor: default;
}

.notif-bell__list {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  overflow: auto;
}

.notif-bell__item {
  width: 100%;
  display: grid;
  gap: 0.2rem;
  text-align: left;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0.65rem 0.7rem;
  cursor: pointer;
}

.notif-bell__item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.notif-bell__item.is-unread {
  background: rgba(204, 28, 57, 0.1);
}

.notif-bell__title {
  font-size: 0.86rem;
  font-weight: 600;
}

.notif-bell__body {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notif-bell__item time {
  color: var(--muted);
  font-size: 0.72rem;
}

.notif-bell__empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem 0.85rem;
}

.header__burger {
  display: none;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  gap: 0.4rem;
}

.header__burger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.header__burger.is-open span:first-child {
  transform: translateY(5px) rotate(45deg);
}

.header__burger.is-open span:last-child {
  transform: translateY(-5px) rotate(-45deg);
}

@media (max-width: 980px) {
  .header__tools-name {
    display: none;
  }

  .header__tools {
    gap: 0.75rem;
  }
}

@media (max-width: 720px) {
  .header__burger {
    display: flex;
  }

  .header__inner {
    display: flex;
    gap: 0.85rem;
    padding: 0.85rem 1.1rem;
    padding-top: max(0.85rem, env(safe-area-inset-top, 0px));
    min-height: 3.6rem;
  }

  .header__mark {
    width: 0.65rem;
    height: 1.4rem;
  }

  .header__name {
    font-size: 1.2rem;
    letter-spacing: 0.12em;
  }

  .header__account-trigger {
    min-height: 2.75rem;
    padding: 0.25rem 0.15rem;
  }

  .header__account-trigger img,
  .header__account-fallback {
    width: 34px;
    height: 34px;
  }

  .header__account-fallback {
    font-size: 0.85rem;
  }

  .header__account-caret {
    border-left-width: 4.5px;
    border-right-width: 4.5px;
    border-top-width: 5px;
  }

  .notif-bell__btn {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 12px;
  }

  .notif-bell__btn svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  .header__burger {
    width: 2.75rem;
    height: 2.75rem;
  }

  .header__burger span {
    width: 1.35rem;
  }

  .header__burger.is-open span:first-child {
    transform: translateY(0.4rem) rotate(45deg);
  }

  .header__burger.is-open span:last-child {
    transform: translateY(-0.4rem) rotate(-45deg);
  }

  .header__nav {
    position: absolute;
    inset: 100% 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    flex: none;
    width: 100%;
    padding: 0.35rem 1.15rem 1.15rem;
    background: rgba(18, 18, 20, 0.98);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .header__nav.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .header__nav a {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 1.05rem 0.15rem;
    min-height: 3.15rem;
    border-bottom: 1px solid var(--line);
  }

  .header__nav a:last-child {
    border-bottom: 0;
  }

  .header__nav a.active::after {
    display: none;
  }

  .header__nav a.active {
    color: var(--text);
  }

  .header__tools {
    margin-left: auto;
    gap: 0.55rem;
  }

  .header__auth {
    min-height: 2.55rem;
    font-size: 0.88rem !important;
    padding: 0.45rem 1.05rem !important;
  }

  /* Full-bleed under header so the panel does not clip off-screen */
  .notif-bell__drop {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 4.15rem);
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    max-width: none;
    z-index: 120;
  }
}
