* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #c41e3a;
    --primary-dark: #9a1830;
    --bg: #f5f5f7;
    --card: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --border: #e5e5ea;
    --success: #34c759;
    --warning: #ff9500;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg);
}

/* Header */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    min-height: 48px;
}

.header h1 {
    flex: 1;
    font-size: 17px;
    font-weight: 600;
    text-align: center;
}

.back-btn {
    font-size: 28px;
    color: var(--primary);
    text-decoration: none;
    width: 32px;
    line-height: 1;
}

.header-right {
    width: 32px;
    text-align: right;
    font-size: 14px;
}

/* Main */
.main {
    flex: 1;
    padding: 16px;
    padding-bottom: 80px;
}

/* Login Page */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 24px;
    background: linear-gradient(160deg, #fff 0%, #fef2f4 100%);
}

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 40px;
}

.login-form {
    width: 100%;
    max-width: 340px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    background: var(--card);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
}

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-block {
    width: 100%;
}

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-error {
    background: #fff2f0;
    color: #cf1322;
    border: 1px solid #ffccc7;
}

.alert-success {
    background: #f6ffed;
    color: #389e0d;
    border: 1px solid #b7eb8f;
}

/* Course Cards */
.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.course-card {
    background: var(--card);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    transition: transform 0.2s;
}

.course-card:active {
    transform: scale(0.98);
}

.course-cover {
    width: 96px;
    height: 96px;
    min-width: 96px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary) 0%, #e85d75 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: rgba(255,255,255,0.9);
}

.course-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.course-info {
    flex: 1;
    min-width: 0;
    padding: 0;
}

.course-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.course-info p {
    font-size: 13px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.course-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.course-progress {
    margin-top: 10px;
}

.course-progress-bar {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.course-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #e85d75);
    border-radius: 3px;
    transition: width 0.3s;
}

.course-progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.course-progress-tip {
    margin-top: 8px;
    font-size: 12px;
    color: var(--primary);
    line-height: 1.5;
}

.course-progress-tip--done {
    color: #16a34a;
}

.learning-overview {
    background: var(--card);
    border-radius: 16px;
    padding: 18px;
    margin-top: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.learning-overview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.learning-overview-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.learning-overview-badge {
    font-size: 11px;
    color: var(--primary);
    background: rgba(196, 30, 58, 0.08);
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.learning-overview-progress {
    margin-bottom: 18px;
}

.learning-overview-progress-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}

.learning-overview-percent {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.learning-overview-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.learning-overview-bar {
    height: 10px;
    background: var(--bg);
    border-radius: 5px;
    overflow: hidden;
}

.learning-overview-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #e85d75);
    border-radius: 5px;
    transition: width 0.3s;
}

.learning-overview-summary {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.learning-overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.learning-overview-item {
    background: var(--bg);
    border-radius: 12px;
    padding: 14px 12px;
}

.learning-overview-item-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.learning-overview-item-value {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
}

.learning-overview-tip {
    font-size: 13px;
    color: var(--primary);
    line-height: 1.6;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

.learning-overview-tip--done {
    color: #16a34a;
}

/* Celebration Modal */
.celebrate-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.celebrate-overlay[hidden] {
    display: none !important;
}

.celebrate-card {
    width: 100%;
    max-width: 340px;
    background: var(--card);
    border-radius: 20px;
    padding: 28px 24px 24px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    animation: celebratePop 0.35s ease;
}

@keyframes celebratePop {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.celebrate-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 12px;
}

.celebrate-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.celebrate-message {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.celebrate-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.celebrate-actions .btn {
    flex: 1;
    max-width: 140px;
}

/* Lesson List */
.lesson-item {
    background: var(--card);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.lesson-item:active {
    background: #fafafa;
}

.lesson-cover {
    width: 120px;
    height: 68px;
    min-width: 120px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary) 0%, #e85d75 100%);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lesson-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lesson-cover-placeholder {
    font-size: 18px;
    font-weight: 600;
    color: rgba(255,255,255,0.95);
}

.lesson-cover-badge {
    position: absolute;
    left: 6px;
    bottom: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 10px;
    line-height: 1.4;
}

.lesson-num {
    width: 36px;
    height: 36px;
    background: var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

.lesson-num.completed {
    background: var(--success);
    color: #fff;
}

.lesson-content {
    flex: 1;
    min-width: 0;
}

.lesson-content h4 {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lesson-content .meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.lesson-arrow {
    color: var(--text-secondary);
    font-size: 18px;
}

/* Video Player */
.video-container {
    background: #000;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    vertical-align: top;
}

.lesson-detail {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

.lesson-detail h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.lesson-detail p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.learner-badge {
    display: inline-block;
    background: #fff1f0;
    color: var(--primary);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s;
}

.lesson-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-item {
    background: var(--card);
    border-radius: 12px;
    padding: 14px 10px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.lesson-tips {
    background: var(--card);
    border-radius: 16px;
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.lesson-tips h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.lesson-tips ul {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.8;
}

.comments-section {
    background: var(--card);
    border-radius: 16px;
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.comments-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.comments-count {
    font-size: 12px;
    color: var(--text-secondary);
}

.comment-form {
    margin-bottom: 16px;
}

.comment-input {
    width: 100%;
    min-height: 88px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    resize: vertical;
    outline: none;
    font-family: inherit;
}

.comment-input:focus {
    border-color: var(--primary);
}

.comment-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.comment-count {
    font-size: 12px;
    color: var(--text-secondary);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.comment-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 24px 12px;
}

.comment-item {
    display: flex;
    gap: 12px;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #e85d75);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.comment-body {
    flex: 1;
    min-width: 0;
}

.comment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.comment-author {
    font-size: 14px;
    font-weight: 600;
}

.comment-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.comment-content {
    font-size: 14px;
    color: var(--text);
    line-height: 1.6;
    word-break: break-word;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 15px;
}

/* Tabbar */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0 10px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 11px;
}

.tab-item.active {
    color: var(--primary);
}

.tab-icon {
    font-size: 22px;
    margin-bottom: 2px;
}

/* Welcome */
.welcome-bar {
    background: linear-gradient(135deg, var(--primary), #e85d75);
    color: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}

.welcome-bar h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.welcome-bar p {
    font-size: 13px;
    opacity: 0.85;
}
