/* ==========================================================================
   KidsMap Modern Unified Header & Mobile Burger Drawer
   ========================================================================== */

:root {
  --km-brand-spruce: #0d4924;
  --km-brand-spruce-dark: #08361a;
  --km-brand-emerald: #1f8a4c;
  --km-brand-emerald-dark: #136f38;
  --km-brand-emerald-light: #eef7f1;
  --km-brand-sage: #a8d59b;
  --km-header-bg: rgba(255, 255, 255, 0.88);
  --km-header-bg-scrolled: rgba(255, 255, 255, 0.96);
  --km-header-border: rgba(13, 73, 36, 0.08);
  --km-header-shadow: 0 4px 20px -2px rgba(13, 73, 36, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.02);
  --km-header-shadow-scrolled: 0 10px 30px -4px rgba(13, 73, 36, 0.12), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
}

/* ── Topbar Reset & Wrapper ── */
.km-header.topbar {
  display: block !important;
  box-sizing: border-box !important;
  position: sticky !important;
  top: 12px !important;
  z-index: 1000 !important;
  margin: 0 auto !important;
  width: 100% !important;
  max-width: 1320px !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  transition: transform 0.25s ease;
}

.km-header-inner {
  container: header-row / inline-size;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 1.125em;
  min-height: 64px;
  background: var(--km-header-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--km-header-border);
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--km-header-shadow);
  transition: background-color 0.25s, border-color 0.25s, box-shadow 0.25s;
  position: relative;
  z-index: 10;
}

.km-header.is-scrolled .km-header-inner {
  background: var(--km-header-bg-scrolled);
  border-color: rgba(13, 73, 36, 0.12);
  box-shadow: var(--km-header-shadow-scrolled);
  min-height: 60px;
  padding: 6px 1.125em;
}

/* ── Brand Lockup ── */
.km-brand {
  display: inline-flex !important;
  align-items: center !important;
  grid-area: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
  min-width: 0;
  max-width: 360px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.km-brand:hover {
  transform: scale(1.02);
}

.km-brand:active {
  transform: scale(0.98);
}

.km-brand-logo-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 44px;
  flex: 0 0 38px;
  position: relative;
  filter: drop-shadow(0 2px 4px rgba(13, 73, 36, 0.12));
  transition: filter 0.25s ease, transform 0.25s ease;
}

.km-brand:hover .km-brand-logo-frame {
  filter: drop-shadow(0 4px 10px rgba(31, 138, 76, 0.35));
  transform: translateY(-1px);
}

.km-brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.km-brand-title {
  font-family: var(--font-display, "Baloo 2", system-ui, sans-serif);
  font-size: 24px;
  font-weight: 800;
  color: var(--km-brand-spruce-dark);
  letter-spacing: -0.025em;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

/* ── Desktop Navigation ── */
.km-nav-desktop {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  min-width: 0;
  gap: 4px;
  margin: 0;
  padding: 0;
}

.km-nav-desktop a::after,
.km-nav-item::after {
  display: none !important;
  content: none !important;
}

.km-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 8px;
  white-space: nowrap;
  border-radius: var(--radius-md, 12px);
  font-size: 14.5px;
  font-weight: 600;
  color: #47584d;
  text-decoration: none !important;
  background: transparent;
  border: 1px solid transparent;
  outline: none;
  box-shadow: none !important;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  line-height: 1.25;
  position: relative;
  font-family: inherit;
  user-select: none;
}

.km-nav-item:hover {
  color: #1f2933;
  background: #f0f5f2;
  border-color: transparent;
  transform: none !important;
  box-shadow: none !important;
}

.km-nav-item.active {
  color: #0d4924 !important;
  background: #eaf6ee !important;
  border-color: #cbe7d8 !important;
  font-weight: 750 !important;
  box-shadow: none !important;
  transform: none !important;
}

.km-nav-item.active:hover {
  background: #e2f2e7 !important;
  border-color: #b7dfc8 !important;
  color: #08361a !important;
}

.km-chevron {
  font-size: 18px !important;
  line-height: 1;
  color: #64776a;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), color 0.18s ease;
}

.km-nav-item:hover .km-chevron {
  color: #1f2933;
}

