/* MedAI shared nav bar (medai-nav.js) — the one bar on top of every MedAI page.
 *
 * Colours come from the variables digest.css defines (both pages load it). Desktop: logo,
 * the four destinations with the current one highlighted, then language (a globe menu) /
 * theme / user on the right. Phones (≤720px): logo, the current page's name and ☰; the ☰ opens a
 * full-width panel with the destinations, language, theme and sign-out. Nothing in the
 * bar is wider than the viewport at 320px: the title truncates, the logo is the mark only.
 */
/* the pages mount the bar into <div id="medai-nav">: that wrapper is what sticks (a sticky
   child of a box exactly its own height never moves) */
#medai-nav { position: sticky; top: 0; z-index: 20; touch-action: manipulation; }
#medai-nav a, #medai-nav button, #medai-nav [role="menuitem"], #medai-nav [role="menuitemradio"],
#medai-nav a *, #medai-nav button * { touch-action: manipulation; }
.mn {
  position: relative;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.mn-in {
  max-width: 1320px; margin: 0 auto; height: 60px; display: flex; align-items: center; gap: 12px;
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
}
.mn-brand { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 700; font-size: 17px; letter-spacing: .02em; flex: none; text-decoration: none; min-width: 0; }
.mn-brand:hover { text-decoration: none; }
.mn-brand img { border-radius: 7px; width: 28px; height: 28px; }
.mn-brand span { white-space: nowrap; }
.mn-title { display: none; }
.mn-items { display: flex; align-items: center; gap: 2px; margin-left: 8px; min-width: 0; }
.mn-item {
  padding: 6px 11px; border-radius: 8px; color: var(--fg-2); font-size: 14px; white-space: nowrap;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-width: 0;
  transition: background-color .14s ease, color .14s ease;
}
.mn-item:hover { background: var(--surface-2); color: var(--fg); text-decoration: none; }
.mn-item.on { background: var(--brand-soft); color: var(--fg); font-weight: 600; }
.mn-item[aria-current="page"] { background: var(--brand-soft); color: var(--fg); font-weight: 600; }
.mn-right { margin-left: auto; display: flex; align-items: center; gap: 6px; min-width: 0; }
/* language and theme: an icon button each; the menu under it lists the choices, the current
   one checked */
.mn-langwrap { position: relative; flex: none; }
.mn .icon-btn.mn-drop[aria-expanded="true"] { background: var(--surface-2); color: var(--fg); }
.mn-langmenu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 168px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}
.mn-langmenu[hidden], .mn-langlist[hidden] { display: none; }
.mn-lang-item {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 10px;
  border: 0; border-radius: 7px; background: none; color: var(--fg); font: inherit; font-size: 14px; text-align: left;
  cursor: pointer; white-space: nowrap; transition: background-color .12s ease;
}
.mn-lang-item:hover, .mn-lang-item:focus-visible { background: var(--surface-2); outline: none; }
.mn-lang-item[aria-checked="true"] { font-weight: 600; }
.mn-lang-item svg { color: var(--brand); }
.mn .icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; flex: none;
  border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--fg-2); font-size: 20px; line-height: 1;
  transition: background-color .14s ease, color .14s ease;
}
.mn .icon-btn:hover { background: var(--surface-2); color: var(--fg); }
.mn .who { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; flex: none; text-decoration: none; transition: background-color .14s ease; }
.mn .who:hover { background: var(--surface-2); text-decoration: none; }
.mn .who-av { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; display: block; border: 1px solid var(--line); }
.mn .who-av-fallback { display: grid; place-items: center; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; border-color: transparent; }
.mn .bar-link { padding: 6px 10px; border-radius: 8px; color: var(--fg-2); background: none; border: 0; cursor: pointer; font-size: 13.5px; white-space: nowrap; transition: background-color .14s ease, color .14s ease; }
.mn .bar-link:hover { background: var(--surface-2); color: var(--fg); }
.mn .mn-more { display: none; font-size: 22px; }

/* phones: the ☰ panel. Kept in the DOM once; rebuilt on every open. */
.mn-pop { display: none; }
.mn-pop a, .mn-pop button.item {
  display: flex; width: 100%; align-items: center; min-height: 44px; padding: 10px 12px; border-radius: 9px; border: 0;
  background: none; color: var(--fg); font-size: 15px; text-align: left; cursor: pointer; text-decoration: none;
  transition: background-color .12s ease;
}
.mn-pop a:hover, .mn-pop button.item:hover { background: var(--surface-2); text-decoration: none; }
.mn-pop a.on { background: var(--brand-soft); font-weight: 600; }
.mn-pop .mn-langrow { gap: 10px; }
.mn-pop .mn-langrow svg { color: var(--fg-2); }
.mn-pop .mn-langcur { margin-left: auto; color: var(--muted); font-size: 14px; }
.mn-pop .mn-langrow svg:last-child { transition: transform .15s; }
.mn-pop .mn-langrow[aria-expanded="true"] svg:last-child { transform: rotate(90deg); }
.mn-pop .mn-langlist { padding: 0 0 4px 28px; }
.mn-pop .mn-lang-item { padding: 10px; font-size: 15px; }
.mn-pop .who-line { padding: 8px 12px 6px; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mn-pop .mn-sep { height: 1px; background: var(--line); margin: 6px 0; }
.mn-pop .mn-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 0 2px; }
.mn-pop .mn-row button.item { flex: 1 1 110px; min-width: 0; justify-content: center; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; white-space: nowrap; }

@media (max-width: 720px) {
  .mn-in { height: 54px; gap: 8px; }
  .mn-brand span { display: none; }
  .mn-brand img { width: 28px; height: 28px; }
  .mn-title { display: block; flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 15px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mn-items, .mn-right .mn-langwrap, .mn-right .who, .mn-right .bar-link { display: none !important; }
  .mn .mn-more { display: inline-flex; }
  .mn-pop {
    display: block; position: absolute; left: 0; right: 0; top: 100%;
    background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 12px 32px rgba(0, 0, 0, .16);
    padding: 6px 12px calc(10px + env(safe-area-inset-bottom)); max-height: calc(100vh - 54px); overflow: auto;
  }
  .mn-pop[hidden] { display: none; }
}
@media (max-width: 360px) {
  .mn-in { padding: 0 10px; gap: 6px; }
  .mn .icon-btn { width: 30px; }
}
