:root {
        --bg: #f4f7f4;
        --bg-strong: #e6ede7;
        --surface: #ffffff;
        --surface-soft: #f8faf8;
        --text: #17211b;
        --muted: #647269;
        --faint: #97a29b;
        --line: #dfe7e1;
        --accent: #216e4e;
        --accent-2: #2f80ed;
        --accent-3: #c45532;
        --warning: #b97706;
        --danger: #c63f36;
        --shadow: 0 18px 45px rgba(35, 60, 45, 0.08);
        --radius: 8px;
    }

    * { margin: 0; padding: 0; box-sizing: border-box; }
    html { height: 100%; }
    body {
        height: 100vh;
        min-height: 100vh;
        background:
            linear-gradient(120deg, rgba(33,110,78,.08), transparent 30%),
            linear-gradient(240deg, rgba(47,128,237,.08), transparent 28%),
            var(--bg);
        color: var(--text);
        display: flex;
        overflow: hidden;
        font: 14px/1.55 "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Segoe UI", sans-serif;
    }
    button, input, select, textarea { font: inherit; }

    .sidebar {
        width: 248px;
        background: rgba(255,255,255,.86);
        border-right: 1px solid var(--line);
        padding: 22px 14px;
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        backdrop-filter: blur(18px);
    }
    .sidebar h2 {
        padding: 0 10px 18px;
        font-size: 18px;
        line-height: 1.25;
        color: var(--text);
        font-weight: 750;
        border-bottom: 1px solid var(--line);
        margin-bottom: 14px;
    }
    .sidebar h2::after {
        content: "Personal OS";
        display: block;
        margin-top: 5px;
        font-size: 11px;
        color: var(--faint);
        letter-spacing: .04em;
        text-transform: uppercase;
    }
    .nav-item {
        padding: 11px 12px;
        margin: 3px 0;
        cursor: pointer;
        transition: .18s ease;
        color: var(--muted);
        display: flex;
        align-items: center;
        gap: 10px;
        border-radius: var(--radius);
        border: 1px solid transparent;
        font-weight: 650;
    }
    .nav-item:hover { background: var(--surface-soft); color: var(--text); }
    .nav-item.active {
        background: #eaf4ee;
        color: var(--accent);
        border-color: #cfe0d5;
        box-shadow: inset 3px 0 0 var(--accent);
    }
    .sidebar-bottom {
        margin-top: auto;
        padding-top: 18px;
        border-top: 1px solid var(--line);
    }
    .sync-status {
        font-size: 12px;
        color: var(--faint);
        line-height: 1.55;
        margin-top: 8px;
        min-height: 20px;
    }
    .sync-status.is-error { color: #c24c34; }
    .sync-modal-status {
        margin: 12px 0 14px;
        padding: 11px 12px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: #f6faf7;
        color: var(--muted);
        font-size: 13px;
        line-height: 1.6;
        min-height: 42px;
        white-space: pre-line;
    }
    .sync-modal-status.is-error {
        border-color: #efc6ba;
        background: #fff7f4;
        color: #b7432c;
    }
    .btn {
        padding: 8px 13px;
        border: 1px solid transparent;
        border-radius: var(--radius);
        cursor: pointer;
        font-size: 13px;
        font-weight: 700;
        transition: .18s ease;
        outline: none;
        min-height: 36px;
    }
    .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
        outline: 3px solid rgba(47,128,237,.18);
        outline-offset: 1px;
    }
    .btn-primary { background: var(--accent); color: #fff; box-shadow: 0 10px 22px rgba(33,110,78,.16); }
    .btn-primary:hover { background: #19583e; transform: translateY(-1px); }
    .btn-secondary { background: var(--surface); color: var(--muted); border-color: var(--line); }
    .btn-secondary:hover { color: var(--text); border-color: #cad7cf; background: var(--surface-soft); }
    .btn-danger { background: #fff4f2; color: var(--danger); border-color: #f4d1cb; }
    .btn-danger:hover { background: #ffe6e1; }

    .main {
        flex: 1;
        min-width: 0;
        height: 100vh;
        overflow-y: auto;
        scrollbar-gutter: stable;
        padding: 28px clamp(18px, 4vw, 48px) 52px;
    }
    .page { display: none; max-width: 1260px; margin: 0 auto; animation: pageIn .22s ease; }
    .page.active { display: block; }
    @keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

    .page-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
        margin-bottom: 18px;
    }
    .page-title { font-size: 24px; font-weight: 800; color: var(--text); }
    .page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

    .card {
        background: rgba(255,255,255,.92);
        border-radius: var(--radius);
        padding: 18px;
        margin-bottom: 18px;
        box-shadow: var(--shadow);
        border: 1px solid rgba(223,231,225,.9);
    }
    .card-title {
        font-size: 15px;
        font-weight: 800;
        color: var(--text);
        margin-bottom: 13px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        flex-wrap: wrap;
    }
    .section-title {
        font-size: 12px;
        color: var(--faint);
        margin-bottom: 10px;
        font-weight: 800;
        letter-spacing: .04em;
        text-transform: uppercase;
    }

    .today-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, .95fr); gap: 18px; }
    .dashboard-hero {
        display: grid;
        grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr);
        gap: 18px;
        margin-bottom: 18px;
    }
    .hero-panel {
        min-height: 172px;
        background: #123226;
        color: #fff;
        border-radius: var(--radius);
        padding: 24px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        box-shadow: 0 22px 50px rgba(18,50,38,.18);
        position: relative;
        overflow: hidden;
    }
    .hero-panel::before {
        content: "";
        position: absolute;
        inset: auto -80px -90px auto;
        width: 240px;
        height: 240px;
        background: radial-gradient(circle, rgba(88, 190, 137, .3), transparent 68%);
        pointer-events: none;
    }
    .hero-date { font-size: 13px; color: rgba(255,255,255,.7); font-weight: 700; }
    .hero-title { font-size: clamp(24px, 3vw, 36px); font-weight: 850; line-height: 1.18; max-width: 680px; margin: 12px 0; overflow-wrap: anywhere; }
    .hero-meta { color: rgba(255,255,255,.74); display: flex; gap: 14px; flex-wrap: wrap; }
    .quick-create {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .quick-create .btn { width: 100%; background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.2); }
    .quick-create .btn:hover { background: rgba(255,255,255,.16); }
    .summary-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .summary-card {
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        padding: 14px;
        min-height: 81px;
    }
    .summary-value { font-size: 26px; line-height: 1; font-weight: 850; color: var(--accent); }
    .summary-label { margin-top: 7px; font-size: 12px; color: var(--muted); font-weight: 700; }

    .timeline-group { margin-bottom: 24px; position: relative; }
    .timeline-date {
        font-size: 13px;
        font-weight: 850;
        color: var(--accent);
        margin-bottom: 10px;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .timeline-date::before {
        content: '';
        width: 9px;
        height: 9px;
        border-radius: 50%;
        background: var(--accent);
        box-shadow: 0 0 0 4px rgba(33,110,78,.12);
    }
    .timeline-item {
        background: rgba(255,255,255,.96);
        border-radius: var(--radius);
        padding: 14px 16px;
        margin-bottom: 9px;
        border: 1px solid var(--line);
        border-left: 4px solid #bac8be;
        box-shadow: 0 8px 22px rgba(35,60,45,.05);
        cursor: pointer;
        transition: .18s ease;
    }
    .timeline-item:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(35,60,45,.09); border-color: #ccd8d0; }
    .item-type {
        display: inline-flex;
        align-items: center;
        min-height: 22px;
        padding: 2px 8px;
        border-radius: 999px;
        font-size: 12px;
        color: #fff;
        margin-right: 8px;
        font-weight: 800;
        vertical-align: middle;
    }
    .type-日记, .type-日计划 { background: #2f80ed; border-left-color: #2f80ed; }
    .type-工作记录 { background: #0f766e; border-left-color: #0f766e; }
    .type-灵感碎片 { background: #e0a018; color: #1f1a10; border-left-color: #e0a018; }
    .type-周复盘, .type-月复盘, .type-年复盘 { background: #7a5ac8; border-left-color: #7a5ac8; }
    .type-周计划, .type-月计划, .type-年度计划, .type-3年计划 { background: #216e4e; border-left-color: #216e4e; }
    .type-终身愿景 { background: #c45532; border-left-color: #c45532; }
    .type-习惯打卡-全天 { background: #718096; border-left-color: #718096; }
    .type-习惯打卡-晨间 { background: #d97706; border-left-color: #d97706; }
    .type-习惯打卡-午间 { background: #ca8a04; border-left-color: #ca8a04; }
    .type-习惯打卡-晚间, .type-习惯打卡-学习 { background: #7a5ac8; border-left-color: #7a5ac8; }
    .type-习惯打卡-运动 { background: #2f80ed; border-left-color: #2f80ed; }
    .type-习惯打卡-工作 { background: #b97706; border-left-color: #b97706; }
    .type-习惯打卡-生活 { background: #216e4e; border-left-color: #216e4e; }
    .timeline-item[class*="type-"] {
        background: rgba(255,255,255,.96);
        color: var(--text);
    }
    .timeline-item[class*="type-"] .item-title { color: var(--text); }
    .timeline-item[class*="type-"] .item-preview { color: var(--muted); }
    .timeline-item[class*="type-"] .item-meta { color: var(--faint); }
    .type-待办 { background: #d87863; border-left-color: #d87863; }
    .type-习惯 { background: #4f8b67; border-left-color: #4f8b67; }
    .item-title { font-size: 15px; font-weight: 800; display: inline; color: var(--text); }
    .item-meta { font-size: 12px; color: var(--faint); margin-top: 7px; display: flex; gap: 14px; flex-wrap: wrap; }
    .item-preview { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .record-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 12px; align-items: stretch; margin-bottom: 9px; }
    .record-time {
        color: var(--faint);
        font-size: 12px;
        font-weight: 850;
        padding-top: 15px;
        text-align: right;
        font-variant-numeric: tabular-nums;
    }
    .record-row .timeline-item { margin-bottom: 0; }
    .segmented {
        display: inline-flex;
        gap: 4px;
        padding: 4px;
        background: #edf3ef;
        border: 1px solid var(--line);
        border-radius: var(--radius);
    }
    .segmented button {
        border: none;
        background: transparent;
        color: var(--muted);
        border-radius: 6px;
        padding: 7px 12px;
        cursor: pointer;
        font-weight: 850;
    }
    .segmented button.active { background: #fff; color: var(--accent); box-shadow: 0 6px 16px rgba(35,60,45,.08); }
    .calendar-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
    .record-calendar { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
    .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); }
    .calendar-head, .calendar-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; }
    .calendar-head { padding: 10px 12px; color: var(--muted); font-size: 12px; font-weight: 850; background: var(--surface-soft); }
    .calendar-cell { min-height: 172px; padding: 10px; background: #fff; }
    .calendar-cell.is-today { background: #edf7f1; }
    .calendar-date { color: var(--text); font-weight: 850; margin-bottom: 8px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
    .calendar-date small { color: var(--faint); font-weight: 700; }
    .calendar-cell-body { display: grid; gap: 6px; }
    .calendar-event {
        border-left: 3px solid var(--event-border, var(--accent));
        background: var(--event-bg, #eef6f1);
        color: var(--event-ink, var(--text));
        border-radius: 8px;
        padding: 7px 9px;
        margin-bottom: 6px;
        font-size: 12px;
        cursor: pointer;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        border: 1px solid rgba(0,0,0,.04);
        box-shadow: inset 0 0 0 1px rgba(255,255,255,.24);
    }
    .calendar-event.is-done { opacity: .58; }
    .calendar-more { font-size: 12px; color: var(--muted); font-weight: 800; padding-top: 2px; }
    .agenda-shell {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: calc(var(--radius) + 2px);
        overflow: hidden;
        box-shadow: var(--shadow);
    }
    .agenda-head {
        display: grid;
        background: var(--surface-soft);
        border-bottom: 1px solid var(--line);
    }
    .agenda-corner {
        border-right: 1px solid var(--line);
        background: var(--surface-soft);
    }
    .agenda-day-head {
        min-width: 0;
        padding: 12px 10px 11px;
        border-right: 1px solid var(--line);
        background: var(--surface-soft);
    }
    .agenda-day-head.is-today { background: #e9f7f0; }
    .agenda-day-head:last-child { border-right: none; }
    .agenda-day-label { font-size: 12px; color: var(--muted); font-weight: 850; margin-bottom: 6px; }
    .agenda-day-number { font-size: 24px; font-weight: 900; color: var(--text); line-height: 1; }
    .agenda-day-extra { font-size: 12px; color: var(--faint); margin-left: 6px; font-weight: 700; }
    .agenda-all-day {
        display: grid;
        border-bottom: 1px solid var(--line);
    }
    .agenda-all-day-label {
        border-right: 1px solid var(--line);
        background: #fbfdfb;
        color: var(--muted);
        font-size: 12px;
        font-weight: 850;
        padding: 12px 10px;
    }
    .agenda-all-day-cell {
        min-height: 74px;
        padding: 8px;
        border-right: 1px solid var(--line);
        background: #fcfffd;
        display: grid;
        align-content: start;
        gap: 6px;
    }
    .agenda-all-day-cell:last-child { border-right: none; }
    .agenda-all-day-item,
    .agenda-event-block {
        background: var(--event-bg, #eef6f1);
        color: var(--event-ink, var(--text));
        border: 1px solid var(--event-border, #d3e2d8);
        box-shadow: inset 0 0 0 1px rgba(255,255,255,.24);
    }
    .agenda-all-day-item {
        border-radius: 10px;
        padding: 8px 10px;
        font-size: 12px;
        font-weight: 800;
        cursor: pointer;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .agenda-all-day-item.is-done { opacity: .55; }
    .agenda-body {
        display: grid;
        grid-template-columns: 72px minmax(0, 1fr);
        background: #fff;
    }
    .agenda-time-axis {
        border-right: 1px solid var(--line);
        background: #fff;
    }
    .agenda-hour-label {
        height: 64px;
        border-top: 1px solid #edf2ee;
        text-align: right;
        padding: 4px 10px 0 0;
        font-size: 12px;
        color: var(--faint);
        font-weight: 800;
        font-variant-numeric: tabular-nums;
    }
    .agenda-columns {
        position: relative;
        min-width: 0;
        background: #fff;
    }
    .agenda-columns-grid {
        display: grid;
        position: relative;
    }
    .agenda-day-column {
        position: relative;
        min-height: 1152px;
        border-right: 1px solid var(--line);
        background:
            repeating-linear-gradient(
                to bottom,
                rgba(0,0,0,0),
                rgba(0,0,0,0) 63px,
                #edf2ee 63px,
                #edf2ee 64px
            );
    }
    .agenda-day-column.is-today {
        background:
            linear-gradient(180deg, rgba(70, 140, 98, .08), rgba(70, 140, 98, .03)),
            repeating-linear-gradient(
                to bottom,
                rgba(0,0,0,0),
                rgba(0,0,0,0) 63px,
                #edf2ee 63px,
                #edf2ee 64px
            );
    }
    .agenda-day-column:last-child { border-right: none; }
    .agenda-hour-slot { height: 64px; }
    .agenda-event-layer {
        position: absolute;
        inset: 0;
        pointer-events: none;
    }
    .agenda-event-block {
        position: absolute;
        left: 8px;
        border-radius: 12px;
        padding: 8px 10px;
        cursor: pointer;
        overflow: hidden;
        pointer-events: auto;
        box-shadow: 0 10px 18px rgba(25, 42, 31, .08);
    }
    .agenda-event-block.is-done { opacity: .58; }
    .agenda-event-time {
        font-size: 11px;
        color: rgba(49, 69, 56, .72);
        font-weight: 800;
        margin-bottom: 3px;
    }
    .agenda-event-title {
        font-size: 13px;
        font-weight: 900;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }
    .agenda-event-meta {
        margin-top: 4px;
        font-size: 11px;
        color: rgba(49, 69, 56, .72);
        font-weight: 700;
    }
    .agenda-more {
        font-size: 12px;
        color: var(--muted);
        font-weight: 800;
        padding: 2px 6px 0;
    }
    .habit-view { display: none; }
    .habit-view.active { display: block; }
    .habit-matrix { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
    .habit-matrix-grid { display: grid; grid-template-columns: 160px repeat(30, 36px); min-width: 1240px; }
    .habit-matrix-cell { min-height: 34px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); }
    .habit-matrix-cell.name { justify-content: flex-start; padding: 0 10px; font-weight: 850; color: var(--text); background: var(--surface-soft); position: sticky; left: 0; z-index: 2; }
    .habit-matrix-cell.head { font-weight: 850; background: var(--surface-soft); }
    .habit-dot { width: 16px; height: 16px; border-radius: 5px; background: #e3e9e5; }
    .habit-dot.done { background: var(--accent); box-shadow: inset 0 0 0 2px rgba(255,255,255,.42); }

    .period-item {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 132px;
        gap: 14px;
        align-items: center;
        padding: 13px 14px;
        background: var(--surface-soft);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        margin-bottom: 9px;
        cursor: pointer;
        transition: .18s ease;
    }
    .period-item:hover { background: #fff; transform: translateY(-1px); }
    .period-info h4 { font-size: 14px; font-weight: 800; margin-bottom: 4px; }
    .period-info p { font-size: 12px; color: var(--muted); }
    .progress-bar { height: 7px; background: #e9efe9; border-radius: 999px; overflow: hidden; }
    .progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #59ad79); transition: .3s; border-radius: inherit; }

    .modal-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15,25,20,.46);
        display: none;
        align-items: center;
        justify-content: center;
        z-index: 100;
        padding: 18px;
        backdrop-filter: blur(8px);
    }
    .modal-overlay.active { display: flex; }
    .modal {
        background: var(--surface);
        border-radius: var(--radius);
        width: min(760px, 100%);
        max-width: calc(100vw - 28px);
        max-height: 90vh;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 24px;
        border: 1px solid rgba(255,255,255,.7);
        box-shadow: 0 28px 80px rgba(20,35,28,.24);
    }
    .modal-sm { width: min(520px, 100%); }
    .modal-md { width: min(700px, 100%); }
    .modal-lg { width: min(880px, 100%); }
    .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 14px; }
    .modal-title { font-size: 18px; font-weight: 850; color: var(--text); }
    .close-btn { background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius); width: 34px; height: 34px; cursor: pointer; color: var(--muted); line-height: 1; }
    .close-btn:hover { color: var(--text); background: #fff; }
    .form-group { margin-bottom: 15px; }
    .form-group label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 800; }
    .form-group input, .form-group select, .form-group textarea, .filter-bar input, .filter-bar select, .year-select {
        width: 100%;
        padding: 8px 10px;
        border: 1px solid #d3ded7;
        border-radius: var(--radius);
        font-size: 14px;
        outline: none;
        transition: .18s ease;
        background: #fff;
        color: var(--text);
    }
    .form-group input:focus, .form-group select:focus, .form-group textarea:focus, .filter-bar input:focus, .filter-bar select:focus, .year-select:focus { border-color: var(--accent-2); }
    .form-group textarea { min-height: 150px; resize: vertical; line-height: 1.7; }
    .form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
    .form-section-title {
        margin: 18px 0 10px;
        color: var(--text);
        font-size: 13px;
        font-weight: 900;
    }
    .mini-link {
        margin-top: 7px;
        border: none;
        background: transparent;
        color: var(--accent-2);
        font-size: 12px;
        font-weight: 800;
        cursor: pointer;
        padding: 0;
    }
    .mini-link:hover { color: var(--accent); }
    .save-status { font-size: 12px; color: var(--faint); text-align: right; margin-top: 8px; }
    .record-preview-shell { display: grid; gap: 16px; }
    .record-preview-top {
        padding: 18px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: linear-gradient(135deg, #f6fbf8 0%, #eef6f1 100%);
    }
    .record-preview-title { font-size: 24px; font-weight: 900; color: var(--text); margin: 12px 0 10px; line-height: 1.35; }
    .record-preview-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        color: var(--muted);
        font-size: 12px;
    }
    .record-preview-meta span {
        padding: 6px 10px;
        border-radius: 999px;
        background: rgba(255,255,255,.72);
        border: 1px solid #dbe7df;
    }
    .record-preview-content,
    .record-preview-todos {
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: #fff;
        padding: 18px;
        box-shadow: 0 12px 28px rgba(34, 56, 43, .05);
    }
    .record-preview-heading { font-size: 13px; font-weight: 900; color: var(--accent); margin-bottom: 12px; letter-spacing: .03em; }
    .record-preview-section { padding: 14px 0; border-top: 1px solid #edf2ee; }
    .record-preview-section:first-child { padding-top: 0; border-top: none; }
    .record-preview-section h4 { font-size: 14px; font-weight: 850; color: var(--text); margin-bottom: 8px; }
    .record-preview-text { font-size: 14px; color: #425247; line-height: 1.9; white-space: normal; word-break: break-word; }
    .record-preview-placeholder,
    .record-preview-empty { color: var(--faint); }
    .record-preview-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
    .record-preview-todo-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 0;
        border-top: 1px dashed #edf2ee;
        color: var(--text);
        font-size: 14px;
    }
    .record-preview-todo-item:first-of-type { border-top: none; padding-top: 0; }
    .record-preview-todo-item.done { color: var(--faint); text-decoration: line-through; }
    .record-preview-dot {
        width: 10px;
        height: 10px;
        border-radius: 999px;
        background: #d1ddd4;
        flex: 0 0 auto;
    }
    .record-preview-todo-item.done .record-preview-dot { background: var(--accent); }

    .snapshot-help {
        padding: 12px 13px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: #f6faf7;
        color: var(--muted);
        font-size: 13px;
        line-height: 1.6;
        margin-bottom: 14px;
    }
    .snapshot-list {
        display: grid;
        gap: 10px;
        max-height: 48vh;
        overflow: auto;
        padding-right: 2px;
    }
    .snapshot-item {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px;
        align-items: center;
        padding: 12px 13px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: #fff;
    }
    .snapshot-main { min-width: 0; }
    .snapshot-title {
        font-weight: 850;
        color: var(--text);
        margin-bottom: 4px;
        overflow-wrap: anywhere;
    }
    .snapshot-meta {
        color: var(--faint);
        font-size: 12px;
        line-height: 1.5;
    }
    .snapshot-actions {
        display: flex;
        gap: 7px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .snapshot-empty {
        padding: 18px;
        text-align: center;
        color: var(--faint);
        border: 1px dashed var(--line);
        border-radius: 14px;
        background: var(--surface-soft);
    }

    .type-section { margin-bottom: 20px; }
    .type-section h4 { font-size: 12px; color: var(--muted); margin-bottom: 10px; font-weight: 850; letter-spacing: .04em; }
    .type-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
    .type-card {
        padding: 15px 10px;
        background: var(--surface-soft);
        border-radius: var(--radius);
        text-align: center;
        cursor: pointer;
        transition: .18s ease;
        border: 1px solid var(--line);
    }
    .type-card:hover { background: #fff; border-color: #bfd1c5; transform: translateY(-1px); box-shadow: 0 10px 24px rgba(35,60,45,.08); }
    .type-card .icon { font-size: 22px; margin-bottom: 5px; }
    .type-card .name { font-size: 13px; color: var(--text); font-weight: 800; }

    .todo-list { list-style: none; }
    .todo-item { display: flex; align-items: center; gap: 9px; padding: 7px 0; font-size: 14px; min-width: 0; }
    .todo-item input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--accent); flex: 0 0 auto; }
    .todo-item.done .todo-text { text-decoration: line-through; color: var(--faint); }
    .todo-text { flex: 1; cursor: pointer; min-width: 0; overflow-wrap: anywhere; }
    .todo-text small { display: block; margin-top: 3px; color: var(--faint); font-size: 12px; font-weight: 650; }
    .todo-meta { font-size: 12px; color: var(--faint); white-space: nowrap; }
    .section-title-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 8px;
        min-width: 0;
    }
    .today-grid > div { min-width: 0; }
    .section-title-row .section-title { margin-bottom: 0; min-width: 0; white-space: nowrap; }
    .todo-pool-toolbar { display: flex; flex-wrap: nowrap; gap: 4px; margin-bottom: 0; flex: 0 1 auto; min-width: 0; }
    .todo-pool-toolbar .btn {
        min-height: 24px;
        padding: 2px 7px;
        border-radius: 999px;
        font-size: 11px;
        line-height: 1.35;
        flex: 0 1 auto;
    }
    .todo-pool-toolbar .btn.active {
        background: #e2efe6;
        border-color: #b7d0be;
        color: var(--accent);
        box-shadow: inset 0 0 0 1px rgba(70, 120, 86, .08);
    }
    .todo-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; flex: 0 0 auto; flex-wrap: wrap; }
    .todo-mini-btn {
        min-height: 24px;
        padding: 2px 8px;
        border-radius: 999px;
        font-size: 11px;
        line-height: 1.35;
        white-space: nowrap;
    }
    .todo-pool-hint { margin-top: 8px; color: var(--faint); font-size: 12px; }
    .todo-add { display: flex; gap: 8px; margin-top: 10px; }
    .todo-add input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid #d3ded7; border-radius: var(--radius); font-size: 13px; outline: none; }
    .todo-add input:focus { border-color: var(--accent-2); }
    .sub-todos { margin-left: 25px; margin-top: 4px; border-left: 2px solid var(--line); padding-left: 10px; }
    .todo-expand { cursor: pointer; color: var(--faint); font-size: 12px; user-select: none; margin-right: 4px; }

    .filter-bar {
        display: flex;
        gap: 10px;
        margin-bottom: 18px;
        align-items: center;
        flex-wrap: wrap;
        background: rgba(255,255,255,.76);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        padding: 12px;
    }
    .filter-bar input, .filter-bar select { width: auto; min-width: 132px; }
    .todo-table {
        width: 100%;
        background: var(--surface);
        border-radius: var(--radius);
        overflow: hidden;
        box-shadow: var(--shadow);
        border: 1px solid var(--line);
        border-collapse: separate;
        border-spacing: 0;
    }
    .todo-table th, .todo-table td { padding: 12px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
    .todo-table th { background: var(--surface-soft); font-weight: 850; color: var(--muted); font-size: 12px; }
    .todo-table tr:last-child td { border-bottom: none; }
    .todo-table tbody tr:hover td { background: #fbfdfb; }
    .todo-title-cell { cursor: pointer; font-weight: 750; color: var(--text); overflow-wrap: anywhere; }
    .todo-title-cell.is-done { text-decoration: line-through; color: var(--faint); font-weight: 650; }
    .todo-title-meta {
        margin-top: 5px;
        color: var(--faint);
        font-size: 12px;
        font-weight: 650;
        text-decoration: none;
    }
    .todo-session-editor {
        display: grid;
        grid-template-columns: minmax(130px, 1.1fr) minmax(92px, .8fr) minmax(92px, .8fr);
        gap: 8px;
        margin-bottom: 10px;
        min-width: 0;
    }
    .todo-session-editor input {
        min-width: 0;
        padding: 8px 10px;
        border: 1px solid #d3ded7;
        border-radius: var(--radius);
        outline: none;
    }
    .todo-session-editor #todo-session-note { grid-column: 1 / -1; }
    .todo-session-editor .btn {
        grid-column: 1 / -1;
        justify-self: end;
        min-height: 30px;
        padding: 5px 12px;
        border-radius: 999px;
        font-size: 12px;
    }
    .todo-session-list {
        display: grid;
        gap: 8px;
        margin-bottom: 14px;
    }
    .todo-session-empty {
        padding: 10px 12px;
        border: 1px dashed #d9e3dc;
        border-radius: 14px;
        color: var(--faint);
        font-size: 12px;
        background: #f8fbf8;
    }
    .todo-session-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        padding: 11px 12px;
        border: 1px solid #dce8df;
        border-radius: 16px;
        background:
            linear-gradient(135deg, rgba(255,255,255,.95), rgba(244,250,246,.92));
        box-shadow: 0 8px 18px rgba(45, 73, 54, .06);
        min-width: 0;
    }
    .todo-session-main { display: grid; gap: 3px; min-width: 0; }
    .todo-session-main strong { font-size: 13px; color: var(--text); }
    .todo-session-main span { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
    .todo-session-item .btn {
        min-height: 25px;
        padding: 3px 9px;
        border-radius: 999px;
        font-size: 11px;
        flex: 0 0 auto;
    }
    .todo-due,
    .todo-urgency {
        display: inline-flex;
        align-items: center;
        min-height: 24px;
        padding: 2px 9px;
        border-radius: 999px;
        font-size: 12px;
        font-weight: 850;
        white-space: nowrap;
        flex: 0 0 auto;
    }
    .todo-due { background: #eef5f0; color: #446052; }
    .todo-due-none { background: #f1f3ef; color: #788176; }
    .todo-urgency-urgent { background: #ffe9df; color: #b13c13; }
    .todo-urgency-high { background: #fff3d2; color: #956000; }
    .todo-urgency-medium { background: #eaf4ff; color: #2564a8; }
    .todo-urgency-low { background: #eef5f0; color: #547060; }
    .tag { display: inline-flex; align-items: center; min-height: 22px; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #edf1ee; color: var(--muted); font-weight: 800; }
    .tag-健身 { background: #e8f4ff; color: #1e68bc; }
    .tag-学习 { background: #f1ecff; color: #6d4bc2; }
    .tag-工作 { background: #fff5e5; color: #9a5b03; }
    .tag-生活 { background: #eaf6ee; color: #216e4e; }

    .habit-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
    .habit-tab { padding: 8px 13px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font-size: 14px; transition: .18s ease; line-height: 1.4; font-weight: 800; }
    .habit-tab:hover { background: #fff; }
    .habit-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
    .habit-tab.tag-全天.active { background: #718096; border-color: #718096; }
    .habit-tab.tag-晨间.active { background: #d97706; border-color: #d97706; }
    .habit-tab.tag-午间.active { background: #ca8a04; border-color: #ca8a04; }
    .habit-tab.tag-晚间.active, .habit-tab.tag-学习.active { background: #7a5ac8; border-color: #7a5ac8; }
    .habit-tab.tag-运动.active { background: #2f80ed; border-color: #2f80ed; }
    .habit-tab.tag-工作.active { background: #b97706; border-color: #b97706; }
    .habit-tab.tag-生活.active { background: #216e4e; border-color: #216e4e; }
    .heatmap-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
    .year-select { min-width: 110px; max-width: 150px; }
    .heatmap-container { overflow-x: auto; padding: 4px 0 10px; }
    .heatmap { display: grid; grid-template-rows: repeat(7, 1fr); gap: 4px; grid-auto-flow: column; }
    .heatmap-cell { width: 19px; height: 19px; border-radius: 5px; background: #e3e9e5; cursor: pointer; transition: .15s; position: relative; }
    .heatmap-cell:hover { outline: 2px solid #8aa494; transform: scale(1.12); z-index: 2; }
    .heatmap-cell.level-1 { background: #bfe5ca; }
    .heatmap-cell.level-2 { background: #79c98f; }
    .heatmap-cell.level-3 { background: #36a766; }
    .heatmap-cell.level-4 { background: #16633d; }
    .heatmap-cell.future { cursor: not-allowed; opacity: .38; }
    .heatmap-cell::after {
        content: attr(data-date) ' · 打卡 ' attr(data-count) ' 次';
        position: absolute;
        top: -32px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(15,25,20,.9);
        color: #fff;
        font-size: 12px;
        padding: 4px 8px;
        border-radius: 6px;
        display: none;
        white-space: nowrap;
        z-index: 10;
        pointer-events: none;
    }
    .heatmap-cell:hover::after { display: block; }
    .heatmap-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 8px; padding: 0 4px; font-weight: 800; min-width: 1040px; }
    .weekday-labels { position: absolute; left: -30px; top: 0; display: flex; flex-direction: column; justify-content: space-around; height: 100%; font-size: 12px; color: var(--muted); font-weight: 800; }
    .heatmap-wrapper { position: relative; padding-left: 35px; width: max-content; }
    .stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 20px; }
    .stat-card { background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 10px; text-align: center; }
    .stat-value { font-size: 24px; font-weight: 850; color: var(--accent); margin-bottom: 5px; }
    .stat-label { font-size: 12px; color: var(--muted); font-weight: 750; }

    .goal-card {
        background: var(--surface);
        border-radius: var(--radius);
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: var(--shadow);
        border: 1px solid var(--line);
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 16px;
        align-items: center;
    }
    .goal-info h4 { font-size: 15px; margin-bottom: 5px; font-weight: 850; }
    .goal-info p { font-size: 12px; color: var(--muted); }
    .goal-card .progress-bar { width: 220px; margin-top: 8px; }
    .template-select { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
    .template-select select { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid #d3ded7; border-radius: var(--radius); font-size: 13px; outline: none; }
    .template-editor {
        display: none;
        margin: 12px 0 16px;
        border: 1px solid #cfe0d5;
        border-radius: var(--radius);
        background: linear-gradient(135deg, #f7fbf7 0%, #eef7f1 100%);
        padding: 12px;
    }
    .template-editor.active { display: block; }
    .template-editor-head {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        align-items: flex-start;
        margin-bottom: 10px;
    }
    .template-editor-title {
        font-size: 13px;
        font-weight: 850;
        color: var(--accent);
    }
    .template-editor-meta { margin-top: 3px; font-size: 12px; color: var(--muted); line-height: 1.6; }
    .template-editor-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
    .template-editor-actions button {
        border: 1px solid #c9d9cf;
        background: rgba(255,255,255,.75);
        color: var(--accent);
        border-radius: 999px;
        padding: 5px 10px;
        font-size: 12px;
        font-weight: 750;
        cursor: pointer;
    }
    .template-editor-actions button:hover { background: #fff; box-shadow: 0 5px 14px rgba(64, 103, 78, .12); }
    .template-field {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        margin-bottom: 8px;
        overflow: hidden;
        box-shadow: 0 8px 18px rgba(62, 89, 69, .05);
    }
    .template-field summary {
        cursor: pointer;
        padding: 10px 12px;
        font-weight: 850;
        color: var(--text);
        list-style: none;
    }
    .template-field summary::-webkit-details-marker { display: none; }
    .template-field summary::after {
        content: "展开";
        float: right;
        color: var(--faint);
        font-size: 12px;
        font-weight: 750;
    }
    .template-field[open] summary::after { content: "收起"; }
    .template-field textarea {
        width: calc(100% - 24px);
        margin: 0 12px 12px;
        min-height: 72px;
        border: 1px solid #d3ded7;
        border-radius: var(--radius);
        padding: 9px 10px;
        resize: vertical;
        outline: none;
        line-height: 1.65;
    }
    .form-group textarea.is-preview {
        background: #f7faf8;
        color: #51665a;
        border-style: dashed;
    }
    .form-group textarea.is-preview:focus {
        border-color: #d3ded7;
        box-shadow: none;
    }
    .content-sync-note {
        display: none;
        margin: -2px 0 8px;
        padding: 9px 11px;
        border-radius: var(--radius);
        background: #f4faf5;
        border: 1px solid #d5e5d9;
        color: #51715a;
        font-size: 12px;
        line-height: 1.6;
    }
    .content-sync-note.active { display: block; }
    .empty-state { text-align: center; padding: 36px 16px; color: var(--faint); font-size: 13px; border: 1px dashed #cbd8d0; border-radius: var(--radius); background: rgba(255,255,255,.52); }

    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-track { background: #edf3ef; border-radius: 999px; }
    ::-webkit-scrollbar-thumb { background: #9dad9f; border-radius: 999px; border: 2px solid #edf3ef; }
    ::-webkit-scrollbar-thumb:hover { background: #9dad9f; }

    @media (max-width: 980px) {
        body { display: block; height: auto; overflow: auto; overflow-x: hidden; }
        .sidebar { width: 100%; display: block; position: sticky; top: 0; z-index: 20; padding: 12px; border-right: none; border-bottom: 1px solid var(--line); overflow-x: hidden; }
        .sidebar h2 { margin-bottom: 10px; padding-bottom: 10px; }
        .nav-item { display: inline-flex; width: auto; margin-right: 6px; padding: 9px 11px; }
        .sidebar-bottom { margin-top: 10px; padding-top: 10px; }
        .main { width: 100%; height: auto; overflow: visible; padding: 18px 14px 38px; }
        .page, .card, .hero-panel { max-width: 100%; }
        .dashboard-hero, .today-grid { grid-template-columns: 1fr; }
        .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
        .todo-table { min-width: 860px; }
        #page-todos { overflow-x: auto; }
    }

    @media (max-width: 640px) {
        .page-header, .heatmap-header, .goal-card, .period-item { grid-template-columns: 1fr; display: grid; align-items: stretch; }
        .page-actions { justify-content: stretch; }
        .page-actions .btn, .page-header .btn { width: 100%; }
        .summary-grid, .stats-grid, .type-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .form-row { grid-template-columns: 1fr; }
        .quick-create { grid-template-columns: 1fr; }
        .filter-bar input, .filter-bar select { width: 100%; }
        .todo-item { align-items: flex-start; flex-wrap: wrap; }
        .todo-text { flex-basis: calc(100% - 34px); }
        .todo-actions { width: 100%; padding-left: 26px; justify-content: flex-start; }
        .section-title-row { align-items: center; }
        .todo-pool-toolbar { gap: 3px; }
        .todo-pool-toolbar .btn { padding-inline: 5px; font-size: 10px; }
        .todo-session-editor { grid-template-columns: 1fr; }
        .todo-session-item { align-items: stretch; flex-direction: column; }
        .todo-session-item .btn { align-self: flex-start; }
        .modal { padding: 18px; }
        .sidebar-bottom > div { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .card-title { display: block; }
        .record-row { grid-template-columns: 48px minmax(0, 1fr); gap: 8px; }
        .calendar-grid { grid-template-columns: repeat(7, minmax(96px, 1fr)); overflow-x: auto; }
    }
