/* ==========================================================================
   LNLN UIS SDK — the uniform top bar embedded in every app.
   Self-contained; uses the app's --accent*/--bg-* tokens (from uis_head()),
   with fallbacks. One clean bar: brand · app links · switcher · profile.
   Fully responsive: on narrow screens the app links collapse into a drawer.
   ========================================================================== */

.uis-bar {
    --uis-h: 54px;
    position: sticky !important; top: 0 !important; z-index: 1000 !important;
    height: var(--uis-h) !important; min-height: var(--uis-h);
    /* Bulletproof horizontal layout — host-app CSS must not restack it. */
    display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important;
    align-items: center !important; gap: .5rem !important;
    width: auto !important; box-sizing: border-box;
    margin: 0 !important; padding: 0 .8rem !important;
    background: color-mix(in srgb, var(--bg-secondary, #101010) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border, #262626);
    color: var(--text-primary, #fff);
    font-family: "Lexend", system-ui, sans-serif;
}
/* Direct children never stretch to full width (which would stack them). */
.uis-bar > * { flex: 0 0 auto; }
.uis-bar > .uis-bar-spacer { flex: 1 1 auto !important; }
.uis-bar > .uis-bar-links { flex: 0 1 auto; }
.uis-bar * { box-sizing: border-box; }

.uis-bar-burger { display: none; background: none; border: none; color: var(--text-secondary, #d4d4d4);
    font-size: 22px; cursor: pointer; padding: 4px; border-radius: 8px; }
.uis-bar-burger:hover { background: var(--bg-tertiary, #1a1a1a); }
.uis-bar-burger iconify-icon { pointer-events: none; }

.uis-bar-brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: inherit;
    padding: .2rem .4rem; border-radius: 8px; flex-shrink: 0; }
.uis-bar-brand:hover { background: var(--bg-tertiary, #1a1a1a); }
.uis-bar-brand img { height: 22px; width: auto; display: block; }
.uis-bar-appname { font-weight: 700; font-size: .92rem; white-space: nowrap; }

/* App's own nav links, inline */
.uis-bar-links { display: flex; align-items: center; gap: .15rem; margin-left: .5rem; overflow: hidden; }
.uis-bar-links a { display: flex; align-items: center; gap: .4rem; padding: .45rem .7rem; border-radius: 8px;
    text-decoration: none; color: var(--text-secondary, #d4d4d4); font-size: .88rem; white-space: nowrap;
    transition: background .14s, color .14s; }
.uis-bar-links a:hover { background: var(--bg-tertiary, #1a1a1a); color: var(--text-primary, #fff); }
.uis-bar-links a.active { color: var(--accent, #5a9fff); background: var(--accent-0t1, rgba(90,159,255,.1)); font-weight: 600; }
.uis-bar-links iconify-icon { font-size: 17px; }

.uis-bar-spacer { flex: 1; }

.uis-bar-btn, .uis-bar-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%; background: transparent; border: none; cursor: pointer;
    color: var(--text-secondary, #d4d4d4); font-size: 20px; padding: 0; flex-shrink: 0;
    transition: background .16s, transform .16s, color .16s;
}
.uis-bar-btn:hover, .uis-bar-avatar:hover { background: var(--bg-tertiary, #1a1a1a); transform: translateY(-1px); }
.uis-bar-avatar { overflow: hidden; }
.uis-bar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.uis-avatar-fallback { width: 100%; height: 100%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent, #5a9fff); color: var(--accent-ink, #fff); font-weight: 700; font-size: .9rem; }

/* Dropdown panels (apps + profile) — anchored to the viewport's right edge so
   they never open off-screen; high z-index so they sit above app content.
   Elevated "glass console" look: a layered dark surface with a faint accent
   wash at the top-right, a hairline highlight along the top edge, and a deep
   soft shadow so the panel reads as floating glass rather than a flat box. */
.uis-panel {
    /* Shared chrome only. POSITION is set per-breakpoint below (desktop dropdown
       vs mobile bottom sheet) so the two never conflict. */
    position: fixed; overflow-y: auto;
    background:
        radial-gradient(120% 80% at 100% 0%, var(--accent-0t1, rgba(90,159,255,.10)) 0%, transparent 55%),
        linear-gradient(180deg, color-mix(in srgb, var(--bg-elevated, #161616) 96%, #fff) 0%, var(--bg-elevated, #161616) 42%);
    border: 1px solid var(--border, #262626);
    border-radius: 18px;
    box-shadow: 0 24px 60px -12px rgba(0,0,0,.62), 0 4px 14px rgba(0,0,0,.4),
        inset 0 1px 0 rgba(255,255,255,.05);
    padding: .55rem; z-index: 1100;
    transform-origin: top right; animation: uis-pop .18s cubic-bezier(.2,.8,.2,1);
}
@keyframes uis-pop { from { opacity: 0; transform: scale(.96) translateY(-6px); } to { opacity: 1; transform: none; } }
.uis-panel-head { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 600;
    color: var(--text-muted, #737373); padding: .5rem .55rem .55rem; display: flex; align-items: center; gap: .45rem; }
.uis-panel-head::before { content: ""; width: 5px; height: 5px; border-radius: 50%;
    background: var(--accent, #5a9fff); box-shadow: 0 0 8px var(--accent, #5a9fff); flex-shrink: 0; }
/* Search topbar for the apps panel — a full-width field that filters live. */
.uis-apps-search { position: relative; display: flex; align-items: center; margin: .15rem .15rem .5rem; }
.uis-apps-search iconify-icon { position: absolute; left: .7rem; font-size: 17px; color: var(--text-muted, #737373);
    pointer-events: none; transition: color .14s; }
.uis-apps-search input { width: 100%; box-sizing: border-box; padding: .6rem .8rem .6rem 2.15rem;
    font-family: inherit; font-size: .86rem; color: var(--text-primary, #fff);
    background: color-mix(in srgb, var(--bg-primary, #0a0a0a) 55%, transparent);
    border: 1px solid var(--border, #262626); border-radius: 11px; outline: none;
    transition: border-color .14s, background .14s, box-shadow .14s; }
.uis-apps-search input::placeholder { color: var(--text-muted, #737373); }
.uis-apps-search input:focus { border-color: var(--accent-0t2, rgba(90,159,255,.4));
    background: color-mix(in srgb, var(--bg-primary, #0a0a0a) 30%, transparent);
    box-shadow: 0 0 0 3px var(--accent-0t1, rgba(90,159,255,.1)); }
.uis-apps-search input:focus + iconify-icon, .uis-apps-search:focus-within iconify-icon { color: var(--accent, #5a9fff); }

.uis-apps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; min-width: 264px; padding: .1rem;
    /* Cap at ~3 rows of tiles (a row ≈ 96px), then scroll with a custom bar.
       Edge-fade masks the clip so tiles dissolve into the scroll area. */
    max-height: 306px; overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: var(--border-light, #404040) transparent;
    -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
    mask-image: linear-gradient(180deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%); }
.uis-apps-grid::-webkit-scrollbar { width: 8px; }
.uis-apps-grid::-webkit-scrollbar-track { background: transparent; margin: 6px 0; }
.uis-apps-grid::-webkit-scrollbar-thumb { background: var(--border-light, #3a3a3a); border-radius: 99px;
    border: 2px solid transparent; background-clip: padding-box; }
.uis-apps-grid::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--accent, #5a9fff) 55%, var(--border-light, #3a3a3a)); background-clip: padding-box; }
/* Each app is a tile: an accent-tinted icon chip stacked over its name. On hover
   the tile lifts and the icon chip brightens with a soft accent glow — no border
   outlines, just depth and light. */
.uis-app { display: flex; flex-direction: column; align-items: center; gap: .45rem; padding: .7rem .3rem .6rem; border-radius: 14px;
    text-decoration: none; color: var(--text-secondary, #d4d4d4); font-size: .72rem; font-weight: 500; text-align: center;
    transition: background .16s, transform .16s, box-shadow .16s; }
.uis-app-ic { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 13px; font-size: 24px;
    background: linear-gradient(160deg, var(--bg-tertiary, #1e1e1e), color-mix(in srgb, var(--bg-tertiary, #1e1e1e) 82%, #000));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06); transition: transform .16s, box-shadow .16s; }
.uis-app-ic img { width: 26px; height: 26px; object-fit: contain; }
.uis-app:hover { color: var(--text-primary, #fff); }
.uis-app:hover .uis-app-ic { transform: scale(1.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08),
        0 0 0 4px var(--accent-0t1, rgba(90,159,255,.12)), 0 6px 16px -6px rgba(0,0,0,.6); }
.uis-app:active .uis-app-ic { transform: scale(1.05); }
.uis-empty { grid-column: 1/-1; text-align: center; color: var(--text-muted, #737373); padding: 1.2rem 1rem; font-size: .85rem; }
.uis-empty a { color: var(--accent, #5a9fff); text-decoration: none; font-weight: 600; }
.uis-spin { width: 22px; height: 22px; border: 2px solid var(--border, #333); border-top-color: var(--accent, #5a9fff);
    border-radius: 50%; animation: uis-spin .7s linear infinite; margin: 1.4rem auto; grid-column: 1/-1; }
@keyframes uis-spin { to { transform: rotate(360deg); } }

.uis-profile-panel { min-width: 288px; padding-top: 0; overflow: hidden; }
/* A subtle accent banner behind the identity block gives the profile a
   "membership card" feel instead of a bare row. */
.uis-profile-head { position: relative; display: flex; gap: .8rem; align-items: center;
    padding: 1.15rem .7rem .8rem; margin: 0 -.55rem 0; border-radius: 16px 16px 0 0;
    background:
        radial-gradient(90% 120% at 0% 0%, var(--accent-0t1, rgba(90,159,255,.14)), transparent 62%),
        linear-gradient(180deg, var(--accent-0t1, rgba(90,159,255,.08)), transparent 88%); }
.uis-profile-av { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--bg-elevated, #161616), 0 0 0 3.5px var(--accent-0t2, rgba(90,159,255,.32)),
        0 4px 12px rgba(0,0,0,.4); }
.uis-profile-id { min-width: 0; flex: 1; }
.uis-profile-name { font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: .4rem; }
.uis-profile-email { font-size: .8rem; color: var(--text-muted, #737373); }
/* Admin pill, pushed to the far right of the identity row. */
.uis-profile-badge { flex-shrink: 0; align-self: flex-start; font-size: .62rem; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase; padding: .2rem .5rem; border-radius: 999px;
    color: var(--accent, #5a9fff); background: var(--accent-0t1, rgba(90,159,255,.12));
    border: 1px solid var(--accent-0t2, rgba(90,159,255,.28)); }

/* Row 2: quick actions as square icon buttons. */
.uis-profile-quick { display: flex; gap: .4rem; padding: .7rem .55rem .35rem; }
.uis-qbtn { flex: 1; display: inline-flex; align-items: center; justify-content: center; height: 40px;
    border-radius: 11px; color: var(--text-secondary, #d4d4d4); font-size: 20px; text-decoration: none;
    background: var(--bg-tertiary, #1a1a1a); border: 1px solid var(--border, #262626);
    transition: background .14s, color .14s, transform .14s, border-color .14s; }
.uis-qbtn:hover { color: var(--accent, #5a9fff); background: var(--accent-0t1, rgba(90,159,255,.1));
    border-color: var(--accent-0t2, rgba(90,159,255,.28)); transform: translateY(-1px); }
.uis-qbtn:active { transform: translateY(0); }
.uis-qbtn-danger:hover { color: #ff8585; background: rgba(242,109,109,.12); border-color: rgba(242,109,109,.35); }

.uis-profile-actions { display: flex; flex-direction: column; gap: .15rem; padding: .55rem .1rem .2rem;
    border-top: 1px solid var(--border, #262626); margin-top: .35rem; }
.uis-profile-actions a { display: flex; align-items: center; gap: .7rem; padding: .55rem .55rem; border-radius: 11px;
    text-decoration: none; color: var(--text-secondary, #d4d4d4); font-size: .9rem; font-weight: 500;
    transition: background .14s, color .14s, transform .14s; }
.uis-profile-actions a:hover { background: var(--bg-tertiary, #1a1a1a); color: var(--text-primary, #fff); transform: translateX(2px); }
/* Leading icon sits in its own tinted chip so the action list reads as rows,
   not loose text. */
.uis-profile-actions iconify-icon { color: var(--accent, #5a9fff); font-size: 17px; width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center; border-radius: 9px;
    background: var(--accent-0t1, rgba(90,159,255,.1)); flex-shrink: 0; transition: background .14s; }
.uis-profile-actions a:hover iconify-icon { background: var(--accent-0t2, rgba(90,159,255,.2)); }
.uis-profile-foot { text-align: center; font-size: .68rem; letter-spacing: .02em; color: var(--text-muted, #737373);
    padding: .55rem .4rem .3rem; margin-top: .35rem; border-top: 1px solid var(--border, #262626); }


/* Nav panel (app's own links) — same dropdown chrome as the other panels. */
.uis-panel-nav { display: flex; flex-direction: column; gap: .1rem; }
.uis-panel-nav a { display: flex; align-items: center; gap: .7rem; padding: .7rem .6rem; border-radius: 9px;
    text-decoration: none; color: var(--text-secondary, #d4d4d4); font-size: .95rem; }
.uis-panel-nav a:hover, .uis-panel-nav a.active { background: var(--bg-tertiary, #1a1a1a); color: var(--text-primary, #fff); }
.uis-panel-nav a.active { color: var(--accent, #5a9fff); }
.uis-panel-nav iconify-icon { font-size: 20px; }

/* The menu button only surfaces on mobile (desktop shows links inline). */
.uis-bar-nav-btn { display: none; }

/* Grip handle — only visible when a panel is a bottom sheet (mobile). */
.uis-sheet-grip { display: none; }

/* Scrim behind mobile bottom-sheets. Visibility is driven ENTIRELY by the
   `hidden` attribute (toggled in JS) — never force display on, or it covers the
   page and swallows every tap. The [hidden] guard beats any display rule. */
.uis-scrim { position: fixed; inset: 0; z-index: 1150; background: rgba(0,0,0,.5);
    animation: uis-fade-in .18s ease; }
.uis-scrim[hidden], .uis-panel[hidden] { display: none !important; }
@keyframes uis-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ===== Mobile: bar keeps the SAME buttons as desktop; nav links collapse into
   the menu button; every panel becomes a bottom sheet sliding up from below. */
@media (max-width: 720px) {
    .uis-bar-links { display: none !important; }        /* links move into the menu-button sheet */
    .uis-bar-appname { display: inline !important; }
    .uis-bar-nav-btn { display: inline-flex !important; }  /* menu button appears */

    /* Every panel is a bottom sheet on mobile. */
    .uis-panel {
        top: auto; left: 0; right: 0; bottom: 0;
        width: 100%; min-width: 0; max-width: none;
        max-height: 80vh;
        border-radius: 18px 18px 0 0;
        padding: .4rem 1rem 1.4rem;
        transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
        animation: none; z-index: 1200;
        box-shadow: 0 -12px 40px rgba(0,0,0,.5);
    }
    .uis-panel.open { transform: translateY(0); }

    /* Grip handle at the top of each sheet. */
    .uis-sheet-grip { display: block; width: 38px; height: 4px; border-radius: 999px;
        background: var(--border, #3a3a3a); margin: .3rem auto .6rem; }

    /* Roomier tap targets in sheets. The sheet itself caps at 80vh and scrolls,
       so let the grid grow naturally instead of double-scrolling inside it. */
    .uis-apps-grid { grid-template-columns: repeat(4, 1fr); max-height: none; overflow: visible;
        -webkit-mask-image: none; mask-image: none; }
    .uis-profile-actions a, .uis-panel-nav a { padding: .85rem .6rem; font-size: 1rem; }
    .uis-profile-actions iconify-icon, .uis-panel-nav iconify-icon { font-size: 22px; }
}
@media (min-width: 721px) {
    .uis-scrim { display: none !important; }
    /* Desktop: top-right dropdown anchored to the viewport (never off-screen). */
    .uis-panel {
        top: 58px; right: 10px; left: auto; bottom: auto;
        min-width: 240px; max-width: min(340px, calc(100vw - 20px));
        max-height: calc(100vh - 68px);
        transform-origin: top right; animation: uis-pop .16s cubic-bezier(.2,.8,.2,1);
    }
}
