/* ============================================
   时光小助手 - 样式表
   设计理念：温暖、友好、正向激励
   ============================================ */

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

:root {
    /* 主题色 */
    --bg-gradient: linear-gradient(180deg, #FFF8F0 0%, #F0F4FF 100%);
    --card-bg: #FFFFFF;
    --text-primary: #2D3748;
    --text-secondary: #718096;
    --text-light: #A0AEC0;

    /* 活动色 */
    --study: #4A90D9;
    --study-light: #EBF4FE;
    --reading: #9B6DD7;
    --reading-light: #F3EDFC;
    --fun: #F5A623;
    --fun-light: #FEF5E7;
    --exercise: #52C41A;
    --exercise-light: #F0FBE8;
    --rest: #50C7E8;
    --rest-light: #E8F8FD;
    --hobby: #E85A9A;
    --hobby-light: #FDE8F2;

    /* 功能色 */
    --success: #52C41A;
    --danger: #FF6B6B;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
    --radius: 20px;
    --radius-sm: 12px;
    --radius-lg: 28px;

    /* 动画 */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    overflow-x: hidden;
    padding-bottom: 90px;
}

#app {
    min-height: 100vh;
}

/* --- 视图切换 --- */
.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden {
    display: none !important;
}

/* --- 顶部信息栏 --- */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 12px;
    gap: 12px;
}

.greeting {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mascot {
    font-size: 40px;
    line-height: 1;
    animation: bounce 2s ease-in-out infinite;
}

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

.greeting-text {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
}

.date-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.daily-summary {
    background: var(--study-light);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.summary-label {
    font-size: 11px;
    color: var(--text-secondary);
    display: block;
}

.summary-value {
    font-size: 15px;
    font-weight: 800;
    color: var(--study);
}

/* --- 计时区域 --- */
.timer-section {
    padding: 8px 20px 20px;
}

.section-title {
    text-align: center;
    margin-bottom: 24px;
}

.section-title h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* 活动选择网格 */
.activity-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.activity-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 10px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 3px solid transparent;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.activity-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    opacity: 0.8;
}

.activity-card[data-type="study"]::before { background: var(--study); }
.activity-card[data-type="reading"]::before { background: var(--reading); }
.activity-card[data-type="fun"]::before { background: var(--fun); }
.activity-card[data-type="exercise"]::before { background: var(--exercise); }
.activity-card[data-type="rest"]::before { background: var(--rest); }
.activity-card[data-type="hobby"]::before { background: var(--hobby); }

.activity-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.activity-card:active {
    transform: scale(0.95);
}

.activity-icon {
    font-size: 36px;
    margin-bottom: 8px;
    display: block;
}

.activity-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.activity-today {
    font-size: 11px;
    color: var(--text-light);
}

/* 计时状态 */
.active-state {
    text-align: center;
    padding: 10px 0;
}

.timer-ring-container {
    position: relative;
    width: 220px;
    height: 220px;
    margin: 0 auto 20px;
}

.timer-ring {
    transform: rotate(-90deg);
}

.timer-ring-bg {
    fill: none;
    stroke: #E2E8F0;
    stroke-width: 12;
}

.timer-ring-progress {
    fill: none;
    stroke: var(--study);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 628.3;
    stroke-dashoffset: 628.3;
    transition: stroke-dashoffset 0.5s linear, stroke 0.5s ease;
}

.timer-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.timer-activity-icon {
    font-size: 48px;
    margin-bottom: 4px;
}

.timer-activity-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.timer-time {
    font-size: 36px;
    font-weight: 900;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -1px;
}

.encouragement {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    min-height: 22px;
    transition: opacity 0.5s ease;
}

.btn-stop {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    color: white;
    border: none;
    padding: 16px 48px;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.3);
    font-family: inherit;
}

.btn-stop:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.4);
}

.btn-stop:active {
    transform: scale(0.96);
}

