/* Critical header controls: visible first paint + hidden panel guards. */
.search-login-container {
    grid-column: 3;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-right: clamp(8px, 2vw, 20px);
    gap: clamp(6px, 1.5vw, 15px);
}
.search-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}
.search-button {
    position: relative;
    color: var(--color-text);
    padding: 8px;
    background-color: #142736;
    border: 1px solid rgba(24, 180, 255, 0.5);
    border-radius: 50%;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}
.search-button:hover {
    background-color: #1c364b;
}
.search-button .tt-icon,
#settings-toggle .tt-icon {
    width: 1.22rem;
    height: 1.22rem;
    stroke-width: 2.15;
}
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-color: rgba(11, 26, 34, 0.95);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: var(--z-index-search);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding-top: 100px;
}
.search-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.search-form-container {
    width: 90%;
    max-width: 750px;
    position: relative;
}
.search-form {
    position: relative;
    isolation: isolate;
    display: flex;
    gap: 10px;
    background: transparent;
    padding: 15px;
    border: none;
    clip-path: polygon(
        var(--cut-md) 0, 100% 0, 100% calc(100% - var(--cut-md)),
        calc(100% - var(--cut-md)) 100%, 0 100%, 0 var(--cut-md)
    );
}
.search-form::before,
.search-form::after {
    content: '';
    position: absolute;
    z-index: -1;
    clip-path: polygon(
        var(--cut-md) 0, 100% 0, 100% calc(100% - var(--cut-md)),
        calc(100% - var(--cut-md)) 100%, 0 100%, 0 var(--cut-md)
    );
}
.search-form::before {
    inset: 0;
    background: var(--color-accent);
}
.search-form::after {
    inset: 2px;
    background: #142736;
}
.search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--color-text);
    font-size: 1.125rem;
    padding: 0.3125rem 0.625rem;
    outline: none;
}
.search-input::placeholder {
    color: #999;
}
.search-submit,
.search-close {
    background: none;
    border: none;
    color: var(--color-accent);
    cursor: pointer;
    padding: 0.3125rem 0.625rem;
    font-size: 1.125rem;
}
.search-submit .tt-icon,
.search-close .tt-icon {
    width: 1.2rem;
    height: 1.2rem;
    display: block;
}
.login-button {
    white-space: nowrap;
    font-size: 1em;
    position: relative;
    color: var(--color-text);
    text-decoration: none;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    z-index: 1;
}
.login-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--color-accent);
    background-image: linear-gradient(90deg, transparent 0%, #c9a84c 50%, transparent 100%);
    background-size: 200% 100%;
    background-position: 200% 0;
    z-index: -1;
    clip-path: polygon(
        var(--cut-sm) 0, 100% 0, 100% calc(100% - var(--cut-sm)),
        calc(100% - var(--cut-sm)) 100%, 0 100%, 0 var(--cut-sm)
    );
    transition: background-position 0.5s ease;
}
.login-button:hover::before {
    background-position: -100% 0;
}
.login-button::after {
    content: '';
    position: absolute;
    inset: 2px;
    background: #142736;
    z-index: -1;
    clip-path: polygon(
        calc(var(--cut-sm) - 1px) 0, 100% 0, 100% calc(100% - var(--cut-sm) + 1px),
        calc(100% - var(--cut-sm) + 1px) 100%, 0 100%, 0 calc(var(--cut-sm) - 1px)
    );
}
.user-menu-container {
    position: relative;
}
.avatar-container {
    cursor: pointer;
    position: relative;
    isolation: isolate;
    display: inline-grid;
    place-items: center;
    line-height: 0;
}
.user-avatar {
    display: block;
    position: relative;
    z-index: 2;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid transparent;
    background-color: #142736;
    transition: border-color 0.3s;
}
.user-avatar:hover {
    border-color: var(--color-accent);
}
.avatar-unread-counter {
    position: absolute;
    bottom: -5px;
    right: -5px;
    z-index: 3;
}
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #142736;
    padding: 8px 0;
    margin-top: 10px;
    min-width: 12.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
