/* ---------- avatars and AI glyphs ---------- */
.av { width: 22px; height: 22px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; color: #fff; font: 600 9.5px/1 var(--font); letter-spacing: 0.02em; position: relative; }
.av.md { width: 28px; height: 28px; font-size: 11px; }
.av.lg { width: 36px; height: 36px; font-size: 13px; }
.av.xl { width: 44px; height: 44px; font-size: 15px; }
/* AI apps: their real logos on their own app-icon tiles */
.ai { width: 18px; height: 18px; border-radius: 5px; flex: none; display: inline-grid; place-items: center; overflow: hidden; }
.ai svg { width: 66%; height: 66%; }
/* Logos that carry their own background (Codex) always fill the tile, wherever a page shrinks plain marks. */
.ai.full > svg { width: 100% !important; height: 100% !important; }
.ai.light { box-shadow: inset 0 0 0 1px rgb(15 18 30 / 0.1); }
.ai.xs { width: 16px; height: 16px; border-radius: 4.5px; }
.ai.sm { width: 20px; height: 20px; border-radius: 6px; }
.ai.md { width: 24px; height: 24px; border-radius: 7px; }
.ai.lg { width: 40px; height: 40px; border-radius: 11px; }
.ai.xl { width: 52px; height: 52px; border-radius: 14px; }
.logo-stack { display: inline-flex; align-items: center; }
.logo-stack .ai { box-shadow: 0 0 0 2px var(--surface); margin-left: -3px; }
.logo-stack .ai.light { box-shadow: 0 0 0 2px var(--surface), inset 0 0 0 1px rgb(15 18 30 / 0.12); }
.logo-stack .ai:first-child { margin-left: 0; }
.nav-item .logo-stack { margin-left: auto; }
.nav-item .logo-stack .ai { box-shadow: 0 0 0 2px var(--canvas); }
.av .badge { position: absolute; right: -4px; bottom: -3px; width: 13px; height: 13px; border-radius: 4px; box-shadow: 0 0 0 2px var(--surface); display: grid; place-items: center; overflow: hidden; }
.av .badge svg { width: 68%; height: 68%; }
.av .badge.full svg { width: 100%; height: 100%; }
.actor { display: inline-flex; align-items: center; gap: 6px; }
.via { color: var(--muted); }
.via b { color: var(--ink-2); font-weight: 550; }

/* ---------- overlays ---------- */
.scrim { position: fixed; inset: 0; background: rgb(11 13 18 / 0.28); display: grid; place-items: start center; padding-top: 12vh; z-index: 50; animation: fade 0.15s ease; }
.scrim.center { place-items: center; padding-top: 0; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(520px, calc(100vw - 32px)); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-modal); animation: pop 0.2s var(--ease); overflow: hidden; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.985); } }
.modal-h { display: flex; align-items: flex-start; gap: 10px; padding: 18px 20px 0; }
.modal-h h2 { margin: 0; font: 650 16px/1.3 var(--font-display); letter-spacing: -0.015em; }
.modal-h p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.modal-b { padding: 16px 20px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
.roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.role { padding: 11px 12px; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line-2); text-align: left; transition: box-shadow 0.12s, background 0.12s; }
.role:hover { background: var(--sunken); }
.role.on { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-soft); }
.role b { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; }
.role.on b { color: var(--accent-ink); }
.role span { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.link-box { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 5px 0 12px; border-radius: var(--r-md); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line); margin-top: 14px; }
.link-box code { flex: 1; font: 12.5px var(--mono); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette { width: min(620px, calc(100vw - 32px)); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-modal); overflow: hidden; animation: pop 0.18s var(--ease); }
.palette .in { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 52px; border-bottom: 1px solid var(--line); }
.palette .in input { flex: 1; border: 0; outline: none; font-size: 15px; background: none; }
.palette .res { max-height: 400px; overflow-y: auto; padding: 6px; }
.palette .grp { font-size: 11px; font-weight: 600; color: var(--faint); padding: 10px 10px 4px; }
.palette .opt { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--r); cursor: pointer; }
.palette .opt .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette .opt .t small { color: var(--muted); margin-left: 6px; font-size: 12px; }
.palette .opt.on { background: var(--hover); }
.palette .opt .ent { opacity: 0; }
.palette .opt.on .ent { opacity: 1; }
.palette .foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--faint); }
.palette .foot span { display: inline-flex; align-items: center; gap: 5px; }
.menu { position: fixed; min-width: 220px; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--sh-pop); padding: 5px; z-index: 60; animation: pop 0.14s var(--ease); }
.menu .mi { display: flex; align-items: center; gap: 9px; width: 100%; height: 32px; padding: 0 9px; border-radius: 6px; text-align: left; font-size: 12.5px; color: var(--ink-2); }
.menu .mi:hover { background: var(--hover); color: var(--ink); }
.menu .mi .r { margin-left: auto; color: var(--faint); }
.menu .ml { font-size: 11px; font-weight: 600; color: var(--faint); padding: 8px 9px 4px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 70; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 11px; border-radius: var(--r-md); background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 500; box-shadow: 0 12px 32px -8px rgb(11 13 18 / 0.45); animation: toast-in 0.25s var(--ease); }
.toast .ic { width: 20px; height: 20px; border-radius: 6px; background: rgb(255 255 255 / 0.12); display: grid; place-items: center; }
.toast button { color: #aeb3c4; font-weight: 600; margin-left: 6px; }
.toast button:hover { color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.sheet { position: fixed; top: 8px; right: 8px; bottom: 8px; width: min(480px, calc(100vw - 16px)); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-modal); z-index: 55; display: flex; flex-direction: column; animation: sheet-in 0.26s var(--ease); }
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } }
.sheet-h { display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px 20px; border-bottom: 1px solid var(--line); }
.sheet-h h2 { margin: 0; font: 650 16px/1.25 var(--font-display); letter-spacing: -0.015em; }
.sheet-h p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.sheet-b { padding: 20px; overflow-y: auto; flex: 1; }

