.nav {
  position: sticky;
  top: 14px;
  z-index: 30;
  direction: ltr;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 24px;
  border: 1px solid color-mix(in srgb, var(--stroke) 75%, rgba(0, 216, 255, 0.22));
  background:
    linear-gradient(115deg, rgba(127, 32, 216, 0.12), rgba(8, 173, 214, 0.08)),
    var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(120%);
}

.nav::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.05), transparent 48%);
}

.lang-wrap {
  position: relative;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.lang-trigger {
  min-width: 98px;
  height: 44px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: color-mix(in srgb, var(--surface-solid) 92%, rgba(8, 173, 214, 0.08));
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.lang-trigger:hover {
  border-color: color-mix(in srgb, var(--cyan) 55%, var(--stroke));
  box-shadow: 0 0 0 3px rgba(8, 173, 214, 0.14);
}

.lang-trigger:focus-visible,
.theme-toggle:focus-visible,
.nav-connect:focus-visible,
.nav-links a:focus-visible,
.bottom-bar a:focus-visible,
.lang-option:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.lang-current {
  font-size: 0.84rem;
  letter-spacing: 0.05em;
}

.lang-flag {
  font-size: 1rem;
  line-height: 1;
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  left: auto;
  right: 0;
  z-index: 120;
  width: 238px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background:
    linear-gradient(145deg, rgba(127, 32, 216, 0.08), rgba(8, 173, 214, 0.08)),
    var(--surface-elevated);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  direction: ltr;
  text-align: left;
  display: grid;
  gap: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.lang-wrap.is-open .lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-title {
  margin: 0;
  padding: 2px 6px 8px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.lang-option {
  width: 100%;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  min-height: 40px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.lang-option:hover {
  border-color: color-mix(in srgb, var(--cyan) 60%, var(--stroke));
  background: rgba(8, 173, 214, 0.09);
  transform: translateY(-1px);
}

.lang-option .fi {
  flex: 0 0 18px;
}

.lang-option.is-active {
  border-color: rgba(0, 216, 255, 0.55);
  background: rgba(0, 216, 255, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-solid) 90%, rgba(127, 32, 216, 0.07));
  text-decoration: none;
  color: inherit;
  direction: ltr;
  min-width: 0;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.brand:hover {
  border-color: color-mix(in srgb, var(--violet) 54%, var(--stroke));
  background: color-mix(in srgb, var(--surface-solid) 90%, rgba(127, 32, 216, 0.14));
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 28px rgba(110, 48, 210, 0.32);
  flex: 0 0 auto;
}

.brand-name {
  font-family: "Exo2Var", sans-serif;
  font-size: clamp(0.82rem, 1.15vw, 0.98rem);
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-links {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border-radius: 0.5rem;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 650;
  padding: 8px 14px;
  border-radius: 0.5rem;
  transition: color 0.2s ease, background 0.2s ease;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-links a.is-active {
  color: #fff;
  background: linear-gradient(120deg, var(--violet), var(--cyan));
}

.nav-actions {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: color-mix(in srgb, var(--surface-solid) 92%, rgba(8, 173, 214, 0.07));
  color: var(--text);
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
  justify-content: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover {
  border-color: color-mix(in srgb, var(--cyan) 55%, var(--stroke));
  box-shadow: 0 0 0 3px rgba(8, 173, 214, 0.14);
}

.theme-toggle span {
  display: none;
}

.nav-connect {
  width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: 14px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  position: relative;
  line-height: 1;
  font-size: 0;
  border-color: var(--stroke);
  background: color-mix(in srgb, var(--surface-solid) 92%, rgba(127, 32, 216, 0.07));
}

.nav-connect::before {
  content: "\f2f6";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 1.05rem;
  line-height: 1em;
  display: block;
  text-align: center;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.nav-connect.is-logout::before {
  content: "\f2f5";
}

.nav-connect:hover {
  border-color: color-mix(in srgb, var(--violet) 55%, var(--stroke));
  box-shadow: 0 0 0 3px rgba(127, 32, 216, 0.14);
}

html[dir="rtl"] .nav {
  grid-template-columns: auto 1fr auto;
}

html[dir="rtl"] .lang-dropdown {
  right: 0;
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] .lang-option {
  flex-direction: row-reverse;
  justify-content: flex-end;
  text-align: right;
}

html[dir="rtl"] .lang-title {
  text-transform: none;
  letter-spacing: 0.02em;
}

html[dir="rtl"] .lang-trigger {
  flex-direction: row-reverse;
}

html[dir="rtl"] .lang-current {
  letter-spacing: 0;
}

.bottom-bar {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 32;
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow);
}

.bottom-bar a {
  text-decoration: none;
  color: var(--muted);
  display: grid;
  gap: 4px;
  justify-items: center;
  align-content: center;
  min-height: 52px;
  border-radius: 10px;
  font-weight: 650;
  font-size: 0.77rem;
}

.bottom-bar a.is-active {
  color: #fff;
  background: linear-gradient(120deg, var(--violet), var(--cyan));
}

.bottom-bar i {
  font-size: 0.94rem;
}

@media (max-width: 1024px) {
  .nav {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand links actions";
    gap: 10px;
    padding: 11px;
  }

  .brand {
    grid-area: brand;
    justify-self: start;
    max-width: 100%;
  }

  .nav-actions {
    grid-area: actions;
  }

  .nav-links {
    grid-area: links;
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 760px) {
  .nav {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 10px;
  }

  .nav-links {
    display: none;
  }

  .brand {
    order: 1;
    justify-self: auto;
    min-width: 0;
    flex: 1 1 auto;
    justify-content: flex-start;
    padding-inline: 6px 8px;
    border-radius: 14px;
  }

  .nav-actions {
    order: 2;
    justify-self: auto;
    flex: 0 0 auto;
    gap: 8px;
    margin-inline-start: auto;
  }

  .brand-name {
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(50vw, 210px);
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
    min-height: 40px;
    justify-content: center;
    padding: 0;
    border-radius: 12px;
  }

  .nav-connect {
    padding: 0;
    width: 40px;
    height: 40px;
    min-height: 40px;
    display: inline-grid;
    place-items: center;
    line-height: 1;
    font-size: 0;
    border-radius: 12px;
  }

  .nav-connect::before {
    font-size: 1rem;
  }

  .lang-trigger {
    min-width: 92px;
    height: 40px;
    border-radius: 12px;
  }

  .lang-dropdown {
    width: min(84vw, 280px);
  }

  .nav-actions .lang-dropdown {
    right: 0;
    left: auto;
  }

  .bottom-bar {
    display: grid;
  }
}