@media screen and (min-width: 769px) {
    .user-menu-container:hover .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -5px;
    right: 20px;
    width: 10px;
    height: 10px;
    background-color: #142736;
    transform: rotate(45deg);
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.625rem 1.25rem;
    color: var(--color-text);
    text-decoration: none;
    white-space: nowrap;
}
.menu-item .tt-icon {
    width: 1.1rem;
    height: 1.1rem;
}
#settings-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: var(--header-height);
}
#settings-toggle {
    background: none;
    border: 1px solid rgba(119, 92, 49, 0.4);
    color: var(--color-accent);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    font-size: 14px;
}
#settings-toggle:hover,
#settings-toggle[aria-expanded="true"] {
    background-color: rgba(119, 92, 49, 0.18);
    border-color: var(--color-accent);
    color: var(--color-accent-light);
}
.settings-panel {
    --sp-cut: 10px;
    position: fixed;
    top: var(--header-height);
    right: 10px;
    width: 240px;
    padding: 16px;
    background: #0d1f2d;
    border: 1px solid var(--color-accent);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
    z-index: 9999;
    isolation: isolate;
}
.settings-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
#theme-toggle-button.theme-switch {
    --reactor-cut: 8px;
    --reactor-inner-cut: 6px;
    --reactor-glow: var(--color-energy);
    --reactor-bg: #0d1f2b;
    --hex-stroke: #00eaff;
    --hex-glow: rgba(0, 234, 255, 0.6);
    display: inline-flex;
    align-items: center;
    width: 110px;
    height: 40px;
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
    flex-shrink: 0;
    background: linear-gradient(135deg, #bf953f 0%, #fcf6ba 25%, #b38728 50%, #fbf5b7 75%, #aa771c 100%);
    border: none;
    border-radius: 0;
    padding: 0;
    overflow: hidden;
    clip-path: polygon(
        var(--reactor-cut) 0, calc(100% - var(--reactor-cut)) 0,
        100% var(--reactor-cut), 100% calc(100% - var(--reactor-cut)),
        calc(100% - var(--reactor-cut)) 100%, var(--reactor-cut) 100%,
        0 calc(100% - var(--reactor-cut)), 0 var(--reactor-cut)
    );
    transition: none;
}
#theme-toggle-button.theme-switch::after {
    content: '';
    position: absolute;
    inset: 2px;
    background: var(--reactor-bg);
    clip-path: polygon(
        var(--reactor-inner-cut) 0, calc(100% - var(--reactor-inner-cut)) 0,
        100% var(--reactor-inner-cut), 100% calc(100% - var(--reactor-inner-cut)),
        calc(100% - var(--reactor-inner-cut)) 100%, var(--reactor-inner-cut) 100%,
        0 calc(100% - var(--reactor-inner-cut)), 0 var(--reactor-inner-cut)
    );
    z-index: 1;
}
.reactor-glow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--reactor-glow) 0%, transparent 70%);
    z-index: 2;
    pointer-events: none;
    transition: left 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.reactor-energy-trail {
    position: absolute;
    top: calc(50% - 1px);
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--reactor-glow) 30%, var(--reactor-glow) 70%, transparent);
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    border-radius: 1px;
}
.theme-switch-thumb {
    width: 32px;
    height: 32px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}
