  :root {
            --primary: #667eea;
            --primary-dark: #4c51bf;
            --accent: #764ba2;
            --bg-soft: #f4f5fb;
        }

        * { box-sizing: border-box; }

        body {
            background: radial-gradient(circle at top, #e3eeff 0, #f8f9ff 45%, #f5f6fa 100%);
            display: flex;
            flex-direction: column;
            height: 100vh;
            overflow: hidden;
            font-family: 'Poppins', sans-serif;
            font-size: 14px;
        }

        /* Override Bootstrap default button look */
        .btn {
            border-radius: 999px;
            border: 1px solid rgba(255,255,255,0.7);
            padding: 5px 12px;
            font-size: 13px;
            font-weight: 500;
           /* background: rgba(255,255,255,0.1);*/
            /*color: #f9fafb;*/
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
            backdrop-filter: blur(4px);
        }
        .btn-sm { padding: 4px 9px; font-size: 11px; }
       /* .btn:hover {
            background: rgba(255,255,255,0.25);
            color: #ffffff;
        }*/
        .btn-outline-light {
            border-color: rgba(255,255,255,0.7) !important;
        }

        /* NAVBAR */
        .navbar-custom {
            flex-shrink: 0;
            z-index: 1000;
            background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 70%);
            box-shadow: 0 4px 20px rgba(0,0,0,0.12);
            min-height: 48px;
        }
        .navbar-brand {
            font-size: 18px;
        }

        /* APP LAYOUT */
        .app-container {
            display: flex;
            flex-grow: 1;
            position: relative;
            overflow: hidden;
            padding: 8px 8px 6px 8px;
            gap: 8px;
        }

        /* LEFT TOOLBAR */
        .toolbar-sidebar {
            width: 90px;
            background: rgba(255,255,255,0.98);
           /* border-radius: 14px;*/
            border: 1px solid rgba(230,230,245,0.9);
            padding: 8px 6px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 5px;
            overflow-y: auto;
            box-shadow: 0 10px 30px rgba(0,0,0,0.06);
        }

        /* Sidebar scroll styling (improved) */
        .toolbar-sidebar::-webkit-scrollbar {
            width: 6px;
        }
        .toolbar-sidebar::-webkit-scrollbar-track {
            background: transparent;
        }
        .toolbar-sidebar::-webkit-scrollbar-thumb {
            background: #d1d5db;
            border-radius: 999px;
        }
        .toolbar-sidebar:hover::-webkit-scrollbar-thumb {
            background: #9ca3af;
        }

        .tool-btn {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            border: 1px solid transparent;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #555;
            background: transparent;
            font-size: 1.1rem;
            transition: all 0.18s ease;
            position: relative;
            cursor: pointer;
        }
        .tool-btn:hover {
            background: #f0f2ff;
            color: var(--accent);
            transform: translateY(-1px);
        }
        .tool-btn.active {
            background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
            color: #fff;
            box-shadow: 0 6px 16px rgba(118,75,162,0.35);
        }
        .tool-btn:hover::after {
            content: attr(title);
            position: absolute;
            left: 130%;
            top: 50%;
            transform: translateY(-50%);
            background: #111827;
            color: #fff;
            padding: 2px 6px;
            border-radius: 999px;
            font-size: 10px;
            white-space: nowrap;
            box-shadow: 0 4px 10px rgba(0,0,0,0.3);
            pointer-events: none;
            z-index: 50;
        }
        .divider {
            width: 30px;
            height: 1px;
            background: #e5e7eb;
            margin: 4px 0;
        }

        /* Bottom actions pinned */
        .bottom-actions {
            margin-top: auto;
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        /* Symbol / preset buttons (small) */
        .symbol-label {
            font-size: 9px;
            text-transform: uppercase;
            color: #9ca3af;
            font-weight: 600;
            letter-spacing: .05em;
            margin-top: 3px;
            text-align: center;
        }
        .symbol-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 3px;
            margin-top: 2px;
            justify-content: center;
        }
        .symbol-btn {
            width: 30px;
            height: 30px;
           /* border-radius: 7px;*/
            border: 1px solid #e5e7eb;
            background: #f9fafb;
            font-size: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.15s ease;
        }
        .symbol-btn:hover {
            background: #eef2ff;
            border-color: #c7d2fe;
        }

        /* CANVAS SECTION */
        .canvas-shell {
            flex: 1;
            position: relative;
            display: flex;
            align-items: stretch;
            justify-content: center;
            min-width: 0;
        }
        .canvas-wrapper {
            flex: 1;
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
        }
        .canvas-frame {
            background: #ffffff;
           /* border-radius: 18px;
            box-shadow: 0 18px 50px rgba(15,23,42,0.16);*/
            padding: 10px;
            display: inline-flex;
            max-width: 100%;
            max-height: 100%;
        }
        canvas {
            display: block;
            border-radius: 10px;
        }

        /* RIGHT PROPERTIES PANEL */
        .properties-panel {
            position: absolute;
            top: 8px;
            right: 6px;
            width: 240px;
            background: rgba(255,255,255,0.98);
            backdrop-filter: blur(6px);
            padding: 8px 9px;
            border-radius: 14px;
            box-shadow: 0 16px 40px rgba(15,23,42,0.2);
            border: 1px solid rgba(229,231,235,0.98);
            z-index: 40;
            display: none;
            max-height: calc(100% - 26px);
            overflow-y: auto;
            font-size: 12px;
        }
        .small-muted {
            font-size: 10px;
            color: #9ca3af;
            text-transform: uppercase;
            letter-spacing: .04em;
            font-weight: 600;
        }

        /* STATUS BAR */
        .status-bar {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            background: rgba(255,255,255,0.98);
            border-top: 1px solid #e5e7eb;
            padding: 4px 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            z-index: 20;
            font-size: 11px;
            color: #4b5563;
        }

        /* ZOOM CONTROLS (bottom-right) */
        .zoom-controls {
            position: absolute;
            right: 10px;
            bottom: 36px;
            display: flex;
            flex-direction: column;
            gap: 3px;
            z-index: 30;
        }
        .zoom-btn {
            width: 28px;
            height: 28px;
            border-radius: 999px;
            border: 1px solid #e5e7eb;
            background: #ffffff;
            font-size: 17px;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            box-shadow: 0 6px 14px rgba(15,23,42,0.15);
            transition: all 0.15s ease;
        }
        .zoom-btn:hover {
            background: #eef2ff;
            border-color: #c7d2fe;
        }

        /* MODAL */
        .modal-overlay {
            position:fixed;
            inset:0;
            background:rgba(15,23,42,0.45);
            z-index:1999;
            display:none;
        }
        .equation-modal {
            position:fixed;
            top:50%;
            left:50%;
            transform:translate(-50%,-50%);
            background:#ffffff;
            padding:16px 14px 12px;
            border-radius:14px;
            box-shadow:0 26px 80px rgba(15,23,42,0.45);
            z-index:2000;
            width:420px;
            max-width:92vw;
            display:none;
            font-size: 13px;
        }
        .equation-modal h5 {
            font-size: 16px;
        }

        @media (max-width: 992px) {
            .properties-panel { right: 4px; width: 220px; }
        }
        @media (max-width: 768px) {
            body { font-size: 13px; }
            .navbar-brand { font-size: 16px; }
            .app-container { padding: 6px; gap: 6px; }
            .toolbar-sidebar { width: 58px; border-radius: 12px; padding: 6px 4px; }
            .tool-btn { width: 36px; height: 36px; font-size: 1rem; }
            .properties-panel { width: 210px; padding: 7px 8px; border-radius: 12px; font-size: 11px; }
            .small-muted { font-size: 9px; }
            .equation-modal { width: 90vw; padding: 12px 10px 10px; }
            .equation-modal h5 { font-size: 14px; margin-bottom: 6px; }
            #mathPreview { padding: 6px !important; min-height: 45px !important; }
            .btn { font-size: 11px; padding: 4px 8px; box-shadow:0 2px 6px rgba(0,0,0,0.12); }
            .symbol-label { font-size: 8px; }
            .symbol-btn { width: 24px; height: 24px; font-size: 11px; }
            .status-bar { padding: 4px 6px; font-size: 10px; }
        }