.km-nav-item.active .km-chevron {
  color: #0d4924;
}

.km-dropdown-wrapper.is-open .km-dropdown-trigger {
  background: #f0f5f2;
  color: #1f2933;
}

.km-dropdown-wrapper.is-open .km-dropdown-trigger.active {
  background: #eaf6ee !important;
  border-color: #cbe7d8 !important;
  color: #0d4924 !important;
}

/* ── Action Button: "Добавить место" (Delicate Soft-Pill) ── */
.km-btn-add-place {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-pill, 999px);
  font-size: 13.5px;
  font-weight: 600;
  color: #0d6b35 !important;
  background: rgba(31, 138, 76, 0.08);
  border: 1px solid rgba(31, 138, 76, 0.26);
  box-shadow: none;
  text-decoration: none;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  line-height: 1.2;
}

.km-btn-add-place:hover {
  background: #eef7f1;
  border-color: #1f8a4c;
  color: #08361a !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(31, 138, 76, 0.14);
}

.km-btn-add-place:active {
  transform: translateY(0);
  background: #e2f6e9;
}

.km-btn-add-icon {
  font-size: 17px !important;
  color: #1f8a4c;
  transition: transform 0.22s ease;
}

.km-btn-add-place:hover .km-btn-add-icon {
  transform: rotate(90deg);
}

/* ── Dropdown Menus ── */
.km-dropdown-wrapper {
  position: relative;
}

.km-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(13, 73, 36, 0.1);
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 12px 32px -4px rgba(13, 73, 36, 0.12), 0 4px 12px rgba(0, 0, 0, 0.04);
  padding: 8px;
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.96);
  transform-origin: top left;
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.18s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.18s;
  pointer-events: none;
}

.km-dropdown-menu--right {
  left: auto;
  right: 0;
  transform-origin: top right;
}

/* Open State */
.km-dropdown-wrapper.is-open .km-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.km-dropdown-wrapper.is-open .km-chevron {
  transform: rotate(180deg);
}

.km-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md, 12px);
  text-decoration: none;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.km-dropdown-item:hover {
  background: #f3f9f2;
  color: #0d6b35;
  transform: translateX(3px);
}

.km-dropdown-item.active {
  background: var(--km-brand-emerald-light);
  color: #0d6b35;
  font-weight: 600;
}

.km-dropdown-icon {
  font-size: 20px !important;
  color: #136f38;
  flex-shrink: 0;
}

.km-dropdown-label {
  font-size: 14px;
  font-weight: 600;
  color: inherit;
}

.km-dropdown-divider {
  height: 1px;
  background: rgba(13, 73, 36, 0.08);
  margin: 6px 0;
}

/* ── Header Actions (Right) ── */
.km-header-actions,
.km-header-actions.topbar-right {
  display: flex !important;
  align-items: center !important;
  grid-area: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Language Switcher (Desktop Dropdown) ── */
.km-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill, 999px);
  background: #ffffff;
  border: 1px solid rgba(13, 73, 36, 0.12);
  font-size: 13.5px;
  font-weight: 700;
  color: #1f2937;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.km-lang-btn:hover {
  border-color: var(--km-brand-emerald);
  box-shadow: 0 2px 8px rgba(31, 138, 76, 0.15);
  transform: translateY(-1px);
}

.km-lang-flag {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.km-lang-flag img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.km-dropdown-lang {
  min-width: 108px;
  width: auto;
  padding: 6px;
  border-radius: var(--radius-lg, 16px);
}

.km-lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm, 8px);
}

.km-lang-option img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.km-lang-opt-code {
  font-size: 13.5px;
  font-weight: 700;
  color: #374151;
}

.km-lang-option.active .km-lang-opt-code {
  color: #0d6b35;
}

.km-lang-check {
  font-size: 16px !important;
  color: #136f38;
  margin-left: auto;
}

/* ── Auth / User Group ── */
.km-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-pill, 999px);
  background: #ffffff;
  border: 1px solid rgba(13, 73, 36, 0.15);
  color: #0d6b35;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.18s ease;
  box-shadow: 0 2px 6px rgba(13, 73, 36, 0.04);
}

