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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
}

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

/* 页面 */
.page {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.page.active {
    display: flex;
}

/* 头部 */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 0.5px solid #e0e0e0;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    font-weight: 600;
    color: #1c1c1e;
}

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

.header-center {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    color: #1c1c1e;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #534ab7;
    cursor: pointer;
    padding: 4px;
}

.text-btn {
    background: none;
    border: none;
    font-size: 14px;
    color: #534ab7;
    cursor: pointer;
}

.back-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #534ab7;
    cursor: pointer;
    padding: 4px 8px;
}

/* 日历页 */
.calendar-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

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

.weekdays span {
    font-size: 13px;
    color: #8e8e93;
}

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

.calendar-day {
    min-height: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    padding: 6px 2px;
    gap: 2px;
}

.calendar-day:active {
    background: #f2f2f7;
}

.calendar-day.today {
    background: rgba(83, 74, 183, 0.12);
}

.calendar-day.today .day-num {
    color: #534ab7;
    font-weight: 600;
}

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

.day-num {
    font-size: 16px;
    color: #1c1c1e;
    line-height: 1.2;
}

.day-lunar {
    font-size: 10px;
    color: #8e8e93;
    margin-top: 2px;
}

.day-holiday {
    font-size: 9px;
    color: #e24b4a;
    margin-top: 1px;
}

.day-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #534ab7;
    margin-top: 2px;
}

/* 今日页 */
.today-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.habit-item {
    display: flex;
    align-items: center;
    background: #f2f2f7;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.habit-item.completed {
    opacity: 0.6;
}

.habit-info {
    flex: 1;
}

.habit-name {
    font-size: 15px;
    color: #1c1c1e;
    font-weight: 500;
}

.habit-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.progress-bar {
    width: 80px;
    height: 6px;
    background: #e5e5ea;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #34c759;
    border-radius: 3px;
    transition: width 0.2s;
}

.progress-text {
    font-size: 12px;
    color: #8e8e93;
}

.habit-status {
    font-size: 13px;
    color: #34c759;
    font-weight: 500;
}

.habit-action {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e6f1fb;
    color: #007aff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.habit-action.completed {
    background: #eaf3de;
    color: #34c759;
}

/* 待办页 */
.tag-bar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tag-bar::-webkit-scrollbar {
    display: none;
}

.tag-item {
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    border: 0.5px solid #e0e0e0;
    background: #f2f2f7;
    color: #3a3a3c;
}

.tag-item.active {
    background: #534ab7;
    color: #fff;
    border-color: #534ab7;
}

.todo-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 80px;
}

.todo-item {
    display: flex;
    align-items: flex-start;
    background: #f2f2f7;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
}

.todo-item.completed {
    opacity: 0.5;
}

.todo-item.completed .todo-text {
    text-decoration: line-through;
}

.todo-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid #c7c7cc;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.todo-item.completed .todo-checkbox {
    background: #34c759;
    border-color: #34c759;
}

.todo-checkbox::after {
    content: "";
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    display: none;
}

.todo-item.completed .todo-checkbox::after {
    display: block;
}

.todo-content {
    flex: 1;
}

.todo-text {
    font-size: 15px;
    color: #1c1c1e;
    line-height: 1.4;
}

.todo-date {
    font-size: 12px;
    color: #8e8e93;
    margin-top: 4px;
}

/* 创建页 */
.create-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.create-type {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.type-btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: 0.5px solid #e0e0e0;
    background: #f2f2f7;
    font-size: 15px;
    color: #3a3a3c;
    cursor: pointer;
}

.type-btn.active {
    background: #534ab7;
    color: #fff;
    border-color: #534ab7;
}

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

.form-label {
    display: block;
    font-size: 14px;
    color: #3a3a3c;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 0.5px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    background: #f2f2f7;
    outline: none;
}

.form-input:focus {
    border-color: #534ab7;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #534ab7;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: #534ab7;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 20px;
}

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

/* 设置页 */
.settings-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #fff;
    border-bottom: 0.5px solid #f2f2f7;
    cursor: pointer;
}

.setting-item span:first-child {
    font-size: 15px;
    color: #1c1c1e;
}

.arrow {
    font-size: 18px;
    color: #c7c7cc;
}

.version {
    font-size: 14px;
    color: #8e8e93;
}

/* 开关 */
.switch {
    position: relative;
    width: 50px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #e5e5ea;
    border-radius: 30px;
    transition: 0.2s;
}

.slider:before {
    content: "";
    position: absolute;
    height: 26px;
    width: 26px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.switch input:checked + .slider {
    background: #34c759;
}

.switch input:checked + .slider:before {
    transform: translateX(20px);
}

/* 标签管理 */
.tags-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.tag-manage-item {
    display: flex;
    align-items: center;
    background: #f2f2f7;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
}

.tag-drag {
    font-size: 18px;
    color: #c7c7cc;
    margin-right: 12px;
    cursor: grab;
}

.tag-name {
    flex: 1;
    font-size: 15px;
    color: #1c1c1e;
}

.tag-edit, .tag-delete {
    background: none;
    border: none;
    font-size: 14px;
    color: #534ab7;
    cursor: pointer;
    margin-left: 12px;
}

.tag-delete {
    color: #e24b4a;
}

/* 底部导航 */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 0 10px;
    background: #fff;
    border-top: 0.5px solid #e0e0e0;
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 16px;
    color: #8e8e93;
}

.nav-item.active {
    color: #534ab7;
}

.nav-icon {
    font-size: 22px;
}

.nav-text {
    font-size: 11px;
}

/* FAB */
.fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #534ab7;
    color: #fff;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(83,74,183,0.3);
    z-index: 10;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    align-items: flex-end;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #fff;
    width: 100%;
    max-width: 430px;
    border-radius: 16px 16px 0 0;
    padding: 12px 0;
    animation: slideUp 0.2s ease;
}

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

.modal-content button {
    display: block;
    width: 100%;
    padding: 16px;
    background: none;
    border: none;
    border-bottom: 0.5px solid #f2f2f7;
    font-size: 16px;
    color: #007aff;
    cursor: pointer;
    text-align: center;
}

.modal-content button.danger {
    color: #e24b4a;
}

.modal-content button:last-child {
    border-bottom: none;
}

.confirm-content {
    padding: 24px 20px;
    border-radius: 16px;
    margin: auto 20px 20px;
    text-align: center;
}

.confirm-content p {
    font-size: 16px;
    color: #1c1c1e;
    margin-bottom: 20px;
}

.confirm-btns {
    display: flex;
    gap: 12px;
}

.confirm-btns button {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: 0.5px solid #e0e0e0;
    background: #f2f2f7;
    font-size: 15px;
    color: #1c1c1e;
    cursor: pointer;
}

.confirm-btns button.danger {
    background: #e24b4a;
    color: #fff;
    border-color: #e24b4a;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #8e8e93;
    font-size: 14px;
}

/* 隐藏 */
.hidden {
    display: none !important;
}
