        :root {
            --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            --mono: 'DM Mono', monospace;

            --ink: #1a1a1a;
            --ink-mid: #888;
            --ink-lt: #bbb;
        }

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

        body {
            font-family: var(--sans);
            background: #ffffff;
            color: var(--ink);
            overflow: hidden;
        }

        .container {
            display: flex;
            flex-direction: column;
            height: 100vh;
            max-width: 100vw;
            margin: 0;
            padding: 20px 32px;
            box-sizing: border-box;
            background: #ffffff;
        }

        .toggle-group {
            display: flex;
            border: 1px solid #e0e0e0;
            border-radius: 6px;
            overflow: hidden;
            background: #fff;
            margin-right: 8px;
        }

        .tgl-btn {
            padding: 6px 12px;
            background: transparent;
            border: none;
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            color: #888;
            transition: all 0.15s;
            white-space: nowrap;
        }

        .tgl-btn:hover {
            color: #1a1a1a;
            background: #f5f5f5;
        }

        .tgl-btn.active {
            background: #1a1a1a;
            color: #fff;
        }

        .tgl-btn+.tgl-btn {
            border-left: 1px solid #e0e0e0;
        }

        .time-group-header {
            grid-column: 1 / -1;
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px 0 4px 0;
            border-bottom: 1px solid #e0e0e0;
        }

        .time-group-label {
            font-size: 11px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: #888;
            white-space: nowrap;
            position: sticky;
            left: 0;
            background: #ffffff;
            padding-left: 20px;
            padding-right: 12px;
            z-index: 10;
        }

        /* ── LEFT PANEL ── */
        .left-panel {
            flex: 4;
            display: flex;
            flex-direction: column;
            min-width: 0;
            height: 100%;
        }

        .task-log-header {
            display: none;
        }

        .task-log {
            flex: 1;
            overflow-y: auto;
            background: #ffffff;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            padding: 16px;
            margin-bottom: 0;
        }

        .task-entry {
            padding: 10px 0 10px 12px;
            border-left: 2px solid #f0f0f0;
            font-size: 12px;
            line-height: 1.5;
            color: #1a1a1a;
            transition: all 0.15s;
        }

        .task-entry {
            padding: 10px 0 10px 12px;
            border-left: 2px solid #f5f5f5;
            font-size: 12px;
            line-height: 1.5;
            color: #1a1a1a;
            transition: all 0.15s;
        }

        .task-entry:hover {
            border-left-color: #1a1a1a;
            background: #fafafa;
        }

        .task-text {
            margin-bottom: 3px;
        }

        .task-timestamp {
            font-family: var(--mono);
            font-size: 10px;
            color: var(--ink-lt);
            font-weight: 400;
        }

        .task-input-section {
            margin-top: 16px;
            flex-shrink: 0;
        }

        .task-input {
            width: 100%;
            padding: 9px 11px;
            border: 1px solid #e0e0e0;
            border-radius: 6px;
            font-size: 12px;
            font-family: inherit;
            background: #fafafa;
            resize: vertical;
            min-height: 56px;
            margin-bottom: 8px;
            color: #1a1a1a;
        }

        .task-input:focus {
            outline: none;
            border-color: #888;
            background: #fff;
        }

        .add-task-btn {
            width: 100%;
            padding: 9px;
            background: #1a1a1a;
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.2s;
        }

        .add-task-btn:hover {
            background: #444;
        }

        /* RIGHT PANEL */
        .right-panel {
            flex: 1;
            min-width: 280px;
            background: transparent;
            display: flex;
            flex-direction: column;
            height: 100%;
        }

        .tracker-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            flex-shrink: 0;
        }

        .panels-wrapper {
            display: flex;
            flex: 1;
            min-height: 0;
            gap: 24px;
            align-items: stretch;
        }

        .tracker-title {
            font-size: 22px;
            font-weight: 600;
            letter-spacing: -0.4px;
        }

        .tracker-title {
            display: flex;
            align-items: center;
            gap: 12px;
            font-size: 22px;
            font-weight: 600;
            letter-spacing: -0.4px;
        }

        .title-icon {
            width: 32px;
            height: 32px;
            object-fit: contain;
        }

        .controls {
            display: flex;
            gap: 12px;
        }

        .control-btn {
            padding: 8px 16px;
            background: #f5f5f5;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
        }

        .control-btn:hover {
            background: #e8e8e8;
        }

        .control-btn.danger {
            color: #d32f2f;
        }

        .control-btn.danger:hover {
            background: #ffebee;
            border-color: #d32f2f;
        }

        .edit-toggle {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            font-size: 13px;
            font-weight: 500;
            color: #888;
            cursor: pointer;
            padding: 8px 16px;
            border: 1px solid #ddd;
            border-radius: 6px;
            background: #fff;
            transition: all 0.15s;
            user-select: none;
            white-space: nowrap;
        }

        .edit-toggle:hover {
            color: #1a1a1a;
            background: #f5f5f5;
        }

        .edit-toggle.on {
            background: #fff8e1;
            border-color: #f0c040;
            color: #b45000;
        }

        .edit-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: #e0e0e0;
            flex-shrink: 0;
            transition: background 0.2s;
        }

        .edit-toggle.on .edit-dot {
            background: #f0a020;
        }

        .cat-add-btn,
        .label-controls {
            display: none !important;
        }

        body.edit-mode .cat-add-btn {
            display: inline-block !important;
        }

        body.edit-mode .label-controls {
            display: flex !important;
        }

        .mobile-only {
            display: none;
        }

        .grid-wrapper {
            background: #ffffff;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            padding: 16px 0;
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
        }

        .grid-container {
            display: grid;
            column-gap: 2px;
            row-gap: 0;
            overflow-x: auto;
            padding: 0 20px 12px 0;
        }

        .month-band,
        .week-band {
            grid-row-start: auto;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 4px 0;
            min-width: 0;
        }

        .month-band {
            grid-row: 1;
            margin-top: 8px;
        }

        .week-band {
            grid-row: 2;
        }

        .month-band-line,
        .week-band-line {
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 1px;
            background: #e8e6e0;
            z-index: 0;
        }

        .month-band-label,
        .week-band-label {
            position: relative;
            z-index: 1;
            background: #ffffff;
            padding: 0 10px;
            font-size: 11px;
            font-weight: 600;
            color: #888;
            white-space: nowrap;
        }

        .week-band-label {
            font-family: var(--mono);
            font-size: 9px;
            color: #bbb;
        }

        .day-date {
            grid-row: 3;
            text-align: center;
            font-family: var(--mono);
            font-size: 9px;
            font-weight: 500;
            color: #888;
            cursor: pointer;
            transition: all 0.1s ease;
            padding: 2px 0;
        }

        .day-date:hover {
            color: #1a1a1a;
            font-weight: 700;
            transform: scale(1.2);
        }

        .day-letter {
            grid-row: 4;
            text-align: center;
            font-family: var(--mono);
            font-size: 9px;
            font-weight: 300;
            color: #d4d0c8;
            padding-bottom: 0px;
        }

        .category-header {
            grid-column: 1 / -1;
            font-weight: 700;
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            padding: 3px 0 3px 0;
            margin-top: 0;
            border-bottom: 1px solid #e0e0e0;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .category-header span {
            position: sticky;
            left: 0;
            background: #ffffff;
            padding-left: 20px;
            padding-right: 12px;
            z-index: 10;
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }

        .week-header {
            grid-row: 1;
            text-align: center;
            font-family: var(--sans);
            font-weight: 600;
            padding: 8px 0;
            font-size: 13px;
            color: var(--ink-mid);
        }

        .day-number {
            grid-row: 2;
            text-align: center;
            font-family: var(--mono);
            font-size: 10px;
            color: var(--ink-lt);
            padding: 4px 0 8px 0;
        }

        .cat-add-btn {
            display: none;
            cursor: pointer;
            font-size: 12px;
            font-weight: 400;
            color: #bbb;
            background: none;
            border: none;
            padding: 0;
            line-height: 1;
            transition: color 0.15s;
            position: relative;
            z-index: 10;
        }

        .cat-add-btn:hover {
            color: #1a1a1a;
        }


        .habit-label {
            grid-column: 1;
            position: sticky;
            left: 0;
            background: #ffffff;
            z-index: 10;
            padding: 0px 6px 0px 20px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 12px;
            min-height: 16px;
            gap: 6px;
        }

        .label-controls {
            display: none;
            gap: 4px;
            flex-shrink: 0;
        }

        .l-btn {
            background: none;
            border: none;
            font-size: 10px;
            cursor: pointer;
            color: #999;
        }

        .l-btn:hover {
            color: #1a1a1a;
        }

        .l-btn.red:hover {
            color: #d32f2f;
        }

        .habit-cell {
            width: 14px;
            height: 14px;
            border: 1px solid #1a1a1a;
            border-radius: 3px;
            cursor: pointer;
            transition: all 0.15s ease;
            align-self: center;
            justify-self: center;
        }

        .habit-cell:hover {
            transform: scale(1.1);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
            z-index: 5;
        }

        .habit-cell.completed {
            background: #1a1a1a;
        }

        .habit-cell.completed.past-week {
            background: #8a9097;
            border-color: #8a9097;
        }

        .habit-cell.miss {
            background: repeating-linear-gradient(45deg,
                    #1a1a1a,
                    #1a1a1a 2px,
                    #ffffff 2px,
                    #ffffff 4px);
            border-color: #1a1a1a;
            opacity: 0.8;
        }

        .habit-cell.is-today {
            border: 2px solid #2196f3 !important;
            transform: scale(1.1);
        }

        .habit-cell.padding {
            background-color: #ebebeb;
            border: 1px solid #d6d6d6;
            pointer-events: none;
        }

        .habit-cell.fulfilled {
            background: #f0f0f0;
            border: 1px solid #ddd;
        }

        .habit-cell.off-routine {
            border: 1px dashed #999;
            opacity: 0.5;
        }

        .habit-cell[data-reason]:hover::after {
            content: attr(data-reason);
            position: absolute;
            bottom: 130%;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.85);
            color: #fff;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 11px;
            white-space: nowrap;
            z-index: 999;
            pointer-events: none;
        }

        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }

        ::-webkit-scrollbar-track {
            background: #f1f1f1;
        }

        ::-webkit-scrollbar-thumb {
            background: #c0c0c0;
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #a0a0a0;
        }

        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            align-items: center;
            justify-content: center;
        }

        .modal.active {
            display: flex;
        }

        .modal-content {
            background: white;
            padding: 32px;
            border-radius: 12px;
            max-width: 400px;
            text-align: center;
        }

        .modal-title {
            font-size: 20px;
            font-weight: 600;
            margin-bottom: 12px;
        }

        .modal-text {
            font-size: 14px;
            color: #666;
            margin-bottom: 24px;
            line-height: 1.5;
        }

        .modal-buttons {
            display: flex;
            gap: 12px;
            justify-content: center;
        }

        .modal-btn {
            padding: 10px 24px;
            border: none;
            border-radius: 6px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
        }

        .modal-btn.cancel {
            background: #f5f5f5;
            color: #1a1a1a;
        }

        .modal-btn.cancel:hover {
            background: #e8e8e8;
        }

        .modal-btn.confirm {
            background: #d32f2f;
            color: white;
        }

        .modal-btn.confirm:hover {
            background: #b71c1c;
        }

        .modal-btn.black {
            background: #1a1a1a;
            color: white;
        }

        .modal-btn.black:hover {
            background: #333;
        }

        .m-input {
            width: 100%;
            padding: 10px;
            margin-bottom: 12px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-family: inherit;
            font-size: 13px;
        }

        .m-label {
            display: block;
            text-align: left;
            font-size: 12px;
            color: #666;
            margin-bottom: 4px;
            font-weight: 600;
        }

        .habit-cell[data-reason] {
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .habit-cell[data-reason]::before {
            content: "T";
            font-family: var(--sans);
            font-size: 10px;
            font-weight: 700;
            line-height: 1;
        }

        .habit-cell.derivative-cell[data-reason]::before {
            font-size: 7px;
        }

        .habit-cell[data-reason]:not(.completed):not(.miss)::before {
            color: #1a1a1a;
        }

        .habit-cell.completed[data-reason]::before {
            color: #ffffff;
        }

        .habit-cell.miss[data-reason]::before {
            color: #d32f2f;
            text-shadow: 0px 0px 2px rgba(255, 255, 255, 0.9);
        }

        .action-buttons {
            display: flex;
            gap: 12px;
        }

        .mobile-menu-btn {
            display: none;
        }

        .mobile-view-toggle {
            display: none;
        }

        .grid-nav-btn.on {
            background: #fff8e1;
            border-color: #f0c040;
        }

        .day-context-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 16px;
            margin-bottom: 20px;
        }

        .dc-box {
            background: #fff;
            border: 1.5px solid #1a1a1a;
            border-radius: 12px;
            padding: 16px;
            text-align: left;
        }

        .dc-box-title {
            font-size: 16px;
            font-weight: 500;
            margin-bottom: 12px;
            color: #1a1a1a;
        }

        .dc-bh-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            font-size: 12px;
        }

        .day-context-btn {
            background-color: #ffebf8 !important;
            border: 1px solid #FD3DB5 !important;
            color: #c21482 !important;
            font-weight: 600;
        }

        .day-context-btn:hover {
            background-color: #fcdbf0 !important;
            border-color: #e62aa2 !important;
        }

        .week-band-label {
            position: relative;
            z-index: 1;
            background: #ffffff;
            padding: 0 10px;
            font-size: 11px;
            font-weight: 600;
            color: #888;
            white-space: nowrap;
            cursor: pointer;
            transition: all 0.1s ease;
        }

        .week-band-label:hover {
            color: #1a1a1a;
            transform: scale(1.1);
        }

        .off-routine-cross {
            color: #d32f2f;
            font-size: 12px;
            font-family: var(--sans);
            font-weight: 700;
            display: block;
            line-height: 8px;
            margin-top: 3px;
        }

        @media (max-width: 650px) {
            .day-context-grid {
                grid-template-columns: 1fr;
            }
        }

        @media (min-width: 769px) {
            #mobileEditBtn {
                display: none !important;
            }
        }

        @media (max-width: 768px) {
            body {
                overflow: auto !important;
                height: auto;
            }

            .container {
                height: auto;
                min-height: 100vh;
                overflow: visible;
                display: block;
                padding: 10px 0;
            }

            .desktop-only {
                display: none !important;
            }

            .mobile-only {
                display: block !important;
                padding: 12px 16px 20px 16px;
                width: 100%;
                box-sizing: border-box;
            }

            .mobile-only .week-band {
                grid-row: 1;
                margin-top: 0;
            }

            .mobile-only .day-date {
                grid-row: 2;
            }

            .mobile-only .day-letter {
                grid-row: 3;
                padding-bottom: 0px;
            }

            .mobile-only .time-header {
                margin-top: 0 !important;
                padding-top: 4px;
            }

            .left-panel {
                background: transparent;
                padding: 0 16px;
                border: none;
                width: 100%;
                display: flex !important;
                flex-direction: column;
                height: 100%;
                overflow-y: auto;
            }

            .right-panel {
                width: 100%;
                padding: 0 16px;
                display: none !important;
                flex-direction: column;
                height: 100%;
                flex-shrink: 0;
                overflow-y: auto;
            }

            .tracker-header {
                flex-direction: column;
                align-items: flex-start;
                gap: 16px;
                position: relative;
                padding: 0 16px;
                margin-bottom: 16px;
            }

            .tracker-title {
                font-size: 18px;
                max-width: calc(100% - 130px);
                line-height: 1.2;
            }

            .title-icon {
                width: 24px;
                height: 24px;
            }

            .controls {
                width: 100%;
                flex-wrap: wrap;
                gap: 8px;
                padding: 0 16px;
                box-sizing: border-box;
            }

            .mobile-view-toggle {
                display: flex;
                align-items: center;
                justify-content: center;
                padding: 0 12px;
                height: 40px;
                font-weight: 600;
                font-size: 13px;
                border: 1px solid #1a1a1a;
                border-radius: 6px;
                background: #1a1a1a;
                color: #fff;
                position: absolute;
                top: -4px;
                right: 64px;
                z-index: 10;
            }

            .mobile-menu-btn {
                display: flex;
                align-items: center;
                justify-content: center;
                padding: 0;
                width: 40px;
                height: 40px;
                font-weight: 700;
                font-size: 22px;
                border: 1px solid #ddd;
                border-radius: 6px;
                background: #fff;
                position: absolute;
                top: -4px;
                right: 16px;
            }

            .action-buttons {
                display: none;
                position: absolute;
                top: 44px;
                right: 16px;
                background: white;
                border: 1px solid #e0e0e0;
                border-radius: 8px;
                padding: 8px;
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
                flex-direction: column;
                gap: 4px;
                z-index: 1000;
                min-width: 140px;
            }

            .action-buttons.show {
                display: flex;
            }

            .action-buttons .edit-toggle {
                border: none;
                padding: 10px 8px;
                width: 100%;
                background: transparent;
                justify-content: flex-start;
            }

            .action-buttons .edit-toggle.on {
                background: #fff8e1;
                border-radius: 4px;
            }

            .action-buttons .control-btn {
                width: 100%;
                text-align: left;
                justify-content: flex-start;
                border: none;
                background: transparent;
            }

            .action-buttons .control-btn:hover {
                background: #f5f5f5;
            }

            .unlock-btn {
                position: absolute;
                top: 0;
                right: 16px;
                width: auto !important;
                flex: none !important;
                padding: 8px 12px !important;
                font-size: 12px !important;
            }

            .control-btn,
            .edit-toggle {
                flex: 1 1 auto;
                text-align: center;
                justify-content: center;
                padding: 12px 10px;
                font-size: 13px;
            }

            .toggle-group {
                width: 100%;
                margin-right: 0;
            }

            .tgl-btn {
                flex: 1;
                padding: 10px;
            }

            .grid-wrapper {
                padding: 12px 8px 12px 8px;
                margin-top: 12px;
                max-width: 100vw;
                width: 100%;
                box-sizing: border-box;
                flex: none;
                overflow-y: visible;
            }

            .grid-container {
                overflow-x: auto;
                padding-bottom: 12px;
                -webkit-overflow-scrolling: touch;
            }

            .habit-label {
                font-size: 12px;
                padding-right: 12px;
            }

            .habit-cell {
                width: 15px;
                height: 15px;
            }

            body.show-log-view .right-panel {
                display: flex !important;
            }

            body.show-log-view .left-panel {
                display: none !important;
            }

            body.show-log-view .grid-wrapper,
            body.show-log-view #calendarView,
            body.show-log-view .controls {
                display: none !important;
            }

            body.edit-mode .mobile-only .habit-cell,
            body.edit-mode .mobile-only .week-band,
            body.edit-mode .mobile-only .day-date,
            body.edit-mode .mobile-only .day-letter {
                display: none !important;
            }

            body.edit-mode .mobile-only .grid-container {
                grid-template-columns: 1fr !important;
                row-gap: 0;
            }

            body.edit-mode .mobile-only .habit-label {
                padding: 6px 0;
                border-bottom: 1px solid #f0f0f0;
                min-height: auto;
            }

            body.edit-mode .mobile-only .l-btn {
                font-size: 10px;
                padding: 2px 6px;
                background: transparent;
                border: none;
                margin-left: 0;
                color: #bbb;
            }

            body.edit-mode .mobile-only .l-btn.red {
                color: #e57373;
                background: transparent;
                border: none;
            }

            .modal-content {
                padding: 20px 16px !important;
                margin: 0 auto !important;
                width: 92% !important;
                max-height: 85vh !important;
                overflow-y: auto !important;
                box-sizing: border-box;
            }

            .day-context-grid {
                gap: 12px !important;
                margin-bottom: 16px !important;
            }

            .dc-box {
                padding: 14px !important;
            }

            .dc-box-title {
                font-size: 15px !important;
                margin-bottom: 8px !important;
            }

            .dc-box textarea {
                min-height: 70px !important;
            }

            .modal-buttons {
                flex-direction: column !important;
                gap: 8px !important;
                margin-top: 10px !important;
            }

            .modal-buttons .modal-btn {
                flex: none !important;
                width: 100% !important;
                margin: 0 !important;
            }

            .modal-btn {
                width: 100%;
                padding: 12px;
            }

            .panels-wrapper {
                display: block;
                height: auto;
            }

            .cal-container {
                padding: 10px 5px !important;
            }

            .cal-day-number {
                font-size: 26px !important;
                top: 2px !important;
                left: 2px !important;
                transform: none !important;
            }

            .cal-day-cell {
                min-height: 50px !important;
                padding: 2px !important;
                display: block !important;
            }

            .cal-day-preview {
                display: none;
            }

            .cal-day-header {
                display: block;
            }

            .cal-dot {
                width: 6px;
                height: 6px;
            }

            .cal-legend {
                gap: 8px;
                justify-content: center;
            }

            .cal-day-cell.is-today {
                border-width: 1.5px !important;
            }
        }

        /* --- CALENDAR STYLES --- */
        .cal-container {
            max-width: 1100px;
            margin: 0 auto;
            padding: 20px 0;
            box-sizing: border-box;
        }

        .cal-header {
            display: flex;
            align-items: baseline;
            gap: 10px;
            margin-bottom: 6px;
        }

        .cal-nav-btn {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 14px;
            color: #999;
            padding: 0 2px;
        }

        .cal-nav-btn:hover {
            color: #333;
        }

        .cal-month-title {
            font-size: 18px;
            font-weight: 500;
            color: #111;
            letter-spacing: -0.3px;
        }

        .cal-year-title {
            font-size: 14px;
            color: #999;
        }

        .cal-today-btn {
            font-size: 11px;
            margin-left: 6px;
            cursor: pointer;
            border: 1px solid #ddd;
            background: #fafafa;
            border-radius: 4px;
            padding: 2px 6px;
        }

        .cal-logged-count {
            margin-left: auto;
            font-size: 11px;
            color: #bbb;
        }

        .cal-legend {
            display: flex;
            gap: 14px;
            margin-bottom: 8px;
            flex-wrap: wrap;
        }

        .cal-legend-item {
            display: flex;
            align-items: center;
            gap: 5px;
            font-size: 11px;
            color: #999;
        }

        .cal-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            flex-shrink: 0;
        }

        .cal-stats-bar {
            display: flex;
            height: 8px;
            border-radius: 4px;
            overflow: hidden;
            margin: 16px 0;
            background: #eeeeee;
            box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
        }

        .cal-stats-segment {
            height: 100%;
            transition: width 0.3s ease;
        }

        .cal-dow-grid {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 3px;
            margin-bottom: 3px;
        }

        .cal-dow-item {
            font-size: 10px;
            color: #bbb;
            text-align: center;
            padding: 2px 0;
        }

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

        .cal-day-cell {
            min-height: 108px;
            background: #fafafa;
            border: 1px solid #ebebeb;
            border-radius: 3px;
            padding: 5px 6px;
            cursor: pointer;
            box-sizing: border-box;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            gap: 3px;
            transition: background 0.1s;
        }

        .cal-day-cell:hover {
            background: #f5f5f5;
        }

        .cal-day-cell.is-today {
            background: #fffcfc;
            border: 2px solid #d32f2f !important;
            position: relative;
            z-index: 2;
            box-shadow: inset 0 0 4px rgba(211, 47, 47, 0.1);
        }

        .cal-day-cell.is-today.colored-cell {
            border: 2px solid #d32f2f !important;
        }

        .cal-day-cell.is-future {
            opacity: 0.38;
        }

        .cal-day-cell {
            position: relative;
            min-height: 108px;
            background: #fafafa;
            border: 1px solid #ebebeb;
            border-radius: 3px;
            padding: 5px 6px;
            cursor: pointer;
            box-sizing: border-box;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            gap: 3px;
            transition: background 0.1s;
        }

        .cal-day-header {
            display: block;
        }

        .cal-day-number {
            position: absolute;
            top: 4px;
            left: 4px;
            font-size: 42px;
            font-weight: 700;
            letter-spacing: -2px;
            color: rgba(0, 0, 0, 0.05);
            z-index: 0;
            pointer-events: none;
            line-height: 0.8;
            margin: 0;
            transition: color 0.1s;
        }

        .cal-day-preview {
            font-size: 10.5px;
            color: #444;
            line-height: 1.45;
            word-break: break-word;
            overflow: hidden;
            position: relative;
            z-index: 1;
            padding-top: 2px;
        }

        .cal-modal-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.5);
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }

        .cal-modal-content {
            background: #fff;
            border-radius: 12px;
            padding: 20px 22px;
            width: 420px;
            max-width: 92vw;
            box-sizing: border-box;
            max-height: 90vh;
            overflow-y: auto;
            text-align: left;
        }

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

        .cal-modal-title {
            font-size: 16px;
            font-weight: 600;
            color: #222;
        }

        .cal-close-btn {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 20px;
            color: #aaa;
            padding: 0;
            line-height: 1;
        }

        .cal-segment {
            margin-bottom: 14px;
            padding-bottom: 14px;
            border-bottom: 1px solid #f0f0f0;
        }

        .cal-segment:last-child {
            border-bottom: none;
        }

        .cal-horizon-selector {
            display: flex;
            align-items: center;
            gap: 7px;
            margin-bottom: 8px;
        }

        .cal-h-btn {
            width: 22px;
            height: 22px;
            border-radius: 50%;
            cursor: pointer;
            flex-shrink: 0;
            background: #f0f0f0;
            border: 1.5px solid #ddd;
            padding: 0;
            transition: all 0.1s;
        }

        .cal-h-label {
            font-size: 11px;
            color: #999;
            margin-left: 3px;
        }

        .cal-textarea-wrapper {
            position: relative;
        }

        .cal-textarea {
            width: 100%;
            resize: vertical;
            font-family: inherit;
            font-size: 12px;
            color: #333;
            background: #fafafa;
            border: 1px solid #e8e8e8;
            border-radius: 6px;
            padding: 7px 8px;
            box-sizing: border-box;
            outline: none;
            line-height: 1.5;
            min-height: 60px;
        }

        .cal-char-count {
            position: absolute;
            bottom: 6px;
            right: 8px;
            font-size: 10px;
            color: #ccc;
        }

        .cal-modal-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 10px;
        }

        .cal-day-cell.colored-cell .cal-day-number {
            color: rgba(255, 255, 255, 0.18) !important;
            text-shadow: none;
        }

        .cal-day-cell.colored-cell .cal-day-number {
            color: #fff;
            font-weight: 600;
            text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        }

        .cal-day-cell.colored-cell .cal-day-preview {
            color: rgba(255, 255, 255, 0.95);
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
        }

        .cal-day-cell.colored-cell:hover {
            filter: brightness(0.9);
        }

        .grid-corner-nav {
            grid-column: 1;
            grid-row: 1 / span 4;
            align-self: stretch;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 6px;
            padding-left: 20px;
            padding-right: 16px;
            background: #ffffff;
            position: sticky;
            left: 0;
            z-index: 20;
            border-bottom: 1px solid transparent;
        }

        .grid-nav-btn {
            background: #fafafa;
            border: 1px solid #e0e0e0;
            border-radius: 6px;
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: #888;
            font-size: 14px;
            transition: all 0.2s;
        }

        .grid-nav-btn:hover {
            background: #f0f0f0;
            color: #1a1a1a;
            border-color: #ccc;
        }

        .habit-label {
            position: sticky;
            left: 0;
            background: #ffffff;
            z-index: 10;
        }

        .task-entry {
            position: relative;
            padding: 10px 0 10px 12px;
            border-left: 2px solid #f5f5f5;
            font-size: 12px;
            line-height: 1.5;
            color: #1a1a1a;
            transition: all 0.15s;
        }

        .log-delete-btn {
            display: none;
            position: absolute;
            top: 8px;
            right: 8px;
            background: none;
            border: none;
            color: #d32f2f;
            font-size: 16px;
            cursor: pointer;
            line-height: 1;
            padding: 4px;
        }

        .log-delete-btn:hover {
            color: #b71c1c;
        }

        .task-entry:hover .log-delete-btn {
            display: block;
        }

        /* --- Aggregate view --- */
        .heat-container {
            margin-bottom: 40px;
            font-family: var(--sans);
        }

        .heat-title {
            font-size: 13px;
            font-weight: 700;
            text-transform: uppercase;
            margin-bottom: 15px;
            color: #1a1a1a;
            letter-spacing: 0.5px;
        }

        .heat-wrapper {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            overflow-x: auto;
            padding-bottom: 10px;
        }

        .heat-months {
            display: flex;
            position: relative;
            height: 20px;
            font-size: 11px;
            color: #1a1a1a;
            font-weight: 500;
        }

        .heat-grid {
            display: grid;
            grid-template-rows: repeat(7, 13px);
            grid-auto-flow: column;
            gap: 3px;
        }

        .heat-cell {
            width: 13px;
            height: 13px;
            border-radius: 2px;
            position: relative;
            transition: transform 0.1s;
        }

        .heat-cell:not(.heat-out):hover {
            transform: scale(1.2);
            z-index: 10;
            border: 1px solid rgba(0, 0, 0, 0.2);
        }

        .heat-dow {
            display: grid;
            grid-template-rows: repeat(7, 13px);
            gap: 3px;
            font-size: 9px;
            color: #999;
            padding-top: 20px;
            line-height: 13px;
            font-weight: 500;
            text-align: right;
            padding-right: 5px;
        }

        .heat-month-label {
            position: absolute;
            bottom: 2px;
            padding-left: 4px;
            border-left: 1px solid #d0d0d0;
            height: 12px;
            line-height: 12px;
            color: #666;
        }

        .global-tooltip {
            position: fixed;
            background: rgba(26, 26, 26, 0.95);
            color: #fff;
            padding: 5px 8px;
            border-radius: 4px;
            font-size: 11px;
            white-space: nowrap;
            z-index: 99999;
            pointer-events: none;
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.15s ease;
            font-family: var(--sans);
            transform: translate(-50%, -100%);
            margin-top: -8px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
        }

        .global-tooltip.visible {
            opacity: 1;
            visibility: visible;
        }

        .heat-out {
            background: transparent;
            pointer-events: none;
        }

        .heat-0 {
            background: #ebedf0;
        }

        .heat-1 {
            background: #c6e48b;
        }

        .heat-2 {
            background: #7bc96f;
        }

        .heat-3 {
            background: #239a3b;
        }

        .heat-4 {
            background: #196127;
        }

        #newThreadDays,
        #editThreadDays {
            display: none;
            padding: 5px 0;
        }

        .day-toggle {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            cursor: pointer;
            user-select: none;
            flex: 1;
        }

        .day-toggle input {
            display: none;
        }

        .day-label {
            font-size: 10px;
            text-transform: uppercase;
            color: #bbb;
            font-weight: 400;
            transition: color 0.2s ease;
        }

        .day-box {
            width: 14px;
            height: 14px;
            border: 1px solid #ddd;
            border-radius: 3px;
            background: #fff;
            transition: all 0.2s ease;
        }

        .day-toggle:hover .day-label {
            color: #888;
        }

        .day-toggle:hover .day-box {
            border-color: #bbb;
        }

        .day-toggle input:checked+.day-box {
            background: #1a1a1a;
            border-color: #1a1a1a;
        }

        .day-toggle input:checked~.day-label {
            color: #1a1a1a;
        }

        .control-btn.black {
            background: #1a1a1a !important;
            color: #fff !important;
            border-color: #1a1a1a !important;
        }

        .habit-label.is-derivative {
            padding-left: 20px !important;
            font-size: 11px;
            color: #666;
            border-bottom: none;
            min-height: 14px;
            line-height: 1.1;
        }

        .habit-cell.derivative-cell {
            width: 12px !important;
            height: 12px !important;
            align-self: center;
            justify-self: center;
            border-radius: 2px;
            border-width: 1px !important;
            margin: 0 !important;
        }

        .branch-icon {
            color: #999;
            margin-right: 4px;
            font-family: 'DM Mono', monospace;
            font-weight: 300;
            display: inline-block;
            letter-spacing: -1px;
        }

        /* --- QUICK EDIT PANEL --- */
        .quick-edit-panel {
            display: none;
            align-items: center;
            gap: 12px;
            margin-right: 12px;
            padding-right: 12px;
            border-right: 1px solid #e0e0e0;
        }

        body.show-quick-edit .quick-edit-panel {
            display: flex;
        }

        .qe-parent {
            width: 100px;
            padding: 3px 4px;
            font-size: 10px;
            color: #666;
            border: 1px solid #ddd;
            border-radius: 4px;
            background: #fafafa;
        }

        .qe-parent:focus {
            outline: none;
            border-color: #1a1a1a;
        }

        .qe-cadence {
            display: flex;
            gap: 2px;
        }

        .qe-day-tgl {
            cursor: pointer;
        }

        .qe-day-tgl input {
            display: none;
        }

        .qe-day-box {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 16px;
            height: 16px;
            font-size: 9px;
            font-weight: 500;
            color: #bbb;
            border: 1px solid #ddd;
            border-radius: 3px;
            background: #fff;
            transition: all 0.15s;
            user-select: none;
        }

        .qe-day-tgl input:checked+.qe-day-box {
            background: #1a1a1a;
            color: #fff;
            border-color: #1a1a1a;
        }

        .habit-name {
            margin-right: auto;
            text-align: left;
        }

        .qe-parent:disabled,
        #editThreadParent:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            background-color: #f5f5f5;
            border-color: #e0e0e0;
        }

        .week-status-strip {
            display: flex;
            gap: 1px;
            height: 4px;
            background: #f0f0f0;
            border-radius: 2px;
            overflow: hidden;
        }

        .status-day-segment {
            flex: 1;
            height: 100%;
        }

        .grid-corner-nav {
            grid-row: 1 / span 6 !important;
        }
