.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

html.auth-pending body {
  visibility: hidden;
}

html.session-header-pending #auth-header-mount {
  visibility: hidden;
}

.auth-offline-notice {
  margin: 0;
  padding: 10px 16px;
  border-bottom: 1px solid color-mix(in srgb, #f59e0b 35%, var(--border));
  background: color-mix(in srgb, #fef3c7 75%, var(--card));
  color: var(--foreground);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: none;
  padding: 12px 20px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  object-fit: contain;
  box-shadow: none;
}

.brand-copy-block {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-weight: 800;
  color: var(--foreground);
  font-size: 16px;
  letter-spacing: 0;
}

.brand-tagline {
  font-size: 11px;
  color: var(--muted-text);
  margin-top: 2px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  color: var(--muted-text);
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.nav-btn:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
}

.nav-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 10px 35px rgba(99, 102, 241, 0.25);
}

.nav-btn.is-active:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.nav-btn.is-outline {
  background: rgba(255,255,255,0.75);
  color: var(--primary);
  border-color: rgba(99,102,241,0.3);
}

.nav-btn.is-outline:hover {
  background: #fff;
  border-color: var(--primary);
}

.nav-btn svg {
  width: 16px;
  height: 16px;
}

.nav-btn span {
  white-space: nowrap;
}

.divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 8px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted-text);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.mobile-header-actions {
  display: none;
}

.mobile-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  font-size: 18px;
}

.mobile-nav-toggle svg {
  width: 19px;
  height: 19px;
}

.auth-header {
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
}

.auth-header .auth-header-inner {
  max-width: none;
  padding-right: 20px;
  padding-left: 20px;
}

.auth-header .auth-nav-link > svg,
.auth-header .auth-menu-trigger > svg,
.auth-header .auth-menu-panel a > svg,
.auth-header .user-panel a > svg,
.auth-header .header-icon > svg,
.auth-header .mobile-auth-nav a > svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.auth-header .auth-menu-trigger > svg:last-child {
  width: 14px;
  height: 14px;
}

.auth-header {
  position: sticky;
  top: 0;
  z-index: 60;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
}

.auth-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  gap: 16px;
}

.auth-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  color: var(--foreground);
}

.auth-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: contain;
}

.auth-brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.15;
}

.auth-brand-copy strong {
  color: var(--foreground);
  font-size: 16px;
  font-weight: 800;
}

.auth-brand-copy small {
  margin-top: 3px;
  color: var(--muted-text);
  font-size: 10px;
}

.auth-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.auth-nav-link,
.auth-menu-trigger,
.header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.auth-nav-link:hover,
.auth-menu-trigger:hover,
.header-icon:hover,
.auth-nav-link.is-active {
  background: rgba(99, 102, 241, .1);
  color: var(--primary);
}

.auth-menu,
.user-menu,
.notification-menu {
  position: relative;
}

.notification-trigger {
  position: relative;
}

