
/* =========================================================
   Tutorial Studio
   Compact Topbar
   顶部栏紧凑布局
   ========================================================= */

.topbar {
    box-sizing: border-box;
    height: 48px;
    min-height: 48px;
    padding: 0 16px;
    gap: 24px;

    display: flex;
    align-items: center;

    position: relative;
    z-index: 40;

    background: #fff;
    border-bottom: 1px solid var(--line);

    transition:
        height .22s ease,
        min-height .22s ease,
        padding .22s ease,
        border-color .22s ease;
}


/* =========================================================
   品牌区域
   ========================================================= */

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 200px;
    flex-shrink: 0;
}

.brand-mark {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 8px;

    background: linear-gradient(135deg, #6575ee, #8b95f7);
    color: #fff;

    display: grid;
    place-items: center;

    font-weight: 800;
    box-shadow: 0 3px 9px rgba(86, 103, 232, .16);
}

.brand-title {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
}

.brand-sub {
    font-size: 9px;
    color: #a1aaba;
    letter-spacing: 1.1px;
    margin-top: 2px;
}


/* =========================================================
   主菜单
   ========================================================= */

.menu-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.menu-bar button {
    box-sizing: border-box;
    height: 32px;
    min-height: 32px;
    padding: 0 12px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 7px;

    background: transparent;
    color: #465166;

    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .1px;
    line-height: 1;

    cursor: pointer;
    white-space: nowrap;

    transition:
        color .16s ease,
        background .16s ease,
        box-shadow .16s ease;
}

.menu-bar button:hover {
    background: #f3f5fa;
    color: #273247;
}

.menu-bar button:active {
    background: #eceff7;
    color: #24304a;
}

.menu-bar button:focus-visible {
    outline: none;
    background: #f1f3fa;
    color: #273247;
    box-shadow: 0 0 0 2px rgba(101, 117, 238, .12);
}


/* =========================================================
   右侧操作区域
   ========================================================= */

.top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}


/* =========================================================
   顶部操作按钮统一尺寸
   ========================================================= */

.top-actions .btn,
.top-actions .account-login-btn,
.top-actions .account-user-trigger,
.top-actions .app-launcher-btn {
    box-sizing: border-box;

    height: 32px;
    min-height: 32px;
    max-height: 32px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    font-family: inherit;
    font-size: 13px;
    line-height: 1;

    border-radius: 8px;
}


/* =========================================================
   普通按钮
   ========================================================= */

.btn {
    padding: 0 13px;
    border: 1px solid var(--line);
    background: #fff;

    cursor: pointer;
    font-weight: 600;

    transition:
        background .16s ease,
        border-color .16s ease,
        color .16s ease,
        box-shadow .16s ease;
}

.btn:hover {
    background: #f6f7fa;
}

.btn.soft {
    background: var(--soft);
    color: #4d5fd5;
    border-color: #dfe3ff;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}


/* =========================================================
   导出按钮
   ========================================================= */

#exportBtn {
    position: relative;
    overflow: hidden;

    height: 32px;
    min-height: 32px;
    max-height: 32px;

    padding: 0 13px;
    gap: 6px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 8px;

    background: linear-gradient(
        115deg,
        #3478f6 0%,
        #6366f1 25%,
        #a855f7 50%,
        #ec4899 75%,
        #3478f6 100%
    );

    background-size: 300% 300%;
    background-position: 0% 50%;

    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;

    box-shadow: 0 2px 7px rgba(99, 102, 241, .17);

    animation: exportGradientIntro 2.5s ease-in-out 1 both;

    transition:
        background-position .25s ease,
        box-shadow .18s ease,
        filter .18s ease;
}

#exportBtn svg {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
}

#exportBtn span {
    line-height: 1;
}

@keyframes exportGradientIntro {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 50% 50%;
    }
}

#exportBtn:hover {
    filter: brightness(1.06);
    box-shadow: 0 3px 10px rgba(99, 102, 241, .24);
}

#exportBtn:active {
    filter: brightness(.97);
}

#exportBtn:focus-visible {
    outline: 2px solid #818cf8;
    outline-offset: 2px;
}


/* =========================================================
   账户区域
   ========================================================= */

.account-area,
.account-guest,
.account-user {
    align-items: center;
    flex-shrink: 0;
}

.account-area {
    display: flex;
}

.account-guest,
.account-user {
    display: flex;
}

/* 防止 display:flex 覆盖 hidden */

.account-guest[hidden],
.account-user[hidden],
.account-dropdown[hidden] {
    display: none !important;
}


/* =========================================================
   登录按钮
   加深蓝紫背景
   ========================================================= */

.top-actions .account-login-btn {
    padding: 0 13px;
    gap: 6px;

    border: 1px solid #c7ceff;
    border-radius: 8px;

    background: #e1e5ff;
    color: #4353bd;

    font-weight: 700;
    cursor: pointer;

    box-shadow: 0 1px 3px rgba(79, 91, 190, .08);

    transition:
        background .16s ease,
        border-color .16s ease,
        color .16s ease,
        box-shadow .16s ease;
}

.top-actions .account-login-btn:hover {
    background: #d4dbff;
    border-color: #b5c0ff;
    color: #3546ae;
    box-shadow: 0 2px 6px rgba(79, 91, 190, .12);
}

