:root {
    --bg: #0b0b0e;
    --glass: rgb(22 22 26 / 0.62);
    --glass-strong: rgb(26 26 31 / 0.82);
    --panel: #17171b;
    --hover: rgb(255 255 255 / 0.05);
    --selected: rgb(255 255 255 / 0.09);
    --line: rgb(255 255 255 / 0.08);
    --line-strong: rgb(255 255 255 / 0.13);
    --text: #f0f0f3;
    --text-2: #a6a6b0;
    --text-3: #72727c;
    --accent: #7c6cff;
    --ok: #34d399;
    --bad: #f87171;
    --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --r-lg: 16px;
    --r-md: 10px;
    --r-sm: 7px;
    --col: 720px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }

body {
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 var(--font);
    -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 75%, white); outline-offset: 2px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

kbd {
    display: inline-grid;
    place-items: center;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 5px;
    background: rgb(255 255 255 / 0.07);
    border: 1px solid var(--line);
    color: var(--text-2);
    font: 500 11px/1 var(--font);
}

/* ---------- Wallpaper ---------- */
.wallpaper, .dim { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.wallpaper {
    background: var(--bg) center / cover no-repeat;
    transition: opacity .3s;
}
.wallpaper.plain { background-image: none; }
.dim { background: #000; opacity: .2; }

/* ---------- App frame: sidebar + window ---------- */
.app {
    --sb-w: 260px;
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: var(--sb-w) minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    transition: grid-template-columns .34s var(--ease);
}
/* The sidebar collapses smoothly; its contents keep their width and clip. */
.app[data-sidebar="closed"] { grid-template-columns: 0px minmax(0, 1fr); }
.app[data-sidebar="closed"] .sidebar { visibility: hidden; opacity: 0; transition: visibility 0s .34s, opacity .2s; }
.app[data-sidebar="open"] #sb-show { display: none; }

.icon-btn {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-2);
    text-decoration: none;
}
.icon-btn { transition: background .15s, color .15s, transform .18s var(--ease); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(.9); }
.icon-btn:disabled { opacity: .35; cursor: default; pointer-events: none; }
.icon-btn[hidden] { display: none; }
.icon-btn[aria-pressed="true"] { background: var(--selected); color: var(--text); }

/* ---------- Sidebar ---------- */
.sidebar {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    padding: 12px 8px 10px;
    background: rgb(18 18 22 / 0.72);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(30px) saturate(1.5);
    -webkit-backdrop-filter: blur(30px) saturate(1.5);
    transition: opacity .25s;
}
.sidebar > * { min-width: calc(var(--sb-w) - 17px); }
.sb-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 32px; padding: 0 0 0 8px; margin-bottom: 10px; }
.sb-brand { display: flex; align-items: center; gap: 9px; min-width: 0; font-weight: 600; font-size: 13.5px; }
.sb-brand img { border-radius: 5px; flex: none; }
.sb-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { position: relative; flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.tab-pill {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 0;
    border-radius: 9px;
    background: rgb(255 255 255 / 0.11);
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.05), 0 1px 2px rgb(0 0 0 / 0.3);
    opacity: 0;
    pointer-events: none;
}
.tab-pill.ready { transition: transform .32s var(--ease), height .32s var(--ease), opacity .2s; }
.tabs .tab { z-index: 1; }
.sb-label { margin: 16px 10px 6px; color: var(--text-3); font-size: 11.5px; font-weight: 600; }
.list { display: flex; flex-direction: column; gap: 2px; }
.sb-empty { margin: 4px 10px; color: var(--text-3); font-size: 12.5px; }

.tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 36px;
    padding: 0 6px 0 9px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font-size: 13.5px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    outline: none;
    transition: background .12s;
}
.tab:hover { background: var(--hover); }
.tab[aria-current="page"]:hover { background: transparent; }
.tab .item-icon, .tab-glyph { transition: transform .2s var(--ease); }
.tab:active .item-icon, .tab:active .tab-glyph { transform: scale(.9); }
.tab:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 80%, white); }
.tab-glyph { flex: none; display: grid; place-items: center; width: 20px; height: 20px; color: var(--text-2); }
.tab-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.tab .kbds { opacity: 0; transition: opacity .12s; }
.tab:hover .kbds { opacity: 1; }

.item-icon {
    flex: none;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    object-fit: cover;
    background: #fff;
    box-shadow: 0 0 0 1px var(--line-strong);
}
.item-text { flex: 1; display: flex; min-width: 0; }
.item-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { display: none; }
.tab { transition: background .15s, height .25s var(--ease); }

.status { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12.5px; }
.status::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.status[data-state="checking"]::before { animation: pulse 1.2s ease-in-out infinite; }
.status[data-state="up"] { color: var(--text-2); }
.status[data-state="up"]::before { background: var(--ok); }
.status[data-state="down"] { color: color-mix(in srgb, var(--bad) 70%, var(--text-2)); }
.status[data-state="down"]::before { background: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }
.tab .status { flex: none; padding: 0 4px; }


.more {
    flex: none;
    display: none;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
}
.tab:hover .more, .more:focus-visible { display: grid; }
.more:hover { background: rgb(255 255 255 / 0.1); color: var(--text); }
@media (hover: none) { .tab .more { display: grid; } }

