/* --- 全局与布局样式 --- */
.tutorial-layout {
    display: flex;
    height: calc(100vh - 60px); /* Header is 60px */
    width: 100%;
    overflow: hidden;
    background: var(--bg);
}

/* --- 左侧目录 (Directory) --- */
.sidebar-wrapper {
    width: 260px;
    border-right: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
}
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
}
.tutorial-item {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}
.tutorial-item:hover {
    background: var(--secondary-light);
}
.tutorial-item.active {
    background: var(--primary-light);
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

/* --- 中间展示区 (Content) --- */
.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--bg);
}
.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 40px 60px;
    scroll-behavior: smooth;
}
.markdown-body {
    max-width: 800px;
    margin: 0 auto;
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 16px;
    animation: km-fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.markdown-body h1, .markdown-body h2 {
    color: var(--primary-dark-2);
    margin-top: 32px;
    margin-bottom: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.markdown-body p {
    margin-bottom: 20px;
}
.markdown-body pre {
    background: #1e1E1E;
    color: #D4D4D4;
    padding: 20px;
    border-radius: var(--el-border-radius-base);
    overflow-x: auto;
    font-family: Consolas, Monaco, monospace;
    font-size: 14px;
    margin: 24px 0;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}
.markdown-body code:not(pre code) {
    background: var(--primary-light);
    color: var(--primary-dark-2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: Consolas, Monaco, monospace;
}
.markdown-body blockquote {
    margin: 24px 0;
    padding-left: 16px;
    border-left: 4px solid var(--accent);
    color: var(--text-secondary);
    font-style: italic;
}

.step-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px;
    margin: 40px auto 0;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* --- 右侧游乐场 (Playground) --- */
.playground-wrapper {
    width: 380px;
    border-left: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.playground-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
}
.playground-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #F8FAFC;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.chat-bubble {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: km-fadeInUp 0.4s ease-out backwards;
}
.chat-bubble.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-bubble.ai {
    align-self: flex-start;
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}
.chat-bubble.error {
    align-self: flex-start;
    background: #FEF2F2;
    color: var(--error);
    border: 1px solid #FECACA;
    border-bottom-left-radius: 4px;
}
.playground-input {
    padding: 20px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

@keyframes km-fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 移动端响应式 --- */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 50;
    width: 50px !important;
    height: 50px !important;
}

.mobile-nav-toggle .el-icon {
    font-size: 24px;
}

.mobile-nav-toggle:hover {
    background-color: var(--primary);
    color: white;
}

@media (max-width: 900px) {
    .tutorial-layout {
        flex-direction: column;
        overflow-y: auto;
        height: auto;
        min-height: calc(100vh - 60px);
    }
    
    /* Hide desktop sidebar on mobile */
    .sidebar-wrapper,
    .hidden-sm-and-down {
        display: none !important;
    }
    
    .mobile-nav-toggle {
        display: flex;
    }
    .content-wrapper {
        flex: none;
        /* padding-top: 60px; Space for toggle */
    }
    .content-scroll {
        /* padding: 80px 20px 20px; 为顶部按钮留出空间 */
        overflow: visible;
    }
    .markdown-body {
        font-size: 15px;
    }
    .interaction-card {
        padding: 16px;
    }
    .step-nav {
        flex-direction: column;
        gap: 12px;
    }
    .step-nav .el-button {
        width: 100%;
    }
    .playground-wrapper {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        flex: none;
        height: 50vh; /* 使用视口高度比例而非固定值 */
        min-height: 400px;
    }
}

@media (max-width: 600px) {
    .content-scroll {
        padding: 70px 16px 16px;
    }
    .markdown-body {
        font-size: 14px;
    }
    .markdown-body pre {
        padding: 14px;
        font-size: 13px;
    }
}

.loading-dot {
    width: 6px; height: 6px; background: #CBD5E1; border-radius: 50%;
    animation: km-bounce 1.4s infinite ease-in-out both;
}
.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes km-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* --- 互动组件样式 (Interactions) --- */
.interaction-block {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px dashed var(--border);
}

.interaction-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.quiz-option {
    margin-bottom: 12px;
    display: flex !important;
    height: auto !important;
    min-height: 40px;
    padding: 10px 15px !important;
    white-space: normal !important;
    align-items: center;
}

.quiz-option .el-radio__label {
    white-space: normal !important;
    line-height: 1.5 !important;
    word-break: break-word;
}

.quiz-radio-group {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
}

.quiz-radio-group .el-radio {
    margin-right: 0 !important;
}

.quiz-explanation {
    margin-top: 16px;
    padding: 16px;
    border-radius: 8px;
    font-size: 14px;
}
.quiz-explanation.correct {
    background: #ECFDF5;
    border: 1px solid #10B981;
    color: #065F46;
}
.quiz-explanation.incorrect {
    background: #FEF2F2;
    border: 1px solid #EF4444;
    color: #991B1B;
}

.fill-blank-text {
    line-height: 2;
    font-size: 15px;
}

/* UI 引导高亮动画 */
.km-highlight {
    position: relative;
    z-index: 100;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5);
    border-radius: 4px;
    animation: km-breathe 2s infinite ease-in-out;
}

@keyframes km-breathe {
    0%, 100% { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.7); }
}

/* --- Inline Style Replacements --- */
.tutorial-empty {
    padding: 20px;
    color: #999;
    font-size: 13px;
    text-align: center;
}
.sidebar-height-full {
    height: 100%;
    overflow: auto;
}
.tutorial-step-header {
    margin: 0 0 12px 0;
}
.tutorial-step-badge {
    margin-left: 8px;
}
.tutorial-chat-title,
.tutorial-fill-title {
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 15px;
}
.tutorial-quiz-title {
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.5;
}
.tutorial-chat-prompt {
    font-size: 14px;
    margin-bottom: 16px;
    color: var(--text-secondary);
}
.tutorial-quiz-explanation-text {
    margin-top: 8px;
}
.tutorial-fill-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.tutorial-fill-input {
    width: 140px;
}
.tutorial-highlight-demo {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5);
    border-radius: 4px;
}
.tutorial-placeholder {
    opacity: 0;
}
.tutorial-content-empty {
    padding: 100px;
    text-align: center;
    color: #999;
}
.playground-empty-state {
    text-align: center;
    color: #999;
    margin-top: 40px;
    font-size: 13px;
}
.playground-empty-icon {
    font-size: 24px;
    margin-bottom: 8px;
}
.playground-error-icon {
    vertical-align: middle;
    margin-right: 4px;
}
.playground-loading {
    display: flex;
    gap: 4px;
    padding: 18px;
}
.playground-input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}
.playground-input-hint {
    font-size: 12px;
    color: #999;
}