.top-actions .account-login-btn:active {
    background: #c8d1ff;
}

.top-actions .account-login-btn svg {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
}


/* =========================================================
   已登录账户按钮
   ========================================================= */

.top-actions .account-user-trigger {
    padding: 0 9px;
    gap: 6px;

    border: 1px solid #c7ceff;
    border-radius: 8px;

    background: #e1e5ff;
    color: #4353bd;

    font-weight: 700;
    cursor: pointer;

    transition:
        background .16s ease,
        border-color .16s ease,
        color .16s ease,
        box-shadow .16s ease;
}

.top-actions .account-user-trigger:hover {
    background: #d4dbff;
    border-color: #b5c0ff;
}

.top-actions .account-user-trigger:active {
    background: #c8d1ff;
}

.top-actions .account-avatar {
    width: 22px;
    height: 22px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;
    flex-shrink: 0;

    font-size: 11px;
    font-weight: 700;
}

.top-actions .account-username {
    line-height: 1;
    white-space: nowrap;
}

.top-actions .account-chevron {
    width: 14px;
    height: 14px;
    display: block;
    flex-shrink: 0;
}


/* =========================================================
   账户下拉菜单
   ========================================================= */

.account-dropdown {
    z-index: 1000;
}


/* =========================================================
   应用导航按钮
   三根横线图标
   ========================================================= */

.top-actions .app-launcher-btn {
    width: 32px;
    min-width: 32px;
    max-width: 32px;

    height: 32px;
    min-height: 32px;
    max-height: 32px;

    padding: 0;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex-direction: column;
    gap: 4px;

    border: 1px solid #c7ceff;
    border-radius: 8px;

    background: #e1e5ff;
    cursor: pointer;

    box-shadow: 0 1px 3px rgba(79, 91, 190, .08);

    transition:
        background .16s ease,
        border-color .16s ease,
        box-shadow .16s ease;
}

.top-actions .app-launcher-btn:hover {
    background: #d4dbff;
    border-color: #b5c0ff;
}

.top-actions .app-launcher-btn:active {
    background: #c8d1ff;
}

/* 三根横线 */

.top-actions .app-launcher-btn span {
    display: block;

    width: 14px;
    height: 2px;

    flex: 0 0 2px;

    border-radius: 2px;
    background: #5263ca;

    transition: background .16s ease;
}

.top-actions .app-launcher-btn:hover span {
    background: #394bad;
}


/* =========================================================
   统一键盘焦点
   ========================================================= */

.top-actions .btn:focus-visible,
.top-actions .account-login-btn:focus-visible,
.top-actions .account-user-trigger:focus-visible,
.top-actions .app-launcher-btn:focus-visible {
    outline: 2px solid rgba(101, 114, 213, .4);
    outline-offset: 2px;
}


/* =========================================================
   顶部栏折叠按钮
   ========================================================= */

.topbar-toggle {
    position: absolute;

    left: 50%;
    bottom: -10px;

    transform: translateX(-50%);

    width: 30px;
    height: 18px;

    padding: 0;

    border: 1px solid var(--line);
    border-radius: 0 0 8px 8px;

    background: #fff;
    color: #687386;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    z-index: 20;

    font-size: 13px;
    line-height: 1;

    box-shadow: 0 3px 8px rgba(0, 0, 0, .06);

    transition:
        color .18s ease,
        background .18s ease,
        box-shadow .18s ease;
}

.topbar-toggle:hover {
    color: var(--primary);
    background: #f8f9ff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .10);
}

.topbar-toggle-icon {
    display: block;
    line-height: 1;
    font-size: 13px;
    font-weight: 700;
}


/* =========================================================
   顶部栏收起状态
   ========================================================= */

.topbar.collapsed {
    height: 0;
    min-height: 0;

    padding-top: 0;
    padding-bottom: 0;

    border-bottom-color: transparent;

    /*
     * 收起后高度为 0，展开按钮会伸到下方工作区。
     * 顶部栏整体 z-index 为 40，高于画布工具栏 30、低于弹窗 100。
     */
    z-index: 40;
}

.topbar.collapsed .topbar-toggle {
    z-index: 41;

    pointer-events: auto;
}

.topbar.collapsed > *:not(.topbar-toggle) {
    opacity: 0;
    visibility: hidden;
}


/* =========================================================
   收起后的展开提示
   ========================================================= */

.topbar.collapsed .topbar-toggle {
    bottom: -18px;

    width: 34px;
    height: 20px;

    border-radius: 0 0 10px 10px;
}


/* =========================================================
   小屏幕
   ========================================================= */

@media (max-width: 900px) {
    .topbar {
        gap: 12px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .brand {
        min-width: auto;
    }

    .brand-sub {
        display: none;
    }

    .menu-bar {
        gap: 0;
    }

    .menu-bar button {
        padding-left: 8px;
        padding-right: 8px;
        font-size: 12px;
    }

    .top-actions {
        gap: 5px;
    }
}


/* =========================================================
   减少动画
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    #exportBtn {
        animation: none;
        background-position: 50% 50%;
        transition: none;
    }

    .topbar {
        transition: none;
    }
}
