* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90d9;
    --primary-hover: #357abd;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --danger-color: #ff4d4f;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --border-color: #e8e8e8;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

header {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

header h1 {
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.date-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.date-picker input[type="date"] {
    padding: 8px 14px;
    font-size: 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.3s ease;
    cursor: pointer;
    font-family: inherit;
}

.date-picker input[type="date"]:focus {
    border-color: var(--primary-color);
}

.btn-nav {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-color);
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.header-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.btn-primary {
    padding: 8px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    padding: 8px 20px;
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #eee;
}

section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.section-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-header.collapsible {
    cursor: pointer;
    user-select: none;
}

.section-header.collapsible:hover {
    background: var(--bg-color);
}

.section-header .collapse-arrow {
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
    margin-right: 8px;
}

.section-header.collapsed .collapse-arrow {
    transform: rotate(-90deg);
}

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.habit-stats {
    font-size: 13px;
    color: var(--text-secondary);
}

.extras-stats {
    font-size: 13px;
    color: var(--text-secondary);
}

.extras-actions {
    padding: 12px 20px;
}

.btn-add-task {
    width: 100%;
    padding: 12px;
    background: var(--bg-color);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-add-task:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.add-extra-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    color: var(--text-secondary);
}

.time-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.time-inputs .time-input {
    flex: 1;
}

.habits-list, .extras-section .task-list {
    padding: 12px 16px;
}

.habit-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    margin-bottom: 8px;
    background: #fafafa;
}

.habit-item:last-child {
    margin-bottom: 0;
}

.habit-item:hover {
    background: #f0f0f0;
}

.habit-checkbox {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--success-color);
    margin-right: 14px;
    flex-shrink: 0;
}

.habit-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.habit-name {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 500;
}

.habit-item.completed .habit-name {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.habit-streak {
    font-size: 12px;
    color: var(--success-color);
    display: flex;
    align-items: center;
    gap: 4px;
}

.habit-item.completed .habit-streak {
    color: var(--text-secondary);
}

.habit-streak.broken {
    color: var(--danger-color);
}

.empty-habits, .empty-extras {
    padding: 32px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.empty-habits p, .empty-extras p {
    margin-bottom: 8px;
}

.empty-habits.show, .empty-extras.show {
    display: none;
}

.task-input-section {
    padding: 16px 20px;
    display: flex;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
}

.time-input {
    padding: 10px 14px;
    font-size: 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.3s ease;
    min-width: 110px;
}

.time-input:focus {
    border-color: var(--primary-color);
}

.time-separator {
    color: var(--text-secondary);
    font-size: 14px;
}

.task-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.task-input:focus {
    border-color: var(--primary-color);
}

.task-input::placeholder {
    color: #bbb;
}

.btn-add {
    padding: 10px 18px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-add:hover {
    background: var(--primary-hover);
}

.extra-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #fafafa;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.extra-item:last-child {
    margin-bottom: 0;
}

.extra-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--success-color);
    margin-right: 12px;
    flex-shrink: 0;
}

.extra-text {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.extra-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.extra-time {
    font-size: 13px;
    color: #1a73e8;
    background: #e8f4fc;
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.extra-duration {
    font-size: 11px;
    color: #fff;
    background: #ff9800;
    padding: 2px 6px;
    border-radius: 3px;
}

.extra-item.completed .extra-text {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.btn-delete {
    padding: 6px 12px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-delete:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

.stats-section .section-header {
    border-bottom: none;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0 20px 16px;
}

.stat-card {
    text-align: center;
    padding: 16px 8px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

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

.week-chart {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.chart-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.chart-bars {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 80px;
    gap: 8px;
}

.chart-day {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.chart-bar {
    width: 100%;
    max-width: 32px;
    background: var(--bg-color);
    border-radius: 4px 4px 0 0;
    min-height: 8px;
    position: relative;
    transition: all 0.3s ease;
}

.chart-bar.filled {
    background: var(--success-color);
}

.chart-bar.today {
    border: 2px solid var(--primary-color);
}

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

.chart-percent {
    font-size: 10px;
    color: var(--text-secondary);
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.btn-close:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.add-habit {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.habits-manage-list {
    list-style: none;
}

.habit-manage-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.habit-manage-name {
    font-size: 14px;
    color: var(--text-primary);
}

.btn-habit-delete {
    padding: 4px 10px;
    background: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-habit-delete:hover {
    background: var(--danger-color);
    color: white;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1001;
    border-left: 4px solid var(--success-color);
}

.notification.show {
    transform: translateX(0);
}

.notification.warning {
    border-left-color: var(--warning-color);
}

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

@media (max-width: 480px) {
    .container {
        padding: 12px 12px 32px;
    }

    header {
        padding: 16px;
    }

    header h1 {
        font-size: 20px;
    }

    .date-picker {
        gap: 8px;
    }

    .header-actions {
        flex-direction: column;
    }

    .header-actions button {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .stat-card {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
    }

    .stat-value {
        font-size: 22px;
        margin-bottom: 0;
    }

    .task-input-section {
        flex-direction: column;
    }

    .task-input-section .task-input,
    .task-input-section .btn-add {
        width: 100%;
    }

    .task-input-section .time-input {
        width: 100%;
    }
}

.chart-section {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
}

.chart-section canvas {
    max-height: 250px;
}
