/* LingoScreen panel (brand: Miso). Green = primary actions, orange = highlights; the dual-subtitle
   caption (white over yellow) stays the signature motif. Light by default, dark with the system setting. */
:root {
    --bg: #F5F8F6;
    --surface: #FFFFFF;
    --raised: #EAF1ED;
    --edge: #DCE5E0;
    --text: #12201B;
    --muted: #56675F;
    --brand: #0A7A4F;
    --brand-press: #08633F;
    --on-brand: #FFFFFF;
    --accent: #B4501A;
    --helper: #B4501A;      /* second heading line (the "helper subtitle") on the page background */
    --focus: #B4501A;
    --star: #E0A100;
    --danger: #B3261E;
    --hover: rgba(10, 122, 79, .06);
    --rail-bg: rgba(255, 255, 255, .78);
    --glow-a: rgba(29, 180, 122, .14);
    --glow-b: rgba(255, 138, 61, .10);
    --caption: #FFD54F;     /* the real subtitle yellow, always on a dark TV screen */
    --tv-1: #24453A;
    --tv-2: #14231E;
    --tv-3: #070D0B;
    --r-sm: 10px;
    --r-md: 16px;
    --r-lg: 24px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0B1512;
        --surface: #14231E;
        --raised: #1D3129;
        --edge: #24372F;
        --text: #F1F6F3;
        --muted: #9DB3AA;
        --brand: #2BCB8A;
        --brand-press: #23B079;
        --on-brand: #04291B;
        --accent: #FF9A55;
        --helper: #FFD54F;
        --focus: #FFD54F;
        --star: #FFD54F;
        --danger: #FF8A80;
        --hover: rgba(255, 255, 255, .04);
        --rail-bg: rgba(11, 21, 18, .74);
        --glow-a: rgba(29, 180, 122, .16);
        --glow-b: rgba(255, 138, 61, .08);
        color-scheme: dark;
    }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1200px 600px at 85% -10%, var(--glow-a), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, var(--glow-b), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font: 500 16px/1.55 Manrope, system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}
a { color: inherit; }
.sprite { position: absolute; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico.big { width: 44px; height: 44px; stroke-width: 1.4; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* ---------- Shell: side rail on wide screens, bottom tab bar on phones ---------- */
.signed-in .page { margin-left: 248px; }
.page { max-width: 1000px; padding: 48px 48px 120px; }
.rail {
    position: fixed; inset: 0 auto 0 0; width: 248px; padding: 28px 18px;
    display: flex; flex-direction: column; gap: 32px;
    background: var(--rail-bg); border-right: 1px solid var(--edge);
    backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font: 800 21px/1 Nunito, Manrope, system-ui, sans-serif; letter-spacing: -.015em; }
.brand img { flex: none; }
.brand b { font-weight: 800; color: var(--brand); }
.brand.big { font-size: 27px; margin-bottom: 28px; }
.rail-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.rail-nav a {
    display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--r-sm);
    text-decoration: none; color: var(--muted); font-weight: 600;
    transition: background .2s var(--ease), color .2s var(--ease);
}
.rail-nav a:hover { color: var(--text); background: var(--hover); }
.rail-nav a.active { color: var(--text); background: var(--raised); box-shadow: inset 3px 0 0 var(--brand); }
.rail-logout button { width: 100%; justify-content: flex-start; }

/* ---------- Page heading as a pair of subtitles (the one orchestrated motion) ---------- */
.caption-head { margin-bottom: 36px; }
.caption-head .line-top { margin: 0; font-size: clamp(30px, 4vw, 42px); font-weight: 800; letter-spacing: -.025em; line-height: 1.1; }
.caption-head .line-bottom { margin: 10px 0 0; color: var(--helper); font-size: 17px; font-weight: 600; }
.caption-head > * { animation: caption-in .5s var(--ease) both; }
.caption-head .line-bottom { animation-delay: .18s; }
@keyframes caption-in { from { opacity: 0; transform: translateY(8px); filter: blur(3px); } }

/* ---------- Surfaces ---------- */
.panel {
    background: linear-gradient(180deg, var(--hover), transparent 40%), var(--surface);
    border: 1px solid var(--edge); border-radius: var(--r-lg);
    padding: 28px; margin-bottom: 20px;
}
.panel h2 { margin: 0 0 8px; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.panel > .muted { margin: 0 0 20px; max-width: 64ch; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 28px 12px; color: var(--muted); }
.empty p { margin: 0; max-width: 42ch; }

/* ---------- Controls ---------- */
.stack { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 14px; color: var(--muted); font-weight: 600; }
input, select {
    font: inherit; color: var(--text); background: var(--bg);
    border: 1px solid var(--edge); border-radius: var(--r-sm);
    padding: 13px 15px; min-height: 50px; width: 100%;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
input:focus, select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 18%, transparent); }
.btn, button.ghost {
    font: inherit; font-weight: 700; cursor: pointer; border: 1px solid transparent;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 50px; padding: 0 22px; border-radius: 999px;
    transition: transform .15s var(--ease), background .2s var(--ease), border-color .2s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: var(--on-brand); box-shadow: 0 10px 28px -12px color-mix(in srgb, var(--brand) 80%, transparent); }
.btn.primary:hover { background: var(--brand-press); }
.btn.wide { width: 100%; }
.btn.subtle { background: transparent; border-color: var(--edge); color: var(--text); min-height: 42px; padding: 0 16px; }
.btn.subtle:hover { background: var(--raised); }
.btn.danger { color: var(--danger); }
button.ghost { background: none; color: var(--muted); min-height: 44px; padding: 0 14px; }
button.ghost:hover { color: var(--text); background: var(--hover); }

/* ---------- Toasts (flash messages) ---------- */
.toasts { position: fixed; top: 20px; right: 20px; z-index: 20; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
    padding: 14px 18px; border-radius: var(--r-md); background: var(--raised); border: 1px solid var(--edge);
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .45);
    animation: toast-in .45s var(--ease) both, toast-out .4s var(--ease) 5.5s forwards;
}
.toast.ok { border-left: 4px solid var(--brand); }
.toast.error { border-left: 4px solid var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); visibility: hidden; } }