/* ---------- prototype controls ---------- */
.proto { position: fixed; left: 12px; bottom: 12px; z-index: 80; }
.proto > button { height: 28px; padding: 0 10px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 8px 24px -6px rgb(11 13 18 / 0.5); opacity: 0.55; transition: opacity 0.15s; }
.proto > button:hover { opacity: 1; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 20px; }
.empty img { width: 200px; margin-bottom: 10px; }
.empty h3 { margin: 0; font: 600 16px/1.3 var(--font-display); letter-spacing: -0.015em; }
.empty p { margin: 6px 0 16px; color: var(--muted); font-size: 13px; }

/* ---------- switch ---------- */
.switch { width: 34px; height: 20px; border-radius: 999px; background: var(--line-2); position: relative; transition: background 0.18s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(15 18 30 / 0.25); transition: transform 0.2s var(--ease); }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(14px); }
.switch:disabled { opacity: 0.5; cursor: default; }

/* ---------- focus, loading ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field:focus-visible, [contenteditable]:focus-visible, input:focus-visible { outline: none; }
.fcard:focus-visible, .folder:focus-visible, .lrow:focus-visible, .sk-card:focus-visible { outline-offset: 3px; }
.splash { position: fixed; inset: 0; z-index: 100; background: var(--canvas); display: grid; place-items: center; transition: opacity 0.35s ease, visibility 0.35s; }
.splash.done { opacity: 0; visibility: hidden; }
.splash img { width: 88px; height: 88px; }
.loader { display: inline-block; flex: none; background: url(../assets/loader.webp) center/contain no-repeat; }
.loader.sm { width: 16px; height: 16px; } .loader.md { width: 28px; height: 28px; } .loader.lg { width: 56px; height: 56px; }
.btn .loader { filter: none; }
.btn-primary .loader { filter: brightness(0) invert(1); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- menus, dialogs ---------- */
.menu .mi.danger { color: var(--red); }
.menu .mi.danger:hover { background: var(--red-soft); color: var(--red); }
.menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 9px 6px; }
.menu-head b { display: block; font-size: 12.5px; font-weight: 600; }
.menu-head span { font-size: 11.5px; color: var(--muted); }
.ws-mark { width: 24px; height: 24px; border-radius: 7px; flex: none; display: grid; place-items: center; color: #fff; font: 650 12px/1 var(--font-display); }
.ws-mark.sm { width: 20px; height: 20px; border-radius: 6px; font-size: 10.5px; }
.ws-mark.lg { width: 32px; height: 32px; border-radius: 9px; font-size: 14px; }
.btn-danger-solid { background: var(--red); color: #fff; }
.btn-danger-solid:hover { background: #d63c41; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.keys { display: flex; flex-direction: column; }
.keys div { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.keys div:last-child { border-bottom: 0; }
.keys kbd { margin-left: 4px; font-size: 11.5px; padding: 4px 6px; color: var(--ink-2); }
.tree-box { max-height: 300px; overflow-y: auto; padding: 6px; border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--line); }
.tree-box .nav-item { width: 100%; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }
.filedrop { position: fixed; inset: 8px; border-radius: 14px; border: 2px dashed var(--accent); background: rgb(238 240 254 / 0.86); z-index: 90; display: grid; place-items: center; pointer-events: none; animation: fade 0.12s; text-align: center; }
.filedrop b { display: block; font-size: 16px; margin-top: 12px; }
.filedrop span { color: var(--muted); }
.filedrop .fd-ic { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; margin: 0 auto; }
.note { margin: 10px 0 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.code.wrap { white-space: normal; }