.sb-foot { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.hint { margin: 2px 10px; color: var(--text-3); font-size: 12px; }
.sb-scrim { display: none; }

/* ---------- Window ---------- */
.window {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: transparent;
    overflow: hidden;
    transition: background .3s;
}
.window[data-view="detail"], .window[data-view="game"] { background: #0f0f12; }

.toolbar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 48px;
    padding: 0 10px;
    border-bottom: 1px solid var(--line);
    background: rgb(20 20 24 / 0.72);
    backdrop-filter: blur(30px) saturate(1.5);
    -webkit-backdrop-filter: blur(30px) saturate(1.5);
}
.address {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    max-width: 560px;
    height: 32px;
    margin: 0 auto;
    padding: 0 12px;
    border-radius: 9px;
    background: rgb(255 255 255 / 0.06);
    color: var(--text-2);
    font-size: 13px;
}
.address img { flex: none; border-radius: 3px; background: #fff; }
.address span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-actions { display: flex; align-items: center; gap: 4px; }
.clock { padding: 0 6px 0 8px; color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: pre; }

.content { position: relative; flex: 1; min-height: 0; }
.stage, .detail, .frames { position: absolute; inset: 0; }
.stage, .detail { overflow-y: auto; }

/* ---------- Start Page ---------- */
.stage { padding: clamp(32px, 9vh, 96px) 24px 40px; }
.stage > * { width: min(920px, 100%); margin-left: auto; margin-right: auto; }

.profile { display: flex; align-items: center; gap: 18px; margin-bottom: 40px; }
.avatar {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    padding: 0;
    border-radius: 50%;
    border: 0;
    overflow: hidden;
    background: color-mix(in srgb, var(--accent) 62%, #1a1a1f);
    box-shadow: 0 0 0 2px rgb(255 255 255 / 0.14), 0 8px 24px -8px rgb(0 0 0 / 0.6);
    color: #fff;
    font-weight: 600;
    font-size: 22px;
    letter-spacing: -0.02em;
    text-decoration: none;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
a.avatar:hover { box-shadow: 0 0 0 2px rgb(255 255 255 / 0.32), 0 8px 24px -8px rgb(0 0 0 / 0.6); }

.profile-text { min-width: 0; }
.greet-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; }
#greet-name.enter { animation: fade .45s ease-out both; }
.plan-badge {
    padding: 3px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 24%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
    color: color-mix(in srgb, var(--accent) 45%, white);
    font-size: 12px;
    font-weight: 600;
    animation: fade .45s ease-out both;
}
#greeting {
    margin: 0;
    font-size: clamp(1.6rem, 3.4vw, 2.1rem);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.025em;
    overflow-wrap: anywhere;
    text-shadow: 0 1px 12px rgb(0 0 0 / 0.35);
}
#subline { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }

.section-label { margin-top: 0; margin-bottom: 14px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.favs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.fav {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    column-gap: 16px;
    align-items: center;
    padding: 22px;
    min-height: 176px;
    border-radius: var(--r-lg);
    border: 1px solid var(--line);
    background: rgb(22 22 26 / 0.62);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 20px 50px -24px rgb(0 0 0 / 0.75);
    backdrop-filter: blur(28px) saturate(1.4);
    -webkit-backdrop-filter: blur(28px) saturate(1.4);
    text-align: left;
    transition: border-color .15s, background .15s;
}
.fav:hover { border-color: rgb(255 255 255 / 0.2); background: rgb(30 30 36 / 0.82); }
.fav-icon { grid-row: 1 / 3; width: 68px; height: 68px; border-radius: 16px; object-fit: cover; background: #fff; box-shadow: 0 0 0 1px var(--line-strong); }
.fav-name { align-self: end; font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.fav-brand { align-self: start; color: var(--text-3); font-size: 14.5px; }
.fav-desc { grid-column: 1 / -1; align-self: start; margin-top: 16px; color: var(--text-2); font-size: 13.5px; line-height: 1.5; }

.empty-state { grid-column: 1 / -1; padding: 34px 16px 38px; text-align: center; color: var(--text-2); }
.empty-state strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }

.keys {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 28px;
    color: var(--text-3);
    font-size: 12.5px;
}

/* ---------- Options menu ---------- */
.actions {
    position: fixed;
    z-index: 40;
    width: 250px;
    padding: 5px;
    border-radius: 12px;
    background: rgb(28 28 33 / 0.96);
    border: 1px solid var(--line-strong);
    box-shadow: 0 18px 48px -12px rgb(0 0 0 / 0.8);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    text-align: left;
    animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-3px); } }
.actions-title { padding: 6px 8px; color: var(--text-3); font-size: 12px; font-weight: 500; }
.action {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 32px;
    padding: 0 8px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    text-align: left;
    font-size: 13px;
}
.action[aria-selected="true"] { background: var(--selected); }
.action svg { color: var(--text-2); flex: none; }
.action > span:first-of-type { flex: 1; }
.kbds { display: inline-flex; gap: 3px; }

/* ---------- Client page ---------- */
/* A client before launching (or after closing): just who it is and Launch. */
.detail { display: grid; place-items: center; padding: 24px; }
.dcard { display: flex; flex-direction: column; align-items: center; text-align: center; width: min(420px, 100%); }
.dh-logo {
    width: 84px;
    height: 84px;
    border-radius: 21px;
    background: #fff;
    object-fit: cover;
    box-shadow: 0 0 0 1px var(--line-strong), 0 18px 40px -16px rgb(0 0 0 / 0.9);
}
.dcard h1 { margin: 18px 0 0; font-size: 26px; font-weight: 650; letter-spacing: -0.025em; }
.dh-meta { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 4px 0 0; color: var(--text-2); font-size: 13.5px; }
.dcard-actions { display: flex; gap: 8px; margin-top: 24px; }
.dcard-actions .btn { height: 42px; padding: 0 16px; gap: 8px; border-radius: 11px; }
.dcard-links { display: flex; gap: 8px; margin-top: 16px; color: var(--text-3); font-size: 12.5px; }
.dcard-links .text-btn { font-size: 12.5px; }
.launch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    padding: 0 20px;
    border: 0;
    border-radius: 11px;
    background: #f2f2f5;
    color: #111114;
    font-size: 14.5px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 8px 24px -12px rgb(0 0 0 / 0.9);
    transition: background .15s, transform .15s var(--ease);
}
.launch:hover { background: #fff; transform: translateY(-1px); }
.launch:active { transform: translateY(0) scale(.98); }

/* Tab icon picker */
.icons { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-opt { position: relative; display: grid; justify-items: center; gap: 6px; width: 62px; cursor: pointer; }
.icon-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.icon-face {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgb(0 0 0 / 0.25);
    color: var(--text-2);
    transition: border-color .18s, background .18s, transform .18s var(--ease), box-shadow .18s;
}
.icon-face img { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; }
.icon-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); font-size: 11.5px; }
.icon-opt:hover .icon-face { transform: translateY(-2px); background: rgb(255 255 255 / 0.05); }
.icon-opt input:checked + .icon-face { border-color: transparent; box-shadow: 0 0 0 2px var(--accent); background: rgb(255 255 255 / 0.06); }
.icon-opt input:checked ~ .icon-name { color: var(--text); }
.icon-opt input:focus-visible + .icon-face { outline: 2px solid color-mix(in srgb, var(--accent) 75%, white); outline-offset: 3px; }

/* Live browser-tab preview */
.tabprev { margin: 16px 0 2px; border-radius: 11px; overflow: hidden; background: #1c1c21; border: 1px solid var(--line); }
.tabprev-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(260px, 70%);
    height: 34px;
    margin: 8px 0 0 10px;
    padding: 0 10px 0 12px;
    border-radius: 9px 9px 0 0;
    background: #2b2b31;
    font-size: 12.5px;
}
.tabprev-tab img { flex: none; border-radius: 3px; }
.tabprev-tab span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabprev-tab i { color: var(--text-3); font-style: normal; }
.tabprev-bar { padding: 7px 10px 9px; background: #2b2b31; }
.tabprev-bar span { display: block; height: 22px; border-radius: 11px; background: rgb(0 0 0 / 0.3); }

/* Two-choice segmented control */
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 9px; background: rgb(0 0 0 / 0.3); border: 1px solid var(--line); justify-self: end; width: 100%; max-width: 240px; }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span { display: grid; place-items: center; height: 28px; border-radius: 6px; color: var(--text-2); font-size: 12.5px; font-weight: 500; transition: background .18s, color .18s; }
.seg input:checked + span { background: rgb(255 255 255 / 0.1); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.4); }
.seg input:focus-visible + span { outline: 2px solid color-mix(in srgb, var(--accent) 75%, white); }
.client-form .keyrow { justify-content: flex-end; }
.client-form .recorder { min-width: 96px; height: 32px; }