/* ---------- Login ---------- */
.signed-out .page { max-width: 1100px; margin: 0 auto; min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; }
.login { display: grid; grid-template-columns: 1.1fr 1fr; gap: 56px; align-items: center; width: 100%; }
.login-card h1 { margin: 0 0 8px; font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.login-card > .muted { margin: 0 0 28px; }
.tv { padding: 14px; border-radius: 22px; background: linear-gradient(160deg, #22392F, #0B1512); box-shadow: 0 40px 80px -40px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .06); }
.tv-screen {
    position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden;
    background: radial-gradient(120% 90% at 30% 20%, #2E5A48 0%, var(--tv-2) 55%, var(--tv-3) 100%);
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; padding: 0 8% 7%;
}
.cap { font-weight: 800; text-shadow: 0 2px 6px #000, 0 0 2px #000; text-align: center; line-height: 1.25; }
.cap-top { color: #fff; }
.cap-bottom { color: var(--caption); }
.login-stage .cap { font-size: clamp(16px, 2.2vw, 24px); opacity: 0; animation: caption-in .6s var(--ease) forwards; }
.login-stage .cap-top { animation-delay: .5s; }
.login-stage .cap-bottom { animation-delay: .9s; }

/* Miso sits on the TV and says hello: breathing, tail swish, head tilt, blink, ear flick, a wave now and then. */
.login-stage { position: relative; padding-top: 27%; }
.miso { position: absolute; top: 0; right: 7%; width: 31%; height: auto; overflow: visible; filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .22)); }
.miso g, .miso path { transform-box: view-box; }
.miso-tail { transform-origin: 154px 214px; animation: miso-tail 4.2s ease-in-out infinite alternate; }
.miso-body { transform-origin: 120px 226px; animation: miso-breathe 3.2s ease-in-out infinite alternate; }
.miso-head { transform-origin: 120px 150px; animation: miso-tilt 7s ease-in-out infinite alternate; }
.miso-eyes { transform-origin: 120px 101px; animation: miso-blink 5.5s ease-in-out infinite; }
.miso-ear-l { transform-origin: 88px 76px; animation: miso-ear 9s ease-in-out infinite; }
.miso-arm { transform-origin: 146px 184px; animation: miso-wave 6.5s ease-in-out infinite; }
.miso-lines { opacity: 0; animation: miso-lines 6.5s ease-in-out infinite; }
@keyframes miso-tail { from { transform: rotate(-6deg); } to { transform: rotate(7deg); } }
@keyframes miso-breathe { to { transform: scale(1.008, 1.02); } }
@keyframes miso-tilt { from { transform: rotate(-2.5deg); } to { transform: translateY(-1px) rotate(3deg); } }
@keyframes miso-blink { 0%, 88%, 96%, 100% { transform: scaleY(1); } 92% { transform: scaleY(.08); } }
@keyframes miso-ear { 0%, 68%, 80%, 100% { transform: rotate(0); } 71%, 77% { transform: rotate(-13deg); } 74% { transform: rotate(-3deg); } }
@keyframes miso-wave {
    0%, 52%, 88%, 100% { transform: rotate(0); }
    58%, 72% { transform: rotate(-14deg); }
    65%, 79% { transform: rotate(8deg); }
}
@keyframes miso-lines { 0%, 52%, 88%, 100% { opacity: 0; } 58%, 82% { opacity: .9; } }

/* ---------- Devices ---------- */
.pair { display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: center; }
.pair-form { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.code-boxes { display: flex; gap: 8px; }
.code-boxes .digit {
    width: 52px; min-height: 64px; padding: 0; text-align: center; font-size: 28px; font-weight: 800;
    background: var(--bg); border-radius: 12px;
}
.code-boxes .digit:nth-child(3) { margin-right: 10px; }
.code-boxes.done .digit { border-color: var(--brand); animation: pop .35s var(--ease) both; }
.code-boxes.done .digit:nth-child(2) { animation-delay: .03s; } .code-boxes.done .digit:nth-child(3) { animation-delay: .06s; }
.code-boxes.done .digit:nth-child(4) { animation-delay: .09s; } .code-boxes.done .digit:nth-child(5) { animation-delay: .12s; }
.code-boxes.done .digit:nth-child(6) { animation-delay: .15s; }
@keyframes pop { 50% { transform: translateY(-4px); } }
.devices { list-style: none; margin: 8px 0 0; padding: 0; }
.device { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; padding: 18px 0; border-top: 1px solid var(--edge); }
.device:first-child { border-top: 0; }
.device-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--raised); color: var(--muted); position: relative; }
.device-icon.online { color: var(--text); }
.device-icon.online::after { content: ""; position: absolute; right: -2px; top: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 3px solid var(--surface); }
.inline-edit { background: transparent; border-color: transparent; padding: 4px 8px; margin-left: -8px; min-height: 0; font-weight: 700; font-size: 17px; }
.inline-edit:hover { border-color: var(--edge); }
.device-meta { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 14px; }
.status.on { color: var(--brand); font-weight: 700; }

.confirm { display: grid; grid-template-columns: auto 1fr; gap: 18px 20px; align-items: start; }
.confirm .muted { margin: 4px 0 0; max-width: 60ch; }
.row-actions { grid-column: 1 / -1; display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
a.btn { text-decoration: none; }

/* ---------- Source ---------- */
.source-current { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; }
.source-current h2 { font-size: 22px; overflow-wrap: anywhere; }
.source-current .muted { margin: 0; }
.lock { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--brand) 13%, transparent); color: var(--brand); }

/* ---------- Groups ---------- */
.segments { display: inline-flex; gap: 4px; padding: 5px; border-radius: 999px; background: var(--surface); border: 1px solid var(--edge); margin-bottom: 22px; flex-wrap: wrap; }
.segments a { display: flex; align-items: baseline; gap: 8px; text-decoration: none; padding: 10px 18px; border-radius: 999px; font-weight: 700; color: var(--muted); transition: background .25s var(--ease), color .25s var(--ease); }
.segments a small { font-weight: 600; font-size: 12px; opacity: .8; }
.segments a.active { background: var(--brand); color: var(--on-brand); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 24px; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.legend i { display: inline-block; vertical-align: -3px; margin-right: 6px; }
.legend .sw { width: 30px; height: 18px; border-radius: 999px; background: var(--brand); }
.legend .star { width: 16px; height: 16px; background: var(--star); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.search { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--edge); margin-bottom: 18px; color: var(--muted); }
.search input { border: 0; background: transparent; padding-left: 0; box-shadow: none; }
.provider { border: 1px solid var(--edge); border-radius: var(--r-md); background: var(--surface); margin-bottom: 10px; overflow: hidden; }
.provider summary { list-style: none; display: flex; align-items: center; gap: 14px; padding: 16px 18px; cursor: pointer; flex-wrap: wrap; }
.provider summary::-webkit-details-marker { display: none; }
.provider-name { font-weight: 800; font-size: 17px; }
.provider-count { color: var(--muted); font-size: 14px; }
.provider-actions { margin-left: auto; display: flex; gap: 6px; }
.chev { color: var(--muted); transition: transform .25s var(--ease); }
.provider[open] .chev { transform: rotate(90deg); }
.chip { font: inherit; font-size: 13px; font-weight: 700; padding: 7px 12px; border-radius: 999px; cursor: pointer; background: var(--raised); color: var(--text); border: 1px solid var(--edge); }
.chip:hover { border-color: var(--muted); }
.group-list { list-style: none; margin: 0; padding: 0 10px 10px; }
.group-list li { display: grid; grid-template-columns: 1fr auto auto 64px; gap: 14px; align-items: center; padding: 10px 8px; border-radius: var(--r-sm); }
.group-list li:hover { background: var(--hover); }
.group-name small { margin-left: 10px; color: var(--muted); font-size: 13px; }
.switch, .star-toggle { position: relative; display: inline-block; cursor: pointer; }
.switch input, .star-toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { display: block; width: 46px; height: 28px; border-radius: 999px; background: var(--raised); border: 1px solid var(--edge); transition: background .25s var(--ease); }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .25s var(--ease), background .25s var(--ease); }
.switch input:checked + span { background: var(--brand); border-color: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--on-brand); }
.switch input:focus-visible + span, .star-toggle input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 3px; }
.star-toggle span { display: block; width: 26px; height: 26px; background: var(--edge); transition: background .2s var(--ease), transform .2s var(--ease);
    clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.star-toggle input:checked + span { background: var(--star); transform: scale(1.12); }
input.order { min-height: 40px; padding: 6px; text-align: center; }
.savebar {
    position: fixed; left: 50%; bottom: 24px; z-index: 15; transform: translate(-50%, 140%);
    display: flex; align-items: center; gap: 18px; padding: 10px 10px 10px 24px; border-radius: 999px;
    background: var(--raised); border: 1px solid var(--edge); box-shadow: 0 24px 50px -20px rgba(0, 0, 0, .8);
    transition: transform .4s var(--ease); white-space: nowrap;
}
.signed-in .savebar { left: calc(50% + 124px); }
.savebar.show { transform: translate(-50%, 0); }

/* ---------- Settings ---------- */
.settings .preview-tv { max-width: 560px; margin-bottom: 24px; }
.settings .preview-tv .tv-screen { border: 10px solid #1D3129; border-radius: 18px; transition: padding .3s var(--ease); }
.settings .preview-tv p { margin: 10px 0 0; }
.tv-screen .cap { font-size: 22px; transition: font-size .25s var(--ease), color .25s var(--ease), opacity .25s; }
.tv-screen[data-size="SMALL"] .cap { font-size: 17px; }
.tv-screen[data-size="LARGE"] .cap { font-size: 27px; }
.tv-screen[data-layout="TOP_AND_BOTTOM"] { justify-content: space-between; padding-top: 6%; }
.tv-screen[data-layout="PRIMARY_WITH_HINT"] .cap-bottom { font-size: .72em; }
.tv-screen[data-layout="PRIMARY_WITH_HINT"][data-size] .cap-bottom { font-size: 15px; }
.tv-screen[data-layout="BOXED"] .cap { background: rgba(0, 0, 0, .55); padding: 1px 10px; border-radius: 5px; }
.cap:empty { opacity: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0 20px; }
.choice { position: relative; cursor: pointer; display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: var(--r-md); border: 1px solid var(--edge); background: var(--bg); font-weight: 600; font-size: 14px; transition: border-color .2s var(--ease), background .2s var(--ease); }
.choice input, .pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.mini { position: relative; aspect-ratio: 16 / 9; border-radius: 8px; background: linear-gradient(160deg, #2E5A48, #101C18); display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; padding: 0 18% 10%; }
.mini i { display: block; height: 5px; width: 100%; border-radius: 3px; background: #fff; }
.mini i + i { background: var(--caption); width: 80%; }
.mini-top_and_bottom { justify-content: space-between; padding-top: 10%; }
.mini-primary_with_hint i + i { height: 3px; width: 60%; }
.mini-boxed i { box-shadow: 0 0 0 3px rgba(0, 0, 0, .6); }
.sizes { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { position: relative; }
.pill span { display: block; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--edge); font-weight: 700; cursor: pointer; transition: background .2s var(--ease), color .2s var(--ease); }
.pill input:checked + span { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.pill input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.actions { display: flex; justify-content: flex-end; }

/* ---------- Saved lines (phrase book) ---------- */
.phrase-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.phrase-search { flex: 1; min-width: 240px; margin: 0; padding-right: 6px; }
.phrase-search a.chip { text-decoration: none; }
.phrase-tools > .btn { min-height: 50px; }
.phrase-total { margin: 0 0 6px; }
.phrases { list-style: none; margin: 0; padding: 0; }
.phrase { display: grid; grid-template-columns: 1fr auto; gap: 10px 18px; align-items: center; padding: 18px 0; border-top: 1px solid var(--edge); }
.phrase:first-child { border-top: 0; }
.phrase-lines {
    grid-column: 1; padding: 14px 18px; border-radius: var(--r-md);
    background: radial-gradient(120% 140% at 20% 0%, var(--tv-1) 0%, var(--tv-2) 60%, var(--tv-3) 100%);
}
.phrase-lines p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; font-weight: 800; line-height: 1.35; text-shadow: 0 2px 6px #000, 0 0 2px #000; }
.phrase-top { color: #fff; font-size: 19px; }
.phrase-bottom { color: var(--caption); font-size: 17px; margin-top: 4px !important; }
.phrase-meta { grid-column: 1; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 14px; }
.phrase-title { color: var(--text); font-weight: 700; }
.phrase-delete { grid-column: 2; grid-row: 1 / span 2; }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-top: 14px; padding-top: 18px; border-top: 1px solid var(--edge); }
.pager [rel="next"] { justify-self: end; }
.pager [rel="prev"] { justify-self: start; }

/* ---------- Language picker (rail, login card, and page foot on phones) ---------- */
.lang-switch { display: flex; align-items: center; gap: 8px; }
.lang-switch label { position: relative; display: flex; align-items: center; flex: 1; color: var(--muted); }
.lang-switch label .ico { position: absolute; left: 13px; width: 18px; height: 18px; pointer-events: none; }
.lang-switch label::after { content: ""; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; margin-top: -6px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); pointer-events: none; }
.lang-switch select {
    appearance: none; -webkit-appearance: none; cursor: pointer;
    min-height: 40px; padding: 7px 36px 7px 40px; border-radius: 999px;
    background: var(--surface); font-size: 14px; font-weight: 700;
}
.lang-switch select:hover { border-color: var(--muted); }
.js .lang-go { display: none; }
.rail-lang { margin: 0 2px; }
.login-lang { margin-top: 24px; max-width: 240px; }
.page-foot { display: none; }

/* ---------- Phones: bottom tab bar ---------- */
@media (max-width: 860px) {
    .signed-in .page { margin-left: 0; }
    .page { padding: 28px 18px 120px; }
    .rail {
        inset: auto 0 0 0; width: auto; height: auto; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        flex-direction: row; gap: 0; border-right: 0; border-top: 1px solid var(--edge); z-index: 10;
    }
    .rail .brand, .rail-logout span, .rail-lang { display: none; }
    .page-foot { display: flex; justify-content: center; margin-top: 36px; }
    .page-foot .lang-switch { width: min(240px, 100%); }
    .rail-nav { flex-direction: row; justify-content: space-around; }
    .rail-nav a { flex-direction: column; gap: 4px; padding: 8px 6px; font-size: 12px; flex: 1; text-align: center; }
    .rail-nav a.active { box-shadow: inset 0 3px 0 var(--brand); }
    .rail-logout button { width: auto; height: 100%; }
    .signed-in .savebar { left: 50%; bottom: 92px; }
    .login { grid-template-columns: 1fr; gap: 28px; }
    .pair, .source-current { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .choices { grid-template-columns: repeat(2, 1fr); }
    .group-list li { grid-template-columns: 1fr auto auto 54px; gap: 10px; }
    .provider-actions { margin-left: 0; width: 100%; }
    .device { grid-template-columns: auto 1fr; }
    .device > form:last-child { grid-column: 1 / -1; }
    .phrase { grid-template-columns: 1fr; }
    .phrase-delete { grid-column: 1; grid-row: auto; }
    .phrase-top { font-size: 17px; }
    .phrase-bottom { font-size: 15px; }
}
@media (max-width: 420px) {
    .code-boxes .digit { width: 42px; min-height: 56px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
    .login-stage .cap { opacity: 1; }
    .miso, .miso * { animation: none !important; }
    .miso-lines { opacity: .9; }
}

/* Forgot / reset password and account section */
.login.single { grid-template-columns: minmax(0, 440px); justify-content: center; }
.auth-links { margin: 18px 0 0; font-size: 14px; }
.auth-links a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-links a:hover, .auth-links a:focus-visible { text-decoration: underline; }
.account-panel { margin-top: 24px; }
.account-form { max-width: 420px; }
.muted.small { font-size: 13px; margin: 0; }
.rail-version { margin: 8px 0 0; font-size: 11px; opacity: .55; text-align: center; letter-spacing: .04em; }
