nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 0 2rem;
  height: calc(64px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--nav-bg, rgba(10,10,11,0.88));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: background 0.3s, border-color 0.3s;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.nav-logo-icon {
  width: 34px; height: 34px;
  background: var(--blue);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}

.nav-logo-text {
  font-family: var(--display);
  font-size: 16px; font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-badge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent-color, var(--text3));   /* text follows the selected courier's colour */
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
  transition: color 0.4s;
}

/* Header: stay hidden until the language and sizes are applied (set by i18n.js), then fade in */
.nav-logo, .nav-right { transition: opacity 0.2s ease; }
html.js:not(.ready) .nav-logo,
html.js:not(.ready) .nav-right { opacity: 0; }

.nav-link, .nav-cta { white-space: nowrap; }

.nav-link {
  font-size: 13px;
  color: var(--text2);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover { color: var(--text); background: var(--bg3); }

.nav-cta {
  font-size: 13px;
  font-weight: 500;
  color: var(--on-accent, #fff);
  background-color: var(--accent-color, var(--blue));
  padding: 8px 16px;
  border-radius: 9px;
  text-decoration: none;
  transition: background-color var(--glide, 0.8s) ease-in-out, color var(--glide, 0.8s) ease-in-out, filter 0.15s;
}

.nav-cta:hover { filter: brightness(0.9); }

/* LANGUAGE */
.lang-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: none;
  border: 1px solid var(--border2);
  color: var(--text2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 4px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.lang-btn:hover, .lang-btn[aria-expanded="true"] { color: var(--text); border-color: var(--text3); background: var(--bg3); }

.lang-menu {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top, 0px) - 6px);
  right: 12px;
  z-index: 250;
  min-width: 160px;
  padding: 6px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  display: none;
}

.lang-menu.open { display: block; }

.lang-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text2);
  font-family: var(--sans);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.lang-item:hover { background: var(--bg2); color: var(--text); }
.lang-item.active { color: var(--text); font-weight: 500; }
.lang-check { color: var(--accent-color, var(--blue)); }

/* THEME TOGGLE */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.theme-toggle-track {
  display: flex;
  align-items: center;
  width: 56px;
  height: 30px;
  border-radius: 20px;
  background: #1e1e24;
  border: 1.5px solid rgba(255,255,255,0.15);
  position: relative;
  transition: background 0.3s, border-color 0.3s;
}

:root.light .theme-toggle-track {
  background: #e0e3ea;
  border-color: rgba(0,0,0,0.18);
}

.theme-toggle:hover .theme-toggle-track { filter: brightness(1.15); }

.theme-toggle-thumb {
  position: absolute;
  width: 24px; height: 24px;
  border-radius: 50%;
  background-color: var(--accent-color, var(--blue));
  left: 3px;
  transition: left 0.3s cubic-bezier(0.4,0,0.2,1), background-color 0.4s ease-in-out;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  z-index: 1;
}

.theme-toggle.light-mode .theme-toggle-thumb,
:root.light .theme-toggle-thumb { left: calc(100% - 27px); }

.theme-icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  transition: opacity 0.2s;
  z-index: 2;
  pointer-events: none;
}