.km-login-btn:hover {
  background: var(--km-brand-emerald-light);
  border-color: var(--km-brand-emerald);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(31, 138, 76, 0.2);
}

.km-login-icon {
  font-size: 18px !important;
  color: #1f8a4c;
}

.km-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 6px;
  border-radius: var(--radius-pill, 999px);
  background: #ffffff;
  border: 1px solid rgba(13, 73, 36, 0.12);
  color: #1f2937;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.km-user-btn:hover {
  border-color: var(--km-brand-emerald);
  box-shadow: 0 2px 8px rgba(31, 138, 76, 0.15);
}

.km-user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef7f1;
  color: #136f38;
  overflow: hidden;
}

.km-user-avatar img,
.km-user-avatar__img,
.km-user-card-avatar img,
.km-user-card-avatar__img,
.km-drawer-user-avatar img,
.km-drawer-user-avatar__img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}


.km-user-avatar .material-symbols-rounded {
  font-size: 20px !important;
}

.km-dropdown-user {
  min-width: 240px;
}

.km-user-card-brief {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}

.km-user-card-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #eef7f1;
  color: #136f38;
  flex-shrink: 0;
  overflow: hidden;
}

.km-user-card-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.km-user-card-name {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.km-user-card-email {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.km-logout-form {
  margin: 0;
  padding: 0;
}

.km-dropdown-logout {
  color: #dc2626 !important;
}

.km-dropdown-logout .km-dropdown-icon {
  color: #dc2626 !important;
}

.km-dropdown-logout:hover {
  background: #fef2f2 !important;
}

.km-dropdown-add-place {
  color: #0d6b35 !important;
  font-weight: 600;
  background: rgba(31, 138, 76, 0.05);
  border-radius: var(--radius-md, 12px);
  margin: 2px 0;
}

.km-dropdown-add-place .km-dropdown-icon {
  color: #1f8a4c !important;
}

.km-dropdown-add-place:hover {
  background: #eef7f1 !important;
  color: #08361a !important;
  transform: translateX(3px);
}

.km-drawer-user-add-place {
  color: #0d6b35 !important;
  font-weight: 600;
  background: rgba(31, 138, 76, 0.05);
}

.km-drawer-user-add-place .material-symbols-rounded {
  color: #1f8a4c !important;
}

.km-drawer-user-add-place:hover {
  background: #eef7f1 !important;
  color: #08361a !important;
}

/* ── Mobile Burger Button ── */
.km-burger-trigger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md, 12px);
  background: #ffffff;
  border: 1px solid rgba(13, 73, 36, 0.12);
  color: var(--km-brand-spruce);
  cursor: pointer;
  padding: 0;
  transition: all 0.18s ease;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.km-burger-trigger:hover {
  border-color: var(--km-brand-emerald);
  background: #f3f9f2;
  transform: translateY(-1px);
}

.km-burger-trigger:active {
  transform: scale(0.95);
}

.km-burger-icon {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 20px;
  height: 20px;
}

.km-burger-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--km-brand-spruce);
  border-radius: 2px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.km-burger-bar:nth-child(2) {
  width: 14px;
  align-self: flex-start;
  margin-left: 1px;
}

.km-burger-trigger:hover .km-burger-bar:nth-child(2) {
  width: 18px;
}

/* ── Mobile Drawer Component ── */
.km-drawer-wrapper {
  position: fixed;
  inset: 0;
  z-index: 9999;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
  transition: visibility 0.32s;
}

.km-drawer-wrapper.is-active {
  visibility: visible;
  pointer-events: auto;
}

.km-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 54, 26, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.32s ease;
}

.km-drawer-wrapper.is-active .km-drawer-backdrop {
  opacity: 1;
}

.km-drawer-sheet {
  position: absolute;
  top: 0;
  right: 0 !important;
  left: auto !important;
  bottom: 0;
  width: 100%;
  max-width: min(360px, 100vw);
  box-sizing: border-box;
  background: #ffffff;
  box-shadow: -8px 0 32px rgba(13, 73, 36, 0.16);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
  z-index: 2;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.km-drawer-wrapper.is-active .km-drawer-sheet {
  transform: translateX(0);
}

.km-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(13, 73, 36, 0.08);
  background: rgba(255, 255, 255, 0.98);
  position: sticky;
  top: 0;
  z-index: 10;
}

