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

:root {
    --bg-primary: #1b1b1b;
    --bg-secondary: #222222;
    --bg-cell: #262626;
    --bg-cell-hover: #303030;
    --bg-today: #2e2e2e;
    --border-color: #363636;
    --text-primary: #d4d4d4;
    --text-secondary: #888888;
    --text-muted: #666666;
    --text-holiday: #d45a4a;
    --accent: #4a90d9;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

.app {
    display: flex;
    flex-direction: row;
    height: 100vh;
    padding: 0;
}

/* Sidebar */
.sidebar {
    width: 44px;
    background: #181818;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    flex-shrink: 0;
}

.sidebar-top, .sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.sidebar-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.sidebar-btn:hover { color: var(--text-primary); background: #2a2a2a; }
.sidebar-btn.active { color: var(--text-primary); background: #2e2e2e; }

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.view-page {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.view-page.active {
    display: flex;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.month-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 1px;
}

.header-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn {
    border: none;
    cursor: pointer;
    font-size: 14px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-icon {
    background: var(--accent);
    color: #fff;
    width: 32px;
    height: 32px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-right: 8px;
}

.btn-icon:hover { background: #3a80c9; }

.btn-nav {
    background: var(--bg-cell);
    color: var(--text-primary);
    padding: 6px 12px;
    border: 1px solid var(--border-color);
}

.btn-nav:hover { background: var(--bg-cell-hover); }

.btn-today {
    background: var(--bg-cell);
    color: var(--text-primary);
    padding: 6px 16px;
    border: 1px solid var(--border-color);
}

.btn-today:hover { background: var(--bg-cell-hover); }

/* Weekdays */
.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.weekday {
    text-align: center;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.weekday.weekend { color: var(--text-muted); }

/* Calendar Grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    flex: 1;
    min-height: 0;
}

.day-cell {
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 4px 6px;
    background: var(--bg-cell);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
    transition: background 0.15s;
    min-height: 0;
}

.day-cell:hover { background: var(--bg-cell-hover); }
.day-cell.today { background: var(--bg-today); }
.day-cell.other-month { opacity: 0.4; }

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
    flex-shrink: 0;
}

.day-number {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.today .day-number {
    background: var(--accent);
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.day-lunar {
    font-size: 11px;
    color: var(--text-muted);
}

.day-lunar.holiday { color: var(--text-holiday); }
.day-lunar.solar-term { color: #5bb5a6; }

.day-tasks {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.day-tasks::-webkit-scrollbar { width: 2px; }
.day-tasks::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 1px; }

/* Task Item */
.task-item {
    display: flex;
    align-items: center;
    padding: 2px 6px;
    margin-bottom: 2px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.6;
    cursor: pointer;
    transition: filter 0.15s;
    white-space: nowrap;
    overflow: hidden;
}

.task-item:hover { filter: brightness(1.2); }

.task-item.done {
    opacity: 0.5;
    text-decoration: line-through;
}

.task-checkbox {
    width: 12px;
    height: 12px;
    border: 1.5px solid rgba(255,255,255,0.5);
    border-radius: 3px;
    margin-right: 5px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.task-checkbox:hover { border-color: #fff; }

.task-item.done .task-checkbox {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.3);
}

.task-item.done .task-checkbox::after {
    content: '✓';
    font-size: 9px;
    color: #fff;
}

.task-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
}

.task-time {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    margin-left: 4px;
    flex-shrink: 0;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

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

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

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
}

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

.modal-body { padding: 20px; }

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-cell);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus { border-color: var(--accent); }

.color-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
}

.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
}

.btn-cancel {
    background: var(--bg-cell);
    color: var(--text-primary);
    padding: 8px 20px;
    border: 1px solid var(--border-color);
}

.btn-save {
    background: var(--accent);
    color: #fff;
    padding: 8px 20px;
}

.btn-save:hover { background: #3a80c9; }

.btn-delete {
    background: #cc3344;
    color: #fff;
    padding: 8px 16px;
    margin-right: auto;
}

.btn-delete:hover { background: #aa2233; }

/* Context Menu */
.context-menu {
    display: none;
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px 0;
    z-index: 2000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    min-width: 120px;
}

.context-menu.active { display: block; }

.context-item {
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s;
}

.context-item:hover { background: var(--bg-cell-hover); }
.context-item-danger { color: #d45a4a; }
.context-item-danger:hover { background: #3a2222; }

/* Task Management Page */
.page-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 1px;
}

.task-filters {
    display: flex;
    gap: 4px;
}

.btn-filter {
    background: transparent;
    color: var(--text-secondary);
    padding: 5px 14px;
    border: 1px solid var(--border-color);
    font-size: 13px;
}

.btn-filter:hover { color: var(--text-primary); background: var(--bg-cell-hover); }
.btn-filter.active { color: var(--text-primary); background: var(--bg-cell); border-color: var(--accent); }

.tasks-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
}

.tasks-list::-webkit-scrollbar { width: 5px; }
.tasks-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.task-date-group {
    margin-bottom: 16px;
}

.task-date-label {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-date-label .weekday-tag {
    font-size: 11px;
    color: var(--text-muted);
}

.task-date-label .count-tag {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

.task-list-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    background: var(--bg-cell);
    cursor: pointer;
    transition: background 0.15s;
    gap: 10px;
}

.task-list-item:hover { background: var(--bg-cell-hover); }

.task-list-item.done { opacity: 0.5; }

.task-list-color {
    width: 4px;
    height: 28px;
    border-radius: 2px;
    flex-shrink: 0;
}

.task-list-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-muted);
    border-radius: 4px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.task-list-checkbox:hover { border-color: var(--accent); }

.task-list-item.done .task-list-checkbox {
    background: var(--accent);
    border-color: var(--accent);
}

.task-list-item.done .task-list-checkbox::after {
    content: '✓';
    font-size: 12px;
    color: #fff;
    font-weight: 700;
}

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

.task-list-title {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-list-item.done .task-list-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-list-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.task-list-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.task-list-item:hover .task-list-actions { opacity: 1; }

.task-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.task-action-btn:hover { background: var(--bg-cell); color: var(--text-primary); }
.task-action-btn.delete:hover { color: var(--text-holiday); }

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

/* Search Page */
.search-bar {
    padding: 12px 20px;
    flex-shrink: 0;
}

.search-bar .form-input {
    font-size: 15px;
    padding: 10px 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 38px; padding: 6px 0; }
    .sidebar-btn { width: 30px; height: 30px; }
    .sidebar-avatar { width: 28px; height: 28px; margin-bottom: 8px; }
    .day-cell { padding: 2px 3px; }
    .day-number { font-size: 12px; }
    .day-lunar { font-size: 9px; }
    .task-item { font-size: 11px; padding: 1px 4px; }
    .task-time { display: none; }
    .header { padding: 8px 12px; }
    .month-title { font-size: 16px; }
    .task-filters { gap: 2px; }
    .btn-filter { padding: 4px 10px; font-size: 12px; }
}
