.layout {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  --home-header-height: 61px;
}

.layout__header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  min-height: 61px;
  align-items: center;
  justify-content: space-between;
  line-height: var(--type-body-line-height, 1.6);
  padding: 14px clamp(20px, 4vw, 48px);
  border-bottom: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transition:
    background 0.24s ease,
    border-color 0.24s ease,
    box-shadow 0.24s ease,
    -webkit-backdrop-filter 0.24s ease,
    backdrop-filter 0.24s ease;
}

.layout__header--scrolled {
  border-bottom-color: transparent;
  background: oklch(98% 0.004 95 / 0.62);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: none;
}

html[data-theme='dark'] .layout__header--scrolled {
  background: oklch(16% 0.012 70 / 0.72);
}

.layout--home .layout__header {
  z-index: 200;
}

.layout__topnav-left,
.layout__nav,
.layout__brand,
.layout__pill-link {
  display: flex;
  align-items: center;
}

.layout__topnav-left {
  min-width: 0;
  flex: 1;
}

.layout__brand {
  gap: 10px;
  padding-right: 20px;
  color: var(--fg);
}

.layout__brand-logo {
  display: grid;
  width: 80px;
  height: 32px;
  overflow: hidden;
  place-items: center;
}

.layout__brand-wordmark {
  width: auto;
  height: 32px;
}

.layout__nav {
  gap: clamp(16px, 2.5vw, 28px);
}

.layout__nav--actions {
  gap: 16px;
}

.layout__mobile-menu {
  display: none;
  position: relative;
}

.layout__mobile-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.layout__mobile-menu-trigger::-webkit-details-marker {
  display: none;
}

.layout__mobile-menu-panel {
  display: grid;
  gap: 4px;
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-float);
}

.layout__mobile-menu-panel a {
  display: flex;
  min-height: 38px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--fg);
  font-size: 14px;
}

.layout__mobile-menu-panel a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

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

.layout__tools-menu::after {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  height: 12px;
  content: '';
}

.layout__tools-trigger {
  appearance: none;
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.layout__tools-menu:hover .layout__tools-trigger,
.layout__tools-menu:focus-within .layout__tools-trigger {
  border-color: transparent;
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-float);
}

.layout__tools-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 260;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  min-width: 220px;
  padding: 8px;
  border: none;
  border-radius: 14px;
  background: oklch(100% 0.002 95 / 0.96);
  box-shadow: var(--shadow-float);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  visibility: hidden;
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease,
    visibility 0.15s ease;
}

.layout__tools-menu:hover .layout__tools-panel,
.layout__tools-menu:focus-within .layout__tools-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

.layout__tools-panel a {
  display: flex;
  min-height: 38px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--fg);
  font-size: 14px;
}

.layout__tools-panel a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.layout__mobile-menu-group {
  display: grid;
  gap: 4px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.layout__mobile-menu-group > span {
  padding: 4px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.layout__nav a,
.layout__auth-button,
.layout__pill-link {
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background-color 0.15s ease;
}

.layout__auth-button {
  display: inline-flex;
  align-items: center;
  padding: 6px 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.layout__nav a:hover,
.layout__auth-button:hover {
  color: var(--fg);
  text-decoration: none;
}

.layout__pill-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  line-height: 1;
}

.layout__pill-link:hover {
  border-color: var(--accent);
  color: var(--fg);
  text-decoration: none;
}

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

.layout__lang-trigger {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control, 10px);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.layout__lang-trigger:hover {
  border-color: var(--accent);
  background: var(--surface-soft);
}

.layout__lang-trigger[aria-expanded='true'] {
  border-color: var(--accent);
  color: var(--accent);
}

.layout__lang-chevron {
  transition: transform 0.15s ease;
}

.layout__lang-trigger[aria-expanded='true'] .layout__lang-chevron {
  transform: rotate(180deg);
}

.layout__lang-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 260;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  min-width: 168px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: oklch(100% 0.002 95 / 0.96);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
}

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

.layout__lang-title {
  padding: 6px 10px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.layout__lang-option {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-control, 10px);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.layout__lang-option:hover {
  background: var(--surface-soft);
}

.layout__lang-option--current {
  color: var(--accent);
  font-weight: 600;
}

.layout__lang-check {
  display: inline-flex;
  color: var(--accent);
}

.layout__auth-placeholder {
  display: inline-block;
  width: 150px;
  height: 32px;
}

.static-auth-modal-shell {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 20px;
}

.static-auth-modal-shell[hidden] {
  display: none;
}

.static-auth-modal__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: oklch(0% 0 0 / 0.38);
}

.static-auth-modal__card {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  height: min(760px, calc(100vh - 40px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 22px 70px oklch(0% 0 0 / 0.24);
}

.static-auth-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.static-auth-modal__frame {
  width: 100%;
  height: 100%;
  border: 0;
}

.layout__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--accent-bg, oklch(95% 0.015 28));
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.layout__feedback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
}

.layout__feedback:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.layout__feedback svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layout__main.layout__main--home {
  width: 100%;
  max-width: none;
  padding: 0;
}

@media (max-width: 720px) {
  .layout--home .layout__header {
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .layout--home .layout__topnav-left {
    flex: 1 1 auto;
    width: auto;
  }

  .layout--home .layout__nav--primary {
    display: none;
  }

  .layout--home .layout__mobile-menu {
    display: block;
    margin-left: auto;
  }

  .layout--home .layout__mobile-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 240;
  }

  .layout--home .layout__nav--actions {
    flex: 0 0 auto;
  }
}

@media (max-width: 420px) {
  .layout--home .layout__nav--actions a:not(.layout__pill-link),
  .layout--home .layout__nav--actions .layout__auth-button:not(.layout__pill-link) {
    display: none;
  }

  .layout--home .layout__nav--actions .layout__feedback,
  .layout--home .layout__nav--actions .layout__avatar {
    display: inline-flex;
  }
}