.km-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f3f4f6;
  border: none;
  color: #374151;
  cursor: pointer;
  transition: all 0.18s ease;
}

.km-drawer-close:hover {
  background: #fee2e2;
  color: #dc2626;
  transform: rotate(90deg);
}

.km-drawer-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

/* User Card in Mobile Drawer */
.km-drawer-user-box {
  border-radius: var(--radius-lg, 16px);
  background: #f9fafb;
  border: 1px solid rgba(13, 73, 36, 0.08);
  padding: 14px;
}

.km-drawer-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.km-drawer-user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #eef7f1;
  color: #136f38;
  flex-shrink: 0;
  overflow: hidden;
}

.km-drawer-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.km-drawer-user-name {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.km-drawer-user-email {
  font-size: 13px;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.km-drawer-user-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid rgba(13, 73, 36, 0.06);
  padding-top: 10px;
}

.km-drawer-user-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: var(--radius-md, 12px);
  text-decoration: none;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.km-drawer-user-link:hover {
  background: #ffffff;
  color: #0d6b35;
}

.km-drawer-logout-btn {
  color: #dc2626;
}

.km-drawer-logout-btn:hover {
  background: #fef2f2;
}

.km-drawer-guest-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.km-drawer-guest-text strong {
  display: block;
  font-size: 15px;
  color: #111827;
  margin-bottom: 2px;
}

.km-drawer-guest-text p {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
  line-height: 1.4;
}

.km-drawer-login-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md, 12px);
  background: var(--km-brand-emerald-light);
  color: #0d6b35;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid rgba(13, 107, 53, 0.16);
  transition: all 0.18s ease;
}

.km-drawer-login-cta:hover {
  background: #e8f3e5;
  transform: translateY(-1px);
}

/* Mobile CTA Add Place */
.km-drawer-cta-wrap {
  margin-top: -4px;
}

.km-drawer-add-place {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg, 16px);
  background: linear-gradient(135deg, #1f8a4c 0%, #136f38 100%);
  color: #ffffff;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(31, 138, 76, 0.32);
  transition: all 0.2s ease;
}

.km-drawer-add-place:active {
  transform: scale(0.98);
}

.km-drawer-add-icon {
  font-size: 28px !important;
  flex-shrink: 0;
}

.km-drawer-add-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.km-drawer-add-text strong {
  font-size: 15px;
  font-weight: 700;
}

.km-drawer-add-text span {
  font-size: 12px;
  opacity: 0.9;
  line-height: 1.3;
}

.km-drawer-arrow {
  font-size: 20px !important;
  opacity: 0.8;
}

/* Mobile Navigation List */
.km-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.km-drawer-section-title {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9ca3af;
  margin-bottom: 6px;
  padding-left: 4px;
}

.km-drawer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.km-drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md, 12px);
  text-decoration: none;
  color: #374151;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.15s ease;
  position: relative;
}

.km-drawer-link:hover {
  background: #f3f9f2;
  color: #0d6b35;
}

.km-drawer-link.active {
  background: #eef7f1;
  color: #0d6b35;
  font-weight: 700;
}

.km-drawer-item-icon {
  font-size: 22px !important;
  color: #136f38;
  flex-shrink: 0;
}

.km-drawer-item-title {
  flex: 1;
}

.km-drawer-active-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1f8a4c;
}

/* Mobile Language Switcher (Segmented Control with Animated Slider) */
.km-drawer-lang-section {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(13, 73, 36, 0.08);
}

.km-drawer-lang-pills {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: #f0f5f2;
  padding: 4px;
  border-radius: var(--radius-lg, 16px);
  border: 1px solid rgba(31, 41, 51, 0.06);
  isolation: isolate;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 1px 2px rgba(31, 41, 51, 0.04);
}

/* Floating animated slider thumb */
.km-drawer-lang-slider {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px - 12px) / 3);
  background: #ffffff;
  border-radius: var(--radius-md, 12px);
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.08), 0 1px 2px rgba(31, 41, 51, 0.04);
  z-index: 1;
  pointer-events: none;
  will-change: transform;
  transform: translateX(calc(var(--lang-index, 0) * (100% + 6px)));
  transition: transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.2s ease;
}