.notification-count {
  position: absolute;
  top: 1px;
  right: 1px;
  display: grid;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  place-items: center;
  border: 2px solid var(--card);
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.notification-panel {
  position: absolute;
  top: 43px;
  right: 0;
  z-index: 80;
  width: min(360px, calc(100vw - 24px));
  max-height: min(480px, calc(100vh - 90px));
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  color: var(--foreground);
}

.notification-panel[hidden] {
  display: none;
}

.notification-panel-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.notification-panel-heading strong {
  font-size: 14px;
}

.notification-panel-heading button,
.notification-mark-read,
.notification-retry {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
}

.notification-item {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.notification-item:last-child {
  border-bottom: 0;
}

.notification-item.is-unread {
  background: color-mix(in srgb, var(--primary) 6%, var(--card));
}

.notification-item-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.notification-unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
}

.notification-item p {
  margin: 7px 0;
  color: var(--foreground);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.notification-item time {
  display: block;
  margin-bottom: 8px;
  color: var(--muted-text);
  font-size: 10px;
}

.notification-state,
.notification-retry {
  margin: 0;
  padding: 18px 16px;
  color: var(--muted-text);
  font-size: 12px;
  line-height: 1.5;
}

.notification-retry {
  padding-top: 0;
}

.announcement-color-red { color: #dc2626; }
.announcement-color-blue { color: #2563eb; }
.announcement-color-green { color: #16a34a; }
.announcement-color-yellow { color: #ca8a04; }
.announcement-color-purple { color: #9333ea; }
.announcement-color-orange { color: #ea580c; }
.announcement-color-pink { color: #db2777; }

.auth-menu-panel,
.user-panel {
  position: absolute;
  top: 43px;
  left: 0;
  z-index: 70;
  display: none;
  width: 220px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow-card);
}

.auth-menu.is-open .auth-menu-panel,
.user-menu.is-open .user-panel {
  display: block;
}

.auth-menu-panel a,
.user-panel a,
.auth-feature-coming-soon {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border-radius: 7px;
  color: var(--foreground);
  font-size: 12px;
  text-decoration: none;
}

.auth-feature-coming-soon {
  color: var(--muted-text);
  cursor: not-allowed;
  opacity: .58;
  pointer-events: none;
  user-select: none;
}

.auth-feature-coming-soon small {
  margin-left: auto;
  color: var(--muted-text);
  font-size: 9px;
}

.auth-feature-coming-soon svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.auth-menu-panel a:hover,
.user-panel a:hover {
  background: var(--muted);
  color: var(--primary);
}

.auth-menu-panel small {
  margin-left: auto;
  color: var(--muted-text);
  font-size: 9px;
}

.auth-divider {
  width: 1px;
  height: 24px;
  margin: 0 8px;
  background: var(--border);
}

.avatar-button {
  position: relative;
  width: 38px;
  height: 38px;
  padding: 2px;
  border: 2px solid rgba(99, 102, 241, .3);
  border-radius: 50%;
  background: var(--card);
  cursor: pointer;
}

.avatar-image-wrap {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.avatar-image-wrap > img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-frame-overlay {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: none;
  width: 155%;
  height: 155%;
  overflow: hidden;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
}

.avatar-frame-overlay.is-visible { display: block; }

.avatar-frame-overlay img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  image-rendering: pixelated;
}

.avatar-dot {
  position: absolute;
  z-index: 3;
  right: -1px;
  bottom: 1px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: #22c55e;
}

.user-panel {
  right: 0;
  left: auto;
  width: 250px;
}

.user-panel-section-title {
  margin: 4px 8px 3px;
  color: var(--muted-text);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.4;
  text-transform: uppercase;
}

.user-panel strong,
.user-panel small {
  display: block;
  overflow: hidden;
  padding: 3px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-panel strong {
  color: var(--foreground);
  font-size: 12px;
}

.user-panel small {
  color: var(--muted-text);
  font-size: 10px;
}

.user-panel hr {
  margin: 6px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.user-panel .logout-link {
  color: #dc2626;
}

.mobile-auth-actions,
.mobile-auth-nav {
  display: none;
}

.theme-toggle:hover {
  background: rgba(99, 102, 241, 0.06);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.08);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: page-transition-out 160ms ease-in both;
}

::view-transition-new(root) {
  animation: page-transition-in 240ms cubic-bezier(.2, .75, .25, 1) both;
}

.page-entered {
  animation: page-enter 260ms cubic-bezier(.2, .75, .25, 1) both;
}

@keyframes page-transition-out {
  to { opacity: 0; transform: translateY(-4px); }
}

@keyframes page-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes page-transition-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root),
  .page-entered {
    animation: none !important;
  }
}

@media (max-width: 640px) {
  .brand-copy-block {
    display: flex;
  }

  .brand-name {
    font-size: 14px;
  }

  .brand-tagline {
    font-size: 9px;
  }
}

@media (max-width: 767px) {
  .site-header .header-inner {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 14px;
  }

  .mobile-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
  }

  .mobile-theme-toggle {
    display: inline-flex;
  }

  .site-header .main-nav {
    display: none;
    flex: 0 0 100%;
    order: 3;
    align-items: stretch;
    flex-direction: column;
    gap: 3px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }

  .site-header.is-mobile-open .main-nav {
    display: flex;
  }

  .site-header .main-nav .nav-btn {
    justify-content: flex-start;
    width: 100%;
  }

  .site-header .main-nav .divider {
    width: 100%;
    height: 1px;
    margin: 5px 0;
  }

  .site-header .main-nav .theme-toggle {
    display: none;
  }
}

@media (max-width: 1024px) {
  .auth-header .auth-header-inner {
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .auth-header .auth-brand-copy {
    display: flex;
  }

  .auth-header .auth-nav {
    display: none;
  }

  .auth-header .mobile-auth-actions {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
  }

  .auth-header .mobile-auth-nav {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--card);
  }

  .auth-header .mobile-auth-nav.is-open {
    display: grid;
  }

  .auth-header .mobile-auth-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 10px;
    border-radius: 7px;
    color: var(--foreground);
    font-size: 12px;
    text-decoration: none;
  }

  .auth-header .mobile-auth-nav a:hover {
    background: var(--muted);
    color: var(--primary);
  }
}

@media (max-width: 360px) {
  .site-header .brand-tagline {
    display: none;
  }
}

.mobile-avatar-link {
  position: relative;
  display: none;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  padding: 2px;
  border: 2px solid rgba(99, 102, 241, .3);
  border-radius: 50%;
  background: var(--card);
}

.mobile-avatar-link .avatar-image-wrap,
.mobile-avatar-link .avatar-image-wrap > img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.mobile-avatar-link .avatar-frame-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  width: 155%;
  height: 155%;
  overflow: hidden;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
}

.mobile-avatar-link .avatar-frame-overlay img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  image-rendering: pixelated;
}

.mobile-auth-group-trigger {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 9px;
  padding: 11px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.mobile-auth-group-trigger > svg:last-child {
  width: 15px;
  height: 15px;
  margin-left: auto;
  transition: transform .18s ease;
}

.mobile-auth-group-trigger[aria-expanded="true"] > svg:last-child {
  transform: rotate(180deg);
}

.mobile-auth-group-trigger:hover,
.mobile-auth-group-trigger[aria-expanded="true"] {
  background: var(--muted);
  color: var(--primary);
}

.mobile-auth-submenu {
  display: grid;
  gap: 2px;
  padding: 2px 0 6px 18px;
}

.mobile-auth-submenu[hidden] {
  display: none;
}

@media (max-width: 1024px) {
  .auth-header .auth-header-inner {
    flex-wrap: nowrap;
  }

  .auth-header .auth-brand {
    flex: 1 1 auto;
    overflow: hidden;
  }

  .auth-header .mobile-auth-actions {
    flex: 0 0 auto;
  }

  .auth-header .mobile-avatar-link {
    display: inline-flex;
  }

  .auth-header .mobile-auth-nav.is-open {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: min(70vh, 520px);
    overflow-y: auto;
  }

  .auth-header .mobile-auth-nav > a,
  .auth-header .mobile-auth-submenu > a {
    min-height: 40px;
  }

  .auth-header .mobile-auth-group-trigger > svg:first-child {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-auth-group-trigger > svg:last-child {
    transition: none;
  }
}

@media (max-width: 360px) {
  .auth-header .auth-logo {
    width: 34px;
    height: 34px;
  }

  .auth-header .mobile-auth-actions {
    gap: 3px;
  }

  .auth-header .mobile-auth-actions .header-icon {
    width: 34px;
    height: 34px;
  }

  .auth-header .mobile-avatar-link {
    width: 34px;
    height: 34px;
  }
}

@media (max-width: 420px) {
  .auth-header .auth-header-inner {
    gap: 8px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .auth-header .auth-brand {
    gap: 6px;
  }

  .auth-header .auth-logo {
    width: 32px;
    height: 32px;
  }

  .auth-header .auth-brand-copy {
    overflow: hidden;
  }

  .auth-header .auth-brand-copy strong {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .auth-header .auth-brand-copy small {
    display: none;
  }

  .auth-header .mobile-auth-actions {
    gap: 4px;
  }

  .auth-header .mobile-auth-actions .header-icon,
  .auth-header .mobile-avatar-link {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
  }
}