/* ---------- Client settings window (shares .prefs) ---------- */
.cs-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cs-brand img { flex: none; width: 36px; height: 36px; border-radius: 10px; background: #fff; }
.cs-brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cprefs .tabprev { margin: 16px 0 6px; }
.cprefs .icons { gap: 6px; }
.cprefs .block .row-text { margin-bottom: 10px; }
.cprefs .row > .btn { justify-self: end; }
.cprefs .row-text p a { color: var(--text-2); text-decoration: none; }
.cprefs .row-text p a:hover { color: var(--text); text-decoration: underline; }
.prefs .seg { justify-self: end; width: 100%; max-width: 240px; }

/* ---------- Entrance animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }
.stage.enter > *, .detail.enter .dcard > * { animation: rise .5s var(--ease) both; }
.stage.enter > :nth-child(2) { animation-delay: .05s; }
.stage.enter > :nth-child(3) { animation-delay: .09s; }
.stage.enter > :nth-child(4) { animation-delay: .13s; }
.detail.enter .dcard > :nth-child(2) { animation-delay: .04s; }
.detail.enter .dcard > :nth-child(3) { animation-delay: .07s; }
.detail.enter .dcard > :nth-child(4) { animation-delay: .1s; }
.detail.enter .dcard > :nth-child(5) { animation-delay: .13s; }
.game-frame.enter { animation: fade .35s ease-out both; }
#t-settings.enter svg, #d-settings.enter svg { animation: cog-turn .8s cubic-bezier(.3, 0, .15, 1); }
#t-reload.enter svg { animation: reload-turn .75s cubic-bezier(.3, 0, .15, 1); }
@keyframes cog-turn { to { transform: rotate(180deg); } }
@keyframes reload-turn { to { transform: rotate(360deg); } }
.fav { transition: border-color .2s, background .2s, transform .25s var(--ease), box-shadow .25s; }
.fav:hover { transform: translateY(-3px); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 26px 50px -22px rgb(0 0 0 / 0.85); }
.fav:active { transform: translateY(-1px) scale(.99); }
.fav-icon { transition: transform .3s var(--ease); }
.fav:hover .fav-icon { transform: scale(1.04); }
.address span { transition: opacity .2s; }
.wallpaper { transition: background-image .4s, opacity .3s; }

/* ---------- Games running in the launcher ---------- */
.frames { background: #000; }
.game-frame { display: block; width: 100%; height: 100%; border: 0; background: #000; }

/* ---------- Settings window ---------- */
.scrim {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgb(0 0 0 / 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fade .28s ease-out;
}
/* Windows and dropdowns fade out before they hide (conceal() in launcher.js). */
.scrim.closing, .prefs.closing, .dd-list.closing { pointer-events: none; }
.scrim.closing { animation: fade-out .17s ease-in both; }
@keyframes fade-out { to { opacity: 0; } }

.prefs {
    position: fixed;
    z-index: 21;
    top: 50%;
    left: 50%;
    width: min(860px, calc(100vw - 32px));
    height: min(600px, calc(100vh - 32px));
    transform: translate(-50%, -50%);
    display: grid;
    grid-template-columns: 200px 1fr;
    border-radius: var(--r-lg);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 40px 100px -20px rgb(0 0 0 / 0.85);
    overflow: hidden;
    animation: prefs-in .34s cubic-bezier(.16, 1, .3, 1);
}
.prefs.closing { animation: prefs-out .17s ease-in both; }
.prefs:focus { outline: none; }
@keyframes prefs-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 14px)) scale(.965); } }
@keyframes prefs-out { to { opacity: 0; transform: translate(-50%, calc(-50% + 8px)) scale(.98); } }

