        /* ── Reset & Base ─────────────────────────────── */
        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
        body.calendar-editor-page {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            background: #f0f2f5;
            color: #1a1a2e;
            overflow: hidden;
            height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* ── Top Bar ──────────────────────────────────── */
        .cal-topbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            height: 56px;
            min-height: 56px;
            background: #1a1a2e;
            color: #fff;
            padding: 0 20px;
            z-index: 100;
            box-shadow: 0 2px 8px rgba(0,0,0,.15);
        }
        .cal-topbar-left {
            display: flex;
            align-items: center;
            gap: 12px;
            min-width: 0;
        }
        .cal-logo { display: flex; align-items: center; text-decoration: none; }
        .cal-logo img { height: 32px; width: auto; }
        .cal-logo-text { font-weight: 700; font-size: 16px; color: #fff; text-decoration: none; }
        .cal-topbar-sep { width: 1px; height: 24px; background: rgba(255,255,255,.2); }
        .cal-title {
            font-size: 15px;
            font-weight: 500;
            color: rgba(255,255,255,.85);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .cal-topbar-center {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .cal-topbar-center label {
            font-size: 13px;
            color: rgba(255,255,255,.6);
            white-space: nowrap;
        }
        #template-selector {
            background: rgba(255,255,255,.1);
            color: #fff;
            border: 1px solid rgba(255,255,255,.2);
            border-radius: 6px;
            padding: 6px 28px 6px 12px;
            font-size: 14px;
            font-family: inherit;
            cursor: pointer;
            outline: none;
            appearance: none;
            -webkit-appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23fff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 10px center;
            min-width: 200px;
        }
        #template-selector:hover { border-color: rgba(255,255,255,.4); }
        #template-selector option { background: #1a1a2e; color: #fff; }
        .cal-topbar-actions {
            display: flex;
            align-items: center;
            gap: 6px;
            margin: 0 12px;
        }
        .cal-topbar-btn {
            background: rgba(255,255,255,.1);
            border: 1px solid rgba(255,255,255,.2);
            border-radius: 6px;
            color: #fff;
            padding: 6px 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background .15s, border-color .15s;
        }
        .cal-topbar-btn:hover { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.3); }
        .cal-topbar-btn:active { background: rgba(255,255,255,.25); }
        .cal-autosave-status {
            font-size: 12px;
            color: rgba(255,255,255,.5);
            white-space: nowrap;
            opacity: 0;
            transition: opacity .3s;
            margin-left: 4px;
        }
        .cal-autosave-status.visible { opacity: 1; }
        .cal-topbar-right {
            display: flex;
            align-items: center;
            gap: 16px;
        }
        .cal-price-display {
            display: flex;
            align-items: baseline;
            gap: 6px;
        }
        .cal-price-label { font-size: 12px; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .5px; }
        #cal-price { font-size: 20px; font-weight: 700; color: #fff; }
        .cal-btn-buy {
            background: #e63946;
            color: #fff;
            border: none;
            border-radius: 8px;
            padding: 10px 24px;
            font-size: 14px;
            font-weight: 600;
            font-family: inherit;
            cursor: pointer;
            text-transform: uppercase;
            letter-spacing: .5px;
            transition: background .2s, opacity .2s, transform .1s;
            white-space: nowrap;
        }
        .cal-btn-buy:hover:not(:disabled) { background: #c1121f; transform: translateY(-1px); }
        .cal-btn-buy:active:not(:disabled) { transform: translateY(0); }
        .cal-btn-buy:disabled { opacity: .4; cursor: not-allowed; }

        /* ── Month Strip ─────────────────────────────── */
        .cal-months-strip {
            height: 90px;
            min-height: 90px;
            background: #fff;
            border-bottom: 1px solid #e0e2e8;
            display: flex;
            align-items: center;
            padding: 0 12px;
            gap: 8px;
            box-shadow: 0 2px 6px rgba(0,0,0,.04);
            position: relative;
            z-index: 50;
        }
        .cal-strip-arrow {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            border: 1px solid #ddd;
            background: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            flex-shrink: 0;
            transition: background .2s, border-color .2s;
        }
        .cal-strip-arrow:hover { background: #f5f5f5; border-color: #bbb; }
        .cal-strip-arrow svg { width: 16px; height: 16px; stroke: #555; fill: none; stroke-width: 2; }
        .cal-strip-scroll {
            flex: 1;
            display: flex;
            gap: 6px;
            overflow-x: auto;
            scroll-behavior: smooth;
            scrollbar-width: none;
            -ms-overflow-style: none;
            padding: 6px 0;
        }
        .cal-strip-scroll::-webkit-scrollbar { display: none; }
        .cal-month-card {
            flex: 0 0 64px;
            height: 70px;
            border-radius: 8px;
            border: 2px solid transparent;
            background: #f5f6f8;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: border-color .2s, background .2s, box-shadow .2s;
            gap: 4px;
            position: relative;
        }
        .cal-month-card:hover { background: #eef0f4; }
        .cal-month-card.active {
            border-color: #e63946;
            background: #fff5f5;
            box-shadow: 0 2px 8px rgba(230,57,70,.15);
        }
        .cal-month-card.has-photo { background: #edf7ed; }
        .cal-month-card.has-photo.active { background: #fff5f5; }
        .cal-month-card-preview {
            width: 36px;
            height: 28px;
            border-radius: 4px;
            overflow: hidden;
            background: #e0e2e8;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: 600;
            color: #888;
        }
        .cal-month-card-preview img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .cal-month-card-preview .cal-plus-icon {
            font-size: 18px;
            color: #bbb;
            line-height: 1;
        }
        .cal-month-card-label {
            font-size: 10px;
            font-weight: 600;
            color: #555;
            text-transform: uppercase;
            letter-spacing: .3px;
        }
        .cal-month-card.active .cal-month-card-label { color: #e63946; }
        .cal-strip-progress {
            flex-shrink: 0;
            font-size: 12px;
            font-weight: 600;
            color: #888;
            white-space: nowrap;
            padding: 0 8px;
        }
        .cal-strip-progress span { color: #e63946; }

        /* ── Main Area (Canva-style: sidebar LEFT, canvas RIGHT) ── */
        .cal-main {
            flex: 1;
            display: flex;
            overflow: hidden;
        }

        /* ── Center: Calendar Preview ────────────────── */
        .cal-preview {
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            position: relative;
        }
        /* Contextual toolbar (Canva-style: appears above canvas) */
        .cal-context-toolbar {
            height: 48px;
            min-height: 48px;
            background: #fff;
            border-bottom: 1px solid #e0e2e8;
            display: flex;
            align-items: center;
            padding: 0 16px;
            gap: 8px;
            z-index: 10;
        }
        .cal-ctx-group {
            display: flex;
            align-items: center;
            gap: 4px;
        }
        .cal-ctx-sep { width: 1px; height: 24px; background: #e0e2e8; margin: 0 6px; }
        .cal-ctx-btn {
            height: 32px;
            padding: 0 10px;
            border: 1px solid #e0e2e8;
            border-radius: 6px;
            background: #fff;
            cursor: pointer;
            font-size: 12px;
            font-weight: 500;
            font-family: inherit;
            display: flex;
            align-items: center;
            gap: 4px;
            color: #333;
            transition: background .15s, border-color .15s;
        }
        .cal-ctx-btn:hover { background: #f5f5f5; border-color: #ccc; }
        .cal-ctx-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
        .cal-ctx-label { font-size: 12px; color: #666; white-space: nowrap; }
        .cal-ctx-input {
            width: 50px;
            height: 28px;
            border: 1px solid #e0e2e8;
            border-radius: 4px;
            text-align: center;
            font-size: 12px;
            font-family: inherit;
            padding: 0 4px;
        }
        .cal-ctx-select {
            height: 32px;
            border: 1px solid #e0e2e8;
            border-radius: 6px;
            font-size: 12px;
            font-family: inherit;
            padding: 0 8px;
            background: #fff;
            cursor: pointer;
            max-width: 140px;
        }
        .cal-ctx-color {
            width: 28px;
            height: 28px;
            border-radius: 6px;
            border: 2px solid #e0e2e8;
            cursor: pointer;
            padding: 0;
        }
        .cal-context-toolbar .cal-ctx-hint {
            flex: 1;
            text-align: right;
            font-size: 11px;
            color: #999;
        }
        /* Canvas area */
        .cal-canvas-area {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            padding: 24px;
            position: relative;
        }
        .cal-page-container {
            background: #fff;
            border-radius: 0 0 4px 4px;
            box-shadow: 0 4px 24px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.05);
            overflow: hidden;
            display: flex;
            flex-direction: column;
            width: auto;
            flex-shrink: 0;
            position: relative;
        }
        /* ── Spiral binding ─────────────────────────── */
        .cal-spiral {
            height: 18px;
            background: #e8e8e8;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 0 20px;
            border-radius: 4px 4px 0 0;
            box-shadow: 0 2px 8px rgba(0,0,0,.08);
            position: relative;
            z-index: 2;
        }
        .cal-spiral-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #fff;
            border: 1.5px solid #bbb;
            box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
        }
        .cal-spiral-hook {
            position: absolute;
            top: -10px;
            left: 50%;
            transform: translateX(-50%);
            width: 20px;
            height: 14px;
        }
        .cal-spiral-hook svg { width: 100%; height: 100%; }
        .cal-page-photo-area {
            width: 100%;
            position: relative;
            overflow: hidden;
            background: #f0f0f0;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 200px;
        }
        /* Let Fabric.js manage canvas dimensions — do NOT override with CSS width/height */
        .cal-page-photo-area .canvas-container {
            display: block !important;
        }


        /* ── Layers Panel ────────────────────────────── */
        .cal-layers-list {
            display: flex;
            flex-direction: column;
            gap: 3px;
            max-height: 400px;
            overflow-y: auto;
        }
        .cal-layer-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 8px;
            border-radius: 6px;
            background: #fff;
            border: 1.5px solid #e8eaed;
            cursor: pointer;
            transition: border-color .15s, background .15s, box-shadow .15s;
            user-select: none;
        }
        .cal-layer-item:hover { background: #f8f9fa; border-color: #d0d3d8; }
        .cal-layer-item.cal-layer-active {
            border-color: #e63946;
            background: #fff5f5;
            box-shadow: 0 0 0 1px rgba(230,57,70,.15);
        }
        .cal-layer-item.cal-layer-dragging { opacity: .4; }
        .cal-layer-item.cal-layer-drop-above { border-top: 2px solid #e63946; }
        .cal-layer-item.cal-layer-drop-below { border-bottom: 2px solid #e63946; }
        .cal-layer-drag {
            cursor: grab;
            color: #bbb;
            font-size: 14px;
            flex-shrink: 0;
            line-height: 1;
        }
        .cal-layer-drag:active { cursor: grabbing; }
        .cal-layer-thumb {
            width: 40px;
            height: 30px;
            border-radius: 3px;
            flex-shrink: 0;
            background: #f0f0f0;
            object-fit: cover;
            border: 1px solid #e0e0e0;
        }
        .cal-layer-icon {
            width: 40px;
            height: 30px;
            border-radius: 3px;
            flex-shrink: 0;
            background: #f0f0f0;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid #e0e0e0;
        }
        .cal-layer-icon svg { width: 18px; height: 18px; stroke: #888; fill: none; stroke-width: 1.5; }
        .cal-layer-name {
            flex: 1;
            font-size: 12px;
            font-weight: 500;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            color: #333;
        }
        .cal-layer-btn {
            width: 24px;
            height: 24px;
            border: none;
            background: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 4px;
            padding: 0;
            flex-shrink: 0;
            transition: background .15s;
        }
        .cal-layer-btn:hover { background: rgba(0,0,0,.06); }
        .cal-layer-btn svg { width: 16px; height: 16px; stroke: #888; fill: none; stroke-width: 2; }
        .cal-layer-btn.cal-layer-hidden svg { stroke: #ccc; }
        .cal-layer-btn.cal-layer-locked svg { stroke: #e63946; }
        .cal-layers-actions {
            display: flex;
            gap: 6px;
            margin-top: 10px;
            padding-top: 10px;
            border-top: 1px solid #eee;
        }
        .cal-layers-actions .cal-tool-btn { flex: 1; font-size: 11px; padding: 6px 8px; }
        .cal-tool-btn-danger { color: #e63946 !important; border-color: #f5c6cb !important; }
        .cal-tool-btn-danger:hover { background: #fff5f5 !important; }

        /* ── Sub-tabs (Canva-style Allinea/Livelli) ── */
        .cal-subtabs {
            display: flex;
            gap: 0;
            margin-bottom: 12px;
            border: 1px solid #e0e2e8;
            border-radius: 8px;
            overflow: hidden;
        }
        .cal-subtab {
            flex: 1;
            padding: 8px 0;
            border: none;
            background: #fff;
            font-size: 12px;
            font-weight: 600;
            font-family: inherit;
            cursor: pointer;
            color: #78909C;
            transition: background .15s, color .15s;
        }
        .cal-subtab:not(:last-child) { border-right: 1px solid #e0e2e8; }
        .cal-subtab:hover { background: #f5f5f5; color: #333; }
        .cal-subtab.active { background: #e63946; color: #fff; }
        .cal-subpanel { display: none; }
        .cal-subpanel.active { display: block; }

        /* ── Align grid ── */
        .cal-align-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 6px;
        }
        .cal-align-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            padding: 10px 4px;
            border: 1px solid #e8eaed;
            border-radius: 8px;
            background: #fff;
            cursor: pointer;
            transition: background .15s, border-color .15s, box-shadow .15s;
            font-size: 9px;
            font-weight: 500;
            font-family: inherit;
            color: #666;
        }
        .cal-align-btn:hover { background: #f0f7ff; border-color: #4A90D9; box-shadow: 0 1px 4px rgba(74,144,217,.15); }
        .cal-align-btn:active { background: #e0efff; }
        .cal-align-btn svg { width: 22px; height: 22px; stroke: #555; fill: none; stroke-width: 1.5; }

        /* ── Position fields ── */
        .cal-pos-grid {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 6px;
        }
        .cal-pos-field {
            display: flex;
            align-items: center;
            gap: 4px;
            background: #f5f6f8;
            border: 1px solid #e0e2e8;
            border-radius: 6px;
            padding: 4px 6px;
        }
        .cal-pos-field label {
            font-size: 10px;
            font-weight: 600;
            color: #999;
            min-width: 10px;
        }
        .cal-pos-field input {
            width: 100%;
            border: none;
            background: none;
            font-size: 12px;
            font-family: inherit;
            color: #333;
            text-align: right;
            outline: none;
            -moz-appearance: textfield;
        }
        .cal-pos-field input::-webkit-inner-spin-button { -webkit-appearance: none; }
        .cal-pos-lock { justify-content: center; }
        .cal-pos-lock-btn {
            border: 1px solid #e0e2e8;
            background: #fff;
            border-radius: 4px;
            padding: 4px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .cal-pos-lock-btn.active { background: #e63946; border-color: #e63946; }
        .cal-pos-lock-btn.active svg { stroke: #fff; }
        .cal-pos-lock-btn svg { stroke: #888; fill: none; stroke-width: 2; }

        /* ── Order buttons ── */
        .cal-order-btns {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 6px;
        }
        .cal-order-btns .cal-tool-btn { font-size: 10px; padding: 6px 4px; }

        /* ── Layer hover highlight ── */
        .cal-layer-item:hover .cal-layer-name { color: #4A90D9; }
        .cal-photo-placeholder {
            position: absolute;
            inset: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            text-align: center;
            padding: 24px;
            pointer-events: none;
            z-index: 2;
        }
        .cal-photo-placeholder-icon { color: #bbb; margin-bottom: 10px; }
        .cal-photo-placeholder h3 { font-size: 15px; font-weight: 600; color: #666; margin-bottom: 4px; }
        .cal-photo-placeholder p { font-size: 13px; color: #999; line-height: 1.5; }
        .cal-page-month-title {
            text-align: center;
            padding: 12px 16px 8px;
            font-size: 22px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 2px;
            color: #1a1a2e;
            display: none; /* replaced by 3-month grid header */
        }
        /* ── 3-Month Grid (MediaClip style) ─────────── */
        .cal-page-grid {
            padding: 0;
        }
        .cal-three-months {
            display: flex;
            align-items: flex-start;
            gap: 0;
            background: #fff;
        }
        .cal-grid-center {
            flex: 1;
            padding: 6px 8px 10px;
            border-top: 1px solid #e8e8e8;
        }
        .cal-grid-center-title {
            font-size: 13px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            color: var(--cal-title-color, #1a1a2e);
            text-align: center;
            padding: 4px 0 4px;
            font-family: var(--cal-font, 'Inter', sans-serif);
        }
        .cal-grid-table {
            width: 100%;
            border-collapse: collapse;
            table-layout: fixed;
        }
        .cal-grid-table th {
            font-size: 9px;
            font-weight: 600;
            color: #999;
            text-transform: uppercase;
            padding: 3px 2px;
            text-align: center;
        }
        .cal-grid-table td {
            font-size: 10px;
            text-align: center;
            padding: 2px 1px;
            color: var(--cal-grid-color, #444);
            font-family: var(--cal-font, 'Inter', sans-serif);
        }
        .cal-grid-table td.cal-day-sun { color: var(--cal-weekend, #e63946); }
        .cal-grid-table td.cal-day-sat { color: var(--cal-weekend, #e63946); }
        .cal-grid-table td.cal-day-empty { color: transparent; }
        .cal-ctx-btn-danger { color: #e63946 !important; }
        .cal-ctx-btn-danger:hover { background: #fff5f5 !important; border-color: #f5c6cb !important; }

        /* ── Right: Tools Panel ───────────────────────── */
        .cal-tools-panel {
            width: 280px;
            min-width: 280px;
            background: #fafafa;
            border-left: 1px solid #e0e2e8;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        .cal-tool-tabs {
            display: flex;
            flex-wrap: wrap;
            border-bottom: 1px solid #e0e2e8;
            background: #fff;
            flex-shrink: 0;
        }
        .cal-tool-tab {
            flex: 0 0 20%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 2px;
            padding: 8px 4px;
            border: none;
            background: none;
            cursor: pointer;
            color: #78909C;
            font-size: 10px;
            font-weight: 500;
            font-family: inherit;
            transition: color .2s, background .2s;
        }
        .cal-tool-tab:hover { background: #f5f5f5; color: #333; }
        .cal-tool-tab.active { color: #e63946; background: #fff5f5; }
        .cal-tool-tab svg {
            width: 20px; height: 20px;
            fill: none; stroke: currentColor; stroke-width: 1.8;
            stroke-linecap: round; stroke-linejoin: round;
        }
        .cal-tool-content {
            flex: 1;
            overflow: hidden;
            position: relative;
        }
        .cal-tool-panel {
            position: absolute;
            inset: 0;
            overflow-y: auto;
            padding: 12px;
            display: none;
        }
        .cal-tool-panel.active { display: block; }
        .cal-panel-subtitle {
            font-size: 11px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: .6px;
            color: #888;
            margin-bottom: 10px;
            padding-bottom: 6px;
            border-bottom: 1px solid #eee;
        }
        .cal-panel-hint {
            font-size: 12px;
            color: #999;
            line-height: 1.5;
            margin-bottom: 12px;
        }

        /* Photos tab */
        .cal-upload-zone {
            width: 100%;
            border: 2px dashed #c0c4cc;
            border-radius: 10px;
            background: #fafbfc;
            padding: 20px 12px;
            text-align: center;
            cursor: pointer;
            transition: border-color .2s, background .2s;
            margin-bottom: 10px;
        }
        .cal-upload-zone:hover, .cal-upload-zone.cal-dragover {
            border-color: #e63946;
            background: #fff5f5;
        }
        .cal-upload-zone svg { color: #a0a4b0; margin-bottom: 6px; }
        .cal-upload-zone p { font-size: 12px; color: #888; margin: 4px 0; }
        .cal-upload-btn {
            margin-top: 8px;
            background: #e63946; color: #fff; border: none;
            border-radius: 6px; padding: 7px 16px;
            font-size: 12px; font-weight: 600; font-family: inherit;
            cursor: pointer; transition: background .2s;
        }
        .cal-upload-btn:hover { background: #c1121f; }
        .cal-images-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 6px;
        }
        .cal-img-thumb {
            aspect-ratio: 1;
            border-radius: 6px;
            overflow: hidden;
            cursor: grab;
            position: relative;
            border: 2px solid transparent;
            transition: border-color .2s, box-shadow .2s;
        }
        .cal-img-thumb:hover { border-color: #e63946; box-shadow: 0 2px 8px rgba(230,57,70,.15); }
        .cal-img-thumb.assigned { opacity: .5; }
        .cal-img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
        .cal-img-thumb-remove {
            position: absolute; top: 3px; right: 3px;
            width: 18px; height: 18px; border-radius: 50%;
            background: rgba(0,0,0,.6); color: #fff; border: none;
            cursor: pointer; font-size: 11px; line-height: 18px;
            text-align: center; display: none;
        }
        .cal-img-thumb:hover .cal-img-thumb-remove { display: block; }
        .cal-photos-count { font-size: 11px; color: #999; margin: 6px 0; }

        /* Layout tab */
        .cal-template-gallery {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .cal-template-card {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            cursor: pointer;
            transition: border-color .2s, background .2s;
            background: #fff;
        }
        .cal-template-card:hover { border-color: #ccc; background: #fafafa; }
        .cal-template-card.active { border-color: #e63946; background: #fff5f5; }
        .cal-template-preview {
            width: 48px; height: 64px;
            border-radius: 4px; overflow: hidden;
            flex-shrink: 0; display: flex;
            align-items: center; justify-content: center;
            font-size: 10px; font-weight: 600; color: #666;
            background: #f5f5f5;
        }
        .cal-template-name { font-size: 13px; font-weight: 500; color: #333; }

        /* Backgrounds tab */
        .cal-bg-colors {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 6px;
            margin-bottom: 12px;
        }
        .cal-bg-color {
            width: 100%; aspect-ratio: 1;
            border-radius: 6px; border: 2px solid #e0e0e0;
            cursor: pointer; transition: border-color .2s, transform .1s;
            padding: 0;
        }
        .cal-bg-color:hover { transform: scale(1.1); }
        .cal-bg-color.active { border-color: #e63946; box-shadow: 0 0 0 2px rgba(230,57,70,.2); }
        .cal-bg-custom { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
        .cal-bg-custom label { font-size: 12px; color: #555; flex: 1; }
        .cal-bg-custom input[type="color"] {
            width: 32px; height: 32px; border: 2px solid #e0e0e0;
            border-radius: 6px; cursor: pointer; padding: 0; background: none;
        }
        .cal-bg-actions { display: flex; flex-direction: column; gap: 6px; }

        /* Text tab */
        .cal-btn-add-text {
            width: 100%; padding: 10px;
            border: 2px dashed #c0c4cc; border-radius: 8px;
            background: #fafbfc; cursor: pointer;
            font-size: 13px; font-weight: 500; font-family: inherit;
            color: #555; display: flex; align-items: center;
            justify-content: center; gap: 8px;
            transition: border-color .2s, background .2s;
        }
        .cal-btn-add-text:hover { border-color: #e63946; background: #fff5f5; color: #e63946; }
        .cal-btn-add-text svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
        .cal-text-props { margin-top: 12px; }
        .cal-prop-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
        .cal-prop-row label { font-size: 12px; color: #555; min-width: 60px; }
        .cal-prop-row select, .cal-prop-row input[type="number"] {
            flex: 1; padding: 5px 8px; border: 1px solid #ddd;
            border-radius: 6px; font-size: 12px; font-family: inherit;
        }
        .cal-text-style-btns { display: flex; gap: 4px; margin-top: 4px; }
        .cal-style-btn {
            width: 32px; height: 32px; border: 1px solid #ddd;
            border-radius: 6px; background: #fff; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            font-size: 13px; transition: background .2s, border-color .2s;
        }
        .cal-style-btn:hover { background: #f0f0f0; }
        .cal-style-btn.active { background: #e63946; color: #fff; border-color: #e63946; }

        /* Borders tab */
        .cal-borders-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px;
            margin-bottom: 12px;
        }
        .cal-border-item {
            display: flex; flex-direction: column; align-items: center;
            gap: 4px; padding: 8px; border: 2px solid transparent;
            border-radius: 8px; cursor: pointer; background: none;
            font-size: 11px; color: #666; font-family: inherit;
            transition: border-color .2s, background .2s;
        }
        .cal-border-item:hover { background: #f5f5f5; }
        .cal-border-item.active { border-color: #e63946; background: #fff5f5; }
        .cal-border-preview {
            width: 44px; height: 32px; background: #e8e8e8; border-radius: 2px;
        }

        /* Filters tab */
        .cal-filters-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 6px;
        }
        .cal-filter-item {
            display: flex; flex-direction: column; align-items: center;
            gap: 3px; padding: 6px; border: 2px solid transparent;
            border-radius: 6px; cursor: pointer; background: none;
            font-size: 10px; color: #666; font-family: inherit;
            transition: border-color .2s;
        }
        .cal-filter-item:hover { border-color: #ddd; }
        .cal-filter-item.active { border-color: #e63946; }
        .cal-filter-preview {
            width: 100%; aspect-ratio: 1; border-radius: 4px;
            background: #e8e8e8; overflow: hidden;
        }
        .cal-filter-preview img { width: 100%; height: 100%; object-fit: cover; }

        /* Clipart tab */
        .cal-clipart-cats {
            display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px;
        }
        .cal-clipart-cat {
            padding: 4px 10px; border-radius: 12px;
            border: 1px solid #ddd; background: #fff;
            font-size: 11px; font-weight: 500; font-family: inherit;
            cursor: pointer; color: #555; transition: all .2s;
        }
        .cal-clipart-cat:hover { border-color: #ccc; background: #f5f5f5; }
        .cal-clipart-cat.active { background: #e63946; color: #fff; border-color: #e63946; }
        .cal-clipart-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 6px;
        }
        .cal-clipart-item {
            aspect-ratio: 1; border-radius: 6px;
            border: 1px solid #eee; background: #fff;
            cursor: pointer; display: flex;
            align-items: center; justify-content: center;
            padding: 6px; transition: border-color .2s, background .2s;
        }
        .cal-clipart-item:hover { border-color: #e63946; background: #fff5f5; }
        .cal-clipart-item svg { width: 28px; height: 28px; }

        /* Tools tab */
        .cal-tool-section { margin-bottom: 14px; }
        .cal-tool-section h5 {
            font-size: 11px; font-weight: 600; text-transform: uppercase;
            letter-spacing: .5px; color: #888; margin-bottom: 8px;
        }
        .cal-tool-row { display: flex; gap: 6px; margin-bottom: 6px; }
        .cal-tool-btn {
            flex: 1; display: flex; align-items: center;
            justify-content: center; gap: 5px;
            padding: 7px 8px; font-size: 11px; font-weight: 500;
            font-family: inherit; border: 1px solid #e0e0e0;
            border-radius: 6px; background: #fff; color: #333;
            cursor: pointer; transition: background .2s, border-color .2s;
        }
        .cal-tool-btn:hover { background: #f0f0f0; border-color: #ccc; }
        .cal-tool-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }
        .cal-tool-btn-full { width: 100%; }
        .cal-tool-btn-primary {
            background: #e63946; color: #fff; border-color: #e63946;
        }
        .cal-tool-btn-primary:hover { background: #c1121f; border-color: #c1121f; }
        .cal-slider-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
        .cal-slider-row label { font-size: 11px; color: #555; min-width: 50px; }
        .cal-slider-row input[type="range"] {
            flex: 1; -webkit-appearance: none; appearance: none;
            height: 4px; background: #e0e0e0; border-radius: 2px; outline: none;
        }
        .cal-slider-row input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none; width: 14px; height: 14px;
            border-radius: 50%; background: #e63946; cursor: pointer;
            border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
        }
        .cal-slider-row span { font-size: 11px; color: #888; min-width: 30px; text-align: right; }
        .cal-quick-actions { display: flex; flex-direction: column; gap: 6px; }

        /* ── Bottom Bar ──────────────────────────────── */
        .cal-bottombar {
            height: 40px;
            min-height: 40px;
            background: #fff;
            border-top: 1px solid #e0e2e8;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0 20px;
            gap: 24px;
            z-index: 50;
        }
        .cal-current-month {
            font-size: 13px;
            font-weight: 600;
            color: #1a1a2e;
        }
        .cal-bottom-zoom {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 12px;
            color: #888;
        }
        .cal-bottom-zoom button {
            width: 28px;
            height: 28px;
            border-radius: 6px;
            border: 1px solid #ddd;
            background: #fafafa;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            color: #555;
            transition: background .2s;
        }
        .cal-bottom-zoom button:hover { background: #eee; }

        /* ── Loading Overlay ──────────────────────────── */
        .cal-loading {
            position: fixed;
            inset: 0;
            background: rgba(255,255,255,.85);
            backdrop-filter: blur(4px);
            display: none;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            gap: 16px;
            z-index: 9999;
        }
        .cal-loading.active { display: flex; }
        .cal-loading-spinner {
            width: 40px; height: 40px;
            border: 3px solid #e0e0e0;
            border-top-color: #e63946;
            border-radius: 50%;
            animation: cal-spin .7s linear infinite;
        }
        @keyframes cal-spin { to { transform: rotate(360deg); } }
        .cal-loading-text { font-size: 14px; color: #555; font-weight: 500; }

        /* ── Responsive ───────────────────────────────── */
        @media (max-width: 1100px) {
            .cal-tools-panel { width: 240px; min-width: 240px; }
        }
        @media (max-width: 900px) {
            .cal-tools-panel { width: 220px; min-width: 220px; }
            .cal-tool-tab span { display: none; }
            .cal-tool-tab { padding: 6px; }
        }
        @media (max-width: 600px) {
            .cal-topbar { padding: 0 12px; flex-wrap: wrap; height: auto; min-height: 56px; gap: 4px; padding-top: 8px; padding-bottom: 8px; }
            .cal-topbar-center { order: 3; width: 100%; justify-content: center; padding-bottom: 4px; }
            .cal-title { display: none; }
            .cal-months-strip { height: 70px; min-height: 70px; }
            .cal-month-card { flex: 0 0 52px; height: 58px; }
            .cal-month-card-preview { width: 30px; height: 22px; }
            .cal-tools-panel { width: 180px; min-width: 180px; }
            .cal-context-toolbar { flex-wrap: wrap; height: auto; min-height: 40px; padding: 6px 12px; }
        }
