/*
 * Language picker shared by the public site and the panel (lang-picker.js, Plane ECMR-35).
 * Colours come from the page: the site's tokens (--paper, --ink, --brand-*) first, the panel's (--surface, --text,
 * --accent-*) when the site's are not there, so the picker looks the same on both hosts and follows the dark theme.
 * Placement (header, drawer, sign-in screen) stays with each page; this file is the button, the popover and the items.
 */
.lang {
  --lang-surface: var(--paper, var(--surface, #fff));
  --lang-hover: var(--paper-2, var(--surface-3, #eef0f7));
  --lang-ink: var(--ink, var(--text, #0a0f2c));
  --lang-ink-2: var(--ink-2, var(--text-2, #43486a));
  --lang-line: var(--line, var(--border, #e6e8f1));
  --lang-soft: var(--brand-soft, var(--accent-soft, #efecff));
  --lang-brand: var(--brand, var(--accent, #5b3df0));
  --lang-brand-ink: var(--brand-ink, var(--accent-ink, #4526d6));
  --lang-ok: var(--ok, #0d8750);
  --lang-shadow: var(--sh-float, var(--shadow-lg, 0 28px 64px -20px rgb(10 15 44 / .3)));
  position: relative;
}
.lang-flag { flex: none; width: 20px; height: 15px; border-radius: 2px; object-fit: cover; box-shadow: 0 0 0 1px color-mix(in oklab, var(--lang-ink, #0a0f2c) 12%, transparent); }
.lang-b { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--lang-ink-2); font: inherit; }
.lang-b .chev { flex: none; transition: transform .25s var(--e-out, cubic-bezier(.2, .8, .2, 1)); }
.lang.is-open .lang-b .chev { transform: rotate(180deg); }
.lang-b:focus-visible, .lang-list a:focus-visible { outline: 2px solid var(--lang-brand); outline-offset: 2px; }
.lang-list { margin: 0; padding: 0; list-style: none; }
.lang-list[hidden] { display: none; }
.lang-list a { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 8px 10px; border-radius: 8px; font-size: 14px; line-height: 1.2; color: var(--lang-ink-2); text-decoration: none; }
.lang-list a:hover, .lang-list a:focus-visible { background: var(--lang-hover); color: var(--lang-ink); }
.lang-list a[aria-checked="true"] { background: var(--lang-soft); color: var(--lang-brand-ink); font-weight: 600; }
.lang-ok { margin-left: auto; flex: none; color: var(--lang-ok); }
.lang-list a:not([aria-checked="true"]) .lang-ok { visibility: hidden; }

/* in a bar (site header, panel topbar): the flag button and a popover under it, one column unless the page sets more */
.lang-bar .lang-b { height: 36px; padding: 0 8px; border: 1px solid transparent; border-radius: 10px; background: transparent; }
.lang-bar .lang-b:hover, .lang-bar.is-open .lang-b { background: var(--lang-hover); color: var(--lang-ink); }
.lang-bar .lang-b .lang-flag { width: 22px; height: 16px; }
.lang-bar .lang-list {
  position: absolute; top: calc(100% + var(--lang-gap, 12px)); right: -8px; z-index: 60;
  width: min(var(--lang-width, 220px), calc(100vw - 32px));
  display: grid; grid-template-columns: repeat(var(--lang-cols, 1), minmax(0, 1fr)); gap: 2px 6px;
  padding: var(--lang-pad, 8px); background: var(--lang-surface); border: 1px solid var(--lang-line); border-radius: 14px; box-shadow: var(--lang-shadow);
  transform-origin: top right; animation: lang-pop .16s var(--e-out, cubic-bezier(.2, .8, .2, 1));
}
.lang-bar .lang-list[hidden] { display: none; }
/* the button with the name (sign-in screens): a quiet outlined field */
.lang-bar.lang-named .lang-b { gap: 8px; padding: 0 10px 0 12px; border-color: var(--lang-line); background: var(--lang-surface); color: var(--lang-ink); font-weight: 500; font-size: 14px; }
@keyframes lang-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@media (prefers-reduced-motion: reduce) {
  .lang-b .chev { transition: none; }
  .lang-bar .lang-list { animation: none; }
}
