/* ===== 重置与基础 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

:root {
    --pink-light: #FFE4E8;
    --pink-main: #FFB6C1;
    --pink-deep: #FF9AAB;
    --pink-soft: #FFF0F3;
    --white: #FFFFFF;
    --cream: #FFFBF5;
    --text-dark: #5A4A4A;
    --text-medium: #8A7A7A;
    --text-light: #B0A0A0;
    --green: #8DD9A8;
    --green-deep: #5CCB8B;
    --yellow: #FFE066;
    --yellow-deep: #FFD43B;
    --orange: #FFB74D;
    --purple: #D5B8E8;
    --purple-deep: #B98CD9;
    --blue: #A8D8F0;
    --blue-deep: #7EC4E8;
    --shadow-soft: 0 4px 15px rgba(255, 182, 193, 0.25);
    --shadow-card: 0 6px 20px rgba(255, 150, 170, 0.15);
    --shadow-hover: 0 10px 30px rgba(255, 150, 170, 0.3);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #FFF0F3 0%, #FFE4E8 50%, #FFD8DF 100%);
    color: var(--text-dark);
}

/* ===== 背景装饰 ===== */
body::before {
    content: '';
    position: fixed;
    top: -100px;
    right: -100px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,182,193,0.3) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -80px;
    left: -80px;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(255,224,102,0.2) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

/* ===== 主布局 ===== */
#app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    position: relative;
    z-index: 1;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ===== 左侧导航栏 ===== */
.sidebar {
    width: 180px;
    min-width: 180px;
    background: linear-gradient(180deg, #FFFFFF 0%, #FFF5F7 100%);
    box-shadow: 4px 0 20px rgba(255, 182, 193, 0.2);
    display: flex;
    flex-direction: column;
    border-right: 2px solid var(--pink-light);
    z-index: 10;
}

.sidebar-logo {
    text-align: center;
    padding: 20px 10px 16px;
    border-bottom: 2px dashed var(--pink-light);
}

.logo-icon {
    font-size: 40px;
    animation: bounce 2s ease-in-out infinite;
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--pink-deep);
    margin-top: 4px;
    letter-spacing: 1px;
}

.nav-menu {
    list-style: none;
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    gap: 4px;
}

.nav-item:hover {
    background: var(--pink-soft);
    transform: translateX(3px);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--pink-main) 0%, var(--pink-deep) 100%);
    box-shadow: 0 4px 12px rgba(255, 154, 171, 0.4);
    transform: translateX(3px);
}

.nav-item.active .nav-icon,
.nav-item.active .nav-label {
    color: var(--white);
}

.nav-icon {
    font-size: 30px;
    line-height: 1;
}

.nav-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    text-align: center;
}

.sidebar-footer {
    padding: 16px 10px;
    border-top: 2px dashed var(--pink-light);
}

.total-points-badge {
    background: linear-gradient(135deg, var(--yellow) 0%, var(--yellow-deep) 100%);
    border-radius: var(--radius-md);
    padding: 10px 8px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(255, 212, 59, 0.4);
}

.star-icon {
    font-size: 20px;
}

.points-number {
    font-size: 24px;
    font-weight: 800;
    color: #B8860B;
    margin: 0 2px;
}

.points-label {
    font-size: 12px;
    color: #B8860B;
    font-weight: 600;
}

/* ===== 右侧内容区 ===== */
.content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px 32px;
    position: relative;
}

.page {
    display: none;
    animation: fadeIn 0.4s ease;
}

.page.active {
    display: block;
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-dark);
    text-shadow: 2px 2px 0 var(--pink-light);
}

.page-subtitle {
    font-size: 16px;
    color: var(--text-medium);
    margin-top: 8px;
    font-weight: 500;
}

/* ===== 卡片容器 ===== */
.card-container {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.card-container.two-cards .task-card {
    flex: 1;
    min-width: 280px;
    max-width: 50%;
}

.card-container.one-card {
    justify-content: center;
}

.card-container.one-card .task-card {
    max-width: 400px;
    width: 100%;
}

.card-container.three-cards .task-card {
    flex: 1;
    min-width: 220px;
}

/* ===== 任务卡片 ===== */
.task-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow-card);
    text-align: center;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.task-card::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(255,182,193,0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.task-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--pink-light);
}