.km-drawer-lang-pills.is-animating .km-drawer-lang-slider {
  box-shadow: 0 4px 14px rgba(31, 41, 51, 0.14), 0 2px 4px rgba(31, 41, 51, 0.06);
}

.km-drawer-lang-btn {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: var(--radius-md, 12px);
  text-decoration: none !important;
  color: #64776a;
  font-size: 13.5px;
  font-weight: 700;
  background: transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.15s ease;
}

.km-drawer-lang-btn:active {
  transform: scale(0.96);
}

@media (hover: hover) {
  .km-drawer-lang-btn:not(.active):hover {
    color: #1e2b23;
  }
  .km-drawer-lang-btn:not(.active):hover .lang-flag-icon {
    transform: scale(1.06);
  }
}

.km-drawer-lang-btn .lang-flag-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  transition: transform 0.28s cubic-bezier(0.34, 1.45, 0.64, 1);
}

.km-drawer-lang-btn.active {
  color: #0d6b35;
}

.km-drawer-lang-btn.active .lang-flag-icon {
  transform: scale(1.12);
}

@media (prefers-reduced-motion: reduce) {
  .km-drawer-lang-slider {
    transition: none !important;
  }
  .km-drawer-lang-btn .lang-flag-icon {
    transition: none !important;
  }
}

/* ==========================================================================
   Responsive Breakpoints & Mobile Overflow Protection
/* ==========================================================================
   Responsive Breakpoints & Clean Mobile Header
   ========================================================================== */

/* Burger trigger animated X state */
.km-burger-trigger[aria-expanded="true"] {
  border-color: var(--km-brand-emerald) !important;
  background: #f3f9f2 !important;
}

.km-burger-trigger[aria-expanded="true"] .km-burger-bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.km-burger-trigger[aria-expanded="true"] .km-burger-bar:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.km-burger-trigger[aria-expanded="true"] .km-burger-bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

body.km-drawer-locked {
  overflow: hidden !important;
  touch-action: none !important;
}

@media (max-width: 1199px) {
  /* Sticky full-width header across mobile/tablet */
  .km-header.topbar {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
    z-index: 1000 !important;
  }

  .km-header-inner {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 10px 18px !important;
    min-height: 60px !important;
    border-radius: 0 0 16px 16px !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid var(--km-header-border) !important;
    background: var(--km-header-bg) !important;
    backdrop-filter: blur(16px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(16px) saturate(180%) !important;
  }

  .km-header.is-scrolled .km-header-inner {
    min-height: 56px !important;
    padding-block: 8px !important;
  }
}

/* Reserve room for the longest translated navigation and signed-in controls.
   The query measures the row inside its gutters, including on narrower pages. */
@container header-row (inline-size < 70em) {
  .km-nav-desktop,
  .km-btn-add-place,
  .km-auth-wrap,
  .km-lang-wrapper {
    display: none !important;
  }

  .km-brand {
    flex-shrink: 1;
    gap: 8px !important;
  }

  .km-brand-title {
    font-size: 22px !important;
  }

  .km-brand-logo-frame {
    width: 34px !important;
    height: 38px !important;
    flex: 0 0 34px !important;
  }

  .km-header-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
  }

  /* Touch-friendly Burger Trigger (hit area 44x44) */
  .km-burger-trigger {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    border-radius: var(--radius-md, 12px) !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    touch-action: manipulation;
  }

  .km-burger-icon {
    width: 20px !important;
    height: 18px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 4px !important;
  }

  .km-burger-bar {
    width: 18px !important;
    height: 2px !important;
  }

  .km-burger-bar:nth-child(2) {
    width: 14px !important;
    align-self: flex-start !important;
    margin-left: 1px !important;
  }
}

@media (max-width: 480px) {
  .km-header-inner {
    padding: 8px 14px !important;
    min-height: 54px !important;
  }

  .km-brand-title {
    font-size: 20px !important;
  }

  .km-brand-logo-frame {
    width: 32px !important;
    height: 36px !important;
    flex: 0 0 32px !important;
  }
}