.theme-icon-moon { left: 3px; color: white; opacity: 1; }
.theme-icon-sun  { right: 3px; color: #7a7a88; opacity: 0.7; }

.theme-toggle.light-mode .theme-icon-moon,
:root.light .theme-icon-moon { color: #7a7a88; opacity: 0.7; }
.theme-toggle.light-mode .theme-icon-sun,
:root.light .theme-icon-sun  { color: #44444e; opacity: 1; }

:root.light #logoCloud  { display: none !important; }
:root.light #logoParcel { display: block !important; }

@media (max-width: 600px) {
  nav { padding: 0 1rem; }
  .nav-badge { display: none; }
  .nav-hide-sm { display: none; }

  /* header on phones: larger text, and controls sized for fingers */
  .nav-logo-text { font-size: 15px; }
  .nav-link { font-size: 14px; }
  .lang-btn { width: 36px; height: 36px; position: relative; }
  .lang-btn svg { width: 18px; height: 18px; }
  .lang-btn::after { content: ''; position: absolute; inset: -4px; }   /* touch area of 44px around the 36px circle */
}

@media (min-width: 390px) and (max-width: 600px) {
  .nav-logo-text { font-size: 16px; }
}


/* ── Header behaviour shared by every page: copied unchanged from landing.css so all pages match ── */
/* LANDING PAGE */
.nav-cta-ghost { display: none; }
.nav-links { display: flex; align-items: center; gap: 4px; }
@media (max-width: 600px) {
  /* same header as desktop: logo + name, page links, track button, theme toggle.
  Sizes are compact here and landing.js scales the row down further if a phone is narrower. */
  nav { padding-left: 0.5rem; padding-right: 0.5rem; }
  .nav-logo { gap: 6px; flex-shrink: 0; }
  .nav-right { gap: 0; flex-shrink: 0; }
  .nav-links { gap: 0; }
  .nav-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; white-space: nowrap; }
  /* at the top the page links sit on the right; after scrolling they slide away and the button takes their place */
  .nav-right { flex: 0 0 auto; }
  .nav-links {
  flex: 0 0 auto; justify-content: flex-end; max-width: var(--links-w, 320px); overflow: hidden;
  transition: max-width 0.3s ease, opacity 0.25s ease, visibility 0s;
  }
  .nav-link { flex-shrink: 0; }
  html:not(.at-top) .nav-links {
  max-width: 0; opacity: 0; visibility: hidden; pointer-events: none;
  transition: max-width 0.3s ease, opacity 0.2s ease, visibility 0s linear 0.3s;
  }
  html:not(.ready) .nav-links { transition: none; }
  /* no movement while the page is still loading */
  /* "Track a parcel": hidden at the top of the page (its space collapses), slides open after scrolling */
  .nav-cta {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 13px; margin-left: 4px;
  font-size: 14px; white-space: nowrap; max-width: var(--cta-w, 150px); overflow: hidden;
  transition: max-width 0.3s ease, padding 0.3s ease, margin 0.3s ease, opacity 0.25s ease, transform 0.25s ease,
  background-color var(--glide) ease-in-out, color var(--glide) ease-in-out, filter 0.15s;
  }
  html.at-top .nav-cta {
  max-width: 0; padding-left: 0; padding-right: 0; margin-left: 0;
  opacity: 0; transform: translateY(-4px); visibility: hidden; pointer-events: none;
  transition: max-width 0.3s ease, padding 0.3s ease, margin 0.3s ease, opacity 0.2s ease, transform 0.2s ease,
  visibility 0s linear 0.3s, background-color var(--glide) ease-in-out, color var(--glide) ease-in-out;
  }
  html:not(.ready) .nav-cta { transition: none; }
  /* no movement while the page is still loading */
  /* invisible copy that tells the page how wide the real button will be (see landing.js) */
  .nav-cta-ghost {
  display: inline-flex; position: absolute; visibility: hidden; pointer-events: none;
  padding: 0 13px; margin-left: 4px; font-size: 14px; white-space: nowrap; font-weight: 500;
  }
  .theme-toggle { padding: 7px 0; margin-left: 5px; flex-shrink: 0; }
  /* full size: 56 x 30 with a 44px touch area */
  .lang-btn { margin-left: 2px; }
}
@media (max-width: 389px) {
  .nav-link { padding: 0 5px; }
}
@media (max-width: 340px) {
  .nav-link { padding: 0 3px; font-size: 13px; }
  .nav-cta, .nav-cta-ghost { font-size: 13px; padding-left: 10px; padding-right: 10px; }
  .nav-logo { gap: 5px; }
  .lang-btn { width: 32px; height: 32px; }
  .lang-btn svg { width: 16px; height: 16px; }
  .lang-btn::after { inset: -6px; }
  .theme-toggle { zoom: 0.88; padding: 9px 0; }
}