.prefs-nav {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 16px 10px 12px;
    background: rgb(255 255 255 / 0.02);
    border-right: 1px solid var(--line);
}
.prefs-nav h2 { margin: 6px 10px 18px; font-size: 23px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.2; color: var(--text); }
/* The highlight glides between sections, like the sidebar's tab pill. */
.nav-pill {
    position: absolute;
    top: 0; left: 0;
    border-radius: var(--r-sm);
    background: var(--selected);
    pointer-events: none;
    transition: transform .32s var(--ease), width .32s var(--ease), height .32s var(--ease);
}
.nav-item {
    position: relative;
    height: 31px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-2);
    text-align: left;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s, color .2s;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[aria-current="true"] { background: transparent; color: var(--text); }
.nav-foot { margin-top: auto; padding: 8px 10px; }
.danger-link { padding: 0; border: 0; background: none; color: color-mix(in srgb, var(--bad) 85%, white); font-size: 12.5px; }
.danger-link:hover { text-decoration: underline; }

.prefs-body { display: flex; flex-direction: column; min-width: 0; overflow-y: auto; }
.prefs-head {
    flex: none;
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 54px;
    padding: 0 12px 0 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
.prefs-head h3 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
.prefs-head h3.enter { animation: fade .28s ease-out; }
.saved { color: var(--text-3); font-size: 12.5px; }
.close {
    display: grid;
    place-items: center;
    width: 30px; height: 30px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-2);
}
.close:hover { background: var(--hover); color: var(--text); }

