/* ============================================================
   三阶段引导式学习系统 — 思维竞技场样式
   遵循系统整体简朴黑白风格
   ============================================================ */

/* --- Base Layout --- */
.arena-container {
    min-height: calc(100vh - 180px);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* 引导式学习页在桌面端使用更宽的画布，避免主内容被通用 container 限窄 */
@media (min-width: 769px) {
    .main-content > .container:has(> #arena-container) {
        max-width: min(1760px, calc(100vw - 48px));
    }

    .main-content > .container > #arena-container {
        max-width: none;
    }
}

/* --- Progress Header --- */
.arena-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 16px;
}

.arena-title {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 8px;
}

.arena-title i { color: #2563eb; }

.arena-timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 4px 12px;
    border-radius: 16px;
}

/* --- Session lifecycle / recovery status --- */
.session-lifecycle {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    margin-bottom: 16px;
    padding: 14px 18px;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    background: linear-gradient(135deg, #f8fbff 0%, #ffffff 100%);
    color: #334155;
}

.session-lifecycle-copy {
    min-width: 0;
    flex: 1 1 auto;
}

.session-lifecycle-heading {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.session-lifecycle-kicker {
    font-size: 13px;
    font-weight: 700;
    color: #1e3a8a;
}

.session-lifecycle-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 9px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
}

.session-lifecycle[data-session-status="active"] .session-lifecycle-badge {
    background: #dcfce7;
    color: #166534;
}

.session-lifecycle[data-session-status="idle"] .session-lifecycle-badge {
    background: #fef3c7;
    color: #92400e;
}

.session-lifecycle[data-session-status="completed"] .session-lifecycle-badge {
    background: #dbeafe;
    color: #1d4ed8;
}

.session-lifecycle-meta,
.session-lifecycle-next,
.session-lifecycle-note {
    min-width: 0;
    margin: 4px 0 0;
    overflow-wrap: anywhere;
}

.session-lifecycle-meta,
.session-lifecycle-note {
    color: #64748b;
    font-size: 12px;
}

.session-lifecycle-next {
    color: #475569;
    font-size: 13px;
}

.session-lifecycle-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 10px;
    min-width: 0;
}

.session-lifecycle-progress {
    width: 90px;
    height: 6px;
    overflow: hidden;
    border-radius: 99px;
    background: #e2e8f0;
}

.session-lifecycle-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #2563eb;
    transition: width 180ms ease;
}

.session-lifecycle-feedback {
    min-width: 0;
    max-width: 150px;
    color: #64748b;
    font-size: 11px;
    overflow-wrap: anywhere;
}

.session-lifecycle-note {
    flex: 0 1 210px;
    margin-top: 0;
}

@media (max-width: 768px) {
    .session-lifecycle {
        align-items: stretch;
        flex-direction: column;
    }

    .session-lifecycle-actions {
        justify-content: space-between;
    }

    .session-lifecycle-note {
        flex-basis: auto;
    }
}

/* --- Progress Steps --- */
.progress-steps {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 400px;
    margin: 0 24px;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.step-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    background: #f3f4f6;
    color: #9ca3af;
    border: 2px solid #e5e7eb;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.step-circle.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.step-circle.completed {
    background: #10b981;
    color: #fff;
    border-color: #10b981;
}

.step-line {
    flex: 1;
    height: 2px;
    background: #e5e7eb;
    border-radius: 1px;
    transition: background 0.2s ease;
}

.step-line.completed { background: #10b981; }

.step-label {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
}

.step-label.active { color: #2563eb; font-weight: 600; }
.step-label.completed { color: #10b981; }

/* --- Main Content --- */
.arena-body {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    min-height: 520px;
    height: 600px;
}

.arena-body.stage-2-layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.95fr) minmax(260px, 0.85fr);
    gap: 14px;
    height: clamp(600px, calc(100vh - 260px), 820px);
    transition: grid-template-columns 220ms ease;
}

.arena-body.stage-2-layout.companion-collapsed {
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr) 52px;
}

.arena-body.stage-2-layout.preview-collapsed {
    grid-template-columns: minmax(0, 1.65fr) 52px minmax(260px, 0.9fr);
}

.arena-body.stage-2-layout.preview-collapsed.companion-collapsed {
    grid-template-columns: minmax(0, 1fr) 52px 52px;
}

.arena-body.stage-2-layout.companion-collapsed #ai-companion-panel .panel-header,
.arena-body.stage-2-layout.preview-collapsed #stage2-preview-panel .panel-header {
    min-height: 100%;
    padding: 14px 8px;
    flex-direction: column;
    justify-content: flex-start;
    gap: 14px;
}

.arena-body.stage-2-layout.companion-collapsed #ai-companion-panel .panel-header h3,
.arena-body.stage-2-layout.preview-collapsed #stage2-preview-panel .panel-header h3 {
    font-size: 0;
}