.task-card.completed {
    background: linear-gradient(135deg, #F0FFF4 0%, #E0FFE8 100%);
    border-color: var(--green);
}

.task-card.completed::after {
    content: '✅';
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 24px;
    animation: pop 0.4s ease;
}

.card-icon {
    font-size: 56px;
    margin-bottom: 12px;
    display: inline-block;
    animation: wiggle 3s ease-in-out infinite;
}

.card-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.card-desc {
    font-size: 14px;
    color: var(--text-medium);
    margin-bottom: 20px;
    line-height: 1.5;
}

/* ===== 按钮 ===== */
.btn {
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 28px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--pink-main) 0%, var(--pink-deep) 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(255, 154, 171, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(255, 154, 171, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-deep) 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(126, 196, 232, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(126, 196, 232, 0.5);
}

.btn-danger {
    background: linear-gradient(135deg, #FFAB91 0%, #FF8A65 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(255, 138, 101, 0.4);
}

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

/* ===== 卡片状态 ===== */
.card-status {
    margin-top: 14px;
    min-height: 24px;
    font-size: 14px;
    font-weight: 600;
}

.card-status.success {
    color: var(--green-deep);
}

.card-status.pending {
    color: var(--orange);
}

/* ===== 上传区域 ===== */
.upload-area {
    border: 3px dashed var(--pink-main);
    border-radius: var(--radius-md);
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--pink-soft);
    margin-bottom: 8px;
}

.upload-area:hover {
    background: var(--pink-light);
    border-color: var(--pink-deep);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--pink-deep);
    font-weight: 600;
    font-size: 14px;
}

.upload-icon {
    font-size: 36px;
}

.upload-preview {
    max-width: 100%;
    max-height: 120px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
}

/* ===== 复选框 ===== */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-wrapper input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 28px;
    height: 28px;
    border: 3px solid var(--pink-main);
    border-radius: 8px;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--green);
    border-color: var(--green-deep);
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    color: var(--white);
    font-size: 18px;
    font-weight: 900;
}

.checkbox-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
}

.interest-card.checked {
    background: linear-gradient(135deg, #F0FFF4 0%, #E0FFE8 100%);
    border-color: var(--green);
}

/* ===== 积分乐园 ===== */
.points-display {
    background: linear-gradient(135deg, var(--white) 0%, var(--cream) 100%);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
    border: 3px solid var(--yellow);
}

.big-star {
    font-size: 48px;
    animation: spin 3s linear infinite;
    display: inline-block;
}

.big-points {
    font-size: 56px;
    font-weight: 900;
    color: var(--orange);
    line-height: 1;
    margin: 4px 0;
}

.points-text {
    font-size: 16px;
    color: var(--text-medium);
    font-weight: 600;
}

.reward-card {
    text-align: center;
    position: relative;
}

.reward-card .card-icon {
    font-size: 48px;
}

.reward-card .reward-cost {
    display: inline-block;
    background: var(--yellow);
    color: #B8860B;
    font-weight: 800;
    font-size: 18px;
    padding: 6px 16px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.reward-card .btn-exchange {
    background: linear-gradient(135deg, var(--orange) 0%, #FF9800 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

.reward-card .btn-exchange:disabled {
    background: #DDD;
    box-shadow: none;
}

.parent-section {
    margin-top: 28px;
    text-align: center;
}

/* ===== 弹窗 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(90, 74, 74, 0.5);
    z-index: 100;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    animation: modalPop 0.4s ease;
}

.math-modal {
    max-width: 520px;
}

.pinyin-modal {
    max-width: 480px;
}

.parent-modal {
    max-width: 680px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--pink-main) 0%, var(--pink-deep) 100%);
    color: var(--white);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: var(--white);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== 数学练习弹窗 ===== */
.exercise-progress {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-medium);
}

.exercise-progress #exerciseScore {
    color: var(--orange);
}

.exercise-question {
    text-align: center;
    padding: 16px 0;
}

.question-text {
    font-size: 48px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 24px;
}

.answer-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.answer-option {
    background: var(--pink-soft);
    border: 3px solid var(--pink-light);
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.answer-option:hover {
    background: var(--pink-light);
    border-color: var(--pink-main);
    transform: scale(1.05);
}

.answer-option.correct {
    background: var(--green);
    border-color: var(--green-deep);
    color: var(--white);
}

.answer-option.wrong {
    background: #FFAB91;
    border-color: #FF8A65;
    color: var(--white);
    animation: shake 0.4s ease;
}

.exercise-feedback {
    text-align: center;
    margin-top: 16px;
    font-size: 18px;
    font-weight: 700;
    min-height: 28px;
}

.exercise-feedback.correct {
    color: var(--green-deep);
}

.exercise-feedback.wrong {
    color: #FF8A65;
}

/* 完成画面 */
.exercise-complete {
    text-align: center;
    padding: 20px;
}

.exercise-complete .complete-icon {
    font-size: 64px;
    margin-bottom: 12px;
}

.exercise-complete .complete-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.exercise-complete .complete-score {
    font-size: 48px;
    font-weight: 900;
    color: var(--orange);
    margin: 8px 0;
}

.exercise-complete .complete-message {
    font-size: 16px;
    color: var(--text-medium);
    margin-bottom: 20px;
}

/* ===== 拼音识字弹窗 ===== */
.pinyin-progress {
    text-align: center;
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-medium);
}

.pinyin-question {
    text-align: center;
}

.pinyin-character {
    font-size: 96px;
    font-weight: 900;
    color: var(--text-dark);
    margin: 12px 0;
    text-shadow: 3px 3px 0 var(--purple);
}

.pinyin-hint {
    font-size: 16px;
    color: var(--text-medium);
    margin-bottom: 20px;
    font-weight: 600;
}

.pinyin-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.pinyin-option {
    background: var(--pink-soft);
    border: 3px solid var(--purple);
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.pinyin-option:hover {
    background: rgba(213, 184, 232, 0.3);
    transform: scale(1.05);
}

.pinyin-option.correct {
    background: var(--green);
    border-color: var(--green-deep);
    color: var(--white);
}

.pinyin-option.wrong {
    background: #FFAB91;
    border-color: #FF8A65;
    color: var(--white);
    animation: shake 0.4s ease;
}

.pinyin-feedback {
    text-align: center;
    margin-top: 16px;
    font-size: 18px;
    font-weight: 700;
    min-height: 28px;
}

.pinyin-feedback.correct {
    color: var(--green-deep);
}

.pinyin-feedback.wrong {
    color: #FF8A65;
}

/* ===== 家长设置弹窗 ===== */
.parent-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.parent-tab {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--pink-light);
    border-radius: var(--radius-sm);
    background: var(--white);
    font-size: 15px;
    font-weight: 700;
    color: var(--text-medium);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.parent-tab.active {
    background: linear-gradient(135deg, var(--pink-main) 0%, var(--pink-deep) 100%);
    color: var(--white);
    border-color: var(--pink-deep);
}

.parent-content.hidden {
    display: none;
}

.parent-edit-item {
    background: var(--pink-soft);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 12px;
    border: 2px solid var(--pink-light);
}

.parent-edit-item label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-medium);
    margin-bottom: 6px;
}

.parent-edit-item input,
.parent-edit-item select,
.parent-edit-item textarea {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--pink-light);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text-dark);
    font-family: inherit;
    background: var(--white);
    outline: none;
    transition: border-color 0.2s ease;
    -webkit-user-select: text;
    user-select: text;
}