.pane { padding: 6px 28px 28px; }
.pane.enter { animation: pane-in .34s var(--ease) backwards; }
@keyframes pane-in { from { opacity: 0; transform: translateY(var(--from, 10px)); } }
.acct-card {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    background: rgb(255 255 255 / 0.03);
    animation: pane-in .34s var(--ease) backwards;
}
.acct-head { display: flex; align-items: center; gap: 16px; padding: 18px; }
.acct-avatar { flex: none; width: 78px; height: 90px; filter: drop-shadow(0 4px 10px rgb(0 0 0 / 0.35)); }
.acct-avatar img { display: block; width: 100%; height: 100%; object-fit: contain; }
.acct-avatar.letter {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: var(--selected);
    font-size: 28px;
    font-weight: 600;
}
.acct-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acct-name { font-size: 20px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.acct-sub { color: var(--text-2); font-size: 13px; }
.acct-figures { display: flex; flex-wrap: wrap; gap: 1px; margin: 0; border-block: 1px solid var(--line); background: var(--line); }
.acct-figures > div { flex: 1 1 30%; display: flex; flex-direction: column; gap: 1px; padding: 12px 18px; min-width: 0; background: var(--panel); }
.acct-figures dd { margin: 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.acct-figures dt { color: var(--text-2); font-size: 12px; }
.acct-foot { margin: 0; padding: 10px 18px; color: var(--text-2); font-size: 12.5px; }
.alts-empty { margin-top: 14px; padding: 28px 22px; border: 1px dashed var(--line-strong); border-radius: 14px; text-align: center; }
.alts-empty strong { display: block; font-size: 15px; font-weight: 600; }
.alts-empty p { margin: 6px auto 0; max-width: 40ch; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.alt-list { margin: 10px 0 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.alt { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.alt + .alt { border-top: 1px solid var(--line); }
.alt-avatar { flex: none; width: 34px; height: 39px; display: grid; place-items: center; color: var(--text-2); font-weight: 600; }
.alt-avatar img { display: block; width: 100%; height: 100%; object-fit: contain; }
.alt-name { min-width: 0; flex: 1; font-size: 14px; overflow-wrap: anywhere; }
.alt-main { flex: none; padding: 2px 9px; border-radius: 999px; background: var(--selected); font-size: 12px; font-weight: 550; }
.pane-note { margin: 16px 0 4px; color: var(--text-2); font-size: 13px; }

.row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 280px);
    align-items: center;
    gap: 24px;
    padding: 15px 0;
    border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-stack { grid-template-columns: 1fr; gap: 12px; }
.block { padding: 18px 0; border-bottom: 1px solid var(--line); }
.block .row-text { margin-bottom: 12px; }
.row-text label, .row-text .label { display: block; font-size: 13.5px; font-weight: 550; color: var(--text); }
.row-text p { margin: 3px 0 0; color: var(--text-3); font-size: 12.5px; }

.prefs input[type="text"], .prefs input[type="url"], .dd {
    width: 100%;
    height: 34px;
    padding: 0 11px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: rgb(0 0 0 / 0.25);
    color: var(--text);
    font-size: 13.5px;
    transition: border-color .15s, box-shadow .15s;
}
.prefs input::placeholder { color: var(--text-3); }
.prefs input:focus, .dd:focus-visible, .dd[aria-expanded="true"] {
    outline: none;
    border-color: color-mix(in srgb, var(--accent) 70%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.prefs input[type="range"] { width: 100%; accent-color: var(--accent); }

/* Dropdowns: a native <select> stays underneath holding the value. */
.dd-wrap { position: relative; min-width: 0; }
.dd-wrap select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.dd {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
}
.dd:hover { border-color: rgb(255 255 255 / 0.22); }
.dd-value { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd svg { flex: none; color: var(--text-2); transition: transform .24s var(--ease); }
.dd[aria-expanded="true"] svg { transform: rotate(180deg); }
.dd-list {
    position: fixed;
    z-index: 30;
    max-height: 320px;
    overflow-y: auto;
    padding: 5px;
    border-radius: 11px;
    background: rgb(30 30 35 / 0.97);
    border: 1px solid var(--line-strong);
    box-shadow: 0 18px 48px -12px rgb(0 0 0 / 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    transform-origin: top center;
    animation: dd-in .2s var(--ease);
}
.dd-list.up { transform-origin: bottom center; }
.dd-list.closing { animation: dd-out .13s ease-in both; }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px) scale(.97); } }
@keyframes dd-out { to { opacity: 0; transform: scale(.98); } }
.dd-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 32px;
    padding: 0 9px;
    border-radius: var(--r-sm);
    font-size: 13.5px;
    cursor: pointer;
    transition: background .1s;
}
.dd-opt.active { background: var(--selected); }
.dd-opt[aria-selected="true"] { font-weight: 550; }
.dd-opt[aria-selected="true"]::after { content: '✓'; color: color-mix(in srgb, var(--accent) 60%, white); }

.btn {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: rgb(255 255 255 / 0.08);
    font-size: 13px;
    font-weight: 550;
    cursor: pointer;
}
.btn:hover { background: rgb(255 255 255 / 0.12); }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover { color: var(--text); }
.form-error { margin: 8px 0 0; color: color-mix(in srgb, var(--bad) 85%, white); font-size: 12.5px; }

/* Wallpaper picker */
.walls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.wall {
    position: relative;
    aspect-ratio: 16 / 10;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: #222 center / cover;
    box-shadow: inset 0 0 0 1px var(--line-strong);
    overflow: hidden;
}
.wall[aria-checked="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.wall-label {
    position: absolute;
    left: 6px;
    bottom: 5px;
    font-size: 11.5px;
    font-weight: 550;
    text-shadow: 0 1px 4px rgb(0 0 0 / 0.8);
}
.wall-none { background: var(--bg); }
.wall-upload { display: grid; place-items: center; background: rgb(255 255 255 / 0.04); color: var(--text-2); cursor: pointer; }
.wall-upload:hover { background: rgb(255 255 255 / 0.08); color: var(--text); }
.wall-upload span { display: grid; justify-items: center; gap: 4px; font-size: 12px; font-weight: 500; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.swatch {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 0;
    background: var(--sw);
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.18);
}
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--sw); }
.swatch-custom {
    position: relative;
    overflow: hidden;
    background: conic-gradient(#f87171, #fbbf24, #34d399, #38bdf8, #a78bfa, #f472b6, #f87171);
    cursor: pointer;
}
.swatch-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.switch { justify-self: end; position: relative; width: 36px; height: 21px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgb(255 255 255 / 0.14); transition: background .18s; }
.switch span::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 17px; height: 17px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.4);
    transition: transform .18s cubic-bezier(.3, .7, .4, 1);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(15px); }
.switch input:focus-visible + span { outline: 2px solid color-mix(in srgb, var(--accent) 75%, white); outline-offset: 2px; }

.segmented {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 3px;
    border-radius: 9px;
    background: rgb(0 0 0 / 0.3);
    border: 1px solid var(--line);
}
.segmented label { position: relative; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span { display: grid; place-items: center; height: 29px; border-radius: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.segmented input:checked + span { background: rgb(255 255 255 / 0.1); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.4); }
.segmented input:focus-visible + span { outline: 2px solid color-mix(in srgb, var(--accent) 75%, white); }

.keyrow { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.recorder {
    min-width: 116px;
    height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: rgb(0 0 0 / 0.25);
    font-size: 13px;
    font-weight: 600;
}
.recorder.listening { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.text-btn { padding: 0; border: 0; background: none; color: var(--text-2); font-size: 13px; }
.text-btn:hover { color: var(--text); }

.tab-preview { margin-top: 18px; }
.tp-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 240px;
    height: 34px;
    padding: 0 14px;
    border-radius: 10px 10px 0 0;
    background: #2a2a30;
    font-size: 12.5px;
}
.tp-tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-bar { height: 10px; border-radius: 0 8px 8px 8px; background: #2a2a30; }

/* Client settings: drag to the bookmarks bar */
.bookmark {
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 38px;
    padding: 0 14px 0 9px;
    border-radius: 10px;
    border: 1px dashed rgb(255 255 255 / 0.28);
    background: rgb(255 255 255 / 0.07);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: grab;
    transition: background .15s, border-color .15s, transform .18s var(--ease);
}
.bookmark:hover { background: rgb(255 255 255 / 0.12); border-color: color-mix(in srgb, var(--accent) 70%, white); transform: translateY(-1px); }
.bookmark:active { cursor: grabbing; transform: scale(.97); }
.bookmark img { width: 22px; height: 22px; border-radius: 6px; background: #fff; pointer-events: none; }

/* Client settings: Info */
.info-block { padding: 16px 0; border-bottom: 1px solid var(--line); }
.info-block h4 { margin: 0; font-size: 13.5px; font-weight: 550; }
.info-block p { margin: 4px 0 0; color: var(--text-2); font-size: 13px; line-height: 1.55; }
.info-link { word-break: break-all; }

.game-row .row-text { display: flex; align-items: center; gap: 12px; }
.game-row img { width: 28px; height: 28px; border-radius: 7px; background: #fff; box-shadow: 0 0 0 1px var(--line-strong); }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
    .app, .app[data-sidebar="closed"] { grid-template-columns: minmax(0, 1fr); }
    /* The sidebar slides over the window. */
    .sidebar {
        position: fixed;
        z-index: 30;
        top: 0; bottom: 0; left: 0;
        width: min(290px, calc(100vw - 48px));
        background: rgb(22 22 26 / 0.96);
        box-shadow: 20px 0 60px -20px rgb(0 0 0 / 0.8);
        transition: transform .32s var(--ease), visibility 0s;
    }
    .sidebar > * { min-width: 0; }
    .app[data-sidebar="closed"] .sidebar { opacity: 1; transform: translateX(-105%); transition: transform .28s var(--ease), visibility 0s .28s; }
    .app[data-sidebar="open"] #sb-show { display: grid; }
    .sb-scrim { display: block; position: fixed; inset: 0; z-index: 29; background: rgb(0 0 0 / 0.45); animation: fade .25s ease-out; }
    .clock, .keys, .tab .kbds { display: none; }
    .stage { padding: 28px 16px 32px; }
    .favs { grid-template-columns: 1fr; }
    .fav { min-height: 0; }
    .dcard-actions { flex-wrap: wrap; justify-content: center; }
    .seg, .prefs .seg { justify-self: start; max-width: none; }
    .cprefs .row > .btn { justify-self: start; }
    .segmented { grid-template-columns: repeat(3, 1fr); }
    .prefs { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .prefs-nav { flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
    .prefs-nav h2, .nav-foot { display: none; }
    .nav-item { flex: none; }
    .row { grid-template-columns: 1fr; gap: 10px; }
    .switch, .swatches, .keyrow { justify-self: start; justify-content: flex-start; }
    .bookmark { justify-self: start; }
    .pane, .prefs-head { padding-left: 18px; padding-right: 18px; }
    .walls { grid-template-columns: repeat(3, 1fr); }
}

@media (hover: none) {
    .keys { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

#t-inject[data-result="ok"] { color: var(--ok); }
.toasts {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(360px, calc(100vw - 36px));
    padding: 11px 15px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: rgb(22 22 26 / 0.96);
    color: var(--text);
    font-size: 13.5px;
    box-shadow: 0 16px 40px -12px rgb(0 0 0 / 0.6);
    opacity: 0;
    transform: translateY(10px) scale(.98);
    transition: opacity .22s ease, transform .22s var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast svg { flex: none; color: var(--text-2); }