@media (max-width: 360px) {
  .km-header-inner {
    padding: 6px 12px !important;
    min-height: 50px !important;
  }

  .km-brand-title {
    font-size: 18.5px !important;
  }

  .km-brand-logo-frame {
    width: 28px !important;
    height: 32px !important;
    flex: 0 0 28px !important;
  }

  .km-burger-trigger {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    border-radius: var(--radius-md, 12px) !important;
  }
}

@media (max-width: 330px) {
  .km-header-inner {
    padding: 6px 10px !important;
    min-height: 48px !important;
  }

  .km-brand-title {
    font-size: 17px !important;
  }

  .km-brand-logo-frame {
    width: 26px !important;
    height: 30px !important;
    flex: 0 0 26px !important;
  }

  .km-burger-trigger {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    border-radius: var(--radius-md, 12px) !important;
  }
}

/* ── Scrolled backdrop (desktop) ──
   The floating header sits 12px below the viewport edge and is inset from
   the sides, so scrolled content used to show through those gaps. A soft
   strip in the page background fades the content out behind the header. */
@media (min-width: 1200px) {
  .km-header.topbar::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 92px;
    background: linear-gradient(to bottom, var(--bg, #fcfcfc) 0%, var(--bg, #fcfcfc) 62%, rgba(252, 252, 252, 0) 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-base, 260ms) var(--ease-out-quint, ease-out);
    z-index: -1;
  }
  .km-header.topbar.is-scrolled::before { opacity: 1; }
}

/* ==========================================================================
   Header: Catalog accent + animated language picker
   (.km-mlang is shared by the desktop dropdown and the mobile chip)
   ========================================================================== */
.km-m-catalog {
  display: none;
}

/* ── Language chip ── */
.km-mlang {
  position: relative;
}

.km-mlang__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 8px 0 5px;
  border-radius: 999px;
  border: 1px solid rgba(13, 73, 36, 0.14);
  background: linear-gradient(180deg, #ffffff 0%, #f3faf5 100%);
  color: var(--km-brand-spruce);
  font: inherit;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 2px 8px -3px rgba(13, 73, 36, 0.18);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}

.km-mlang__chip:active {
  transform: scale(0.93);
}

.km-mlang__chip:focus-visible {
  outline: 3px solid rgba(31, 138, 76, 0.35);
  outline-offset: 2px;
}

.km-mlang.is-open .km-mlang__chip {
  border-color: var(--km-brand-emerald);
  box-shadow: 0 0 0 3px rgba(31, 138, 76, 0.14), 0 6px 14px -6px rgba(13, 73, 36, 0.3);
}

.km-mlang__flag {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 2px #fff, 0 1px 4px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.km-mlang__flag img,
.km-mlang__opt-flag img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.km-mlang.is-open .km-mlang__flag {
  transform: rotate(-8deg) scale(1.06);
}

.km-mlang__chevron {
  color: #4b7a5c;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.km-mlang.is-open .km-mlang__chevron {
  transform: rotate(180deg);
}

/* ── Language popover ── */
.km-mlang__menu {
  position: absolute;
  top: calc(100% + 12px);
  right: -50px;
  z-index: 1100;
  width: 232px;
  padding: 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.97);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(13, 73, 36, 0.1);
  box-shadow: 0 24px 48px -12px rgba(13, 73, 36, 0.28), 0 6px 16px -6px rgba(0, 0, 0, 0.08);
  transform-origin: calc(100% - 82px) -8px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(0.86);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

/* tail pointing at the chip */
.km-mlang__menu::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 82px;
  width: 12px;
  height: 12px;
  background: inherit;
  border-left: 1px solid rgba(13, 73, 36, 0.1);
  border-top: 1px solid rgba(13, 73, 36, 0.1);
  border-radius: 3px 0 0 0;
  transform: rotate(45deg);
}

.km-mlang.is-open .km-mlang__menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: opacity 0.2s ease, transform 0.42s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s;
}

.km-mlang__title {
  display: block;
  padding: 6px 10px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b8f78;
}

.km-mlang__option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 14px;
  color: #1f2937;
  text-decoration: none;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transform: translateX(10px);
  transition: background-color 0.18s ease, opacity 0.2s ease, transform 0.2s ease;
}