.btn-switch-text {
    display: block;
    margin: 16px auto 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

.btn-switch-text:hover {
    color: var(--study);
}

/* --- 今日概览 --- */
.today-overview {
    padding: 0 20px;
    margin-top: 20px;
}

.today-overview h3 {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.overview-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.overview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.overview-item-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    flex-shrink: 0;
}

.overview-item-info {
    flex: 1;
    min-width: 0;
}

.overview-item-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.overview-item-time {
    font-size: 12px;
    color: var(--text-light);
}

.overview-item-duration {
    font-size: 16px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.empty-hint {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    padding: 20px;
}

/* --- 底部导航 --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.nav-item {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transition: var(--transition);
    font-family: inherit;
    opacity: 0.5;
}

.nav-item.active {
    opacity: 1;
}

.nav-icon {
    font-size: 24px;
    transition: var(--transition);
}

.nav-item.active .nav-icon {
    transform: scale(1.15);
}

.nav-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
}

/* --- 统计视图 --- */
.tab-bar {
    display: flex;
    padding: 0 20px;
    gap: 8px;
    margin-bottom: 16px;
}

.tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    box-shadow: var(--shadow);
}

.tab.active {
    background: var(--study);
    color: white;
}

.stats-content {
    padding: 0 20px;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--card-bg);
    padding: 16px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.stat-card-blue::after { background: var(--study); }
.stat-card-purple::after { background: var(--reading); }
.stat-card-orange::after { background: var(--fun); }
.stat-card-green::after { background: var(--exercise); }

.stat-card-icon {
    font-size: 28px;
    margin-bottom: 6px;
}

.stat-card-value {
    font-size: 24px;
    font-weight: 900;
    color: var(--text-primary);
}

.stat-card-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* 图表卡片 */
.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.chart-card h3 {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.donut-chart-container {
    position: relative;
    width: 220px;
    height: 220px;
    margin: 0 auto 16px;
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.donut-total {
    font-size: 28px;
    font-weight: 900;
    color: var(--text-primary);
}

.donut-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* 目标进度 */
.goal-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.goal-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.goal-name {
    font-weight: 700;
    color: var(--text-primary);
}

.goal-value {
    font-weight: 800;
    color: var(--text-secondary);
}

.goal-bar {
    height: 10px;
    background: #EDF2F7;
    border-radius: 10px;
    overflow: hidden;
}

.goal-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 活动日志 */
.activity-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.log-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #F7FAFC;
    border-radius: var(--radius-sm);
}

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

.log-info {
    flex: 1;
    min-width: 0;
}

.log-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.log-time {
    font-size: 12px;
    color: var(--text-light);
}

.log-duration {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
}

/* 柱状图容器 */
.bar-chart-container {
    width: 100%;
    position: relative;
}

/* 周汇总 */
.week-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.week-summary-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.week-summary-icon {
    font-size: 24px;
    width: 40px;
    text-align: center;
}

.week-summary-info {
    flex: 1;
}

.week-summary-name {
    font-size: 14px;
    font-weight: 700;
}

.week-summary-bar {
    height: 8px;
    background: #EDF2F7;
    border-radius: 8px;
    margin-top: 4px;
    overflow: hidden;
}

.week-summary-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.8s ease;
}

.week-summary-value {
    font-size: 14px;
    font-weight: 800;
    min-width: 60px;
    text-align: right;
}

/* 本周之星 */
.week-highlights {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.highlight-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #FEF5E7 0%, #FFF8F0 100%);
    border-radius: var(--radius-sm);
}

.highlight-emoji {
    font-size: 32px;
}

.highlight-text {
    flex: 1;
}

.highlight-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
}

.highlight-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- 成就视图 --- */
.achievement-streak {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: linear-gradient(135deg, #FF8E53 0%, #FF6B6B 100%);
    margin: 0 20px 16px;
    padding: 24px;
    border-radius: var(--radius-lg);
    color: white;
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.25);
}

.streak-flame {
    font-size: 48px;
    animation: flameFlicker 1.5s ease-in-out infinite;
}

@keyframes flameFlicker {
    0%, 100% { transform: scale(1) rotate(-3deg); }
    50% { transform: scale(1.1) rotate(3deg); }
}

.streak-number {
    font-size: 42px;
    font-weight: 900;
    line-height: 1;
}

.streak-label {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 4px;
}

.achievement-stats {
    display: flex;
    padding: 0 20px;
    gap: 10px;
    margin-bottom: 20px;
}

