/* Language switcher — header + mobile drawer */
.nav-lang-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-lang-btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 50%;
  background: rgba(2, 6, 23, 0.65);
  color: #e2e8f0;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc((var(--nav-control-h, 52px) - 8px) / 2);
  min-width: calc((var(--nav-control-h, 52px) - 8px) / 2);
  height: calc((var(--nav-control-h, 52px) - 8px) / 2);
  max-height: 22px;
  padding: 0;
  overflow: hidden;
  font-size: 0.72rem;
  line-height: 1;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.nav-lang-btn:hover,
.nav-lang-btn[aria-expanded="true"] {
  border-color: rgba(74, 222, 128, 0.55);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.2);
  background: rgba(0, 32, 16, 0.45);
}

.nav-lang-btn-flag {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  pointer-events: none;
}

.nav-lang-btn-code {
  position: relative;
  z-index: 1;
  font-size: 0.48rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f8fafc;
  text-shadow:
    0 0 4px rgba(0, 0, 0, 0.95),
    0 1px 3px rgba(0, 0, 0, 0.9),
    0 0 8px rgba(0, 0, 0, 0.75);
}

.nav-lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 120;
  min-width: 168px;
  max-height: min(320px, 60vh);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(74, 222, 128, 0.35);
  background: rgba(15, 23, 42, 0.98);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  scrollbar-width: thin;
  scrollbar-color: rgba(34, 197, 94, 0.55) rgba(2, 10, 18, 0.95);
}

.nav-lang-menu::-webkit-scrollbar,
.i18n-translate-menu::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.nav-lang-menu::-webkit-scrollbar-track,
.i18n-translate-menu::-webkit-scrollbar-track {
  background: rgba(2, 10, 18, 0.95);
  border-radius: 8px;
}

.nav-lang-menu::-webkit-scrollbar-thumb,
.i18n-translate-menu::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(74, 222, 128, 0.55), rgba(34, 197, 94, 0.4));
  border-radius: 8px;
  border: 1px solid rgba(6, 40, 18, 0.8);
}

.nav-lang-menu::-webkit-scrollbar-thumb:hover,
.i18n-translate-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(134, 239, 172, 0.7);
}

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

.nav-lang-option {
  appearance: none;
  width: 100%;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
}

.nav-lang-option:hover {
  background: rgba(34, 197, 94, 0.12);
  color: #ecfdf5;
}

.nav-lang-option-active {
  background: rgba(34, 197, 94, 0.2);
  color: #bbf7d0;
  font-weight: 600;
}

.nav-lang-flag {
  flex-shrink: 0;
}

.nav-lang-flag-img {
  width: 1.35rem;
  height: 1rem;
  border-radius: 2px;
  object-fit: cover;
}

.nav-cluster--left .nav-lang-wrap {
  margin-right: 4px;
}

.nav-mobile-bar .nav-lang-wrap {
  position: static;
  transform: none;
  flex-shrink: 0;
}

.nav-drawer-lang {
  display: none;
}

.nav-drawer-lang-slot .nav-lang-wrap--drawer-circle {
  position: relative;
}

.nav-lang-btn--drawer-circle {
  width: 28px;
  min-width: 28px;
  height: 28px;
  max-height: 28px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(34, 197, 94, 0.45);
  background: rgba(2, 6, 23, 0.85);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.12);
  box-sizing: border-box;
  overflow: hidden;
  flex-shrink: 0;
}

.nav-lang-btn--drawer-circle .nav-lang-btn-code {
  display: none !important;
}

.nav-lang-btn--drawer-circle .nav-lang-btn-flag {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  border-radius: 50%;
}

/* Mobile / app toolbar: ☰ left, flag right, same row height */
.nav-mobile-toolbar {
  display: grid !important;
  grid-template-columns: var(--nav-mobile-toggle, 35px) 1fr var(--nav-mobile-toggle, 35px);
  grid-template-rows: var(--nav-mobile-toggle, 35px);
  align-items: center;
  justify-items: stretch;
  column-gap: 8px;
  box-sizing: border-box;
}

.nav-mobile-toolbar .nav-drawer-toggle {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  align-self: center;
  flex-shrink: 0;
  box-sizing: border-box;
  margin: 0 !important;
  width: var(--nav-mobile-toggle, 35px);
  min-width: var(--nav-mobile-toggle, 35px);
  height: var(--nav-mobile-toggle, 35px);
  min-height: var(--nav-mobile-toggle, 35px);
}

