:root {
    --side-bg: #1f2a44;
    --side-bg-2: #17203a;
    --brand: #3b6ef6;
    --brand-dark: #2f5ad8;
    --bg: #f4f6fb;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: #2b3246;
    font-family: "Microsoft YaHei", "PingFang SC", -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

/* ---------- 后台布局 ---------- */
.admin-wrap { display: flex; min-height: 100vh; }

.admin-side {
    width: 220px;
    flex: 0 0 220px;
    background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
    color: #cfd8ef;
}
.admin-side .brand {
    height: 60px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.admin-side .menu-group-title {
    padding: 18px 20px 8px;
    font-size: 12px;
    letter-spacing: 1px;
    color: #7d8bb3;
}
.admin-side .menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    color: #cfd8ef;
    font-size: 14px;
}
.admin-side .menu a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.admin-side .menu a.active { background: var(--brand); color: #fff; font-weight: 600; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
    height: 60px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid #e8ecf5;
}
.admin-topbar .title { font-size: 16px; font-weight: 600; }
.admin-content { padding: 20px 24px 40px; flex: 1; }

/* ---------- 通用卡片 ---------- */
.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: 0 6px 18px rgba(31, 42, 68, .06);
    margin-bottom: 18px;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.table { vertical-align: middle; }
.table th { color: #6b7590; font-weight: 600; white-space: nowrap; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: 0 6px 18px rgba(31, 42, 68, .06);
    display: flex;
    align-items: center;
    gap: 14px;
}
.stat-card .ico {
    width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px;
}
.stat-card .num { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-card .label { color: #8a93a8; font-size: 12px; }

/* ---------- 标签 ---------- */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 12px;
    background: #eef2ff;
    color: var(--brand);
}
.tag-gray { background: #f1f3f8; color: #6b7590; }
.tag-green { background: #e8f8ef; color: #18a058; }
.tag-red { background: #fdeeee; color: #e0434c; }
.tag-orange { background: #fff4e5; color: #e8912d; }

/* ---------- 富文本字段 ---------- */
.rich-field-box { border: 1px solid #e2e7f0; border-radius: 8px; overflow: hidden; background: #fff; }
.rich-field-box .rich-tb { border-bottom: 1px solid #f0f2f7; }
.rich-field-box .rich-ed { min-height: 140px; }
.rich-extra {
    display: flex; gap: 8px; padding: 6px 8px;
    background: #fbfcfe; border-bottom: 1px solid #f0f2f7;
}
.rich-ed video, .rich-ed audio { max-width: 100%; }

/* 编辑器内音频节点：去掉 video 占位的透明棋盘底，改为音频播放器卡片 */
.rich-ed .w-e-textarea-video-container.is-audio {
    background: #f8fafc;
    border: 1px solid #e6eaf3;
    padding: 6px 8px;
    border-radius: 8px;
}
.w-e-audio-player {
    display: block;
    width: 100%;
    max-width: 520px;
    height: 40px;
}

/* 音视频播放器 */
.media-audio { width: 100%; max-width: 520px; margin: 6px 0; }
.media-video { max-width: 100%; margin: 6px 0; }

/* 题干/选项内容样式 */
.q-stem { font-size: 15px; line-height: 1.8; }
.q-stem img, .q-option img { max-width: 100%; }
.q-stem audio, .q-stem video, .q-option audio, .q-option video { max-width: 100%; margin: 6px 0; }
.q-option { padding: 4px 0; }

/* ---------- 学生端 ---------- */
.stu-header {
    background: linear-gradient(120deg, #3b6ef6, #6a8cff);
    color: #fff;
    padding: 14px 0;
}
.stu-header .wrap {
    max-width: 1180px; margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
}
.stu-container { max-width: 1180px; margin: 24px auto; padding: 0 20px 60px; }

.exam-card {
    background: #fff; border-radius: 14px; padding: 18px 20px;
    box-shadow: 0 8px 24px rgba(31, 42, 68, .08);
    transition: transform .15s ease, box-shadow .15s ease;
}
.exam-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(31, 42, 68, .12); }
.exam-card .exam-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.exam-meta { color: #7c86a0; font-size: 13px; }

.exam-layout { display: grid; grid-template-columns: 250px 1fr; gap: 20px; align-items: start; }
.exam-side { position: sticky; top: 20px; }
.exam-side .nav-group { background: #fff; border-radius: 12px; padding: 14px 16px; box-shadow: 0 6px 18px rgba(31, 42, 68, .06); margin-bottom: 14px; }
.q-nums { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.q-num {
    width: 34px; height: 34px; border-radius: 8px; border: 1px solid #dfe4ef;
    background: #fff; color: #5b6479; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 13px;
}
.q-num.answered { background: var(--brand); color: #fff; border-color: var(--brand); }

.timer-box {
    background: #fff; border-radius: 12px; padding: 14px 16px; text-align: center;
    box-shadow: 0 6px 18px rgba(31, 42, 68, .06);
}
.timer-box .clock { font-size: 26px; font-weight: 700; color: var(--brand); letter-spacing: 1px; }

.question-block { background: #fff; border-radius: 12px; padding: 18px 20px; margin-bottom: 14px; box-shadow: 0 4px 14px rgba(31, 42, 68, .05); }
.question-block .q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.question-block .q-no { font-weight: 700; font-size: 15px; }
.answer-box { margin-top: 12px; padding-top: 12px; border-top: 1px dashed #e6eaf3; }
.result-right { color: #18a058; font-weight: 600; }
.result-wrong { color: #e0434c; font-weight: 600; }
.result-part { color: #e8912d; font-weight: 600; }

.login-box {
    position: relative; z-index: 1;
    max-width: 420px; margin: 8vh auto; background: #fff; border-radius: 16px;
    padding: 32px; box-shadow: 0 18px 40px rgba(31, 42, 68, .12);
}
.login-box h3 { margin-bottom: 20px; font-weight: 700; }

/* ---------- 学生登录页 ---------- */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    padding: 32px 20px;
    position: relative;
    background: #22325c url('/static/img/student-login-bg.jpg') center center / cover no-repeat fixed;
}
.login-page::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background:
        radial-gradient(1100px 560px at 12% 18%, rgba(59, 110, 246, .55), transparent 62%),
        linear-gradient(125deg, rgba(17, 30, 62, .88) 0%, rgba(30, 49, 105, .66) 46%, rgba(62, 47, 126, .52) 100%);
}

.login-card {
    position: relative; z-index: 1;
    display: grid; grid-template-columns: 1.06fr .94fr;
    width: min(980px, 100%);
    background: #fff; border-radius: 22px; overflow: hidden;
    box-shadow: 0 30px 70px rgba(10, 20, 45, .45);
    animation: loginIn .55s cubic-bezier(.22, .61, .36, 1) both;
}
@keyframes loginIn {
    from { opacity: 0; transform: translateY(18px) scale(.99); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .login-card { animation: none; } }

.login-intro {
    position: relative; overflow: hidden;
    padding: 44px 40px 34px;
    display: flex; flex-direction: column; justify-content: space-between; gap: 28px;
    color: #fff;
    background: linear-gradient(155deg, #3b6ef6 0%, #5a68e8 52%, #7d5ad6 100%);
}
.login-intro::before,
.login-intro::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.login-intro::before { width: 220px; height: 220px; left: -70px; bottom: -90px; }
.login-intro::after { width: 320px; height: 320px; right: -110px; top: -80px; }
.login-intro > * { position: relative; z-index: 1; }

.login-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; letter-spacing: .5px; }
.login-logo {
    width: 38px; height: 38px; flex: none; border-radius: 11px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .35);
    font-size: 19px;
}
.login-intro h2 { margin: 26px 0 12px; font-size: 27px; line-height: 1.45; font-weight: 700; letter-spacing: 1px; }
.login-slogan { margin: 0; max-width: 320px; font-size: 13px; line-height: 1.9; color: rgba(255, 255, 255, .86); }
.login-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.login-features li { display: flex; align-items: center; gap: 12px; }
.login-features i {
    width: 36px; height: 36px; flex: none; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .18); font-size: 16px;
}
.login-features b { display: block; font-size: 13.5px; font-weight: 600; }
.login-features span { font-size: 12px; color: rgba(255, 255, 255, .78); }
.login-intro-foot { font-size: 12px; color: rgba(255, 255, 255, .72); }

.login-form { padding: 46px 44px 34px; display: flex; flex-direction: column; justify-content: center; }
.login-form h1 { margin: 0 0 6px; font-size: 24px; font-weight: 700; color: #1f2a44; }
.login-sub { margin: 0 0 26px; font-size: 13px; color: #8a93a8; }
.login-form .form-label { margin-bottom: 6px; font-size: 13px; font-weight: 600; color: #4b556e; }

.login-field { position: relative; margin-bottom: 18px; }
.login-field > i {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: #9aa3b8; font-size: 15px; pointer-events: none;
}
.login-field .form-control {
    height: 46px; padding-left: 40px;
    border: 1px solid #e2e7f0; border-radius: 10px;
    background: #f8faff; font-size: 14px;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-field .form-control:focus {
    background: #fff; border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(59, 110, 246, .12);
}
.login-field input[type="password"] { padding-right: 44px; }
.login-eye {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 34px; border: 0; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: none; color: #9aa3b8;
}
.login-eye:hover { color: var(--brand); background: #eef2ff; }

.login-submit {
    width: 100%;
    height: 48px; margin-top: 6px; border: 0; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    color: #fff; font-size: 15px; font-weight: 600; letter-spacing: 2px;
    background: linear-gradient(120deg, #3b6ef6, #6a8cff);
    box-shadow: 0 10px 22px rgba(59, 110, 246, .32);
    transition: transform .15s, box-shadow .15s, filter .15s;
}
.login-submit:hover { transform: translateY(-1px); box-shadow: 0 14px 26px rgba(59, 110, 246, .38); filter: brightness(1.03); }
.login-submit:active { transform: translateY(0); }
.login-submit:disabled { opacity: .75; cursor: default; transform: none; }

.login-foot {
    margin-top: 22px; display: flex; align-items: center; justify-content: space-between;
    gap: 10px; font-size: 12px; color: #9aa3b8;
}
.login-foot a { color: #7c86a0; }
.login-foot a:hover { color: var(--brand); }

.login-brand-mobile { display: none; margin-bottom: 22px; color: #1f2a44; }
.login-brand-mobile .login-logo { background: linear-gradient(135deg, #3b6ef6, #7d5ad6); border: 0; color: #fff; }

@media (max-width: 860px) {
    .login-page { padding: 20px 14px; background-attachment: scroll; }
    .login-card { grid-template-columns: 1fr; }
    .login-intro { display: none; }
    .login-brand-mobile { display: flex; }
    .login-form { padding: 32px 24px 26px; }
}

.foot-note { color: #98a0b5; font-size: 12px; }

/* 分页 */
.pagination { margin: 16px 0 0; }
.pagination .active span { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 列表分页条 ---------- */
.pager {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid #f0f2f7;
}
.pager-info { color: #7c86a0; font-size: 13px; }
.pager-info b { color: #2b344a; font-weight: 600; }
.pager-ctrl { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.pager-size { display: inline-flex; align-items: center; gap: 6px; margin: 0 6px 0 0; color: #7c86a0; font-size: 13px; }
.pager-size .form-select { width: auto; padding-right: 26px; }
.pager-btn {
    min-width: 34px; height: 34px; padding: 0 10px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid #e2e7f0; background: #fff; color: #5b6479;
    border-radius: 8px; font-size: 13px; cursor: pointer; transition: all .15s;
}
.pager-btn:hover:not(:disabled):not(.active) { border-color: var(--brand); color: var(--brand); }
.pager-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pager-btn:disabled { opacity: .45; cursor: not-allowed; }
.pager-gap { color: #b3bacd; padding: 0 2px; }
.pager-jump { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; color: #7c86a0; font-size: 13px; }
.pager-jump .form-control { width: 62px; }

.empty-tip { padding: 40px; text-align: center; color: #98a0b5; }

/* 下拉多选组件 */
.ms-wrap { position: relative; }
.ms-wrap .ms-toggle {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; text-align: left; background-color: #fff; cursor: pointer;
}
.ms-wrap .ms-toggle .ms-text {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ms-wrap .ms-toggle .ms-text.is-empty { color: #98a0b5; }
.ms-wrap .ms-toggle .ms-caret { color: #98a0b5; font-size: 12px; transition: transform .15s; }
.ms-wrap.is-open .ms-toggle { border-color: var(--brand, #3a6ff2); box-shadow: 0 0 0 3px rgba(58, 111, 242, .12); }
.ms-wrap.is-open .ms-caret { transform: rotate(180deg); }
.ms-panel {
    display: none; position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px);
    background: #fff; border: 1px solid #e6eaf3; border-radius: 10px;
    box-shadow: 0 12px 28px rgba(31, 42, 68, .14); padding: 8px;
}
.ms-panel.is-open { display: block; }
.ms-panel .ms-search { margin-bottom: 6px; }
.ms-panel .ms-actions {
    display: flex; gap: 12px; padding: 2px 6px 6px; border-bottom: 1px solid #f0f2f8; margin-bottom: 4px;
}
.ms-panel .ms-btn {
    border: 0; background: none; padding: 0; color: var(--brand, #3a6ff2); font-size: 13px; cursor: pointer;
}
.ms-panel .ms-btn:hover { text-decoration: underline; }
.ms-panel .ms-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; }
.ms-panel .ms-item {
    display: flex; align-items: center; gap: 8px; padding: 7px 10px;
    border-radius: 8px; cursor: pointer; font-size: 14px;
}
.ms-panel .ms-item:hover { background: #f4f6fc; }
.ms-panel .ms-item .ms-tick {
    width: 16px; height: 16px; flex: none; border: 1px solid #c8cfdf; border-radius: 4px; position: relative;
}
.ms-panel .ms-item.is-active { color: var(--brand, #3a6ff2); font-weight: 600; }
.ms-panel .ms-item.is-active .ms-tick { background: var(--brand, #3a6ff2); border-color: var(--brand, #3a6ff2); }
.ms-panel .ms-item.is-active .ms-tick::after {
    content: ''; position: absolute; left: 4px; top: 1px; width: 6px; height: 10px;
    border: 2px solid #fff; border-top: 0; border-left: 0; transform: rotate(40deg);
}
.ms-panel .ms-empty { display: none; padding: 12px; text-align: center; color: #98a0b5; font-size: 13px; }

/* ---------- 学生端：顶部导航（手机端可收起） ---------- */
.stu-brand-row { display: flex; align-items: center; gap: 10px; margin-right: 24px; }
.stu-nav-toggle { display: none; }
.stu-nav-panel { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 16px; }
.stu-nav-links, .stu-nav-user { display: flex; align-items: center; gap: 16px; }
.stu-header .stu-nav-panel a { color: #fff; opacity: .85; }
.stu-header .stu-nav-panel a:hover { opacity: 1; }
.stu-user-meta { opacity: .8; }

.exam-head { margin-bottom: 14px; }
.exam-head h5 { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.exam-head-meta { font-size: 13px; }

.exam-mobile-bar { display: none; }
.exam-backdrop { display: none; }
.exam-side-head { display: none; }

/* ---------- 学生端：手机适配 ---------- */
@media (max-width: 768px) {
    /* 顶部菜单收起 */
    .stu-header { padding: 10px 0; }
    .stu-header .wrap { flex-wrap: wrap; gap: 0; }
    .stu-brand-row { width: 100%; justify-content: space-between; margin-right: 0; }
    .stu-brand { font-size: 16px; }
    .stu-nav-toggle {
        display: inline-flex; align-items: center; gap: 6px;
        padding: 6px 12px; border-radius: 8px; font-size: 13px;
        color: #fff; background: rgba(255, 255, 255, .16);
        border: 1px solid rgba(255, 255, 255, .32);
    }
    .stu-nav-toggle.is-active { background: rgba(255, 255, 255, .3); }
    .stu-nav-panel {
        display: none; flex: none; width: 100%;
        flex-direction: column; align-items: stretch; gap: 0;
        margin-top: 10px; padding-top: 4px;
        border-top: 1px solid rgba(255, 255, 255, .2);
    }
    .stu-nav-panel.is-open { display: flex; }
    .stu-nav-links, .stu-nav-user { flex-direction: column; align-items: stretch; gap: 0; }
    .stu-nav-panel a, .stu-nav-user span { padding: 10px 2px; font-size: 14px; }
    .stu-user-name { font-weight: 600; }

    .stu-container { margin: 14px auto; padding: 0 12px 40px; }

    /* 考试页头部与悬浮工具条 */
    .exam-head h5 { font-size: 17px; }
    .exam-head-meta { font-size: 12px; }
    .exam-mobile-bar {
        display: flex; align-items: center; justify-content: space-between; gap: 8px;
        position: sticky; top: 0; z-index: 1040;
        margin-bottom: 12px; padding: 8px 10px;
        border-radius: 12px; color: #fff;
        background: linear-gradient(120deg, #3b6ef6, #6a8cff);
        box-shadow: 0 8px 20px rgba(31, 42, 68, .2);
    }
    .exam-mobile-bar .em-clock {
        display: inline-flex; align-items: center; gap: 5px;
        font-size: 15px; font-weight: 700; letter-spacing: .5px;
        font-variant-numeric: tabular-nums;
    }
    .exam-mobile-bar .em-clock.is-warning { color: #ffe08a; }
    .em-btn {
        display: inline-flex; align-items: center; gap: 5px;
        padding: 7px 11px; border-radius: 9px; font-size: 13px;
        color: #fff; background: rgba(255, 255, 255, .16);
        border: 1px solid rgba(255, 255, 255, .42);
    }
    .em-btn:active { background: rgba(255, 255, 255, .3); }
    .em-btn-primary { background: #fff; border-color: #fff; color: var(--brand); font-weight: 700; }
    .em-answered { font-size: 12px; opacity: .9; }

    .exam-layout { grid-template-columns: 1fr; gap: 0; }

    /* 答题卡抽屉 */
    .exam-side {
        position: fixed; left: 0; right: 0; top: 0; z-index: 1055;
        max-height: 82vh; overflow-y: auto;
        margin: 0; padding: 12px 14px 18px;
        background: #f4f6fb;
        border-radius: 0 0 16px 16px;
        box-shadow: 0 16px 36px rgba(15, 25, 50, .28);
        transform: translateY(-102%);
        transition: transform .25s ease;
    }
    .exam-side.is-open { transform: none; }
    .exam-side .timer-box { display: none; }
    .exam-side-head {
        display: flex; align-items: center; justify-content: space-between;
        margin-bottom: 10px; font-size: 15px;
    }
    .em-close {
        display: inline-flex; align-items: center; gap: 4px;
        padding: 5px 10px; border-radius: 8px; font-size: 13px;
        color: #5b6479; background: #fff; border: 1px solid #e2e7f0;
    }
    .exam-backdrop {
        display: block; position: fixed; inset: 0; z-index: 1050;
        background: rgba(15, 25, 50, .45);
        opacity: 0; visibility: hidden; transition: opacity .25s ease;
    }
    .exam-backdrop.is-open { opacity: 1; visibility: visible; }
    body.exam-sheet-open { overflow: hidden; }

    .exam-side .nav-group { margin-bottom: 10px; }
    .q-nums { gap: 8px; }
    .q-num { width: 40px; height: 40px; font-size: 14px; }

    /* 题目区：触控与阅读优化 */
    .question-block { padding: 14px; scroll-margin-top: 72px; }
    .q-stem { font-size: 15.5px; line-height: 1.75; }
    .q-option {
        padding: 10px 12px; margin-bottom: 8px;
        border: 1px solid #eef1f8; border-radius: 10px; background: #fafbff;
    }
    .q-option:active { background: #eef2ff; }
    .q-option input[type="radio"],
    .q-option input[type="checkbox"] { width: 18px; height: 18px; margin-right: 8px; vertical-align: -3px; }
    /* iOS 聚焦输入时不自动放大页面 */
    .question-block .form-control, .question-block textarea { font-size: 16px; }
    .question-block textarea { min-height: 88px; }
    .question-block .input-group-text { font-size: 12px; }
}