.arena-body.stage-2-layout.companion-collapsed #ai-companion-panel .panel-header h3 i,
.arena-body.stage-2-layout.preview-collapsed #stage2-preview-panel .panel-header h3 i {
    font-size: 15px;
}

.arena-body.stage-2-layout.companion-collapsed #companion-panel-content,
.arena-body.stage-2-layout.preview-collapsed #stage2-preview-content {
    display: none;
}

.arena-body.stage-2-layout.companion-collapsed .panel-collapse-toggle,
.arena-body.stage-2-layout.preview-collapsed .stage2-preview-toggle {
    padding: 7px;
    border-radius: 7px;
}

.arena-body.stage-2-layout.companion-collapsed .panel-collapse-toggle span,
.arena-body.stage-2-layout.preview-collapsed .stage2-preview-toggle span {
    display: none;
}

.arena-body.stage-2-layout.companion-collapsed .panel-collapse-toggle i,
.arena-body.stage-2-layout.preview-collapsed .stage2-preview-toggle i {
    transform: rotate(180deg);
}

/* 阶段一以答题区为主：伴学助手保持可见，但不抢占回答宽度。 */
.arena-body.stage-1-layout {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    transition: grid-template-columns 220ms ease;
}

.arena-body.stage-1-layout.companion-collapsed {
    grid-template-columns: minmax(0, 1fr) 52px;
}

.arena-body.stage-1-layout.companion-collapsed #right-panel {
    min-width: 0;
}

.arena-body.stage-1-layout.companion-collapsed #ai-companion-panel .panel-header {
    min-height: 100%;
    padding: 14px 8px;
    flex-direction: column;
    justify-content: flex-start;
    gap: 14px;
}

.arena-body.stage-1-layout.companion-collapsed #ai-companion-panel .panel-header h3 {
    font-size: 0;
}

.arena-body.stage-1-layout.companion-collapsed #ai-companion-panel .panel-header h3 i {
    font-size: 15px;
}

.arena-body.stage-1-layout.companion-collapsed #companion-panel-content {
    display: none;
}

.arena-body.feynman-layout {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    height: clamp(600px, calc(100vh - 260px), 820px);
}

#stage-3 > .panel-body {
    display: flex;
    min-height: 0;
    overflow: hidden;
}

#stage-3 .stage3-forum {
    flex: 1;
    height: 100%;
    min-height: 0;
}

.arena-body.feynman-layout > #right-panel {
    align-self: start;
    height: fit-content;
}

.arena-body.feynman-layout > #right-panel #stage3-goal-panel.active {
    flex: 0 0 auto;
    height: auto;
    overflow: visible;
}

#stage3-goal-panel .panel-body {
    overflow: visible;
}

#stage3-goal-panel .forum-goal-card {
    margin: 0;
}

