* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

#app {
    max-width: 640px;
    margin: 0 auto;
    min-height: 100vh;
    background: #fff;
    position: relative;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 20px 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-title {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 16px;
}

.nav-tabs {
    display: flex;
    gap: 8px;
}

.nav-tab {
    flex: 1;
    padding: 10px 0;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    cursor: pointer;
    position: relative;
    transition: color 0.3s;
}

.nav-tab.active {
    color: #fff;
    font-weight: 600;
}

.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: #fff;
    border-radius: 2px;
}

.app-main {
    flex: 1;
    padding: 16px;
    padding-bottom: 80px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

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

.cal-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #f0f2f5;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.cal-btn:active {
    background: #e0e2e5;
}

.cal-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

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

.calendar-weekdays span {
    padding: 8px 0;
    font-size: 12px;
    color: #999;
    font-weight: 500;
}

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

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

.cal-day:active {
    background: #f0f2f5;
}

.cal-day.other-month {
    color: #ccc;
}

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

.cal-day.selected {
    background: #764ba2;
    color: #fff;
    font-weight: 600;
}

.cal-day .event-dot {
    width: 5px;
    height: 5px;
    background: #ff6b6b;
    border-radius: 50%;
    margin-top: 2px;
}

.cal-day.today .event-dot,
.cal-day.selected .event-dot {
    background: #fff;
}

.today-section {
    text-align: center;
    margin-bottom: 20px;
}

.btn-add {
    width: 100%;
    padding: 12px;
    font-size: 15px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
}

.btn-primary:active {
    opacity: 0.85;
}

.btn-small {
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
}

.btn-danger {
    background: #ff6b6b;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
}

.day-events {
    margin-top: 16px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
}

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

.event-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.event-card:active {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.event-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.event-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #f0f2f5;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
}

.event-tag.location {
    background: #e8f4fd;
    color: #1890ff;
}

.event-tag.person {
    background: #f6ffed;
    color: #52c41a;
}

.event-tag.more {
    background: #f0f0f0;
    color: #999;
    font-weight: 500;
}

.event-content {
    font-size: 13px;
    color: #666;
    line-height: 1.6;
}

.event-time-info {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #eee;
    font-size: 12px;
}

.event-time {
    color: #999;
    margin-right: 12px;
}

.event-time.updated {
    color: #1890ff;
}

.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.search-input:focus {
    border-color: #667eea;
}

.filter-select {
    padding: 8px 10px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
    outline: none;
    min-width: 80px;
}

.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}

.timeline-date {
    flex-shrink: 0;
    width: 50px;
    text-align: center;
}

.timeline-date .day {
    font-size: 20px;
    font-weight: 700;
    color: #667eea;
    line-height: 1.2;
}

.timeline-date .month {
    font-size: 12px;
    color: #999;
}

.timeline-content {
    flex: 1;
    min-width: 0;
}

.timeline-content .title {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-content .desc {
    font-size: 12px;
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-meta {
    font-size: 11px;
    color: #aaa;
    margin-top: 4px;
}

.timeline-time {
    margin-right: 8px;
}

.timeline-time.updated {
    color: #1890ff;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
}

.stat-num {
    font-size: 28px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #666;
}

.manage-section {
    margin-bottom: 24px;
}

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

.manage-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.manage-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #fafafa;
    border-radius: 8px;
    cursor: pointer;
}

.manage-item:active {
    background: #f0f0f0;
}

.manage-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.manage-item-desc {
    font-size: 12px;
    color: #999;
    margin-top: 2px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal {
    background: #fff;
    width: 100%;
    max-width: 640px;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    position: sticky;
    top: 0;
    background: #fff;
}

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

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 120px;
    overflow-y: auto;
    padding: 4px;
}

.people-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 8px;
}

.checkbox-more, .checkbox-empty {
    color: #999;
    font-size: 12px;
    padding: 4px 8px;
}

.selected-people {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

.selected-tag {
    display: inline-flex;
    align-items: center;
    background: #e8f4fd;
    color: #1890ff;
    padding: 2px 8px;
    border-radius: 4px;
    margin: 2px;
}

.remove-tag {
    background: none;
    border: none;
    color: #1890ff;
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    margin-left: 2px;
}

.remove-tag:hover {
    color: #ff4d4f;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #f5f5f5;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.checkbox-item input {
    cursor: pointer;
}

.checkbox-item.checked {
    background: #e8f4fd;
    color: #1890ff;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions button {
    flex: 1;
}

.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    z-index: 2000;
    font-size: 14px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state-text {
    font-size: 14px;
}

.year-group {
    margin-bottom: 16px;
}

.year-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    margin-bottom: 8px;
}

.year-header:active {
    opacity: 0.8;
}

.year-arrow {
    font-size: 12px;
    color: #667eea;
    transition: transform 0.2s;
}

.year-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
}

.year-count {
    font-size: 12px;
    color: #999;
    background: #fff;
    padding: 2px 8px;
    border-radius: 10px;
}

.year-events {
    padding-left: 8px;
}

@media (min-width: 640px) {
    .modal-overlay {
        align-items: center;
    }
    .modal {
        border-radius: 16px;
        max-width: 480px;
    }
}
