@layer components {
    .tr-site-header {
        position: fixed;
        inset: 0 0 auto;
        z-index: 1000;
        padding: 16px 24px;
        border-bottom: 1px solid var(--tr-border);
        background: var(--tr-header);
    }
    .tr-site-header__inner { width: min(1760px, calc(100vw - 48px)); margin: 0 auto; display: flex; align-items: center; gap: 24px; }
    .tr-brand { min-height: 36px; display: inline-flex; align-items: center; padding: 0 8px 0 44px; color: #fff; background: url('/imgs/tradingray-logo.svg') left center / 36px no-repeat; font-size: 18px; font-weight: 600; text-decoration: none; white-space: nowrap; }
    .tr-site-nav { flex: 1; display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; }
    .tr-site-nav li { list-style: none; }
    .tr-site-nav a { min-height: 36px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: var(--tr-radius-pill); color: var(--tr-text); text-decoration: none; font-size: 14px; font-weight: 500; }
    .tr-site-nav a:hover, .tr-site-nav a.active { background: var(--tr-surface-raised); color: var(--tr-link); }
    .tr-site-nav li[hidden],
    body:not(.is-authenticated) .tr-nav-chart-item {
        display: none !important;
    }
    .tr-site-nav a.tr-nav-chart-btn {
        min-height: 34px;
        height: 34px;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 3px 3px 3px 12px;
        border-radius: 9999px;
        background: linear-gradient(90deg, #3d66ff, #6745ff 37%, #aa2fd1 68%, #ec0879);
        color: #ffffff;
        font-size: 13.5px;
        font-weight: 700;
        text-decoration: none;
        transition: filter 160ms ease, opacity 160ms ease;
    }
    .tr-site-nav a.tr-nav-chart-btn:hover,
    .tr-site-nav a.tr-nav-chart-btn.active {
        filter: brightness(1.12);
        color: #ffffff;
    }
    .tr-nav-chart-btn__label {
        display: inline-flex;
        align-items: center;
    }
    .tr-nav-chart-btn__icon {
        width: 28px;
        height: 28px;
        flex: 0 0 28px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: #12191d;
    }
    .tr-nav-chart-btn__icon svg {
        width: 14px;
        height: 14px;
        flex: 0 0 14px;
        display: block;
        stroke: #ffffff;
    }
    .tr-site-header__actions { display: flex; align-items: center; gap: 8px; }
    .tr-site-header__actions > [hidden], .site-mobile-menu[hidden] { display: none; }
    .tr-site-header__actions > a { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0 16px; border-radius: var(--tr-radius-control); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap; }
    .header-login { color: var(--tr-text); }
    .header-login:hover { color: var(--tr-link); }
    .header-register { background: #fff; color: #0a0a0a; }
    .header-register:hover { background: #dce8ff; }
    .tr-header-control {
        height: 36px;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        margin: 0;
        padding: 0 12px;
        border: 0;
        border-radius: var(--tr-radius-control);
        appearance: none;
        background: var(--tr-surface-soft);
        color: var(--tr-text-secondary);
        font: inherit;
        font-size: 13px;
        font-weight: 500;
        line-height: 1;
        text-align: center;
        white-space: nowrap;
        cursor: pointer;
        user-select: none;
        transition: background-color 160ms ease, color 160ms ease;
    }
    .tr-header-control:hover, .tr-header-control:focus-visible, .header-lang[open] > .tr-header-control { background: var(--tr-surface-hover); color: var(--tr-text); }
    .header-account { min-height: 36px; max-width: 320px; display: inline-flex; align-items: center; gap: 8px; }
    .header-account-link {
        min-width: 0;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        text-decoration: none;
        color: var(--tr-text);
        padding: 3px 8px;
        border-radius: 8px;
        transition: background-color 140ms ease, color 140ms ease;
    }
    .header-account-link:hover {
        background: var(--tr-surface-hover);
        color: #ffffff;
    }
    .header-account-avatar {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        object-fit: cover;
        flex-shrink: 0;
        background: #252833;
        border: 1px solid rgba(255, 255, 255, 0.12);
    }
    .header-account-meta {
        min-width: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        line-height: 1.2;
    }
    .header-account-name {
        min-width: 0;
        font-size: 13px;
        font-weight: 600;
        color: var(--tr-text);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .header-account-handle {
        min-width: 0;
        font-size: 11px;
        color: var(--tr-text-muted);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .header-account-link:hover .header-account-handle {
        color: var(--tr-text-secondary);
    }
    .header-account button { flex: 0 0 auto; }

    .header-lang { position: relative; min-height: 36px; display: inline-flex; align-items: center; padding: 0; border: 0; color: var(--tr-text-secondary); }
    .header-lang summary { min-width: 78px; list-style: none; }
    .header-lang summary::-webkit-details-marker { display: none; }
    .header-lang summary::after { content: ""; width: 7px; height: 7px; flex: 0 0 7px; margin-top: -4px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(45deg); }
    .header-lang[open] summary::after { margin-top: 4px; transform: rotate(225deg); }
    .header-lang-label { display: none; }
    .header-lang-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 1800; width: min(340px, calc(100vw - 32px)); max-height: min(420px, calc(100vh - 84px)); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 6px; overflow-y: auto; border: 1px solid var(--tr-border-strong); border-radius: var(--tr-radius-control); background: rgba(20,20,20,.98); }
    .header-lang-option { min-height: 38px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 0 9px; border-radius: 6px; color: var(--tr-text-secondary); text-decoration: none; font-size: 13px; }
    .header-lang-option:hover, .header-lang-option.is-active { background: var(--tr-border); color: var(--tr-text); }
    .header-lang-option.is-active .header-lang-code { color: var(--tr-link); }
    .header-lang-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .header-lang-code { color: var(--tr-text-muted); font-size: 11px; font-weight: 600; }

    .site-menu-toggle { width: 40px; height: 40px; flex: 0 0 40px; display: none; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--tr-border-strong); border-radius: var(--tr-radius-control); background: rgba(20,20,20,.92); cursor: pointer; }
    .site-menu-toggle img { width: 22px; height: 22px; object-fit: contain; }
    .site-menu-toggle:hover { border-color: var(--tr-link); background: var(--tr-border); }
    .site-mobile-menu { position: fixed; inset: 0; z-index: 2100; }
    .site-menu-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.72); opacity: 0; transition: opacity 220ms ease; }
    .site-menu-panel { position: absolute; top: 0; right: 0; width: min(390px, 90vw); height: 100%; display: flex; flex-direction: column; gap: 24px; padding: 20px; overflow-y: auto; border-left: 1px solid var(--tr-border-strong); background: #0a0a0a; transform: translateX(100%); transition: transform 220ms ease; }
    .site-mobile-menu.is-open .site-menu-backdrop { opacity: 1; }
    .site-mobile-menu.is-open .site-menu-panel { transform: translateX(0); }
    .site-menu-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
    .site-menu-close { position: relative; width: 38px; height: 38px; border: 1px solid var(--tr-border-strong); border-radius: var(--tr-radius-control); background: var(--tr-surface); cursor: pointer; }
    .site-menu-close::before, .site-menu-close::after { content: ""; position: absolute; top: 18px; left: 10px; width: 18px; height: 1px; background: var(--tr-text); }
    .site-menu-close::before { transform: rotate(45deg); }
    .site-menu-close::after { transform: rotate(-45deg); }
    .site-menu-links { display: grid; gap: 6px; }
    .site-menu-link { min-height: 44px; display: flex; align-items: center; padding: 0 14px; border-radius: var(--tr-radius-control); color: var(--tr-text-secondary); text-decoration: none; }
    .site-menu-link:hover, .site-menu-link.is-active { background: var(--tr-surface-raised); color: var(--tr-text); }
    .site-menu-auth { display: grid; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--tr-border); }
    .site-menu-auth > a { min-height: 42px; display: flex; align-items: center; justify-content: center; border-radius: var(--tr-radius-control); text-decoration: none; }
    .site-menu-auth-primary { background: #fff; color: #0a0a0a; }
    .site-menu-account { max-width: none; justify-content: space-between; }
    .site-menu-language { margin-top: auto; }
    .site-menu-language > span { display: block; margin-bottom: 10px; color: var(--tr-text-muted); font-size: 12px; }
    .site-menu-language .header-lang { width: 100%; }
    .site-menu-language .header-lang summary { width: 100%; justify-content: space-between; }
    .site-menu-language .header-lang-menu { display: none; }

    .site-language-dialog { width: 100%; height: 100%; max-width: none; max-height: none; padding: 0; border: 0; background: rgba(0,0,0,.78); }
    .site-language-dialog::backdrop { background: transparent; }
    .site-language-dialog-panel { position: absolute; inset: auto 0 0; max-height: 80vh; padding: 20px; border-top: 1px solid var(--tr-border-strong); border-radius: 18px 18px 0 0; background: #101010; }
    .site-language-dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; font-weight: 600; }
    .site-language-dialog-head button { width: 36px; height: 36px; padding: 8px; border: 0; border-radius: var(--tr-radius-control); background: var(--tr-border); cursor: pointer; }
    .site-language-dialog-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: calc(80vh - 80px); overflow-y: auto; }

    @media (max-width: 1180px) {
        .tr-site-nav { display: none; }
        .tr-site-header__actions { margin-left: auto; }
        .site-menu-toggle { display: inline-flex; }
    }
    @media (max-width: 760px) {
        .tr-site-header { padding: 12px 16px; }
        .tr-site-header__inner { width: 100%; gap: 12px; }
        .tr-site-header__actions { margin-left: auto; }
        .tr-site-header__actions > .header-login, .tr-site-header__actions > .header-lang, .tr-site-header__actions > .header-account { display: none; }
        .tr-site-header__actions > .header-register { min-height: 34px; padding: 0 12px; font-size: 13px; }
    }
    @media (max-width: 520px) {
        .tr-site-header__actions > .header-register { display: none; }
        .tr-brand { font-size: 0; width: 44px; padding: 0; background-position: center; }
    }
}