#stage3-goal-panel .forum-goal-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* --- Panel --- */
.arena-panel {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

.panel-header {
    padding: 12px 20px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel-header h3 i { color: #2563eb; font-size: 14px; }

.stage2-header-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--arena-text-dim);
    font-size: 11px;
    text-align: right;
}

.stage2-answer-progress {
    padding: 3px 8px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
    white-space: nowrap;
}

.panel-collapse-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    background: #eff6ff;
    color: #2563eb;
    padding: 4px 8px;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.panel-collapse-toggle:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

.panel-collapse-toggle:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

.arena-body.stage-1-layout.companion-collapsed .panel-collapse-toggle {
    padding: 7px;
    border-radius: 7px;
}

.arena-body.stage-1-layout.companion-collapsed .panel-collapse-toggle span {
    display: none;
}

.arena-body.stage-1-layout.companion-collapsed .panel-collapse-toggle i {
    transform: rotate(180deg);
}

.panel-body {
    flex: 1;
    padding: 16px 20px;
    overflow-y: auto;
}

/* --- Problem Panel --- */
.problem-panel {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.problem-panel h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 6px;
}

.problem-panel h2 i { color: #f59e0b; }

.problem-description {
    font-size: 13px;
    line-height: 1.7;
    color: #374151;
}

/* --- Stage 1: Textarea --- */
.description-textarea {
    width: 100%;
    min-height: 180px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #1f2937;
    font-size: 14px;
    line-height: 1.7;
    padding: 12px 14px;
    resize: vertical;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.description-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.description-textarea::placeholder { color: #9ca3af; }

.score-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 6px;
    margin-top: 10px;
}

.score-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    border: 2px solid;
    flex-shrink: 0;
}

.score-circle.pass { border-color: #10b981; color: #10b981; }
.score-circle.fail { border-color: #f59e0b; color: #f59e0b; }

.score-feedback {
    font-size: 13px;
    color: #374151;
    line-height: 1.5;
}

/* --- Stage 2: Blocks --- */
.blocks-workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    height: 100%;
}

.block-pool, .block-solution {
    background: #f9fafb;
    border-radius: 6px;
    border: 2px dashed #e5e7eb;
    padding: 10px;
    min-height: 260px;
    transition: border-color 0.2s ease;
}

.block-solution {
    border-color: #2563eb;
    border-style: dashed;
}

.block-solution.drag-over {
    border-color: #10b981;
    background: #f0fdf4;
}

.block-pool-title, .block-solution-title {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.code-block {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: 3px solid #2563eb;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 4px;
    cursor: grab;
    transition: all 0.15s ease;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #1f2937;
    user-select: none;
    position: relative;
}

.code-block:hover {
    border-color: #2563eb;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.code-block:active, .code-block.sortable-drag {
    cursor: grabbing;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.code-block.sortable-ghost {
    opacity: 0.3;
    border-style: dashed;
}

.code-block .block-label {
    font-family: inherit;
    font-size: 10px;
    color: #9ca3af;
    margin-top: 2px;
}

.code-block[data-indent="1"] { margin-left: 24px; }
.code-block[data-indent="2"] { margin-left: 48px; }
.code-block[data-indent="3"] { margin-left: 72px; }
.code-block[data-indent="4"] { margin-left: 96px; }

.indent-controls {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.code-block:hover .indent-controls { opacity: 1; }

.indent-btn {
    width: 20px;
    height: 20px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #6b7280;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
}

.indent-btn:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* --- Stage 3: Chat --- */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.chat-message.user { flex-direction: row-reverse; }

.chat-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    background: #f3f4f6;
}

.chat-avatar.teacher { background: #eff6ff; }
.chat-avatar.student { background: #f0fdf4; }
.chat-avatar.bad-student { background: #fef3c7; }

.chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    word-wrap: break-word;
}

.chat-bubble img, .hint-bubble img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 6px;
    margin-top: 8px;
    display: block;
}

.chat-bubble.ai {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 2px;
}

.chat-bubble.user-msg {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 2px;
}

/* Markdown elements styling inside chat bubbles */
.chat-bubble strong, .hint-bubble strong {
    font-weight: 700 !important;
}
.chat-bubble p {
    margin-bottom: 8px;
}
.chat-bubble p:last-child {
    margin-bottom: 0;
}
.chat-bubble code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: var(--arena-mono, monospace);
    font-size: 0.9em;
}
.chat-bubble.user-msg code {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}
.chat-bubble pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 10px 14px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}
.chat-bubble pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}
.chat-bubble ul, .chat-bubble ol {
    margin-bottom: 8px;
    padding-left: 20px;
}
.chat-bubble ul:last-child, .chat-bubble ol:last-child {
    margin-bottom: 0;
}

.chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 8px 14px;
    color: #1f2937;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.chat-input:focus { border-color: #2563eb; }
.chat-input::placeholder { color: #9ca3af; }

/* --- Stage 3: Public Forum --- */
.stage3-forum {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 100%;
}

.forum-sticky-head {
    position: sticky;
    top: 0;
    z-index: 10;
    flex: 0 0 auto;
    margin: -16px -20px 0;
    padding: 12px 20px 10px;
    border: 1px solid #e2e8f0;
    border-top: 0;
    border-radius: 0 0 16px 16px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 18px -16px rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    transform: translate3d(0, 0, 0);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 220ms ease, background-color 220ms ease;
    will-change: transform;
}

.forum-sticky-head.is-scrolled {
    transform: translate3d(0, -2px, 0);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 12px 24px -16px rgba(15, 23, 42, 0.72);
}

.forum-goal-card {
    flex: 0 0 auto;
    padding: 14px 16px;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: linear-gradient(135deg, #f8fbff 0%, #ffffff 72%);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.06);
}

.forum-goal-summary {
    position: relative;
    display: block;
    padding-right: 42px;
    cursor: pointer;
    list-style: none;
}

.forum-goal-summary::-webkit-details-marker {
    display: none;
}

.forum-goal-summary::after {
    content: '展开';
    position: absolute;
    top: 1px;
    right: 0;
    padding: 3px 7px;
    border-radius: 999px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 10px;
    font-weight: 700;
}

.forum-goal-card[open] .forum-goal-summary::after {
    content: '收起';
}

.forum-goal-summary:focus-visible,
.stage3-guide-summary:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
    border-radius: 6px;
}

.forum-goal-summary-progress {
    margin-top: 12px;
}

.forum-goal-details {
    padding-top: 10px;
}

.forum-goal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.forum-goal-kicker {
    color: #2563eb;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.forum-goal-kicker i {
    margin-right: 4px;
}

.forum-goal-head h4 {
    margin: 4px 0 0;
    color: #172554;
    font-size: 15px;
    line-height: 1.35;
}

.forum-goal-status {
    flex: 0 0 auto;
    padding: 4px 9px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.forum-goal-status.is-ready_for_code,
.forum-goal-status.is-complete {
    background: #dcfce7;
    color: #166534;
}

.forum-goal-description {
    margin: 8px 0 10px;
    color: #475569;
    font-size: 12px;
    line-height: 1.55;
}

.forum-goal-progress-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.forum-goal-progress-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #22c55e);
    transition: width 0.35s ease;
}

.forum-goal-progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    color: #64748b;
    font-size: 11px;
}

.forum-goal-progress-meta span:first-child {
    color: #1d4ed8;
    font-weight: 800;
}

.forum-goal-next {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 9px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 12px;
    line-height: 1.5;
}

.forum-goal-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.forum-goal-step {
    position: relative;
    min-width: 0;
    padding: 7px 8px 7px 26px;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #ffffff;
    color: #64748b;
    font-size: 11px;
    line-height: 1.35;
}

.forum-goal-step::before {
    content: '○';
    position: absolute;
    left: 8px;
    top: 7px;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 700;
}

.forum-goal-step.is-active {
    border-color: #93c5fd;
    background: #f8fbff;
    color: #1e40af;
}

.forum-goal-step.is-active::before {
    content: '→';
    color: #2563eb;
}

.forum-goal-step.is-done {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.forum-goal-step.is-done::before {
    content: '✓';
    color: #16a34a;
}

.forum-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 0 0;
}

.forum-feed {
    overscroll-behavior-y: contain;
}

.forum-targets {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.forum-target-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    background: #f8fafc;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.forum-target-btn:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.forum-target-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.forum-target-btn.is-selected,
.forum-target-btn[aria-pressed="true"] {
    border-color: #2563eb;
    background: #dbeafe;
    box-shadow: 0 0 0 1px #2563eb;
}

.forum-target-label {
    font-size: 13px;
    font-weight: 700;
}

.forum-target-hint {
    font-size: 12px;
    color: #64748b;
}

.forum-reply-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 12px;
}

.forum-reply-context[hidden] {
    display: none;
}

.forum-reply-context-label {
    min-width: 0;
    line-height: 1.5;
}

.forum-reply-clear {
    border: none;
    background: transparent;
    color: #c2410c;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.forum-feed {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.forum-event {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.forum-event.is-user {
    flex-direction: row-reverse;
}

.forum-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
}

.forum-avatar.role-user {
    background: #eff6ff;
}

.forum-avatar.role-teacher_agent {
    background: #eef2ff;
}

.forum-avatar.role-student_agent {
    background: #f0fdf4;
}

.forum-card {
    flex: 1;
    min-width: 0;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.forum-event.is-user .forum-card {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.forum-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.forum-meta-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.forum-role {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
}

.forum-kind {
    padding: 2px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
}

.forum-kind.kind-student_probe {
    background: #dcfce7;
    color: #166534;
}

.forum-kind.kind-user_message {
    background: #dbeafe;
    color: #1d4ed8;
}

.forum-kind.kind-agent_message {
    background: #e2e8f0;
    color: #334155;
}

.forum-relation {
    width: 100%;
    font-size: 12px;
    color: #64748b;
}

.forum-content {
    white-space: pre-wrap;
    word-break: break-word;
    color: #0f172a;
    font-size: 13px;
    line-height: 1.65;
}

.forum-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-start;
}

.forum-reply-action {
    border: none;
    background: transparent;
    color: #2563eb;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.forum-reply-action:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.forum-input-area {
    padding-left: 0;
    padding-right: 0;
}

.stage3-guide-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 0 14px 14px;
}

#student-agent-panel.stage3-guide-drawer.active {
    display: block;
    flex: 0 0 auto;
    height: auto;
    overflow: visible;
    margin-top: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.stage3-guide-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
}

.stage3-guide-summary::-webkit-details-marker {
    display: none;
}

.stage3-guide-summary > span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.stage3-guide-summary > span:first-child i {
    color: #2563eb;
}

.stage3-guide-summary-hint {
    color: #64748b;
    font-size: 11px;
    font-weight: 500;
}

.stage3-guide-summary-hint i {
    margin-left: 4px;
    transition: transform 180ms ease;
}

#student-agent-panel[open] .stage3-guide-summary-hint i {
    transform: rotate(180deg);
}

