/* 左下角亮色主题选择器：布局固定，配色跟随当前主题令牌。 */
.theme-switcher {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 1055;
    font-family: var(--tblr-font-sans-serif, system-ui, sans-serif);
}

.theme-switcher--inline {
    position: relative;
    left: auto;
    bottom: auto;
    z-index: 1055;
    width: 100%;
    min-width: 0;
}

.teacher-sidebar-footer {
    margin-top: auto;
    margin-bottom: 0;
}

.teacher-sidebar-footer-card {
    padding: 10px 10px 12px;
    border-top: 1px solid var(--edu-line, #dfe6ec);
    background: linear-gradient(180deg, rgba(255, 255, 255, .3), var(--edu-sidebar-bg, rgba(255, 255, 255, .9)));
}

.teacher-sidebar-user {
    width: 100%;
    min-width: 0;
    margin-bottom: 8px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--edu-muted, #64748b);
    font-size: 12px;
    text-decoration: none;
}

.teacher-sidebar-user:hover {
    color: var(--edu-brand-1, #2563eb);
    text-decoration: none;
}

.teacher-sidebar-user span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.teacher-sidebar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
}

.teacher-sidebar-actions > * {
    width: 100%;
    min-width: 0;
}

.teacher-sidebar-action-form {
    width: 100%;
    min-width: 0;
    margin: 0;
}

.theme-switcher-trigger {
    min-width: 88px;
    height: 52px;
    padding: 8px 12px 8px 10px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--edu-line, #dfe6ec);
    border-radius: 999px;
    background-color: var(--edu-surface, #fff);
    background-image: var(--edu-card-bg-image, none);
    color: var(--edu-ink, #1f2937);
    box-shadow: var(--edu-shadow-2, 0 18px 36px -28px rgba(15, 23, 42, .45));
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.theme-switcher-trigger:hover,
.theme-switcher-trigger:focus-visible {
    transform: translateY(-2px);
    border-color: var(--edu-brand-1, #2563eb);
    outline: none;
}

.theme-switcher-orb {
    position: relative;
    width: 29px;
    height: 29px;
    flex: 0 0 29px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--edu-brand-mark-bg, var(--edu-grad, linear-gradient(120deg, #2563eb, #06b6d4)));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55);
}

.theme-switcher-orb::after {
    content: "";
    position: absolute;
    inset: 7px;
    border: 2px solid rgba(255, 255, 255, .9);
    border-radius: 50%;
}

.theme-switcher-caption {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.1;
}

.theme-switcher-caption small {
    color: var(--edu-muted, #64748b);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: .04em;
}

.theme-switcher-panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + 12px);
    width: 376px;
    max-width: calc(100vw - 36px);
    max-height: min(620px, calc(100vh - 94px));
    overflow: auto;
    padding: 16px;
    border: 1px solid var(--edu-line, #dfe6ec);
    border-radius: var(--edu-radius, 16px);
    background-color: var(--edu-surface, #fff);
    background-image: var(--edu-card-bg-image, none);
    box-shadow: 0 24px 70px -34px rgba(15, 23, 42, .45), 0 2px 10px rgba(15, 23, 42, .06);
    color: var(--edu-ink, #1f2937);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(.98);
    transform-origin: left bottom;
    transition: opacity .16s ease, visibility .16s ease, transform .16s ease;
}

.theme-switcher.is-open .theme-switcher-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 卡片通过 JS 搬到 body，避免被侧栏的 overflow / stacking context 裁切。 */
.theme-switcher-panel--portal {
    position: fixed;
    right: auto;
    top: auto;
    z-index: 2000;
    max-width: calc(100vw - 24px);
}

.theme-switcher-panel--portal.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.theme-switcher-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 13px;
}

.theme-switcher-head strong {
    display: block;
    margin-bottom: 3px;
    font-family: var(--edu-heading-font, inherit);
    font-size: 15px;
}

.theme-switcher-head p {
    margin: 0;
    color: var(--edu-muted, #64748b);
    font-size: 11px;
    line-height: 1.45;
}

.theme-switcher-close {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border: 1px solid var(--edu-line, #dfe6ec);
    border-radius: 50%;
    background: var(--edu-surface, #fff);
    color: var(--edu-muted, #64748b);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.theme-switcher-close:hover {
    color: var(--edu-brand-1, #2563eb);
    border-color: var(--edu-brand-1, #2563eb);
}

.theme-switcher-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.theme-option {
    position: relative;
    min-width: 0;
    padding: 8px;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) 18px;
    gap: 9px;
    align-items: center;
    border: 1px solid var(--edu-line, #dfe6ec);
    border-radius: calc(var(--edu-radius-xs, 10px) + 1px);
    background-color: rgba(255, 255, 255, .66);
    color: var(--edu-ink, #1f2937);
    text-align: left;
    cursor: pointer;
    transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}

.theme-option:hover,
.theme-option:focus-visible {
    transform: translateY(-1px);
    border-color: var(--edu-brand-1, #2563eb);
    outline: none;
}

.theme-option[aria-selected="true"] {
    border-color: var(--edu-brand-1, #2563eb);
    background: var(--edu-nav-hover-bg, rgba(37, 99, 235, .08));
    box-shadow: inset 0 0 0 1px rgba(var(--edu-brand-rgb, 37, 99, 235), .16);
}

.theme-option-preview {
    width: 58px;
    height: 42px;
    border: 1px solid rgba(15, 23, 42, .1);
    border-radius: 9px;
    background:
        linear-gradient(180deg, var(--theme-a), var(--theme-b)) 0 0 / 12px 100% no-repeat,
        linear-gradient(90deg, var(--theme-a), var(--theme-b)) 17px 7px / 26px 5px no-repeat,
        linear-gradient(#fff, #fff) 17px 16px / 32px 19px no-repeat,
        var(--theme-c);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5);
}

.theme-option[data-theme-key="mint"] .theme-option-preview {
    border-radius: 2px;
    box-shadow: inset 3px 0 0 #10b981;
}

.theme-option[data-theme-key="ocean"] .theme-option-preview {
    border-radius: 15px 15px 5px 15px;
}

.theme-option[data-theme-key="lavender"] .theme-option-preview {
    border: 1px solid #c9b4ef;
    border-radius: 12px;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .8);
}

.theme-option[data-theme-key="sakura"] .theme-option-preview {
    border-left: 3px solid #e11d48;
    border-radius: 2px 8px 8px 2px;
}

.theme-option[data-theme-key="sunset"] .theme-option-preview {
    border: 2px solid #b45309;
    border-radius: 2px;
    box-shadow: 3px 3px 0 #fcd34d;
}

.theme-option[data-theme-key="forest"] .theme-option-preview {
    border-radius: 1px 9px 1px 9px;
    box-shadow: inset 3px 0 0 #16a34a;
}

.theme-option[data-theme-key="cocoa"] .theme-option-preview {
    border: 2px double #b7793f;
    border-radius: 1px;
}

.theme-option[data-theme-key="citrus"] .theme-option-preview {
    border: 2px solid #84cc16;
    border-radius: 14px;
    box-shadow: 2px 2px 0 #d9f99d;
}

.theme-option[data-theme-key="ink"] .theme-option-preview {
    border: 1px solid #6b7280;
    border-radius: 0;
    box-shadow: 3px 3px 0 #cbd5e1;
}

.theme-option-copy {
    min-width: 0;
}

.theme-option-copy strong,
.theme-option-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.theme-option-copy strong {
    font-size: 12px;
    font-weight: 700;
}

.theme-option-copy small {
    margin-top: 2px;
    color: var(--edu-muted, #64748b);
    font-size: 10px;
}

.theme-option-check {
    width: 18px;
    height: 18px;
    border: 1px solid var(--edu-line, #dfe6ec);
    border-radius: 50%;
    color: transparent;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.theme-option[aria-selected="true"] .theme-option-check {
    border-color: var(--edu-brand-1, #2563eb);
    background: var(--edu-brand-1, #2563eb);
    color: #fff;
}

/* 教练端侧栏底部：与设置、退出保持同一按钮尺寸，面板向上展开。 */
.theme-switcher--inline .theme-switcher-trigger {
    width: 100%;
    min-width: 0;
    height: 34px;
    padding: 0 6px;
    gap: 4px;
    border-radius: var(--tblr-border-radius-sm, 6px);
    box-shadow: none;
    background-image: none;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
}

.theme-switcher--inline .theme-switcher-trigger:hover,
.theme-switcher--inline .theme-switcher-trigger:focus-visible {
    transform: none;
    box-shadow: none;
}

.theme-switcher--inline .theme-switcher-orb {
    width: 16px;
    height: 16px;
    flex-basis: 16px;
}

.theme-switcher--inline .theme-switcher-orb::after {
    inset: 4px;
    border-width: 1px;
}

.theme-switcher--inline .theme-switcher-caption {
    display: inline-flex;
    align-items: center;
    color: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

.theme-switcher--inline .theme-switcher-caption small {
    display: none;
}

.theme-switcher--inline .theme-switcher-panel {
    left: 0;
    width: min(376px, calc(100vw - 36px));
}

.teacher-sidebar-action {
    width: 100%;
    height: 34px;
    min-width: 0;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
}

.teacher-sidebar-action i {
    flex: 0 0 auto;
    font-size: 14px;
}

.teacher-sidebar-action span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 992px) {
    /* 给仍需浮动主题入口的桌面侧栏底部控件留空间；教练端已内联到按钮组。 */
    body:not(.layout-teacher) .navbar-vertical .navbar-collapse {
        padding-bottom: 82px;
    }
}

@media (max-width: 575.98px) {
    .theme-switcher:not(.theme-switcher--inline) {
        left: 12px;
        bottom: 12px;
    }

    .theme-switcher:not(.theme-switcher--inline) .theme-switcher-trigger {
        min-width: 52px;
        width: 52px;
        padding: 8px;
        justify-content: center;
    }

    .theme-switcher:not(.theme-switcher--inline) .theme-switcher-caption {
        display: none;
    }

    .theme-switcher-panel {
        max-width: calc(100vw - 24px);
    }

    .theme-switcher-grid {
        grid-template-columns: 1fr;
    }
}

@media print {
    .theme-switcher,
    .theme-switcher-panel {
        display: none !important;
    }
}
