:root {
            --sat: env(safe-area-inset-top, 0px);
            --sab: env(safe-area-inset-bottom, 0px);
            --sal: env(safe-area-inset-left, 0px);
            --sar: env(safe-area-inset-right, 0px);
        }
        * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
        ::-webkit-scrollbar { width: 3px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
        *:focus { outline: none; }
        body { padding-top: var(--sat); }

        .glass {
            background: rgba(18,18,18,0.85);
            backdrop-filter: blur(24px);
            -webkit-backdrop-filter: blur(24px);
            border-bottom: 1px solid rgba(255,255,255,0.07);
        }

        /* ── Toast ── */
        #toast {
            position: fixed;
            bottom: calc(80px + var(--sab));
            left: 50%;
            transform: translateX(-50%) translateY(20px);
            background: rgba(40,40,40,0.95);
            backdrop-filter: blur(20px);
            color: #fff;
            padding: 10px 20px;
            border-radius: 20px;
            font-size: 14px;
            font-weight: 600;
            z-index: 9999;
            opacity: 0;
            transition: opacity 0.25s, transform 0.25s;
            white-space: nowrap;
            border: 1px solid rgba(255,255,255,0.1);
            pointer-events: none;
        }
        #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
        #toast.success { border-color: rgba(48,209,88,0.5); }
        #toast.error   { border-color: rgba(255,69,58,0.5); }

        /* ── App Shell ── */
        #app {
            display: flex;
            height: 100dvh;
            overflow: hidden;
            position: relative;
            max-width: 1024px;
            margin: 0 auto;
        }

        /* ── Sidebar ── */
        #sidebarPanel {
            width: 100%;
            display: flex;
            flex-direction: column;
            background: #000;
            height: 100%;
            flex-shrink: 0;
        }

        /* ── Editor Panel ── */
        #editorPanel {
            flex: 1;
            display: none;
            flex-direction: column;
            background: #000;
            height: 100%;
            position: absolute;
            inset: 0;
            z-index: 20;
        }
        #editorPanel.open { display: flex; }

        /* Desktop: side by side */
        @media (min-width: 768px) {
            #sidebarPanel { width: 300px; border-right: 1px solid #38383A; }
            #editorPanel { position: relative; display: flex; inset: auto; }
        }

        /* ── Note List Item ── */
        .note-item {
            padding: 14px 16px;
            border-radius: 16px;
            background: rgba(44,44,46,0.5);
            cursor: pointer;
            transition: background 0.15s;
            border: 1.5px solid transparent;
            margin-bottom: 8px;
            -webkit-user-select: none;
        }
        .note-item:active { background: rgba(44,44,46,0.9); }
        .note-item.active { border-color: #0A84FF; background: rgba(10,132,255,0.08); }

        /* ── Textarea wrapper grows with content ── */
        #noteBody {
            flex: 1;
            resize: none;
            min-height: 0;
            line-height: 1.7;
        }

        /* ── Bottom bar (mobile) ── */
        #mobileBottomBar {
            position: fixed;
            bottom: 0;
            left: 0; right: 0;
            padding: 10px 16px;
            padding-bottom: calc(10px + var(--sab));
            background: rgba(18,18,18,0.92);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-top: 1px solid rgba(255,255,255,0.07);
            display: flex;
            justify-content: space-around;
            align-items: center;
            z-index: 100;
        }
        @media (min-width: 768px) { #mobileBottomBar { display: none; } }

        /* ── Modal ── */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.7);
            z-index: 200;
            display: flex;
            align-items: flex-end;
            justify-content: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
        }
        .modal-overlay.open {
            opacity: 1;
            pointer-events: all;
        }
        .modal-sheet {
            width: 100%;
            max-width: 480px;
            background: #1C1C1E;
            border-radius: 20px 20px 0 0;
            padding: 20px;
            padding-bottom: calc(20px + var(--sab));
            transform: translateY(100%);
            transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
        }
        .modal-overlay.open .modal-sheet { transform: translateY(0); }
        @media (min-width: 768px) {
            .modal-overlay { align-items: center; }
            .modal-sheet { border-radius: 20px; max-width: 380px; padding-bottom: 20px; }
            .modal-overlay.open .modal-sheet { transform: translateY(0); }
        }

        /* empty state */
        #emptyEditor {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: rgba(152,152,157,0.3);
        }

        /* word count */
        #wordCount { font-size: 11px; color: #98989D; text-align: right; padding: 2px 0 6px; }