.stage3-guide-card {
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}

.stage3-guide-card h4 {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
}

.stage3-guide-card p {
    margin: 0;
    font-size: 12px;
    line-height: 1.6;
    color: #475569;
}

/* --- Code Review (Feynman) --- */
.code-review-panel {
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    margin: 8px 0;
    overflow: hidden;
}

.code-review-header {
    padding: 8px 14px;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    font-size: 12px;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 6px;
}

.code-review-body { padding: 12px; }

.code-review-body pre {
    background: #1e293b;
    border-radius: 6px;
    padding: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #e2e8f0;
    overflow-x: auto;
    margin: 0;
}

.code-fix-input {
    width: 100%;
    min-height: 100px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    padding: 12px;
    resize: none;
    overflow-y: hidden;
    margin-top: 8px;
}

.code-fix-input:focus {
    outline: none;
    border-color: #2563eb;
}

/* --- Buttons --- */
.arena-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.arena-btn-primary {
    background: #2563eb;
    color: #fff;
}

.arena-btn-primary:hover {
    background: #1d4ed8;
}

.arena-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.arena-btn-success {
    background: #10b981;
    color: #fff;
}

.arena-btn-success:hover { background: #059669; }

.arena-btn-outline {
    background: transparent;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.arena-btn-outline:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.arena-btn-send {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.arena-btn-send:hover { background: #1d4ed8; }
.arena-btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Hint --- */
.hint-bubble {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 10px 14px;
    margin: 8px 0;
    font-size: 13px;
    color: #1e40af;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.hint-bubble i {
    color: #2563eb;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Markdown elements styling inside hint bubbles */
.hint-bubble p {
    margin-bottom: 6px;
}
.hint-bubble p:last-child {
    margin-bottom: 0;
}
.hint-bubble code {
    background: rgba(37, 99, 235, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: var(--arena-mono, monospace);
    font-size: 0.9em;
}
.hint-bubble pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
}
.hint-bubble pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}
.hint-bubble ul, .hint-bubble ol {
    margin-bottom: 6px;
    padding-left: 20px;
}
.hint-bubble ul:last-child, .hint-bubble ol:last-child {
    margin-bottom: 0;
}

/* --- Typing Indicator --- */
.typing-indicator {
    display: flex;
    gap: 3px;
    padding: 6px 12px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* --- Stage Transitions --- */
.stage-section {
    display: none;
}

.stage-section.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    height: 100%;
}

/* --- Celebration --- */
.celebration-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.celebration-card {
    background: #fff;
    border-radius: 12px;
    padding: 36px;
    text-align: center;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.celebration-icon { font-size: 48px; margin-bottom: 12px; }

.celebration-title {
    font-size: 20px;
    font-weight: 700;
    color: #10b981;
    margin-bottom: 6px;
}

.celebration-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* --- Preset Loading --- */
.preset-pending {
    text-align: center;
    padding: 60px 20px;
}

.preset-pending i {
    font-size: 36px;
    color: #9ca3af;
    margin-bottom: 12px;
    display: block;
}

.preset-pending h3 {
    font-size: 16px;
    color: #1f2937;
    margin-bottom: 6px;
}

.preset-pending p {
    color: #6b7280;
    font-size: 13px;
}

/* --- Action Bar --- */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    gap: 8px;
}

.action-bar-left {
    display: flex;
    gap: 6px;
}

/* --- Scrollbar --- */
.panel-body::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.panel-body::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 2px;
}

/* --- Responsive --- */
@media (min-width: 769px) and (max-width: 1180px) {
    /* 中等桌面宽度改为“答题 + 预览”双栏，伴学助手独占底部一行，
       避免三个面板把题目和选项压成窄条。 */
    .arena-body.stage-2-layout {
        grid-template-columns: minmax(0, 1.45fr) minmax(250px, 0.8fr);
        grid-template-rows: minmax(0, 1fr) 220px;
        grid-template-areas:
            "quiz preview"
            "companion companion";
        height: clamp(640px, calc(100vh - 250px), 780px);
    }

    .arena-body.stage-2-layout > #left-panel {
        grid-area: quiz;
    }

    .arena-body.stage-2-layout > #stage2-preview-panel {
        grid-area: preview;
    }

    .arena-body.stage-2-layout > #right-panel {
        grid-area: companion;
        min-height: 0;
        height: 220px;
    }

    .arena-body.stage-2-layout.companion-collapsed {
        grid-template-columns: minmax(0, 1.45fr) minmax(250px, 0.8fr);
        grid-template-rows: minmax(0, 1fr) 52px;
    }

    .arena-body.stage-2-layout.preview-collapsed {
        grid-template-columns: minmax(0, 1fr) 52px;
    }

    .arena-body.stage-2-layout.preview-collapsed.companion-collapsed {
        grid-template-columns: minmax(0, 1fr) 52px;
    }
}

