/* =============================================================================
   TiberiusOne — shared styles
   Home hero + /portal login stage (ID card, role panels) + site banner
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Design tokens
   ----------------------------------------------------------------------------- */
:root {
    --bg: #000000;
    --bg-elevated: #141414;
    --bg-card: #0c0c0c;
    --bg-card-top: #161616;
    --text: #f8f8f8;
    --text-muted: #c9c9c9;
    --text-dim: #888888;
    --text-faint: #555555;
    --border: #2e2e2e;
    --border-strong: #3a3a3a;

    --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-serif: "Playfair Display", Georgia, serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --radius-card: 14px;
    --radius-inner: 13px; /* header/footer sit just inside card radius */
    --radius-sm: 8px;
    --radius-pill: 999px;

    --space-xs: 0.5rem;
    --space-sm: 0.85rem;
    --space-md: 1.15rem;
    --space-lg: 1.25rem;
    --space-xl: 2rem;

    --card-max: 420px;
    --photo-size: 120px;
    --photo-size-sm: 96px;
    --stage-max: 960px;

    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --shadow-card: 0 18px 40px rgba(0, 0, 0, 0.55);
    --shadow-panel: 0 18px 40px rgba(0, 0, 0, 0.4);

    /* Role accents */
    --role-admin: #dc5046;
    --role-admin-text: #ffb4ae;
    --role-admin-border: #8a3a34;
    --role-admin-bg-top: #3a1816;
    --role-admin-bg-bot: #24100f;

    --role-vip: #a878ff;
    --role-vip-text: #ddc6ff;
    --role-vip-border: #6b4a9e;
    --role-vip-bg-top: #2a1a40;
    --role-vip-bg-bot: #1a1028;

    --role-guest-text: #bdbdbd;
    --role-denied-text: #c07070;
    --role-denied-border: #5a3030;
    --role-denied-bg: #1a1010;

    color-scheme: dark;
}

/* -----------------------------------------------------------------------------
   Reset / base
   ----------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
}

html {
    /* Avoid height: 100% — locks viewport and clips tall mobile pages */
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100dvh;
    margin: 0;
    padding: var(--space-xl);
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.4;
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
}

/* Landing splash: center the hero in the viewport */
body.landing-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Stage (/portal, admin pages): normal document flow so long content can scroll */
body.stage-page {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: var(--space-lg) 1rem 4rem;
    padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    color: var(--text);
}

body.stage-page.has-site-banner {
    padding-top: 0;
}

/* App shell (banner + left nav + main).
   Page may scroll vertically; nested widgets must not create their own scrollbars. */
html:has(body.app-page) {
    overflow-x: hidden;
    overflow-y: auto;
}

body.app-page {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    height: auto;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    overflow-y: visible;
}

body.app-page.has-site-banner {
    padding-top: 0;
}

/* Nested content: never grow independent scrollports (page scroll only). */
body.app-page .app-main,
body.app-page .app-main * {
    overflow-x: visible;
    overflow-y: visible;
}

/* Clip horizontal bleed without creating a scroll box (no scrollbar). */
body.app-page .app-main {
    overflow-x: clip;
}

/* -----------------------------------------------------------------------------
   Motion
   ----------------------------------------------------------------------------- */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Opacity-only — safe inside overflow/flex layouts (no transform box) */
@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* -----------------------------------------------------------------------------
   Home — coming soon
   ----------------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: 900px;
    text-align: center;
    opacity: 0;
    animation: fade-in-up 1.4s var(--ease-out) forwards;
}

.logo {
    max-width: 220px;
    height: auto;
    margin: 0 auto 3rem;
    filter: brightness(0.95);
}

.container h1 {
    margin-bottom: 1.25rem;
    color: #ffffff;
    font-family: var(--font-serif);
    font-size: clamp(3rem, 8vw, 5.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.coming-soon {
    margin-top: var(--space-xs);
    color: var(--text-muted);
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    font-weight: 500;
    letter-spacing: 0.35em;
    text-transform: uppercase;
}

/* Landing — Enter (bottom right) */
.landing-enter-btn {
    position: fixed;
    right: var(--space-lg);
    bottom: var(--space-lg);
    bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
    z-index: 100;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.4rem;
    border: 1px solid #ffffff;
    border-radius: var(--radius-pill);
    background: var(--bg-elevated);
    color: #f0f0f0;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-decoration: none;
    text-transform: uppercase;
    opacity: 0.85;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.landing-enter-btn:hover {
    opacity: 1;
    background: #1c1c1c;
}

.landing-enter-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 3px;
    opacity: 1;
}

/* -----------------------------------------------------------------------------
   App shell — left nav + main content (collapsible sidebar)
   ----------------------------------------------------------------------------- */
.app-shell {
    display: flex;
    align-items: flex-start;
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    overflow: visible;
}

.app-sidebar {
    flex: 0 0 13.5rem;
    width: 13.5rem;
    min-width: 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
    min-height: calc(100dvh - 3.25rem);
    padding: 0.85rem 0.75rem 2rem;
    border-right: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.45);
    overflow: hidden; /* collapse animation only; nav is short so no scrollbar */
    box-sizing: border-box;
}

.app-sidebar__top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.65rem;
}