.km-mlang.is-open .km-mlang__option {
  opacity: 1;
  transform: translateX(0);
  transition: background-color 0.18s ease,
              opacity 0.3s ease calc(60ms + var(--i, 0) * 55ms),
              transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) calc(60ms + var(--i, 0) * 55ms);
}

.km-mlang__option + .km-mlang__option {
  margin-top: 2px;
}

.km-mlang__option:hover,
.km-mlang__option:focus-visible {
  background: #f2f8f4;
  outline: none;
}

.km-mlang__option:active {
  background: #e6f3ea;
}

.km-mlang__option.is-active {
  background: var(--km-brand-emerald-light);
}

.km-mlang__opt-flag {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, 0.16);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.km-mlang__option:active .km-mlang__opt-flag {
  transform: scale(0.88);
}

.km-mlang__opt-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.km-mlang__opt-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.km-mlang__opt-code {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #7a9384;
}

.km-mlang__option.is-active .km-mlang__opt-name {
  color: var(--km-brand-spruce);
}

.km-mlang__check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--km-brand-emerald);
  color: #fff;
  opacity: 0;
  transform: scale(0.3) rotate(-45deg);
  transition: opacity 0.2s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.km-mlang__option.is-active .km-mlang__check {
  opacity: 1;
  transform: scale(1) rotate(0);
}

/* tap ripple + selection feedback (set by header.js) */
.km-mlang__ripple {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: rgba(31, 138, 76, 0.22);
  pointer-events: none;
  animation: km-mlang-ripple 0.55s ease-out forwards;
}

.km-mlang.is-switching .km-mlang__option:not(.is-active) {
  opacity: 0.45;
}

.km-mlang.is-switching .km-mlang__flag {
  animation: km-mlang-flip 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Older browsers can reach every destination through the drawer. */
@supports not (container-type: inline-size) {
  .km-nav-desktop,
  .km-header-actions .km-auth-wrap,
  .km-mlang--desktop { display: none !important; }
  .km-burger-trigger { display: inline-flex; }
}

/* Keep navigation links visible on laptops. The account button retains its
   full accessible name and the dropdown shows the complete profile name. */
@container header-row (70em <= inline-size < 77em) {
  .km-user-name { display: none; }
}

/* Full navigation */
@container header-row (inline-size >= 70em) {
  .km-mlang:not(.km-mlang--desktop) {
    display: none;
  }

  .km-mlang--desktop .km-mlang__chip {
    height: 42px;
    padding: 0 11px 0 6px;
    gap: 6px;
    font-size: 14px;
  }

  .km-mlang--desktop .km-mlang__menu {
    right: 0;
    width: 248px;
    top: calc(100% + 14px);
    transform-origin: calc(100% - 44px) -8px;
  }

  .km-mlang--desktop .km-mlang__menu::before {
    right: 38px;
  }

  /* Catalog nav item: compass accent */
  .km-nav-item--catalog {
    gap: 7px;
    overflow: hidden;
    isolation: isolate;
    color: #136f38;
    background: rgba(31, 138, 76, 0.07);
    border-color: rgba(31, 138, 76, 0.18);
  }

  .km-nav-item--catalog::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.85) 48%, transparent 66%);
    transform: translateX(-120%);
    animation: km-m-sheen 6s ease-in-out 1.5s infinite;
  }

  .km-nav-item--catalog .km-nav-compass {
    display: inline-flex;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  .km-nav-item--catalog .km-m-catalog__needle {
    transform-origin: 12px 12px;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: km-m-needle 6s cubic-bezier(0.45, 0, 0.2, 1) 0.8s infinite;
  }
}