@media (max-width: 768px) {
    .arena-body, .arena-body.feynman-layout, .arena-body.stage-2-layout {
        grid-template-columns: 1fr;
    }
    .blocks-workspace {
        grid-template-columns: 1fr;
    }
    .arena-header {
        flex-direction: column;
        gap: 8px;
    }
    .progress-steps {
        margin: 0;
        max-width: 100%;
    }
}

/* --- Loading Spinner for Submit Button --- */
.rotating-icon {
    display: inline-block;
    animation: spin-icon 1s linear infinite;
}
@keyframes spin-icon {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Algorithm Summary Panel (Stage 1 Scaffold) --- */
.algorithm-summary-panel {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #2563eb;
    border-radius: 6px;
    margin-bottom: 12px;
    overflow: hidden;
}

.algorithm-summary-header {
    padding: 10px 14px;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
    font-weight: 600;
    color: #1e3a8a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.algorithm-summary-header:hover {
    background: #e2e8f0;
}

.algorithm-summary-body {
    padding: 12px 14px;
    font-size: 13px;
    color: #334155;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* --- Stage 1: compact guidance and wide answer workspace --- */
#stage-1 .panel-body {
    min-width: 0;
}

#stage-1 #stage-qa-inputs-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#stage-1 #stage-qa-inputs-wrapper .qa-item {
    margin-bottom: 0 !important;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

#stage-1 #stage-qa-inputs-wrapper .qa-question-label {
    line-height: 1.55;
}

