:root {
    --bg-color: #f2fbf5;  /* 浅浅的马卡龙绿背景 */
    --card-bg: #ffffff;
    --text-primary: #2d4a36; /* 偏深的绿色字体 */
    --text-secondary: #70917c;
    --primary-color: #81c79a; /* 马卡龙主主题绿 */
    --primary-hover: #6db186;
    --danger-color: #e59188; /* 搭配柔和的警示色 */
    --border-color: #e5f2ea;
    --border-radius: 12px;
}

body.dark-theme {
    --bg-color: #07120b;  /* 深邃的墨绿背景，加深对比 */
    --card-bg: #21482e;   /* 墨绿卡片，提亮以增加区分度 */
    --text-primary: #d1ebd8;
    --text-secondary: #84a690;
    --primary-color: #4b825c; /* 暗色下的沉稳绿色 */
    --primary-hover: #3c6e4e;
    --border-color: #4b6c58;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 隐藏整体页面滚动条（支持绝大多数现代浏览器，但允许滚动） */
html::-webkit-scrollbar {
    display: none;
}

body {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
    background: linear-gradient(135deg, var(--bg-color), var(--border-color));
    background-size: 200% 200%;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    padding: 20px;
    min-height: 100vh;
    transition: color 0.3s;
    animation: gradientFlow 12s ease infinite;
}

.container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: background 0.3s, box-shadow 0.3s, transform 0.3s;
    animation: fadeInRise 0.5s ease-out backwards;
}

.left-column .card:nth-child(1) { animation-delay: 0.1s; }
.left-column .card:nth-child(2) { animation-delay: 0.2s; }
.left-column .card:nth-child(3) { animation-delay: 0.3s; }
.right-column .card:nth-child(1) { animation-delay: 0.2s; }

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color), #a2deba);  /* 马卡龙渐变 */
    color: white;
    background-size: 200% 200%;
    animation: gradientFlow 5s ease infinite, fadeInRise 0.5s ease-out backwards;
}

@keyframes gradientFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.date-section h1 {
    font-size: 2.5rem;
    margin-bottom: 5px;
}

.title-section {
    text-align: center;
}

.title-section .app-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.title-section .app-subtitle {
    font-size: 1rem;
    font-weight: 500;
}

.weather-section {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

#weather-icon {
    font-size: 2rem;
}

#city-info {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
}

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-top: 5px;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.3); }

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.right-column {
    display: flex;
    flex-direction: column;
}

/* 日历样式 */
.calendar-section {
    padding-top: 15px;
    padding-bottom: 15px;
}

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

.calendar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.calendar-header .icon-btn {
    background-color: var(--bg-color);
    color: var(--primary-color);
    font-size: 1rem;
    padding: 5px 12px;
}

.calendar-header .icon-btn:hover {
    background-color: var(--border-color);
    color: var(--primary-hover);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: bold;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-size: 0.9rem;
}

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

.calendar-day {
    padding: 8px 0;
    text-align: center;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    position: relative;
    transition: background 0.2s;
}

.calendar-day:hover {
    background: var(--bg-color);
}

.calendar-day.selected {
    background: var(--primary-color);
    color: white;
}

.calendar-day.other-month {
    color: var(--border-color);
}