.nav-mobile-toolbar .nav-quick-access {
  grid-column: 2;
  grid-row: 1;
  justify-self: stretch;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 2px;
}

.nav-mobile-toolbar .nav-quick-access::-webkit-scrollbar {
  display: none;
}

.nav-quick-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: rgba(2, 6, 23, 0.82);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  -webkit-tap-highlight-color: transparent;
}

.nav-quick-link:hover,
.nav-quick-link:focus-visible,
.nav-quick-link--active {
  border-color: rgba(34, 197, 94, 0.65);
  background: rgba(34, 197, 94, 0.14);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.28);
}

.nav-quick-link-icon {
  pointer-events: none;
}

.nav-drawer-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.nav-drawer-row .nav-drawer-link {
  flex: 1;
  min-width: 0;
}

.nav-quick-pin {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(34, 197, 94, 0.28);
  background: rgba(2, 6, 23, 0.55);
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.nav-quick-pin:hover,
.nav-quick-pin:focus-visible {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.1);
}

.nav-quick-pin--active,
.nav-quick-pin[aria-pressed="true"] {
  border-color: rgba(34, 197, 94, 0.75);
  background: rgba(34, 197, 94, 0.2);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.35);
}

.nav-quick-pin-icon {
  font-size: 1.05rem;
  line-height: 1;
  pointer-events: none;
}

.nav-mobile-toolbar .nav-lang-wrap,
.nav-mobile-toolbar .nav-mobile-lang-slot,
.nav-mobile-toolbar #nav-mobile-lang {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: var(--nav-mobile-toggle, 35px);
  height: var(--nav-mobile-toggle, 35px);
  line-height: 0;
  margin: 0 !important;
}

.nav-mobile-toolbar .nav-lang-btn,
.nav-mobile-toolbar .nav-lang-btn--drawer-circle {
  width: var(--nav-mobile-toggle, 35px) !important;
  min-width: var(--nav-mobile-toggle, 35px) !important;
  height: var(--nav-mobile-toggle, 35px) !important;
  min-height: var(--nav-mobile-toggle, 35px) !important;
  max-height: var(--nav-mobile-toggle, 35px) !important;
  border-radius: 50%;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  overflow: hidden;
}