#stage-1 #stage-qa-inputs-wrapper .qa-question-label > span:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

#stage-1 #stage-qa-inputs-wrapper .qa-answer-textarea {
    min-height: 86px !important;
}

#stage-2 .panel-body {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#stage-2 .quiz-steps-panel {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
}

#stage-2 .quiz-step-question {
    align-items: flex-start;
    line-height: 1.55;
}

#stage-2 .quiz-choice-option {
    min-width: 0;
    align-items: flex-start;
    line-height: 1.5;
}

#stage-2 .quiz-choice-option code {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

#stage-2 .quiz-fill-input {
    min-width: min(180px, 100%);
    max-width: none;
}

.stage1-answer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 2px 0 10px;
    padding: 10px 12px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: linear-gradient(90deg, #eff6ff, #f8fbff);
    color: #1e3a8a;
}

.stage1-answer-toolbar > div {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.stage1-answer-toolbar strong {
    font-size: 13px;
    white-space: nowrap;
}

.stage1-answer-toolbar span {
    color: #64748b;
    font-size: 11px;
    line-height: 1.5;
}

.stage1-answer-progress {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8 !important;
    font-size: 11px !important;
    white-space: nowrap;
}

.stage1-collapsible-panel {
    margin-bottom: 12px;
    border: 1px solid #bfdbfe;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    background: #eff6ff;
    overflow: hidden;
}

.stage1-collapse-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    color: #1e3a8a;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.stage1-collapse-header:hover {
    background: rgba(219, 234, 254, 0.72);
}

.stage1-collapse-header:focus-visible,
.algorithm-summary-header:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: -2px;
}

.stage1-collapse-header > span {
    min-width: 0;
}

.stage1-collapse-header i:first-child,
.stage1-collapse-header > span > i {
    margin-right: 5px;
    color: #2563eb;
}

.stage1-collapse-header small {
    color: #64748b;
    font-size: 11px;
    font-weight: 400;
}

.stage1-collapsible-body {
    padding: 0 14px 12px;
    color: #1e40af;
    font-size: 13px;
    line-height: 1.65;
}

.stage1-collapsible-body[hidden] {
    display: none;
}

.stage1-collapsible-body ul {
    margin: 0;
    padding-left: 20px;
}