.hex-border {
    position: absolute;
    inset: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.hex-border svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 0 3px var(--hex-glow));
    transition: filter 0.4s ease;
}
.hex-border polygon {
    fill: none;
    stroke: var(--hex-stroke);
    stroke-width: 3;
    transition: stroke 0.4s ease;
}
.theme-switch-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 1;
    transition: color 0.4s ease;
}
.theme-switch-icon svg {
    width: 14px;
    height: 14px;
    display: block;
    filter: drop-shadow(0 0 2px currentColor);
}
.theme-switch-label {
    position: relative;
    z-index: 2;
    width: 100%;
    font-size: 0.5625rem;
    font-family: Arial, sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    user-select: none;
    transition: color 0.3s ease;
    line-height: 40px;
    box-sizing: border-box;
}
#theme-toggle-button.theme-switch.dark-active .theme-switch-thumb {
    left: 4px;
}
#theme-toggle-button.theme-switch.dark-active .theme-switch-icon {
    color: #00eaff;
}
#theme-toggle-button.theme-switch.dark-active .reactor-glow {
    left: 0;
}
#theme-toggle-button.theme-switch.dark-active .theme-switch-label {
    color: rgba(0, 234, 255, 0.5);
    text-align: right;
    padding-right: 10px;
    padding-left: 40px;
}
#theme-toggle-button.theme-switch.light-active {
    --reactor-bg: #f0e6d6;
    --reactor-glow: rgba(255, 180, 40, 0.9);
    --hex-stroke: #c9a84c;
    --hex-glow: rgba(230, 160, 30, 0.7);
}
#theme-toggle-button.theme-switch.light-active .theme-switch-thumb {
    left: calc(100% - 32px - 4px);
}
#theme-toggle-button.theme-switch.light-active .theme-switch-icon {
    color: #e8820c;
}
#theme-toggle-button.theme-switch.light-active .reactor-glow {
    left: calc(100% - 36px);
}
#theme-toggle-button.theme-switch.light-active .theme-switch-label {
    color: rgba(180, 120, 30, 0.7);
    text-align: left;
    padding-left: 10px;
    padding-right: 40px;
}
@media screen and (max-width: 600px) {
    .search-login-container {
        grid-column: 4;
        grid-row: 1;
        gap: 0.4rem;
    }
    .search-button,
    #settings-toggle {
        width: 32px;
        height: 32px;
    }
    .search-button {
        padding: 6px;
    }
    .login-button {
        padding: 0.375rem 0.625rem;
        font-size: 0.9em;
    }
    .login-button .tt-icon-sign-in {
        margin-right: 4px;
    }
    #settings-toggle {
        font-size: 13px;
    }
    .user-avatar {
        width: 36px;
        height: 36px;
    }
    #theme-toggle-button.theme-switch {
        --reactor-cut: 6px;
        --reactor-inner-cut: 4px;
        width: 48px;
        height: 36px;
    }
    #theme-toggle-button.theme-switch .theme-switch-label {
        display: none !important;
    }
    #theme-toggle-button.theme-switch .theme-switch-thumb {
        width: 26px;
        height: 26px;
    }
    #theme-toggle-button.theme-switch .hex-border {
        inset: 3px;
    }
    #theme-toggle-button.theme-switch .theme-switch-icon svg {
        width: 11px;
        height: 11px;
    }
    #theme-toggle-button.theme-switch .reactor-glow {
        width: 30px;
        height: 30px;
    }
    #theme-toggle-button.theme-switch.dark-active .theme-switch-thumb {
        left: 4px !important;
    }
    #theme-toggle-button.theme-switch.light-active .theme-switch-thumb {
        left: calc(100% - 26px - 4px) !important;
    }
    #theme-toggle-button.theme-switch.dark-active .reactor-glow {
        left: 0 !important;
    }
    #theme-toggle-button.theme-switch.light-active .reactor-glow {
        left: calc(100% - 30px) !important;
    }
}
@media screen and (min-width: 481px) and (max-width: 600px) {
    .login-button {
        padding: 0.4375rem 0.875rem;
        font-size: 0.95em;
    }
}
@media screen and (max-width: 480px) {
    .search-login-container {
        gap: clamp(4px, 1.5vw, 8px);
        padding-right: clamp(5px, 1.5vw, 10px);
    }
    .login-button {
        padding: 0.375rem 0.625rem;
        font-size: 0.9em;
    }
    .login-button .tt-icon-sign-in {
        margin-right: 4px;
    }
}
@media screen and (max-width: 380px) {
    .search-login-container {
        gap: 5px;
        padding-right: 5px;
    }
    .login-button {
        padding: 8px;
        font-size: 0.85em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .login-button .login-button-text {
        display: none;
    }
    .login-button .tt-icon-sign-in {
        margin-right: 0;
        font-size: 1.1em;
    }
    .search-container .search-button {
        padding: 5px;
    }
    #settings-toggle {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    .settings-panel {
        width: 200px;
        padding: 12px;
    }
    #theme-toggle-button.theme-switch {
        --reactor-cut: 5px;
        --reactor-inner-cut: 3px;
        width: 40px;
        height: 30px;
    }
    #theme-toggle-button.theme-switch .theme-switch-thumb {
        width: 20px;
        height: 20px;
    }
    #theme-toggle-button.theme-switch .hex-border {
        inset: 2px;
    }
    #theme-toggle-button.theme-switch .theme-switch-icon svg {
        width: 9px;
        height: 9px;
    }
    #theme-toggle-button.theme-switch .reactor-glow {
        width: 24px;
        height: 24px;
    }
    #theme-toggle-button.theme-switch .hex-border polygon {
        stroke-width: 4;
    }
    #theme-toggle-button.theme-switch.dark-active .theme-switch-thumb {
        left: 3px !important;
    }
    #theme-toggle-button.theme-switch.light-active .theme-switch-thumb {
        left: calc(100% - 20px - 3px) !important;
    }
    #theme-toggle-button.theme-switch.dark-active .reactor-glow {
        left: 0 !important;
    }
    #theme-toggle-button.theme-switch.light-active .reactor-glow {
        left: calc(100% - 24px) !important;
    }
}
@media screen and (min-width: 601px) and (max-width: 900px) {
    .search-login-container {
        padding-right: 8px;
        gap: 8px;
    }
    #theme-toggle-button.theme-switch {
        --reactor-cut: 6px;
        --reactor-inner-cut: 4px;
        width: 48px;
        height: 36px;
    }
    #theme-toggle-button.theme-switch .theme-switch-label {
        display: none !important;
    }
    #theme-toggle-button.theme-switch .theme-switch-thumb {
        width: 26px;
        height: 26px;
    }
    #theme-toggle-button.theme-switch .hex-border {
        inset: 3px;
    }
    #theme-toggle-button.theme-switch .theme-switch-icon svg {
        width: 11px;
        height: 11px;
    }
    #theme-toggle-button.theme-switch .reactor-glow {
        width: 30px;
        height: 30px;
    }
    #theme-toggle-button.theme-switch.dark-active .theme-switch-thumb {
        left: 4px !important;
    }
    #theme-toggle-button.theme-switch.light-active .theme-switch-thumb {
        left: calc(100% - 26px - 4px) !important;
    }
    #theme-toggle-button.theme-switch.dark-active .reactor-glow {
        left: 0 !important;
    }
    #theme-toggle-button.theme-switch.light-active .reactor-glow {
        left: calc(100% - 30px) !important;
    }
    .search-button {
        width: 34px;
        height: 34px;
    }
    .login-button {
        padding: 0.375rem 0.75rem;
        font-size: 0.9em;
    }
    .user-avatar {
        width: 36px;
        height: 36px;
    }
}