.nav-lang-menu--drawer-circle {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  left: auto;
  min-width: 180px;
  max-height: min(45vh, 280px);
  overflow-y: auto;
  z-index: 5;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.nav-lang-menu--portaled {
  position: fixed;
  z-index: 11050;
  min-width: 180px;
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
}

.i18n-partial-banner {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  max-width: min(92vw, 420px);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(74, 222, 128, 0.4);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.i18n-partial-banner[hidden] {
  display: none;
}

.i18n-partial-banner-text {
  flex: 1;
}

.i18n-partial-banner-dismiss {
  appearance: none;
  border: none;
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .nav-mobile-slot {
    display: none !important;
  }

  #nav-mobile-lang,
  .nav-mobile-lang-slot {
    display: flex !important;
  }

  .nav-drawer-lang-slot,
  .nav-drawer-lang {
    display: none !important;
  }
}

html.app-mode #nav-mobile-lang,
html.app-mode .nav-mobile-bar .nav-lang-wrap {
  display: flex !important;
}

html.app-mode .nav-drawer-lang-slot,
html.app-mode .nav-drawer-lang {
  display: none !important;
}

/* On-demand translation UI — отключён (перевод только через выбор языка) */
.i18n-translate-wrap > .i18n-translate-toolbar,
.i18n-translate-toolbar,
.i18n-translate-btn,
.i18n-translate-btn-wrap,
.i18n-translate-menu,
.i18n-translate-note {
  display: none !important;
}

.i18n-translate-wrap {
  position: static;
}

.i18n-translate-btn--active {
  border-color: rgba(74, 222, 128, 0.75);
  background: rgba(34, 197, 94, 0.15);
}

.i18n-translate-btn--loading {
  opacity: 0.55;
  cursor: wait;
}

.i18n-translate-note {
  font-size: 0.68rem;
  color: #86efac;
  letter-spacing: 0.02em;
}

.i18n-translate-icon {
  pointer-events: none;
}

.i18n-translate-wrap > .i18n-translate-toolbar {
  margin-top: 6px;
}

html[dir="rtl"] .i18n-translate-toolbar {
  flex-direction: row-reverse;
}

.i18n-translate-btn-wrap {
  position: relative;
  display: inline-flex;
}

.i18n-translate-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  bottom: auto;
  z-index: 200;
  width: min(280px, calc(100vw - 24px));
  max-height: min(320px, 52vh);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid rgba(74, 222, 128, 0.42);
  background:
    linear-gradient(165deg, rgba(8, 18, 14, 0.98) 0%, rgba(2, 6, 23, 0.98) 48%, rgba(6, 32, 22, 0.96) 100%);
  box-shadow:
    inset 0 1px 0 rgba(110, 231, 183, 0.1),
    0 0 0 1px rgba(16, 185, 129, 0.08),
    0 14px 36px rgba(0, 0, 0, 0.55),
    0 0 24px rgba(34, 197, 94, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  scrollbar-width: thin;
  scrollbar-color: rgba(34, 197, 94, 0.55) rgba(2, 10, 18, 0.95);
}

.i18n-translate-menu--portaled {
  position: fixed !important;
  z-index: 11060 !important;
  right: auto;
  bottom: auto;
}

.i18n-translate-menu-head {
  margin-bottom: 8px;
}

.i18n-translate-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.i18n-translate-menu .i18n-translate-menu-item {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 34px;
  margin: 0;
  padding: 7px 10px;
  border-radius: 11px;
  border: 1px solid rgba(34, 197, 94, 0.28);
  background:
    linear-gradient(145deg, rgba(6, 78, 59, 0.28) 0%, rgba(2, 6, 23, 0.92) 55%, rgba(20, 83, 45, 0.2) 100%);
  color: #d1fae5;
  font: 600 0.76rem/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0.01em;
  text-align: center;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(110, 231, 183, 0.1),
    0 2px 8px rgba(2, 6, 23, 0.35);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease,
    color 0.15s ease,
    transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.i18n-translate-menu .i18n-translate-menu-item:hover {
  border-color: rgba(74, 222, 128, 0.62);
  background:
    linear-gradient(145deg, rgba(16, 95, 70, 0.42) 0%, rgba(2, 10, 18, 0.95) 52%, rgba(22, 101, 52, 0.34) 100%);
  color: #ecfdf5;
  box-shadow:
    inset 0 1px 0 rgba(167, 243, 208, 0.16),
    0 0 14px rgba(34, 197, 94, 0.18);
}

.i18n-translate-menu .i18n-translate-menu-item:active {
  transform: scale(0.97);
}

.i18n-translate-menu .i18n-translate-menu-item--active {
  border-color: rgba(132, 204, 22, 0.85);
  background:
    linear-gradient(145deg, rgba(34, 120, 78, 0.55) 0%, rgba(4, 20, 14, 0.96) 50%, rgba(54, 140, 72, 0.42) 100%);
  color: #ecfccb;
  box-shadow:
    inset 0 0 0 1px rgba(190, 242, 100, 0.2),
    0 0 16px rgba(132, 204, 22, 0.24);
}

.i18n-translate-menu .i18n-translate-menu-item--original {
  grid-column: 1 / -1;
  border-color: rgba(251, 191, 36, 0.45);
  background:
    linear-gradient(145deg, rgba(66, 32, 6, 0.55) 0%, rgba(2, 6, 23, 0.94) 55%, rgba(92, 48, 8, 0.35) 100%);
  color: #fde68a;
  font-size: 0.8rem;
}

.i18n-translate-menu .i18n-translate-menu-item--original:hover {
  border-color: rgba(251, 191, 36, 0.72);
  color: #fef3c7;
  box-shadow:
    inset 0 1px 0 rgba(253, 230, 138, 0.14),
    0 0 14px rgba(251, 191, 36, 0.16);
}

.msg-bubble .i18n-translate-menu {
  right: -2px;
}

.msg-row.me .i18n-translate-menu {
  right: 0;
  left: auto;
}

.msg-row:not(.me) .i18n-translate-menu {
  left: 0;
  right: auto;
}

.msg-bubble .i18n-translate-wrap,
.msg-text-body.i18n-translate-wrap {
  display: block;
}

.msg-bubble .i18n-translate-toolbar {
  margin-top: 4px;
}

.auth-lang-fixed {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 10;
}

.auth-lang-fixed .nav-lang-menu {
  right: 0;
  left: auto;
}