.stage1-instruction {
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin: 8px 0 12px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 禁止复制选中 */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* --- Developer Debug Panel --- */
.dev-debug-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1e293b;
    color: #f8fafc;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    z-index: 99999;
    width: 260px;
    max-width: calc(100vw - 32px);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    border: 1px solid #334155;
    opacity: 0.9;
    overflow: hidden;
    transition: opacity 0.2s ease, width 0.2s ease;
}
.dev-debug-panel:hover {
    opacity: 1;
}
.dev-debug-panel.is-collapsed {
    width: 148px;
}
.dev-debug-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    color: #38bdf8;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
}
.dev-debug-toggle:focus-visible {
    outline: 2px solid #38bdf8;
    outline-offset: -2px;
}
.dev-debug-title {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.dev-debug-chevron {
    flex: 0 0 auto;
    font-size: 17px;
    line-height: 1;
    transition: transform 0.2s ease;
}
.dev-debug-panel:not(.is-collapsed) .dev-debug-chevron {
    transform: rotate(180deg);
}
.dev-debug-content {
    padding: 0 14px 14px;
    border-top: 1px solid #334155;
}
.dev-debug-panel.is-collapsed .dev-debug-content,
.dev-debug-content[hidden] {
    display: none;
}
.dev-debug-description {
    margin: 8px 0;
    color: #94a3b8;
    font-size: 11px;
}
.dev-debug-btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}
.dev-debug-btn {
    background: #334155;
    color: #f8fafc;
    border: none;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s ease, transform 0.1s ease;
    text-align: center;
}
.dev-debug-btn:hover {
    background: #475569;
}
.dev-debug-btn:active {
    transform: scale(0.97);
}
.dev-debug-btn-primary {
    background: #2563eb;
}
.dev-debug-btn-primary:hover {
    background: #3b82f6;
}
.dev-debug-btn-success {
    background: #16a34a;
}
.dev-debug-btn-success:hover {
    background: #22c55e;
}
.dev-debug-btn-full {
    grid-column: span 2;
}
.dev-debug-trace {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #334155;
}
.dev-debug-trace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.dev-debug-trace-title {
    font-size: 12px;
    font-weight: 700;
    color: #e2e8f0;
}
.dev-debug-trace-summary,
.dev-debug-trace-empty {
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.5;
}
.dev-debug-trace-summary {
    margin-bottom: 8px;
}
.dev-debug-trace-list {
    display: grid;
    gap: 8px;
}
.dev-debug-trace-item {
    padding: 8px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.2);
}
.dev-debug-trace-row {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 8px;
    font-size: 11px;
    line-height: 1.4;
}
.dev-debug-trace-row + .dev-debug-trace-row {
    margin-top: 4px;
}
.dev-debug-trace-key {
    color: #7dd3fc;
    font-weight: 600;
}
.dev-debug-trace-value {
    color: #f8fafc;
    overflow-wrap: anywhere;
}

/* --- Stage 2 Quiz-based step-by-step styles --- */
.quiz-steps-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    max-height: 60vh;
    overflow-y: auto;
}

.quiz-part-header {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    padding: 6px 12px;
    background: #e2e8f0;
    border-radius: 4px;
    margin-top: 8px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.quiz-step-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.quiz-step-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.quiz-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    margin-right: 8px;
}

.quiz-step-question {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.quiz-choice-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-choice-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: #f8fafc;
}

.quiz-choice-option:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.quiz-choice-option.selected {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 0 0 1px #3b82f6;
}

.quiz-choice-option input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.quiz-choice-option code {
    font-family: var(--arena-mono, monospace);
    font-size: 13px;
    color: #0f172a;
    background: transparent;
    padding: 0;
}

.quiz-fill-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    background: #f8fafc;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.quiz-fill-context {
    font-family: var(--arena-mono, monospace);
    font-size: 13px;
    color: #475569;
}

.quiz-fill-input {
    min-width: 120px;
    max-width: 300px;
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-family: var(--arena-mono, monospace);
    font-size: 13px;
    color: #0f172a;
    background: #ffffff;
    outline: none;
    transition: border-color 0.15s ease;
}

.quiz-fill-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.quiz-step-feedback {
    margin-top: 10px;
    font-size: 13px;
    display: none;
}

.quiz-step-correct {
    border-color: #86efac !important;
    background: #f0fdf4 !important;
}

.quiz-step-correct .quiz-step-num {
    background: #22c55e;
    color: #ffffff;
}

.quiz-step-wrong {
    border-color: #fca5a5 !important;
    background: #fef2f2 !important;
}

.quiz-step-wrong .quiz-step-num {
    background: #ef4444;
    color: #ffffff;
}

.feedback-correct {
    display: block;
    color: #166534;
    font-weight: 500;
}

.feedback-wrong {
    display: block;
    color: #991b1b;
    font-weight: 500;
    line-height: 1.4;
}

/* --- Voice Input Buttons & Recording Styles --- */
.arena-btn-voice {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    outline: none;
}

.arena-btn-voice:hover {
    background: #e5e7eb;
    color: #1f2937;
    border-color: #cbd5e1;
}

.arena-btn-voice-small {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid #cbd5e1;
    background-color: #f8fafc;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.arena-btn-voice-small:hover {
    background-color: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
}

.arena-btn-voice.recording,
.arena-btn-voice-small.recording {
    background-color: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
    animation: voice-pulse 1.5s infinite ease-in-out;
}

@keyframes voice-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* 默认隐藏移动端选项卡导航栏，只在手机端媒体查询中激活 */
.arena-mobile-tabs {
    display: none !important;
}

