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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 70px 20px 20px 20px; /* 상단 고정 버튼 높이만큼 여백 */
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* 헤더 */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

header h1 {
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.header-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.date-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.date-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.3s;
}

.date-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

#currentDate {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    background: white;
    cursor: pointer;
}

.header-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.header-action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.header-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* 메인 콘텐츠 */
main {
    padding: 20px;
}

.pds-section {
    margin-bottom: 30px;
    padding: 20px;
    border-radius: 15px;
    background: #f8f9fa;
}

.pds-section h2 {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
    color: #495057;
}

/* ==================== */
/* PLAN + DO 통합 섹션 */
/* ==================== */
.plan-do-section {
    border-left: 5px solid #667eea;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 0;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.section-header h2 {
    margin: 0;
    padding: 0;
    border: none;
}

/* 활동 선택 버튼 (레전드) - 화면 상단 고정 */
.activity-legend-fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 12px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.activity-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 1000px;
    margin: 0 auto;
}


.legend-btn {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.legend-btn.work { background: #4a90d9; color: white; }
.legend-btn.study { background: #ffc107; color: #333; }
.legend-btn.health { background: #ff69b4; color: white; }
.legend-btn.rest { background: #adb5bd; color: white; }
.legend-btn.waste { background: #dc3545; color: white; }
.legend-btn.clear { background: #f8f9fa; color: #495057; border: 2px solid #dee2e6; }

.legend-btn.active {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.5);
    transform: scale(1.05);
}

.legend-btn:hover {
    transform: scale(1.05);
}

/* 다이어리 테이블 */
.diary-table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #dee2e6;
}

.diary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.diary-table thead {
    background: #f1f3f5;
}

.diary-table th {
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.diary-table th.col-check {
    width: 40px;
}

.diary-table th.col-task {
    width: 35%;
    text-align: left;
    padding-left: 15px;
}

.diary-table th.col-time {
    width: 60px;
}

.diary-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background 0.2s;
}

.diary-table tbody tr:hover {
    background: #f8f9fa;
}

.diary-table tbody tr:last-child {
    border-bottom: none;
}

.diary-table td {
    padding: 8px;
    vertical-align: middle;
}

/* 체크박스 셀 */
.diary-table td.cell-check {
    text-align: center;
}

.diary-table td.cell-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

/* 할일 입력 셀 */
.diary-table td.cell-task {
    padding-left: 10px;
}

.diary-table td.cell-task input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.diary-table td.cell-task input:focus {
    outline: none;
    border-color: #667eea;
}

.diary-table td.cell-task input.checked {
    text-decoration: line-through;
    color: #adb5bd;
}

/* 시간 셀 */
.diary-table td.cell-time {
    text-align: center;
    font-weight: 600;
    color: #6c757d;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* 트래커 셀들 */
.diary-table td.cell-tracker {
    padding: 4px;
    width: 40px;
}

.tracker-cell {
    width: 32px;
    height: 32px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    margin: 0 auto;
}

.tracker-cell:hover {
    border-color: #667eea;
    transform: scale(1.1);
}

/* 트래커 색상 */
.tracker-cell.work {
    background: #4a90d9;
    border-color: #4a90d9;
}

.tracker-cell.study {
    background: #ffc107;
    border-color: #ffc107;
}

.tracker-cell.health {
    background: #ff69b4;
    border-color: #ff69b4;
}

.tracker-cell.rest {
    background: #adb5bd;
    border-color: #adb5bd;
}

.tracker-cell.waste {
    background: #dc3545;
    border-color: #dc3545;
    position: relative;
}

.tracker-cell.waste::after {
    content: "×";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 1rem;
}

/* ==================== */
/* SEE 섹션 */
/* ==================== */
.see-section {
    border-left: 5px solid #28a745;
}

.kpt-container {
    display: grid;
    gap: 15px;
}

.kpt-item {
    padding: 15px;
    border-radius: 10px;
    background: white;
}

.kpt-item h3 {
    margin-bottom: 10px;
    font-size: 1rem;
}

.kpt-item.keep { border-left: 4px solid #28a745; }
.kpt-item.problem { border-left: 4px solid #dc3545; }
.kpt-item.try { border-left: 4px solid #ffc107; }

.kpt-item textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.95rem;
    resize: vertical;
    font-family: inherit;
}

.kpt-item textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* 푸터 */
footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    flex-wrap: wrap;
}

.action-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.action-btn.save {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.action-btn.save:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.action-btn.load {
    background: #28a745;
    color: white;
}

.action-btn.load:hover {
    background: #218838;
    transform: translateY(-2px);
}

#status-message {
    font-size: 0.9rem;
    color: #6c757d;
    min-width: 150px;
    text-align: center;
}

#status-message.success {
    color: #28a745;
}

#status-message.error {
    color: #dc3545;
}

/* ==================== */
/* 모달 공통 */
/* ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
    margin: 0;
    color: #495057;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

/* ==================== */
/* 캘린더 모달 */
/* ==================== */
.calendar-modal-content {
    width: 100%;
    max-width: 400px;
}

.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
}

.calendar-nav span {
    font-weight: 600;
    font-size: 1.1rem;
    color: #495057;
}

.cal-nav-btn {
    background: #667eea;
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.cal-nav-btn:hover {
    background: #5a6fd6;
}

.calendar-grid {
    padding: 15px 20px 20px;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 10px;
}

.calendar-header span {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6c757d;
    padding: 8px 0;
}

.calendar-header span:first-child {
    color: #dc3545;
}

.calendar-header span:last-child {
    color: #4a90d9;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    position: relative;
}

.calendar-day:hover {
    background: #e9ecef;
}

.calendar-day.other-month {
    color: #adb5bd;
}

.calendar-day.today {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.calendar-day.today:hover {
    background: #5a6fd6;
}

.calendar-day.selected {
    background: #28a745;
    color: white;
}

.calendar-day.has-record::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 6px;
    height: 6px;
    background: #667eea;
    border-radius: 50%;
}

.calendar-day.today.has-record::after {
    background: white;
}

/* ==================== */
/* 기록 목록 모달 */
/* ==================== */
.history-modal-content {
    width: 100%;
    max-width: 400px;
}

.history-list {
    padding: 10px 20px 20px;
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

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

.history-date {
    font-weight: 600;
    color: #495057;
}

.history-preview {
    font-size: 0.85rem;
    color: #6c757d;
}

.history-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

/* ==================== */
/* 통계 모달 */
/* ==================== */
.stats-modal-content {
    width: 100%;
    max-width: 500px;
}

.stats-tabs {
    display: flex;
    padding: 0 20px;
    border-bottom: 1px solid #e9ecef;
}

.stats-tab {
    flex: 1;
    padding: 15px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.2s;
}

.stats-tab:hover {
    color: #495057;
}

.stats-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.stats-content {
    padding: 20px;
}

.stats-summary,
.stats-chart,
.stats-peak {
    margin-bottom: 25px;
}

.stats-summary h4,
.stats-chart h4,
.stats-peak h4 {
    margin-bottom: 15px;
    color: #495057;
    font-size: 1rem;
}

.activity-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.stat-label {
    width: 80px;
    font-size: 0.9rem;
    color: #495057;
}

.stat-bar-container {
    flex: 1;
    height: 24px;
    background: #e9ecef;
    border-radius: 12px;
    overflow: hidden;
}

.stat-bar {
    height: 100%;
    border-radius: 12px;
    transition: width 0.5s ease;
}

.stat-bar.work { background: #4a90d9; }
.stat-bar.study { background: #ffc107; }
.stat-bar.health { background: #ff69b4; }
.stat-bar.rest { background: #adb5bd; }
.stat-bar.waste { background: #dc3545; }

.stat-value {
    width: 60px;
    text-align: right;
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
}

/* 도넛 차트 */
.chart-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.donut-chart {
    position: relative;
    width: 200px;
    height: 200px;
}

.donut-chart svg {
    transform: rotate(-90deg);
}

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

.donut-chart .total-time {
    font-size: 1.5rem;
    font-weight: 700;
    color: #495057;
}

.donut-chart .total-label {
    font-size: 0.8rem;
    color: #6c757d;
}

/* 활발한 시간대 */
.peak-hours {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.peak-hour-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.peak-hour-rank {
    width: 24px;
    height: 24px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.peak-hour-time {
    font-weight: 600;
    color: #495057;
}

.peak-hour-count {
    font-size: 0.85rem;
    color: #6c757d;
}

.stats-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

/* ==================== */
/* 반응형 */
/* ==================== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 15px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .header-buttons {
        width: 100%;
    }

    .header-action-btn {
        flex: 1;
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    .pds-section {
        padding: 15px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .activity-legend-fixed {
        padding: 10px 15px;
    }

    .activity-legend {
        width: 100%;
        justify-content: center;
        gap: 6px;
    }

    .legend-btn {
        padding: 5px 10px;
        font-size: 0.7rem;
    }

    .diary-table {
        font-size: 0.8rem;
    }

    .diary-table th,
    .diary-table td {
        padding: 6px 4px;
    }

    .diary-table th.col-task {
        width: 30%;
    }

    .diary-table td.cell-task input {
        padding: 6px;
        font-size: 0.8rem;
    }

    .tracker-cell {
        width: 24px;
        height: 24px;
    }

    footer {
        flex-direction: column;
    }

    .action-btn {
        width: 100%;
    }

    .modal {
        padding: 10px;
    }

    .modal-content {
        max-height: 85vh;
    }

    .stats-modal-content {
        max-width: 100%;
    }
}

@media (max-width: 500px) {
    .diary-table-container {
        overflow-x: auto;
    }

    .diary-table {
        min-width: 500px;
    }
}

/* 토스트 메시지 */
.toast-message {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: white;
    padding: 10px 24px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-message.error {
    background: #dc3545;
}