.app-sidebar__toggle {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    width: auto;
    margin: 0;
    padding: 0.2rem 0.15rem;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1;
    cursor: pointer;
}

/* Quiet control: no border, no hover/focus recolor */
.app-sidebar__toggle:hover,
.app-sidebar__toggle:focus,
.app-sidebar__toggle:focus-visible {
    color: var(--text-dim);
    background: transparent;
    border: none;
    outline: none;
}

.app-sidebar__toggle-icon {
    display: inline-block;
    user-select: none;
}

/* Icons via CSS so pre-paint html.tib-nav-collapsed shows the right glyph immediately */
.app-sidebar__toggle-icon::before {
    content: "<<";
}

html.tib-nav-collapsed .app-sidebar__toggle-icon::before {
    content: ">>";
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.app-nav__link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 0.88rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    min-height: 2.4rem;
}

.app-nav__glyph {
    display: none;
    flex: 0 0 auto;
    width: 1.35rem;
    height: 1.35rem;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--text-muted);
}

.app-nav__label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-nav__link:hover {
    color: var(--text);
    background: var(--bg-elevated);
    border-color: var(--border);
}

.app-nav__link:hover .app-nav__glyph {
    color: var(--text);
    border-color: var(--border-strong);
}

.app-nav__link:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.app-nav__link--active {
    color: var(--text);
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}

.app-nav__link--active .app-nav__glyph {
    color: var(--text);
    border-color: var(--border-strong);
    background: #1c1c1c;
}

/* Collapsed: only ">>" expand control (no nav buttons).
   Prefer html.tib-nav-collapsed so state can be set before first paint. */
html.tib-nav-collapsed .app-sidebar {
    flex-basis: 2.5rem;
    width: 2.5rem;
    padding: 0.65rem 0.25rem 1rem;
    /* No width animation on first paint after navigation */
    transition: none;
}

html.tib-nav-collapsed .app-sidebar__top {
    margin-bottom: 0;
    justify-content: center;
}

html.tib-nav-collapsed .app-sidebar__toggle {
    justify-content: center;
    width: 100%;
}

html.tib-nav-collapsed .app-nav {
    display: none;
}

/* Re-enable collapse animation only after the page has settled */
html.tib-nav-ready .app-sidebar {
    transition: flex-basis 0.2s ease, width 0.2s ease, padding 0.2s ease;
}

html.tib-nav-ready.tib-nav-collapsed .app-sidebar {
    transition: flex-basis 0.2s ease, width 0.2s ease, padding 0.2s ease;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    max-width: none;
    padding: 1.25rem 1.5rem 2rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    overflow-x: clip;
    overflow-y: visible;
    box-sizing: border-box;
}

.app-main__header {
    margin-bottom: 1.25rem;
}

.app-main__header h1 {
    font-family: var(--font-serif);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #f0f0f0;
}

.app-main__lead {
    margin-top: 0.35rem;
    color: var(--text-dim);
    font-size: 0.95rem;
}

.app-main__card {
    max-width: 40rem;
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.55;
}

@media (max-width: 720px) {
    .app-shell {
        flex-direction: column;
        overflow: visible;
    }

    .app-sidebar {
        flex: 0 0 auto;
        width: 100%;
        position: static;
        min-height: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0.65rem 0.85rem;
    }

    .app-sidebar__top {
        margin-bottom: 0.5rem;
    }

    .app-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    /* Mobile collapsed: ">>" only */
    html.tib-nav-collapsed .app-sidebar {
        width: auto;
        flex-basis: auto;
        align-self: flex-start;
        padding: 0.4rem 0.35rem;
        border-bottom: none;
    }

    .app-main {
        padding: 1.15rem 1rem 2.5rem;
    }
}

/* -----------------------------------------------------------------------------
   Shared top banner — brand → /home; auth only (Login / profile)
   ----------------------------------------------------------------------------- */
.site-banner {
    position: relative;
    flex: 0 0 auto;
    z-index: 100;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0.7rem 1rem;
    padding-top: calc(0.7rem + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-sizing: border-box;
}

.site-banner__home {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    text-decoration: none;
    min-height: 2rem;
}

.site-banner__home:hover .site-banner__brand {
    color: #ffffff;
}

.site-banner__home:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

.site-banner__logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
    filter: brightness(0.95);
}

