.header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 58px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(251, 251, 253, 0.72);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
}

body.theme-dark .header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
  background: rgba(18, 18, 20, 0.72);
}

.header-inner {
  max-width: 1320px;
  height: 100%;
  margin: 0 auto;
  padding: 0 28px;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 22px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main, var(--text, #1d1d1f));
  font-size: 18px;
  font-weight: 780;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.logo-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.72), transparent 16%),
    linear-gradient(145deg, #0a84ff 0%, #5e5ce6 52%, #1d1d1f 100%);
  box-shadow: 0 10px 24px rgba(0, 113, 227, 0.24);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -0.7px;
}

.nav {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
}

body.theme-dark .nav {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
}

.nav a {
  min-width: 76px;
  padding: 7px 14px;
  border-radius: 999px;
  color: #3a3a3c;
  font-size: 13px;
  font-weight: 560;
  line-height: 1.5;
  text-align: center;
  transition:
    color 0.2s ease,
    background 0.2s ease,
    transform 0.2s ease;
}

body.theme-dark .nav a {
  color: rgba(255, 255, 255, 0.74);
}

.nav a:hover {
  color: #000;
  background: rgba(255, 255, 255, 0.72);
}

body.theme-dark .nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.nav a.active {
  color: #fff;
  background: #1d1d1f;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

body.theme-dark .nav a.active {
  color: #111114;
  background: #fff;
  box-shadow: 0 8px 20px rgba(255, 255, 255, 0.1);
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

.search {
  width: 260px;
  height: 36px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  color: var(--text-soft, var(--muted2, #86868b));
  box-shadow: none;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

body.theme-dark .search {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
}

.search:focus-within {
  background: #fff;
  border-color: rgba(0, 113, 227, 0.34);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.08);
}

body.theme-dark .search:focus-within {
  background: rgba(255, 255, 255, 0.1);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-main, var(--text, #1d1d1f));
  font-size: 13px;
}

.search input::placeholder {
  color: var(--text-soft, var(--muted2, #86868b));
}

.search span {
  font-size: 15px;
  line-height: 1;
  color: var(--text-soft, var(--muted2, #86868b));
}

.theme-toggle,
.profile-trigger {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.62);
  color: #1d1d1f;
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    color 0.18s ease;
}

.theme-toggle:hover,
.profile-trigger:hover,
.profile-menu.open .profile-trigger {
  transform: translateY(-1px);
  background: #fff;
  border-color: rgba(0, 113, 227, 0.18);
  box-shadow: 0 12px 26px rgba(0, 113, 227, 0.2);
}

body.theme-dark .theme-toggle,
body.theme-dark .profile-trigger {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

body.theme-dark .theme-toggle:hover,
body.theme-dark .profile-trigger:hover,
body.theme-dark .profile-menu.open .profile-trigger {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

.profile-center-link {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main, var(--text, #1d1d1f));
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.05);
  font-size: 16px;
  font-weight: 760;
  white-space: nowrap;
}

.profile-center-link:hover,
.profile-center-link.active {
  background: #fff;
  border-color: rgba(0, 113, 227, 0.18);
  box-shadow: 0 14px 28px rgba(0, 113, 227, 0.12);
  transform: translateY(-1px);
}

body.theme-dark .profile-center-link {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

body.theme-dark .profile-center-link:hover,
body.theme-dark .profile-center-link.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

.profile-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.profile-menu::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  width: min(260px, calc(100vw - 24px));
  height: 14px;
}

.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.78), transparent 18%),
    linear-gradient(145deg, #d7e9ff 0%, #0a84ff 52%, #1d1d1f 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.profile-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(260px, calc(100vw - 24px));
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  z-index: 80;
}

body.theme-dark .profile-panel {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(28, 28, 30, 0.92);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
}

.profile-menu.open .profile-panel,
.profile-menu:hover .profile-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.profile-panel-head {
  padding: 9px 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

body.theme-dark .profile-panel-head {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.profile-panel-head strong {
  display: block;
  color: var(--text-main, var(--text, #1d1d1f));
  font-size: 15px;
  line-height: 1.25;
}

.profile-panel-head span,
.profile-panel-head em {
  display: block;
  margin-top: 3px;
  color: var(--text-soft, var(--muted2, #86868b));
  font-size: 12px;
  line-height: 1.35;
  font-style: normal;
}

.profile-menu-list {
  display: grid;
  gap: 4px;
  padding-top: 8px;
}

.profile-menu-list a,
.profile-menu-button {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  color: var(--text-main, var(--text, #1d1d1f));
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.profile-menu-list a:hover,
.profile-menu-button:hover {
  background: rgba(0, 113, 227, 0.1);
  color: var(--blue, #0071e3);
}

body.theme-dark .profile-menu-list a:hover,
body.theme-dark .profile-menu-button:hover {
  background: rgba(10, 132, 255, 0.16);
  color: #8ec5ff;
}

@media (max-width: 1060px) {
  .nav a {
    min-width: auto;
    padding: 7px 13px;
  }

  .search {
    width: 210px;
  }
}

@media (max-width: 900px) {
  .header {
    height: auto;
    overflow: visible;
  }

  .header-inner {
    min-height: 58px;
    padding: 9px 16px;
    grid-template-columns: auto 1fr;
    gap: 12px;
  }

  .nav {
    display: none;
  }

  .header-actions {
    width: 100%;
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .search {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .header {
    height: auto;
    overflow: visible;
  }

  .header-inner {
    height: auto;
    min-height: 0;
    padding: 6px 12px 8px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 8px;
    align-items: center;
  }

  .logo span {
    display: inline-block;
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    grid-column: 2;
    order: 2;
    width: auto;
    justify-self: end;
    gap: 8px;
  }

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

  .profile-center-link {
    min-height: 40px;
    padding: 0 14px;
    font-size: 15px;
  }

  .theme-toggle,
  .profile-trigger {
    width: 40px;
    height: 40px;
  }

  .profile-menu::after {
    display: none;
  }

  .profile-menu:hover .profile-panel {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(0.98);
  }

  .profile-menu.open .profile-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  .nav {
    grid-column: 1 / -1;
    order: 3;
    width: 100%;
    justify-self: stretch;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 4px;
  }

  .nav a {
    min-width: 0;
    padding: 8px 4px;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
  }
}

@media (max-width: 380px) {
  .logo span {
    max-width: 150px;
  }

  .profile-center-link {
    display: none;
  }

  .nav a {
    font-size: 12px;
    padding: 8px 2px;
  }
}

body.auth-modal-open {
  overflow: hidden;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.auth-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 22% 18%, rgba(38, 126, 255, 0.18), transparent 34%),
    radial-gradient(circle at 78% 28%, rgba(164, 205, 255, 0.32), transparent 36%),
    rgba(245, 249, 255, 0.68);
  backdrop-filter: blur(16px);
}

.auth-dialog {
  position: relative;
  width: min(460px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  overflow: auto;
  border: 1px solid rgba(215, 225, 238, 0.9);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 30px 90px rgba(23, 39, 65, 0.18);
  padding: 30px;
  transform: translateY(10px) scale(0.98);
  transition: transform 180ms ease;
}

.auth-modal.open .auth-dialog {
  transform: translateY(0) scale(1);
}

.auth-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: #f4f6f9;
  color: #9aa4b2;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.auth-modal-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 8px 42px 28px 0;
}

.auth-modal-tabs button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #a0a6b1;
  font-weight: 800;
  font-size: 19px;
  padding: 10px 8px;
  cursor: pointer;
}

.auth-modal-tabs button.active {
  background: #18191d;
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.auth-modal-panel h2 {
  margin: 0 0 18px;
  color: #18191d;
  font-size: 24px;
  line-height: 1.2;
}

.auth-modal-note {
  margin: 0 0 18px;
  color: #677282;
  line-height: 1.7;
}

.auth-modal-form {
  display: grid;
  gap: 14px;
}

.auth-modal-form label {
  display: grid;
  gap: 8px;
  color: #657184;
  font-size: 13px;
  font-weight: 700;
}

.auth-modal-form input,
.auth-modal-challenge input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #f4f5f7;
  color: #1e293b;
  font: inherit;
  padding: 14px 18px;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.auth-modal-form input:focus,
.auth-modal-challenge input:focus {
  border-color: #7ab6ff;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 128, 255, 0.12);
}

.auth-modal-helper {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  margin-top: -2px;
  font-size: 13px;
}

.auth-modal-helper a,
.auth-modal-helper button {
  border: 0;
  background: transparent;
  color: #4f5d70;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.auth-modal-submit,
.auth-modal-captcha {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  background: #1579e8;
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(21, 121, 232, 0.22);
}

.auth-modal-submit:disabled {
  cursor: wait;
  opacity: 0.72;
}

.auth-modal-captcha {
  margin-top: 8px;
  border: 1px solid #1f2937;
  border-radius: 4px;
  background: #fff;
  color: #111827;
  box-shadow: none;
}

.auth-modal-challenge {
  display: grid;
  gap: 10px;
  border-radius: 18px;
  background: #f7f9fc;
  padding: 12px;
}

.auth-modal-challenge-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #1f2937;
  font-weight: 800;
}

.auth-modal-challenge-line button {
  border: 0;
  background: transparent;
  color: #1479e8;
  font-weight: 800;
  cursor: pointer;
}

.auth-modal-message {
  min-height: 20px;
  margin: 14px 0 0;
  color: #5d6878;
  font-size: 14px;
}

.auth-modal-message.is-error {
  color: #b42318;
}

.auth-modal-message.is-success {
  color: #047857;
}

@media (max-width: 540px) {
  .auth-modal {
    padding: 14px;
  }

  .auth-dialog {
    padding: 24px 18px;
    border-radius: 24px;
  }

  .auth-modal-tabs {
    margin-right: 34px;
  }

  .auth-modal-tabs button {
    font-size: 15px;
    padding: 9px 4px;
  }
}