/* ============================================================
   移动端响应式样式 (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {
    /* 调整主页面间距 */
    .arena-container {
        padding: 0 8px !important;
        margin-top: 8px !important;
    }

    /* 优化头部进度条和定时器 */
    .arena-header {
        padding: 10px 12px !important;
        margin-bottom: 10px !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    .arena-title {
        font-size: 14px !important;
        gap: 4px !important;
    }

    .progress-steps {
        margin: 0 !important;
        max-width: 140px !important;
        flex: 1 !important;
    }

    .step-label {
        display: none !important; /* 移动端隐藏步骤文字，仅保留圆圈 */
    }

    .step-circle {
        width: 22px !important;
        height: 22px !important;
        font-size: 11px !important;
    }

    .arena-timer {
        font-size: 12px !important;
        padding: 2px 8px !important;
    }

    /* 优化题目面板 */
    .problem-panel {
        padding: 12px 14px !important;
        margin-bottom: 10px !important;
    }

    .problem-panel h2 {
        font-size: 14px !important;
    }

    .problem-description {
        font-size: 12px !important;
        line-height: 1.5 !important;
    }

    /* 移动端标签页导航栏 */
    .arena-mobile-tabs {
        display: flex !important;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 10px;
        overflow: hidden;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    }

    .mobile-tab-btn {
        flex: 1;
        padding: 10px 4px;
        border: none;
        background: none;
        font-size: 13px;
        font-weight: 500;
        color: #4b5563;
        text-align: center;
        cursor: pointer;
        transition: all 0.2s ease;
        border-bottom: 3px solid transparent;
        outline: none;
    }

    .mobile-tab-btn.active {
        color: #2563eb;
        border-bottom-color: #2563eb;
        font-weight: 600;
        background: rgba(37, 99, 235, 0.03);
    }

    /* 主布局转换为单栏 */
    .arena-body {
        display: block !important;
        height: auto !important;
        min-height: unset !important;
    }

    /* 隐藏所有面板，除了当前激活的 mobile-active 面板 */
    .arena-body > .arena-panel {
        display: none !important;
        height: 520px !important; /* 给面板一个标准高度以便在滚动时交互 */
        width: 100% !important;
        margin-bottom: 0 !important;
    }

    .arena-body > .arena-panel.mobile-active {
        display: flex !important;
    }

    /* 内部布局微调 */
    .panel-header {
        padding: 10px 14px !important;
    }

    .panel-header h3 {
        font-size: 13px !important;
    }

    .stage2-header-meta > span:first-child {
        display: none;
    }

    .panel-body {
        padding: 10px 14px !important;
    }

    .forum-sticky-head {
        margin: -10px -14px 0;
        padding: 10px 14px 8px;
        border-radius: 0 0 12px 12px;
    }

    .forum-sticky-head .forum-goal-card {
        padding-bottom: 8px;
    }

    /* 阶段一输入区优化 */
    .description-textarea {
        min-height: 120px !important;
        font-size: 13px !important;
        padding: 8px 10px !important;
    }

    #stage-1 #stage-qa-inputs-wrapper .qa-item {
        padding: 10px 11px !important;
    }

    .stage1-answer-toolbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
        padding: 9px 10px;
    }

    .stage1-answer-progress {
        align-self: flex-end;
    }

    .stage1-collapse-header {
        padding: 9px 10px;
        font-size: 12px;
    }

    .stage1-collapse-header small {
        display: none;
    }

    /* 阶段二题目列表优化 */
    .quiz-steps-panel {
        gap: 12px !important;
    }

    .quiz-step-card {
        padding: 12px !important;
        margin-bottom: 10px !important;
        border-radius: 6px !important;
    }

    .quiz-question-text {
        font-size: 13px !important;
        margin-bottom: 8px !important;
    }

    .quiz-choice-option {
        padding: 8px 10px !important;
        font-size: 12px !important;
        margin-bottom: 6px !important;
    }

    .quiz-fill-input {
        padding: 6px 8px !important;
        font-size: 12px !important;
    }

    .quiz-step-num {
        width: 18px !important;
        height: 18px !important;
        font-size: 10px !important;
    }

    /* 阶段三对话框与输入框 */
    .chat-messages {
        padding: 8px !important;
        gap: 8px !important;
    }

    .chat-bubble {
        max-width: 85% !important;
        padding: 8px 12px !important;
        font-size: 12.5px !important;
    }

    .chat-input-area {
        padding: 8px 10px !important;
    }

    .chat-input {
        font-size: 12px !important;
        padding: 6px 12px !important;
    }

    .forum-targets {
        grid-template-columns: 1fr !important;
    }

    .forum-feed {
        min-height: 0 !important;
    }

    .stage3-guide-panel {
        grid-template-columns: 1fr;
    }

    .stage3-guide-summary {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    #stage3-goal-panel .panel-body {
        overflow-y: auto;
    }

    .forum-card {
        padding: 10px 12px !important;
    }

    .action-bar {
        padding: 10px 0 0 0 !important;
        gap: 8px !important;
    }

    .arena-btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }

    /* 底部通栏排版修复 */
    #code-review-section {
        margin-top: 10px !important;
        padding: 0 6px !important;
    }
}