.site-banner__brand {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #f0f0f0;
    transition: color 0.15s ease;
}

.site-banner__title {
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding-left: 0.85rem;
    border-left: 1px solid var(--border-strong);
}

.site-banner__end {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.85rem;
    margin-left: auto;
}

.site-banner__nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.site-banner__link {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.site-banner__link:hover {
    color: var(--text);
    background: var(--bg-elevated);
    border-color: var(--border);
}

.site-banner__link:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.site-banner__link--primary {
    border-color: var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text);
}

/* Auth chrome: Login (guest) or avatar + @user (signed in) */
.site-banner__auth {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.site-banner__login {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.95rem;
    border: 1px solid #ffffff;
    border-radius: var(--radius-pill);
    background: var(--bg-elevated);
    color: #f0f0f0;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.site-banner__login:hover:not(:disabled) {
    background: #1c1c1c;
}

.site-banner__login:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.site-banner__login:disabled {
    opacity: 0.55;
    cursor: wait;
}

a.site-banner__login--link {
    cursor: pointer;
}

.site-banner__profile {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    max-width: min(16rem, 46vw);
    padding: 0.2rem 0.55rem 0.2rem 0.2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg-elevated);
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.site-banner__profile:hover {
    background: #1c1c1c;
    border-color: var(--border-strong);
}

.site-banner__profile:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.site-banner__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-card);
    flex-shrink: 0;
}

.site-banner__user {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-banner__profile:hover .site-banner__user {
    color: var(--text);
}

/* -----------------------------------------------------------------------------
   Stage — login shell
   ----------------------------------------------------------------------------- */
.telegram-login {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    width: min(var(--stage-max), 100%);
    margin-inline: auto;
}

.post-auth {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: var(--space-lg);
    width: 100%;
}

.role-panel-host {
    flex: 1 1 280px;
    width: 100%;
    max-width: var(--card-max);
    min-width: min(280px, 100%);
}

.telegram-widget-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(320px, 100%);
    min-height: 48px;
    padding: 1rem 1.25rem;
    border: 1px dashed #444;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    text-align: center;
}

.telegram-widget-placeholder code {
    color: var(--text-muted);
}

.portal-login-hint {
    color: var(--text-dim);
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    text-align: center;
    max-width: 22rem;
    line-height: 1.5;
}

.portal-login-hint strong {
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.85em;
}

.id-card-error {
    color: var(--role-denied-text);
    font-size: 0.85rem;
    text-align: center;
}

/* -----------------------------------------------------------------------------
   Shared surface (ID card + role panel)
   ----------------------------------------------------------------------------- */
.id-card,
.role-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: linear-gradient(145deg, var(--bg-card-top) 0%, var(--bg-card) 100%);
    box-shadow: var(--shadow-card);
    opacity: 0;
    animation: fade-in 0.7s var(--ease-out) forwards;
}

/* -----------------------------------------------------------------------------
   ID card
   ----------------------------------------------------------------------------- */
.id-card {
    /* Do not use overflow:hidden on flex children — collapses min-height on mobile */
    flex: 1 1 300px;
    width: min(var(--card-max), 100%);
    max-width: var(--card-max);
    min-height: min-content;
    background: linear-gradient(145deg, var(--bg-card-top) 0%, var(--bg-card) 55%, #121212 100%);
}

.id-card[data-role="admin"] {
    border-color: color-mix(in srgb, var(--role-admin) 45%, transparent);
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--role-admin) 12%, transparent) inset,
        var(--shadow-card);
}

.id-card[data-role="vip"] {
    border-color: color-mix(in srgb, var(--role-vip) 45%, transparent);
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--role-vip) 12%, transparent) inset,
        var(--shadow-card);
}

/* Fallback if color-mix unsupported */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .id-card[data-role="admin"] {
        border-color: rgba(220, 80, 70, 0.45);
        box-shadow:
            0 0 0 1px rgba(220, 80, 70, 0.12) inset,
            var(--shadow-card);
    }

    .id-card[data-role="vip"] {
        border-color: rgba(168, 120, 255, 0.45);
        box-shadow:
            0 0 0 1px rgba(168, 120, 255, 0.12) inset,
            var(--shadow-card);
    }
}

.id-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: var(--space-sm) 1.1rem;
    border-bottom: 1px solid #2a2a2a;
    border-radius: var(--radius-inner) var(--radius-inner) 0 0;
    background: linear-gradient(180deg, #1a1a1a, #111);
}

.id-card__brand {
    color: #fff;
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.id-card__badge {
    padding: 0.28rem 0.55rem;
    border-radius: var(--radius-pill);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.id-card__body {
    display: grid;
    grid-template-columns: var(--photo-size) 1fr;
    gap: var(--space-md);
    align-items: start;
    padding: var(--space-md);
}

.id-card__photo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--photo-size);
    height: var(--photo-size);
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #1a1a1a;
    aspect-ratio: 1 / 1;
}

