/* Language switch and picker (studio/i18n.js), shared by the landing and the studio.
   Colours follow the page tokens when present (studio), else the landing paper palette. */
html.i18n-loading body { visibility: hidden; }
/* Own palette: the landing's page tokens mean other things (and flip in dark mode),
   so the picker reads only --lang-*; the studio maps them to its theme. */
:root { --lang-bg: #fbfaf6; --lang-fg: #1e2a22; --lang-muted: #6f7366; --lang-line: #cdc9b9; --lang-raise: #efebdd;
  --lang-field: #fff; --lang-accent: #273f30; --lang-selected: #e2e8dd; }
.lang-slot { display: inline-flex; margin-left: auto; }
.rail-lang { padding: .4rem .9rem; }
.lang-pill { display: inline-flex; align-items: center; gap: .35rem; min-height: 32px; padding: 0 1.45rem 0 .6rem;
  border: 1px solid var(--lang-line); border-radius: 10px; color: var(--lang-fg); cursor: pointer;
  font: 600 .74rem/1 var(--font-mono, var(--mono, ui-monospace, monospace)); letter-spacing: .04em;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237b7f72' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right .5rem center; }
.lang-pill:focus-visible { outline: 2px solid var(--lang-accent); outline-offset: 2px; }

.lang-dialog { width: min(26rem, calc(100vw - 2rem)); max-height: min(36rem, calc(100dvh - 2rem)); padding: 0; border: 0;
  border-radius: 18px; background: var(--lang-bg); color: var(--lang-fg); box-shadow: 0 24px 60px rgb(0 0 0 / .28); }
.lang-dialog::backdrop { background: rgb(17 18 25 / .45); backdrop-filter: blur(2px); }
.lang-dialog[open] { display: flex; animation: lang-in .18s ease-out; }
.lang-panel { display: flex; flex-direction: column; width: 100%; min-height: 0; padding: 1rem 1rem .6rem; }
.lang-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.lang-title { margin: 0; font: 650 1.05rem/1.2 var(--font-body, system-ui, sans-serif); }
.lang-close { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border: 0; border-radius: 50%;
  background: var(--lang-raise); color: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer; }
.lang-search { color: var(--lang-fg); width: 100%; min-height: 44px; padding: 0 .85rem 0 2.3rem; border: 1px solid var(--lang-line); border-radius: 12px;
  background: var(--lang-field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237b7f72' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E") no-repeat .8rem center;
  color: inherit; font: 400 16px/1.2 var(--font-body, system-ui, sans-serif); }
.lang-search:focus { outline: 2px solid var(--lang-accent); outline-offset: 1px; }
.lang-list { flex: 1; min-height: 0; margin: .6rem 0 0; padding: 0; overflow-y: auto; list-style: none; overscroll-behavior: contain; }
.lang-item { color: var(--lang-fg); display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: .8rem; align-items: center;
  width: 100%; min-height: 48px; padding: .5rem .7rem; border: 0; border-radius: 10px; background: none; color: inherit;
  font: inherit; text-align: left; cursor: pointer; }
.lang-item:hover, .lang-item:focus-visible { background: var(--lang-raise); outline: none; }
.lang-item[aria-selected="true"] { background: var(--lang-selected); }
.lang-native { font-weight: 600; font-size: .98rem; }
.lang-sub { grid-row: 2; font-size: .78rem; color: var(--lang-muted); }
.lang-sub:empty { display: none; }
.lang-tag { grid-row: 1 / span 2; grid-column: 2; font: 600 .7rem/1 var(--font-mono, var(--mono, ui-monospace, monospace)); letter-spacing: .06em; color: var(--lang-muted); }
.lang-empty { margin: 1rem .7rem; color: var(--lang-muted); font-size: .9rem; }
@keyframes lang-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 560px) {
  .lang-dialog { width: 100vw; max-width: 100vw; max-height: 82dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .lang-dialog[open] { animation-name: lang-up; }
}
@keyframes lang-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lang-dialog[open] { animation: none; } }