.ach-stat {
    flex: 1;
    background: var(--card-bg);
    padding: 16px 8px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.ach-stat-value {
    font-size: 20px;
    font-weight: 900;
    color: var(--text-primary);
}

.ach-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.badges-section {
    padding: 0 20px;
}

.badges-section h3 {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 16px;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.badge {
    background: var(--card-bg);
    padding: 16px 8px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
}

.badge.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.badge.unlocked {
    animation: badgePop 0.5s ease;
}

@keyframes badgePop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.badge-icon {
    font-size: 36px;
    margin-bottom: 6px;
}

.badge-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
}

.badge-desc {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 2px;
}

/* --- 家长面板 --- */
.parent-live-status {
    padding: 0 20px;
    margin-bottom: 16px;
}

.live-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #E2E8F0 0%, #F7FAFC 100%);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.live-card.active-study {
    background: linear-gradient(135deg, var(--study-light) 0%, #F0F7FF 100%);
}

.live-card.active-fun {
    background: linear-gradient(135deg, var(--fun-light) 0%, #FFF8F0 100%);
}

.live-card.active-reading {
    background: linear-gradient(135deg, var(--reading-light) 0%, #F8F5FE 100%);
}

.live-card.active-exercise {
    background: linear-gradient(135deg, var(--exercise-light) 0%, #F5FEF0 100%);
}

.live-card.active-rest {
    background: linear-gradient(135deg, var(--rest-light) 0%, #F0FAFE 100%);
}

.live-card.active-hobby {
    background: linear-gradient(135deg, var(--hobby-light) 0%, #FEF5FA 100%);
}

.live-icon {
    font-size: 44px;
}

.live-info {
    flex: 1;
}

.live-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.live-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 2px;
}

.live-time {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

/* 家长今日概览 */
.parent-today,
.parent-notifications,
.parent-settings {
    padding: 0 20px;
    margin-bottom: 20px;
}

.parent-today h3,
.parent-notifications h3,
.parent-settings h3 {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 12px;
}

.parent-stats-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.parent-stat-pill {
    flex-shrink: 0;
    background: var(--card-bg);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    text-align: center;
    min-width: 80px;
}

.parent-stat-pill-icon {
    font-size: 24px;
}

.parent-stat-pill-value {
    font-size: 18px;
    font-weight: 800;
    margin-top: 2px;
}

.parent-stat-pill-label {
    font-size: 11px;
    color: var(--text-secondary);
}

/* 通知列表 */
.notification-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.notification-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.notification-content {
    flex: 1;
}

.notification-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.4;
}

.notification-time {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
}

/* 设置 */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #EDF2F7;
    gap: 12px;
}

/* 家庭码卡片 */
.family-code-card {
    flex-direction: column;
    align-items: stretch;
    background: linear-gradient(135deg, #EBF8FF 0%, #F0FFF4 100%);
    border: 1px solid #BEE3F8;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 8px;
}
.family-code-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}
.family-code-value {
    font-size: 26px;
    font-weight: 900;
    color: #2B6CB0;
    letter-spacing: 4px;
    font-family: 'Courier New', monospace;
}
.btn-copy-code {
    background: #2B6CB0;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-copy-code:hover {
    background: #2C5282;
    transform: translateY(-1px);
}
.btn-copy-code:active {
    transform: translateY(0);
}
.family-url-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #BEE3F8;
    flex-wrap: wrap;
}
.family-url-label {
    font-size: 12px;
    color: #718096;
    font-weight: 600;
}
.family-url-value {
    font-size: 13px;
    color: #2B6CB0;
    font-weight: 700;
    word-break: break-all;
}

.setting-item:last-of-type {
    border-bottom: none;
}

.setting-label {
    flex: 1;
}

.setting-label > span:first-child {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
}

.setting-desc {
    font-size: 12px;
    color: var(--text-light);
    display: block;
    margin-top: 2px;
}

/* 开关 */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #CBD5E0;
    transition: 0.3s;
    border-radius: 26px;
}

.slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider {
    background: var(--study);
}

.switch input:checked + .slider::before {
    transform: translateX(22px);
}

/* 输入框 */
.setting-input {
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    width: 120px;
    text-align: center;
    transition: var(--transition);
}

.setting-input:focus {
    outline: none;
    border-color: var(--study);
}

/* 滑块 */
.goal-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.goal-input-group input[type="range"] {
    width: 120px;
    accent-color: var(--study);
    cursor: pointer;
}

.goal-display {
    font-size: 14px;
    font-weight: 800;
    color: var(--study);
    min-width: 60px;
    text-align: right;
}

.btn-export,
.btn-reset {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    margin-top: 12px;
}

.btn-export {
    background: var(--study-light);
    color: var(--study);
}

.btn-export:hover {
    background: #D6E9FC;
}

.btn-reset {
    background: #FFF5F5;
    color: var(--danger);
}

.btn-reset:hover {
    background: #FFE8E8;
}

/* --- 弹窗 --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal {
    background: white;
    width: 100%;
    max-width: 480px;
    border-radius: 28px 28px 0 0;
    padding: 24px 20px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal h3 {
    font-size: 18px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 4px;
}

.modal-desc {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 20px;
}

.modal-activity-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.btn-cancel {
    width: 100%;
    padding: 14px;
    border: none;
    background: #EDF2F7;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

.btn-cancel:hover {
    background: #E2E8F0;
}

/* --- 庆祝弹窗 --- */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
}

.celebration-content {
    background: white;
    padding: 36px 32px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 320px;
    width: 90%;
    animation: celebratePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 2;
}

@keyframes celebratePop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.celebration-emoji {
    font-size: 64px;
    margin-bottom: 12px;
    animation: bounce 1s ease-in-out infinite;
}

.celebration-title {
    font-size: 24px;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.celebration-desc {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 24px;
}

.btn-celebrate {
    background: linear-gradient(135deg, #52C41A 0%, #38A169 100%);
    color: white;
    border: none;
    padding: 14px 40px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    box-shadow: 0 6px 20px rgba(82, 196, 26, 0.3);
}

.btn-celebrate:hover {
    transform: translateY(-2px);
}

.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confettiFall 3s linear forwards;
}

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

/* --- 响应式 --- */
@media (max-width: 360px) {
    .activity-grid {
        gap: 10px;
    }
    .activity-card {
        padding: 16px 6px;
    }
    .activity-icon {
        font-size: 30px;
    }
    .timer-ring-container {
        width: 180px;
        height: 180px;
    }
    .timer-ring {
        width: 180px;
        height: 180px;
    }
    .timer-time {
        font-size: 30px;
    }
}

/* ============================================
   家庭码设置引导
   ============================================ */
.setup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, #FFF8F0 0%, #F0F4FF 100%);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.setup-overlay.hidden {
    display: none;
}

.setup-container {
    width: 100%;
    max-width: 380px;
    text-align: center;
    padding: 20px 0;
}

.setup-step {
    display: none;
    animation: fadeIn 0.4s ease;
}

.setup-step.active {
    display: block;
}

.setup-logo {
    font-size: 56px;
    margin-bottom: 16px;
    animation: bounce 2s ease-in-out infinite;
}

.setup-container h1 {
    font-size: 28px;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.setup-container h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.setup-tagline {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 36px;
}

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

.setup-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.setup-choice {
    background: var(--card-bg);
    border: 3px solid transparent;
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.setup-choice:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--study);
}

.setup-choice:active {
    transform: scale(0.98);
}

.setup-choice-icon {
    font-size: 40px;
}

.setup-choice-label {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

.setup-choice-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.setup-input {
    width: 100%;
    border: 2px solid #E2E8F0;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 16px;
    font-family: inherit;
    text-align: center;
    transition: var(--transition);
    margin-bottom: 16px;
}

.setup-input:focus {
    outline: none;
    border-color: var(--study);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

.setup-code-input {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 6px;
    text-transform: uppercase;
    padding: 16px;
}

.setup-btn-primary {
    width: 100%;
    background: linear-gradient(135deg, #4A90D9 0%, #357ABD 100%);
    color: white;
    border: none;
    padding: 16px;
    border-radius: var(--radius-sm);
    font-size: 17px;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    box-shadow: 0 6px 20px rgba(74, 144, 217, 0.3);
}

.setup-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(74, 144, 217, 0.4);
}

.setup-btn-primary:active {
    transform: scale(0.98);
}

.setup-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.setup-btn-back {
    display: block;
    margin: 16px auto 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    padding: 8px;
}

.setup-code-box {
    font-size: 36px;
    font-weight: 900;
    letter-spacing: 8px;
    color: var(--study);
    background: var(--study-light);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    border: 2px dashed var(--study);
}

.setup-url-box {
    background: var(--card-bg);
    padding: 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.setup-url-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.setup-url {
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    word-break: break-all;
}

.setup-qr-container {
    margin-bottom: 24px;
}

.setup-qr-img {
    width: 160px;
    height: 160px;
    border-radius: var(--radius-sm);
    border: 2px solid #E2E8F0;
}

.setup-qr-hint {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 8px;
}

.setup-error {
    color: var(--danger);
    font-size: 14px;
    margin-bottom: 12px;
    padding: 10px;
    background: #FFF5F5;
    border-radius: var(--radius-sm);
}

/* ============================================
   连接状态指示器
   ============================================ */
.top-bar-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 3px 8px;
    border-radius: 20px;
    background: var(--card-bg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #FBD38D;
    animation: pulse 1.5s ease-in-out infinite;
}

.conn-dot.connected {
    background: #48BB78;
    animation: none;
}

.conn-dot.disconnected {
    background: #FC8181;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* 家长角色隐藏计时区域的操作按钮 */
body.role-parent .activity-grid .activity-card {
    cursor: default;
}

body.role-parent .activity-card:hover {
    transform: none;
}

body.role-parent .btn-stop {
    display: none;
}

body.role-parent .btn-switch-text {
    display: none;
}

body.role-parent #idle-state .section-title h2 {
    font-size: 18px;
}

body.role-parent #idle-state .section-title .subtitle {
    display: none;
}

/* 家长角色提示 */
.parent-hint-banner {
    background: linear-gradient(135deg, #EBF4FE 0%, #F0F7FF 100%);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--study);
    text-align: center;
    display: none;
}

body.role-parent .parent-hint-banner {
    display: block;
}

/* ===== 创作者信息（启动页） ===== */
.setup-creator-footer {
    margin-top: 32px;
    font-size: 12px;
    color: var(--text-light);
    letter-spacing: 0.5px;
}

.setup-creator-footer .creator-wx {
    color: var(--text-secondary);
    font-weight: 600;
    user-select: all;
    -webkit-user-select: all;
}

/* ===== 关于板块（家长设置页） ===== */
.parent-about {
    margin-top: 24px;
}

.parent-about h3 {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.about-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.about-app-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid #F0F0F0;
    margin-bottom: 16px;
}

.about-logo {
    font-size: 36px;
}

.about-name {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

.about-version {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
}

.about-creator-label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 6px;
}

.about-creator-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.about-creator-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.about-creator-wx {
    font-size: 14px;
    color: var(--study);
    background: var(--study-light);
    padding: 4px 12px;
    border-radius: 20px;
    user-select: all;
    -webkit-user-select: all;
    font-weight: 600;
}

.about-creator-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 10px;
    line-height: 1.5;
}

/* ===== 管理后台页面 ===== */
.admin-body {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: #f5f7fa;
    min-height: 100vh;
}

.admin-login {
    max-width: 400px;
    margin: 80px auto;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    text-align: center;
}

.admin-login h1 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 8px;
    color: #2D3748;
}

.admin-login p {
    font-size: 14px;
    color: #718096;
    margin-bottom: 24px;
}

.admin-login input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #E2E8F0;
    border-radius: 12px;
    font-size: 16px;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.admin-login input:focus {
    border-color: #4A90D9;
}

.admin-login button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #4A90D9, #6BB6E8);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.admin-login button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74,144,217,0.4);
}

.admin-login .login-error {
    color: #FF6B6B;
    font-size: 14px;
    margin-top: 12px;
    display: none;
}

.admin-dashboard {
    display: none;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.admin-header h1 {
    font-size: 22px;
    font-weight: 800;
    color: #2D3748;
}

.admin-header .admin-logout {
    padding: 8px 16px;
    background: #FF6B6B;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.admin-stat-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.admin-stat-card .stat-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.admin-stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: #2D3748;
}

.admin-stat-card .stat-label {
    font-size: 13px;
    color: #718096;
    margin-top: 4px;
}

.admin-section {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 24px;
}

.admin-section h2 {
    font-size: 16px;
    font-weight: 700;
    color: #2D3748;
    margin-bottom: 16px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th {
    text-align: left;
    padding: 10px 12px;
    background: #F7FAFC;
    color: #718096;
    font-weight: 600;
    border-bottom: 2px solid #E2E8F0;
    white-space: nowrap;
}

.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #EDF2F7;
    color: #2D3748;
}

.admin-table tr:hover {
    background: #F7FAFC;
}

.admin-table .empty-row {
    text-align: center;
    color: #A0AEC0;
    padding: 24px;
}

.admin-activity-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.admin-activity-bar .bar-label {
    width: 60px;
    font-size: 13px;
    color: #718096;
}

.admin-activity-bar .bar-track {
    flex: 1;
    height: 24px;
    background: #F0F0F0;
    border-radius: 12px;
    overflow: hidden;
}

.admin-activity-bar .bar-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.6s ease;
    min-width: 2px;
}

.admin-activity-bar .bar-value {
    width: 80px;
    font-size: 13px;
    color: #2D3748;
    font-weight: 600;
    text-align: right;
}

.admin-footer {
    text-align: center;
    font-size: 12px;
    color: #A0AEC0;
    padding: 16px 0;
}