.id-card__photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.id-card__fields {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    min-width: 0;
}

.id-card__field {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
}

.id-card__field dt {
    color: #777;
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.id-card__field dd {
    color: #f0f0f0;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.id-card__footer {
    padding: 0.65rem 1.1rem var(--space-sm);
    border-top: 1px solid #242424;
    border-radius: 0 0 var(--radius-inner) var(--radius-inner);
    background: #0d0d0d;
}

.id-card__hash {
    display: block;
    overflow: hidden;
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* -----------------------------------------------------------------------------
   Role chips
   ----------------------------------------------------------------------------- */
.role-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--bg-elevated);
    color: var(--role-guest-text);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 0.28rem 0.55rem;
}

.role-chip--admin {
    border-color: var(--role-admin-border);
    background: linear-gradient(180deg, var(--role-admin-bg-top), var(--role-admin-bg-bot));
    color: var(--role-admin-text);
}

.role-chip--vip {
    border-color: var(--role-vip-border);
    background: linear-gradient(180deg, var(--role-vip-bg-top), var(--role-vip-bg-bot));
    color: var(--role-vip-text);
}

.role-chip--guest {
    border-color: var(--border-strong);
    background: var(--bg-elevated);
    color: var(--role-guest-text);
}

.role-chip--denied {
    border-color: var(--role-denied-border);
    background: var(--role-denied-bg);
    color: var(--role-denied-text);
}

/* -----------------------------------------------------------------------------
   Role panels (HTMX fragments)
   ----------------------------------------------------------------------------- */
.role-panel {
    min-height: min-content;
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-panel);
}

.role-panel--admin {
    border-color: color-mix(in srgb, var(--role-admin) 40%, transparent);
}

.role-panel--vip {
    border-color: color-mix(in srgb, var(--role-vip) 40%, transparent);
}

.role-panel--guest {
    border-color: var(--border);
}

.role-panel--denied,
.role-panel--loading {
    border-style: dashed;
    color: var(--text-dim);
}

@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .role-panel--admin {
        border-color: rgba(220, 80, 70, 0.4);
    }

    .role-panel--vip {
        border-color: rgba(168, 120, 255, 0.4);
    }
}

.role-panel__header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
    margin-bottom: 0.9rem;
}

.role-panel__title {
    color: #fff;
    font-family: var(--font-serif);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
}

.role-panel__lead {
    margin-bottom: var(--space-sm);
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.45;
}

.role-panel__note {
    color: var(--text-dim);
    font-size: 0.85rem;
    line-height: 1.45;
}

.role-panel__list {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--role-guest-text);
    font-size: 0.9rem;
    line-height: 1.55;
}

.role-panel__actions {
    margin: 0 0 var(--space-sm);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.role-panel__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--role-admin-border);
    background: linear-gradient(180deg, var(--role-admin-bg-top), var(--role-admin-bg-bot));
    color: var(--role-admin-text);
    font-weight: 500;
    font-size: 0.95rem;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.role-panel__btn:hover {
    filter: brightness(1.08);
    border-color: var(--role-admin-text);
}

.role-panel a {
    color: var(--role-admin-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.role-panel code {
    color: #e0e0e0;
}

/* -----------------------------------------------------------------------------
   Responsive
   ----------------------------------------------------------------------------- */
@media (max-width: 720px) {
    body.stage-page {
        padding: var(--space-sm) 0.75rem 5rem;
        padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    }

    .telegram-login {
        width: 100%;
        align-items: stretch;
    }

    /* Block layout avoids flex min-size clipping of tall cards on iOS Safari */
    .post-auth {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 1rem;
    }

    .id-card,
    .role-panel-host {
        flex: none;
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .id-card__body {
        grid-template-columns: var(--photo-size-sm) 1fr;
        gap: var(--space-sm);
        padding: 0.9rem;
    }

    .id-card__photo-wrap {
        width: var(--photo-size-sm);
        height: var(--photo-size-sm);
    }

    .id-card__fields {
        gap: var(--space-xs);
    }

    .id-card__field dd {
        font-size: 0.88rem;
    }

    .landing-enter-btn {
        right: 0.85rem;
        bottom: 0.85rem;
        bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
    }

    .site-banner {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .site-banner__title {
        width: 100%;
        padding-left: 0;
        border-left: none;
        order: 3;
    }
}

@media (max-width: 600px) {
    .logo {
        max-width: 160px;
        margin-bottom: 2.5rem;
    }
}

@media (max-width: 380px) {
    .id-card__body {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .id-card__fields {
        width: 100%;
    }
}
