*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  min-width: 0;
  min-height: 100%;
  scrollbar-gutter: stable;
}

body {
  --header-height: clamp(54px, 7dvh, 64px);
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  height: 100dvh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-ui);
  text-rendering: optimizeLegibility;
}

button,
a {
  font: inherit;
}

button,
img {
  user-select: none;
}

.site-header {
  --header-inline-padding: clamp(12px, 2.5vw, 36px);
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  display: grid;
  flex: 0 0 var(--header-height);
  align-items: center;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  width: 100%;
  min-width: 0;
  height: var(--header-height);
  padding-inline: var(--header-inline-padding);
  border-bottom: 1px solid var(--line);
  background: var(--page);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
  direction: ltr;
}

.site-main {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding-top: var(--header-height);
  background: var(--page);
}

.brand {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  width: clamp(170px, 22vw, 280px);
  height: 100%;
  min-width: 0;
  justify-content: flex-start;
  text-decoration: none;
}

.brand-wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.18em;
  direction: ltr;
  color: var(--ink);
  font-family: var(--font-latin);
  font-size: clamp(1.05rem, 1.8vw, 1.5rem);
  font-weight: 850;
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: nowrap;
}

.brand-wordmark-gold {
  color: var(--accent);
}

.brand-wordmark-ink {
  color: var(--ink);
}

html[dir="ltr"] .brand {
  grid-column: 3;
  justify-self: end;
  justify-content: flex-end;
}

#account-root {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  min-width: 0;
}

html[dir="ltr"] #account-root {
  grid-column: 1;
  justify-self: start;
}

.account-wrap {
  position: static;
}

.account-trigger {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.account-trigger:hover {
  border-color: transparent;
  background: transparent;
  outline: none;
}

.account-trigger:focus-visible {
  border-color: transparent;
  background: transparent;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.account-trigger svg {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
}

.account-avatar-fallback {
  color: var(--ink);
}

.account-menu {
  position: absolute;
  top: calc(100% + 1px);
  inset-inline-end: auto;
  z-index: 30;
  width: min(300px, calc(100vw - 24px));
  max-height: calc(100dvh - var(--header-height));
  padding: 8px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 18px 45px var(--shadow);
  color: var(--ink);
  direction: rtl;
  font-size: clamp(0.9rem, 1vw, 1rem);
}

html[dir="rtl"] .account-menu {
  right: var(--header-inline-padding);
  left: auto;
}

html[dir="ltr"] .account-menu {
  right: auto;
  left: var(--header-inline-padding);
}

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

.account-menu {
  direction: rtl;
}

html[dir="ltr"] .account-menu {
  direction: ltr;
}

.menu-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 10px;
  border-bottom: 1px solid var(--line);
}

.menu-profile img,
.profile-fallback {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--field);
  color: var(--muted);
}

.menu-profile strong {
  display: block;
  font-size: clamp(0.92rem, 1vw, 1rem);
}

.menu-profile small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  direction: ltr;
  text-align: start;
}

.menu-primary,
.menu-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 6px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  text-align: start;
}

.menu-primary {
  justify-content: center;
  margin-bottom: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.menu-primary:hover,
.menu-primary:focus-visible {
  background: var(--accent-strong);
}

.menu-row svg,
.menu-primary svg {
  width: clamp(19px, 1.6vw, 22px);
  height: clamp(19px, 1.6vw, 22px);
  flex: 0 0 auto;
}

.menu-row:hover:not(.menu-static),
.menu-row:focus-visible {
  background: var(--control-hover);
  outline: none;
}

.menu-static {
  cursor: default;
}

.menu-language-row {
  cursor: pointer;
}

.menu-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--line);
}

.menu-row .row-label {
  flex: 1;
}

.language-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 30px;
  margin-inline-start: auto;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.notification-toggle {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-inline-start: auto;
}

.notification-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  display: block;
  width: 38px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  background: var(--line);
}

.toggle-track::after {
  position: absolute;
  inset-block-start: 3px;
  inset-inline-start: 3px;
  display: block;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  transition: transform 0.18s ease;
}

.notification-toggle input:checked + .toggle-track {
  background: var(--accent);
}

.notification-toggle input:checked + .toggle-track::after {
  background: var(--on-accent);
}

html[dir="rtl"] .notification-toggle input:checked + .toggle-track::after {
  transform: translateX(-17px);
}

html[dir="ltr"] .notification-toggle input:checked + .toggle-track::after {
  transform: translateX(17px);
}

.theme-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
}

.theme-choice {
  display: grid;
  place-items: center;
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-choice.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 3px var(--shadow);
}

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

@media (max-width: 560px) {
  body {
    --header-height: 54px;
  }

  .site-header {
    --header-inline-padding: 8px;
  }

  .brand {
    width: auto;
  }

  .brand-wordmark {
    font-size: clamp(0.85rem, 4vw, 1rem);
    letter-spacing: 0.06em;
  }

  .account-trigger {
    width: 46px;
    height: 46px;
  }

  #account-root {
    width: 46px;
    height: 46px;
  }

  .account-menu {
    width: min(360px, calc(100vw - 16px));
  }
}

@media (orientation: landscape) and (max-height: 480px) {
  body {
    --header-height: 50px;
  }

  .brand-logo {
    height: 38px;
  }
}