.calendar-day.has-notes::after,
.calendar-day.has-todos::before {
    content: '';
    position: absolute;
    bottom: 2px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.calendar-day.has-notes:not(.has-todos)::after {
    background-color: var(--danger-color);
    left: 50%;
    transform: translateX(-50%);
}

.calendar-day.has-todos:not(.has-notes)::before {
    background-color: var(--primary-color);
    left: 50%;
    transform: translateX(-50%);
}

.calendar-day.has-notes.has-todos::before {
    background-color: var(--primary-color);
    left: calc(50% - 6px);
}
.calendar-day.has-notes.has-todos::after {
    background-color: var(--danger-color);
    left: calc(50% + 3px);
}

.calendar-day.selected.has-notes::after {
    background-color: var(--danger-color);
    box-shadow: 0 0 2px 1px var(--card-bg);
}

.calendar-day.selected.has-todos::before {
    background-color: var(--primary-color);
    box-shadow: 0 0 2px 1px var(--card-bg);
}

.notes-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.notes-header-flex h2 {
    margin-bottom: 0;
}

.notes-header-flex .icon-btn {
    background-color: var(--primary-color);
    color: white;
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    border: none;
}
.notes-header-flex .icon-btn:hover {
    background-color: var(--primary-hover);
}

.md-toolbar {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.toolbar-btn {
    background-color: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.data-header-flex h2 {
    font-size: 1.2rem;
    margin-bottom: 0;
}

.data-tabs {
    display: flex;
    gap: 5px;
    background: var(--bg-color);
    padding: 4px;
    border-radius: var(--border-radius);
}

.data-tab {
    padding: 4px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: all 0.2s;
    user-select: none;
}

.data-tab.active {
    background: var(--card-bg);
    color: var(--primary-color);
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

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

.file-input {
    font-size: 0.9rem;
    color: var(--text-primary);
    padding-bottom: 5px;
}

.export-btn {
    background-color: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    text-align: left;
    padding: 10px 12px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    font-size: 0.95rem;
}

.export-btn:hover {
    background-color: var(--card-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

#daily-notes, #notes-preview {
    width: 100%;
    flex: 1;
    min-height: 400px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    line-height: 1.5;
    background: var(--card-bg);
    color: var(--text-primary);
}

#daily-notes {
    resize: none;
    outline: none;
}

#notes-preview {
    overflow-y: auto;
    display: none;
}

/* 针对小记专属的精美滚动条 */
#daily-notes::-webkit-scrollbar,
#notes-preview::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
#daily-notes::-webkit-scrollbar-track,
#notes-preview::-webkit-scrollbar-track {
    background: transparent;
}
#daily-notes::-webkit-scrollbar-thumb,
#notes-preview::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 6px;
}
#daily-notes::-webkit-scrollbar-thumb:hover,
#notes-preview::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-color);
}

/* Markdown preview styles */
#notes-preview h1, #notes-preview h2, #notes-preview h3 { margin-bottom: 10px; color: var(--primary-color); }
#notes-preview p { margin-bottom: 10px; }
#notes-preview ul, #notes-preview ol { padding-left: 20px; margin-bottom: 10px; }
#notes-preview blockquote { border-left: 4px solid var(--border-color); padding-left: 10px; color: var(--text-secondary); margin-bottom: 10px; }
#notes-preview code { background-color: var(--bg-color); padding: 2px 4px; border-radius: 4px; font-family: monospace; }
#notes-preview pre { background-color: var(--bg-color); padding: 10px; border-radius: var(--border-radius); overflow-x: auto; margin-bottom: 10px; }
#notes-preview pre code { background-color: transparent; padding: 0; }

@media (max-width: 768px) {
    body { padding: 10px; }
    .card { padding: 15px; }
    
    .main-content { 
        display: flex; 
        flex-direction: column; 
    }
    
    .left-column, .right-column {
        display: contents;
    }
    
    .todo-section { order: 1; }
    .notes-section { order: 2; }
    .calendar-section { order: 3; }
    .data-section { order: 4; }
    
    .header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .weather-section {
        align-items: center;
    }
    
    .weather-section > div:last-child {
        display: flex;
        justify-content: center;
        gap: 10px;
        flex-wrap: wrap;
    }

    .date-section h1 { font-size: 2rem; }
    .title-section .app-title { font-size: 2rem; }
    
    .data-header-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

h2 { margin-bottom: 15px; color: var(--text-primary); }

.todo-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#todo-input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    outline: none;
    background: var(--card-bg);
    color: var(--text-primary);
}
#todo-input:focus { border-color: var(--primary-color); }

button {
    padding: 10px 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
button:hover { 
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(129, 199, 154, 0.3);
}
button:active {
    transform: translateY(1px) scale(0.96);
    box-shadow: none;
}
.icon-btn {
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.icon-btn:active {
    transform: scale(0.9);
}
.danger-btn { background-color: var(--danger-color); }
.danger-btn:hover { background-color: #d32f2f; }

.todo-list { list-style: none; }
.todo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}
.todo-item:hover {
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    padding-left: 15px;
    border-bottom-color: transparent;
}
.todo-item.completed span {
    text-decoration: line-through;
    color: var(--text-secondary);
    transition: color 0.3s;
}
.todo-content {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}
.todo-item:active .todo-content {
    transform: scale(0.98);
}
.todo-content input[type="checkbox"] {
    accent-color: var(--primary-color);
    transform: scale(1.1);
    transition: transform 0.2s;
}
.todo-content input[type="checkbox"]:active {
    transform: scale(0.9);
}
.delete-btn {
    background: none;
    color: var(--danger-color);
    padding: 5px;
}
.delete-btn:hover { background: rgba(229, 115, 115, 0.2); color: var(--danger-color); }

.notes-hint { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 10px; }

#daily-notes:focus { border-color: var(--primary-color); }
.notes-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}
#save-status {
    font-size: 0.8rem;
    color: #4caf50;
    opacity: 0;
    transition: opacity 0.5s;
}