.header-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.lang-switcher {
  position: relative;
  z-index: 1001;
  flex-shrink: 0;
}

.lang-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 2.5rem;
  padding: 0 0.85rem;
  border: 1px solid hsl(var(--input, 214 32% 91%));
  border-radius: 0.375rem;
  background: hsl(var(--background, 0 0% 100%));
  color: hsl(var(--foreground, 222 47% 11%));
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.lang-switcher__btn:hover,
.lang-switcher__btn[aria-expanded="true"] {
  background: hsl(var(--accent, 210 40% 96%));
  border-color: hsl(var(--primary));
  color: hsl(var(--foreground, 222 47% 11%));
}

.lang-switcher__chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.lang-switcher__btn[aria-expanded="true"] .lang-switcher__chevron {
  transform: rotate(180deg);
}

.lang-switcher__list,
header .lang-switcher__list {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  left: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
  width: max-content;
  min-width: 10.5rem;
  max-width: min(16rem, calc(100vw - 1.5rem));
  max-height: min(70vh, 22rem);
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  border: 1px solid hsl(var(--border, 214 32% 91%));
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.lang-switcher__list[hidden],
header .lang-switcher__list[hidden] {
  display: none !important;
}

.lang-switcher__list li,
header .lang-switcher__list li {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  line-height: normal;
  list-style: none;
}

.lang-switcher__link,
header .lang-switcher__list a {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.75rem;
  border-radius: 0.375rem;
  color: hsl(var(--foreground, 222 47% 11%));
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  text-align: left;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lang-switcher__link:hover,
header .lang-switcher__list a:hover {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--foreground, 222 47% 11%));
}

.lang-switcher__item--active,
header .lang-switcher__list a.lang-switcher__item--active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-weight: 600;
  pointer-events: none;
}

.lang-switcher--mobile {
  display: none;
  width: 100%;
  margin: 0 0 1rem;
}

.lang-switcher--mobile .lang-switcher__btn {
  width: 100%;
  justify-content: space-between;
}

.lang-switcher--mobile .lang-switcher__list,
header .lang-switcher--mobile .lang-switcher__list {
  position: static;
  margin-top: 0.5rem;
  max-width: none;
  width: 100%;
  box-shadow: none;
}

@media (min-width: 768px) {
  .header-toolbar {
    gap: 1rem;
  }

  .lang-switcher--mobile {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .lang-switcher__btn {
    height: 2.25rem;
    padding: 0 0.65rem;
    font-size: 0.8125rem;
  }

  .lang-switcher--header .lang-switcher__current {
    max-width: 6.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .lang-switcher--mobile {
    display: block;
  }
}

html[lang="fi"] {
  overflow-wrap: break-word;
  word-break: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}

html[lang="fi"] h1,
html[lang="fi"] h2,
html[lang="fi"] h3,
html[lang="fi"] nav a,
html[lang="fi"] footer a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

html[lang="fi"] a.whitespace-nowrap:not(.w-8):not(.w-10) {
  white-space: normal;
  height: auto;
  min-height: 2.5rem;
  line-height: 1.25;
  text-align: center;
}

@media (max-width: 767px) {
  html[lang="fi"] h1.text-4xl,
  html[lang="fi"] h1.text-3xl {
    font-size: clamp(1.5rem, 7vw, 2.25rem);
  }
}