.parent-edit-item input:focus,
.parent-edit-item select:focus,
.parent-edit-item textarea:focus {
    border-color: var(--pink-main);
}

.parent-edit-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.parent-edit-row > div {
    flex: 1;
}

.parent-edit-item .delete-btn {
    background: #FFAB91;
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    white-space: nowrap;
    height: 38px;
}

.parent-edit-item .delete-btn:hover {
    background: #FF8A65;
}

.parent-add-btn {
    width: 100%;
    padding: 10px;
    border: 2px dashed var(--pink-main);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--pink-deep);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    margin-bottom: 16px;
}

.parent-add-btn:hover {
    background: var(--pink-soft);
}

.parent-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* ===== Toast 提示 ===== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(90, 74, 74, 0.9);
    color: var(--white);
    padding: 16px 28px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    text-align: center;
    max-width: 80%;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ===== 庆祝动画 ===== */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 150;
    overflow: hidden;
}

.celebration .confetti {
    position: absolute;
    width: 12px;
    height: 12px;
    animation: confettiFall 2s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ===== 动画 ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalPop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

@keyframes pop {
    0% { transform: scale(0); }
    80% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== 响应式 - iPad适配 ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 160px;
        min-width: 160px;
    }
    
    .content {
        padding: 20px 24px;
    }
    
    .page-title {
        font-size: 28px;
    }
    
    .card-icon {
        font-size: 48px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 140px;
        min-width: 140px;
    }
    
    .nav-icon {
        font-size: 26px;
    }
    
    .nav-label {
        font-size: 12px;
    }
    
    .content {
        padding: 16px 20px;
    }
    
    .page-title {
        font-size: 24px;
    }
    
    .card-container.three-cards .task-card {
        min-width: 180px;
    }
    
    .question-text {
        font-size: 40px;
    }
    
    .pinyin-character {
        font-size: 80px;
    }
}

/* 竖屏时调整 */
@media (orientation: portrait) {
    .sidebar {
        width: 120px;
        min-width: 120px;
    }
    
    .logo-icon {
        font-size: 32px;
    }
    
    .logo-text {
        font-size: 14px;
    }
    
    .nav-icon {
        font-size: 24px;
    }
    
    .nav-label {
        font-size: 11px;
    }
}