@media (min-width: 1200px) and (hover: hover) {
  .km-mlang--desktop .km-mlang__chip:hover {
    border-color: var(--km-brand-emerald);
    box-shadow: 0 8px 18px -8px rgba(13, 73, 36, 0.35);
    transform: translateY(-1px);
  }

  .km-mlang--desktop .km-mlang__chip:hover .km-mlang__flag {
    transform: rotate(-8deg) scale(1.08);
  }

  .km-mlang--desktop .km-mlang__option:hover .km-mlang__opt-flag {
    transform: scale(1.1) rotate(-6deg);
  }

  .km-mlang--desktop .km-mlang__option:hover .km-mlang__opt-text {
    transform: translateX(3px);
  }

  .km-nav-item--catalog:hover {
    color: #0d4924 !important;
    background: rgba(31, 138, 76, 0.13) !important;
    border-color: rgba(31, 138, 76, 0.3) !important;
  }

  .km-nav-item--catalog:hover .km-m-catalog__needle {
    animation: none;
    transform: rotate(360deg);
  }
}

/* Compact navigation */
@container header-row (inline-size < 70em) {
  .km-header-actions {
    gap: 6px !important;
  }

  .km-mlang {
    display: block;
  }

  /* ── Catalog pill ── */
  .km-m-catalog {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 13px 0 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, #24a35a 0%, var(--km-brand-emerald-dark) 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 6px 16px -6px rgba(19, 111, 56, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    overflow: hidden;
    isolation: isolate;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  }

  /* soft moving sheen */
  .km-m-catalog::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.28) 48%, transparent 66%);
    transform: translateX(-120%);
    animation: km-m-sheen 5.5s ease-in-out 1.2s infinite;
  }

  .km-m-catalog:hover,
  .km-m-catalog:focus-visible {
    color: #fff;
    box-shadow: 0 10px 22px -8px rgba(19, 111, 56, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  }

  .km-m-catalog:active {
    transform: scale(0.94);
  }

  .km-m-catalog:focus-visible {
    outline: 3px solid rgba(31, 138, 76, 0.35);
    outline-offset: 2px;
  }

  .km-m-catalog.is-current {
    background: linear-gradient(135deg, var(--km-brand-spruce) 0%, var(--km-brand-spruce-dark) 100%);
  }

  .km-m-catalog__icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
  }

  .km-m-catalog__needle {
    transform-origin: 12px 12px;
    animation: km-m-needle 6s cubic-bezier(0.45, 0, 0.2, 1) 0.8s infinite;
  }

  .km-m-catalog:active .km-m-catalog__needle {
    animation: none;
    transform: rotate(180deg);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
}

/* As the row narrows, compact the language picker first, then the catalog.
   Both icon-only controls retain their accessible names. */
@container header-row (inline-size < 24em) {
  .km-brand { gap: 6px !important; }
  .km-header-actions { gap: 4px !important; }
  .km-m-catalog { height: 38px; padding: 0 10px 0 8px; gap: 4px; font-size: 13px; }
  .km-mlang__chip { width: 38px; height: 38px; padding: 0; justify-content: center; }
  .km-mlang__code,
  .km-mlang__chevron { display: none; }
  .km-mlang__flag { width: 28px; height: 28px; }
  .km-mlang__menu { right: -45px; transform-origin: calc(100% - 64px) -8px; }
  .km-mlang__menu::before { right: 58px; }
}

@container header-row (inline-size < 20em) {
  .km-m-catalog { width: 38px; padding: 0; justify-content: center; }
  .km-m-catalog__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@keyframes km-m-sheen {
  0%, 70% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

@keyframes km-m-needle {
  0%, 82%, 100% { transform: rotate(0); }
  88% { transform: rotate(-25deg); }
  94% { transform: rotate(15deg); }
}

@keyframes km-mlang-ripple {
  to { transform: scale(26); opacity: 0; }
}

@keyframes km-mlang-flip {
  0% { transform: rotateY(0) scale(1); }
  50% { transform: rotateY(90deg) scale(0.9); }
  100% { transform: rotateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .km-m-catalog::after,
  .km-nav-item--catalog::before,
  .km-m-catalog__needle { animation: none !important; }
  .km-mlang__menu,
  .km-mlang.is-open .km-mlang__menu,
  .km-mlang__option,
  .km-mlang.is-open .km-mlang__option {
    transition: opacity 0.12s linear, visibility 0s !important;
    transform: none !important;
  }
  .km-mlang.is-switching .km-mlang__flag { animation: none; }
}

@media (max-width: 400px) {
  .km-header-inner { padding-inline: 10px !important; }
}
