        :root {
            --accent-color: #0071e3;
            --accent-gradient: linear-gradient(135deg, #0071e3 0%, #0a84ff 100%);
            --accent-glow: rgba(0, 113, 227, 0.15);

            --bg-color: #f5f5f7;
            --card-bg: rgba(255, 255, 255, 0.8);
            --card-border: rgba(210, 210, 215, 0.6);
            --text-color: #1d1d1f;
            --text-muted: #86868b;
            --input-bg: #ffffff;
            --border-color: #d2d2d7;
            --tool-border-color: #6f6f77;
            --hover-bg: rgba(0, 113, 227, 0.08);
            --btn-secondary-bg: #ffffff;

            --success-color: #34c759;
            --error-color: #ff3b30;
            --warning-color: #ff9500;

            --radius-lg: 16px;
            --radius-md: 12px;
            --radius-sm: 8px;

            --shadow-premium: 0 4px 20px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);

            --editor-bg: #ffffff;
            --sidebar-bg: #fbfbfd;
            --toolbar-bg: rgb(186 198 233 / 85%);
            --sidebar-width: 320px;
        }

        [data-theme='dark'] {
            --bg-color: #000000;
            --card-bg: rgba(28, 28, 30, 0.8);
            --card-border: rgba(58, 58, 60, 0.6);
            --text-color: #f5f5f7;
            --text-muted: #86868b;
            --input-bg: #1c1c1e;
            --border-color: #3a3a3c;
            --hover-bg: rgba(10, 132, 255, 0.15);
            --btn-secondary-bg: #2c2c2e;

            --success-color: #30d158;
            --error-color: #ff453a;
            --warning-color: #ff9f0a;

            --shadow-premium: 0 10px 30px rgba(0, 0, 0, 0.4);

            --editor-bg: #1e1e1e;
            --sidebar-bg: #1c1c1e;
            --toolbar-bg: rgba(28, 28, 30, 0.85);
        }

        body {
            background-color: var(--bg-color);
            color: var(--text-color);
            margin: 0;
            padding: 0;
            font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', 'Noto Sans KR', sans-serif;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            transition: background-color 0.3s, color 0.3s;
            -webkit-font-smoothing: antialiased;
        }

        #app {
            flex: 1;
            max-width: 1400px;
            width: 100%;
            margin: 0 auto;
            padding: 32px 24px;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            gap: 24px;
        }

        .app-header {
            text-align: center;
            margin-bottom: 8px;
        }

        .app-header h1 {
            font-size: 2rem;
            font-weight: 700;
            margin: 0 0 8px 0;
            color: var(--text-color);
            letter-spacing: -0.02em;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
        }

        .app-header h1 span.material-symbols-rounded {
            color: var(--accent-color);
        }

        .app-header p {
            color: var(--text-muted);
            margin: 0;
            font-size: 0.95rem;
            font-weight: 400;
            margin: 0 auto;
            line-height: 1.5;
        }

        /* macOS Window-style Workspace Container */
        .workspace-container {
            display: flex;
            flex-direction: column;
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-premium);
            overflow: hidden;
            transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
        }

        .editor-workspace {
            display: flex;
            flex-direction: column;
            position: relative;
        }

        /* Application Header & Menu Bar (Windows Application Style) */
        .app-window-header {
            display: flex;
            flex-direction: column;
            background: var(--toolbar-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-bottom: 1px solid var(--border-color);
            z-index: 30;
            position: relative;
        }

        /* Top Layer: Windows Application Menu Bar */
        .app-menubar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 4px 12px;
            border-bottom: 1px solid rgba(0, 0, 0, 0.06);
            background: rgba(255, 255, 255, 0.35);
            font-size: 0.85rem;
            user-select: none;
        }

        [data-theme='dark'] .app-menubar {
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
            background: rgba(0, 0, 0, 0.2);
        }

        .menubar-left {
            display: flex;
            align-items: center;
            gap: 2px;
        }

        .menubar-item-wrapper {
            position: relative;
            display: inline-block;
        }

        .menubar-btn {
            background: transparent;
            border: 1px solid transparent;
            color: var(--text-color);
            padding: 5px 11px;
            font-size: 0.84rem;
            font-weight: 500;
            border-radius: var(--radius-sm);
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 4px;
            transition: all 0.15s ease;
        }

        .menubar-btn:hover,
        .menubar-btn.active,
        .menubar-item-wrapper:hover > .menubar-btn {
            background-color: var(--hover-bg);
            color: var(--accent-color);
        }

        .menubar-right {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .menubar-action-link {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 4px 10px;
            border-radius: var(--radius-sm);
            color: var(--text-muted);
            text-decoration: none;
            font-size: 0.82rem;
            font-weight: 500;
            transition: all 0.2s ease;
        }

        .menubar-action-link:hover {
            background-color: var(--hover-bg);
            color: var(--accent-color);
        }

        .menubar-action-link span.material-symbols-rounded {
            font-size: 1.05rem;
        }

        .menubar-divider {
            width: 1px;
            height: 14px;
            background-color: var(--border-color);
            margin: 0 4px;
        }

        /* Windows App Dropdown Menus */
        .win-menu {
            position: absolute;
            top: calc(100% + 4px);
            left: 0;
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: var(--radius-md);
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
            z-index: 1000;
            min-width: 220px;
            display: none;
            flex-direction: column;
            padding: 6px 0;
            backdrop-filter: blur(24px);
            -webkit-backdrop-filter: blur(24px);
            animation: dropdownFadeIn 0.15s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        .win-menu.show {
            display: flex;
        }

        .menu-shortcut {
            margin-left: auto;
            font-size: 0.75rem;
            color: var(--text-muted);
            font-family: 'SF Mono', 'Segoe UI', monospace;
            padding-left: 16px;
            opacity: 0.85;
        }

        /* Bottom Layer: Clean 1-Line Quick Formatting Toolbar */
        .app-toolbar-strip {
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 6px 14px;
            overflow-x: auto;
            flex-wrap: nowrap;
            white-space: nowrap;
            scrollbar-width: none;
            -ms-overflow-style: none;
        }

        .app-toolbar-strip::-webkit-scrollbar {
            display: none;
        }

        .strip-group {
            display: flex;
            align-items: center;
            gap: 3px;
            flex-shrink: 0;
        }

        /* Legacy Apple Unified Toolbar Compatibility */
        .apple-toolbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            flex-wrap: nowrap;
            background: var(--toolbar-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-bottom: 1px solid var(--border-color);
            padding: 8px 16px;
            z-index: 20;
            overflow-x: auto;
        }

        .toolbar-group {
            display: flex;
            align-items: center;
            gap: 4px;
            flex-shrink: 0;
        }

        .toolbar-divider {
            width: 1px;
            height: 18px;
            background-color: var(--border-color);
            margin: 0 4px;
            flex-shrink: 0;
        }

        .toolbar-btn {
            background: none;
            border: 1px solid transparent;
            color: var(--text-color);
            width: 34px;
            height: 34px;
            border-radius: var(--radius-sm);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
            padding: 0;
        }

        .toolbar-btn:hover {
            background-color: var(--hover-bg);
            color: var(--accent-color);
        }

        .toolbar-btn.active {
            background-color: var(--accent-color);
            color: #ffffff;
        }

        .toolbar-btn span.material-symbols-rounded {
            font-size: 1.25rem;
        }

        .toolbar-btn:disabled {
            opacity: 0.35;
            cursor: not-allowed;
        }

        .toolbar-btn:disabled:hover {
            background: none;
            color: var(--text-color);
        }

        /* Apple Custom Select Dropdowns */
        .font-size-select {
            background-color: var(--btn-secondary-bg);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            color: var(--text-color);
            padding: 6px 24px 6px 12px;
            font-size: 0.85rem;
            font-weight: 500;
            cursor: pointer;
            outline: none;
            appearance: none;
            -webkit-appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 8px center;
            background-size: 14px;
            min-width: 130px;
            transition: border-color 0.2s, background-color 0.2s;
        }

        .font-size-select:focus {
            border-color: var(--accent-color);
        }

        /* Color Picker Popover */
        .color-picker-container {
            position: relative;
        }

        .color-palette-popover {
            position: absolute;
            top: calc(100% + 8px);
            left: 0;
            background: var(--input-bg);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            padding: 10px;
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 8px;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
            z-index: 50;
            display: none;
            width: max-content;
        }

        .color-palette-popover.show {
            display: grid;
        }

        .color-dot {
            width: 22px;
            height: 22px;
            border-radius: 50%;
            border: 1px solid rgba(0, 0, 0, 0.15);
            cursor: pointer;
            transition: transform 0.15s ease, box-shadow 0.15s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            box-sizing: border-box;
        }

        .color-dot:hover {
            transform: scale(1.18);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        .color-dot.color-dot-reset {
            background-color: transparent !important;
            border: 1px dashed var(--tool-border-color);
        }

        /* Main workspace area split */
        .editor-main-layout {
            display: flex;
            position: relative;
            background-color: var(--bg-color);
            min-height: 650px;
            overflow: hidden;
        }

        /* Document Paper Container */
        .editor-paper-container {
            flex: 1;
            padding: 40px;
            display: flex;
            justify-content: center;
            background-color: var(--bg-color);
            overflow-y: auto;
            transition: padding-right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        .editor-wrapper {
            position: relative;
            width: 100%;
            max-width: 800px;
        }

        /* Clean A4-style Document Paper */
        .wysiwyg-editor {
            background-color: var(--editor-bg);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-lg);
            padding: 48px 56px;
            min-height: 600px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
            color: var(--text-color);
            font-size: 1rem;
            line-height: 1.8;
            outline: none;
            transition: border-color 0.25s, box-shadow 0.25s, background-color 0.3s;
            cursor: text;
            box-sizing: border-box;
        }

        .wysiwyg-editor:focus {
            border-color: rgba(0, 113, 227, 0.4);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 0 0 3px var(--accent-glow);
        }

        .wysiwyg-editor:empty:before {
            content: attr(placeholder);
            color: var(--text-muted);
            cursor: text;
        }

        .wysiwyg-editor p {
            margin: 0 0 16px 0;
        }

        /* Image hover & selection styles */
        .wysiwyg-editor img {
            max-width: 100%;
            height: auto;
            border-radius: var(--radius-md);
            margin: 16px 0;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            display: block;
            cursor: pointer;
            transition: outline 0.15s ease, box-shadow 0.15s ease;
        }

        .wysiwyg-editor img.img-selected {
            outline: 2px solid var(--accent-color, #0071e3);
            outline-offset: 2px;
            box-shadow: 0 6px 20px rgba(0, 113, 227, 0.25);
        }

        /* Floating Image Resizer Overlay */
        .image-resizer-overlay {
            position: absolute;
            border: 2px dashed var(--accent-color, #0071e3);
            pointer-events: none;
            z-index: 100;
            box-sizing: border-box;
            border-radius: 4px;
            transition: opacity 0.15s ease;
        }

        .image-resizer-overlay .resizer-handle {
            position: absolute;
            width: 12px;
            height: 12px;
            background-color: #ffffff;
            border: 2px solid var(--accent-color, #0071e3);
            border-radius: 50%;
            pointer-events: auto;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
            z-index: 101;
            transition: transform 0.15s ease, background-color 0.15s ease;
        }

        .image-resizer-overlay .resizer-handle:hover {
            background-color: var(--accent-color, #0071e3);
            transform: scale(1.3);
        }

        .image-resizer-overlay .handle-nw {
            top: -6px;
            left: -6px;
            cursor: nwse-resize;
        }

        .image-resizer-overlay .handle-ne {
            top: -6px;
            right: -6px;
            cursor: nesw-resize;
        }

        .image-resizer-overlay .handle-sw {
            bottom: -6px;
            left: -6px;
            cursor: nesw-resize;
        }

        .image-resizer-overlay .handle-se {
            bottom: -6px;
            right: -6px;
            cursor: nwse-resize;
        }

        .image-resizer-overlay .resizer-size-badge {
            position: absolute;
            bottom: -28px;
            right: 0;
            background: rgba(0, 0, 0, 0.8);
            color: #ffffff;
            font-size: 11px;
            font-weight: 600;
            padding: 3px 8px;
            border-radius: 4px;
            pointer-events: none;
            white-space: nowrap;
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
            z-index: 102;
            font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, sans-serif;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        /* Floating Image Toolbar */
        .image-resizer-overlay .image-toolbar {
            position: absolute;
            top: -46px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: center;
            gap: 6px;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(14px);
            -webkit-backdrop-filter: blur(14px);
            border: 1px solid rgba(0, 113, 227, 0.25);
            border-radius: 20px;
            padding: 4px 10px;
            box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
            pointer-events: auto;
            white-space: nowrap;
            z-index: 110;
            user-select: none;
        }

        .image-resizer-overlay .image-toolbar-group {
            display: flex;
            align-items: center;
            gap: 3px;
        }

        .image-resizer-overlay .image-toolbar-divider {
            width: 1px;
            height: 16px;
            background: rgba(0, 0, 0, 0.12);
            margin: 0 2px;
        }

        .image-resizer-overlay .image-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 28px;
            height: 28px;
            border: none;
            background: transparent;
            border-radius: 6px;
            color: #1d1d1f;
            cursor: pointer;
            transition: all 0.15s ease;
            font-size: 12px;
            padding: 0;
        }

        .image-resizer-overlay .image-btn span.material-symbols-rounded {
            font-size: 18px;
        }

        .image-resizer-overlay .image-btn:hover {
            background: rgba(0, 113, 227, 0.12);
            color: #0071e3;
            transform: translateY(-1px);
        }

        .image-resizer-overlay .image-btn.active {
            background: #0071e3;
            color: #ffffff;
        }

        .image-resizer-overlay .image-btn:active {
            transform: translateY(0) scale(0.95);
        }

        .image-resizer-overlay .image-btn.danger:hover {
            background: rgba(255, 59, 48, 0.12);
            color: #ff3b30;
        }

        /* Image Toolbar Popover Panels */
        .image-toolbar-popover {
            position: absolute;
            top: 38px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(255, 255, 255, 0.98);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            border: 1px solid rgba(0, 113, 227, 0.2);
            border-radius: 14px;
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.08);
            padding: 12px 14px;
            width: 290px;
            z-index: 120;
            pointer-events: auto;
            animation: popoverFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
            text-align: left;
            user-select: none;
            color: var(--text-color, #1d1d1f);
        }

        @keyframes popoverFadeIn {
            from {
                opacity: 0;
                transform: translateX(-50%) translateY(-6px) scale(0.97);
            }
            to {
                opacity: 1;
                transform: translateX(-50%) translateY(0) scale(1);
            }
        }

        .popover-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 13px;
            font-weight: 700;
            color: var(--text-color, #1d1d1f);
            margin-bottom: 10px;
            padding-bottom: 6px;
            border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        }

        .popover-close-btn {
            background: transparent;
            border: none;
            font-size: 18px;
            line-height: 1;
            color: #86868b;
            cursor: pointer;
            padding: 2px 4px;
            border-radius: 4px;
            transition: all 0.15s;
        }

        .popover-close-btn:hover {
            color: #1d1d1f;
            background: rgba(0, 0, 0, 0.06);
        }

        .popover-section {
            margin-bottom: 10px;
        }

        .popover-section:last-child {
            margin-bottom: 0;
        }

        .popover-label {
            display: block;
            font-size: 11px;
            font-weight: 600;
            color: #86868b;
            margin-bottom: 5px;
        }

        .popover-row {
            display: flex;
            gap: 10px;
        }

        .popover-col {
            flex: 1;
        }

        .popover-chips {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
        }

        .popover-chip {
            background: rgba(0, 0, 0, 0.04);
            border: 1px solid rgba(0, 0, 0, 0.08);
            border-radius: 6px;
            padding: 4px 8px;
            font-size: 11px;
            font-weight: 500;
            color: #1d1d1f;
            cursor: pointer;
            transition: all 0.15s;
        }

        .popover-chip:hover {
            background: rgba(0, 113, 227, 0.08);
            border-color: rgba(0, 113, 227, 0.3);
            color: #0071e3;
        }

        .popover-chip.active {
            background: #0071e3;
            border-color: #0071e3;
            color: #ffffff;
            font-weight: 600;
        }

        .popover-select {
            width: 100%;
            padding: 5px 8px;
            font-size: 12px;
            border: 1px solid rgba(0, 0, 0, 0.15);
            border-radius: 6px;
            background: #ffffff;
            color: #1d1d1f;
            outline: none;
            cursor: pointer;
        }

        .popover-color-wrapper {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .popover-color-picker {
            -webkit-appearance: none;
            -moz-appearance: none;
            appearance: none;
            width: 28px;
            height: 28px;
            border: 1px solid rgba(0,0,0,0.15);
            border-radius: 6px;
            cursor: pointer;
            background: transparent;
            padding: 0;
        }

        .popover-color-picker::-webkit-color-swatch-wrapper {
            padding: 0;
        }

        .popover-color-picker::-webkit-color-swatch {
            border: none;
            border-radius: 5px;
        }

        .color-preview-code {
            font-size: 11px;
            font-weight: 600;
            color: #86868b;
            font-family: monospace;
        }

        /* Popover Grid Chips (Shadow & Filter) */
        .popover-grid-chips {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 6px;
            max-height: 220px;
            overflow-y: auto;
            padding-right: 2px;
        }

        .popover-grid-chips.filter-grid {
            grid-template-columns: repeat(2, 1fr);
        }

        .popover-card-chip {
            display: flex;
            align-items: center;
            gap: 8px;
            background: rgba(0, 0, 0, 0.03);
            border: 1px solid rgba(0, 0, 0, 0.08);
            border-radius: 8px;
            padding: 6px 8px;
            font-size: 11px;
            font-weight: 500;
            color: #1d1d1f;
            cursor: pointer;
            transition: all 0.15s;
            text-align: left;
        }

        .popover-card-chip span.material-symbols-rounded {
            font-size: 18px;
            color: #0071e3;
        }

        .popover-card-chip:hover {
            background: rgba(0, 113, 227, 0.08);
            border-color: rgba(0, 113, 227, 0.3);
            color: #0071e3;
        }

        .popover-card-chip.active {
            background: rgba(0, 113, 227, 0.12);
            border-color: #0071e3;
            color: #0071e3;
            font-weight: 700;
        }

        .preview-box {
            width: 18px;
            height: 18px;
            border-radius: 4px;
            background: #ffffff;
            border: 1px solid rgba(0,0,0,0.1);
            flex-shrink: 0;
        }

        .preview-box.shadow-none { box-shadow: none; }
        .preview-box.shadow-soft { box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
        .preview-box.shadow-deep { box-shadow: 0 8px 16px rgba(0,0,0,0.45); }
        .preview-box.shadow-3d { box-shadow: 0 12px 20px rgba(0,0,0,0.6); }
        .preview-box.shadow-glow-blue { box-shadow: 0 0 8px rgba(0, 113, 227, 0.9); }
        .preview-box.shadow-glow-warm { box-shadow: 0 0 8px rgba(255, 149, 0, 0.9); }
        .preview-box.shadow-glow-neon { box-shadow: 0 0 8px rgba(52, 199, 89, 0.9); }
        .preview-box.shadow-glow-purple { box-shadow: 0 0 8px rgba(175, 82, 222, 0.9); }

        /* Dark Mode Support for Popover and Toolbar */
        body.dark-mode .image-resizer-overlay .image-toolbar {
            background: rgba(30, 30, 32, 0.95);
            border-color: rgba(0, 113, 227, 0.4);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
        }

        body.dark-mode .image-resizer-overlay .image-btn {
            color: #e5e5ea;
        }

        body.dark-mode .image-resizer-overlay .image-toolbar-divider {
            background: rgba(255, 255, 255, 0.15);
        }

        body.dark-mode .image-toolbar-popover {
            background: rgba(30, 30, 32, 0.98);
            border-color: rgba(255, 255, 255, 0.15);
            color: #e5e5ea;
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
        }

        body.dark-mode .popover-header {
            color: #f5f5f7;
            border-bottom-color: rgba(255, 255, 255, 0.1);
        }

        body.dark-mode .popover-chip,
        body.dark-mode .popover-card-chip {
            background: rgba(255, 255, 255, 0.06);
            border-color: rgba(255, 255, 255, 0.12);
            color: #e5e5ea;
        }

        body.dark-mode .popover-select {
            background: #2c2c2e;
            border-color: rgba(255, 255, 255, 0.2);
            color: #f5f5f7;
        }

        body.dark-mode .preview-box {
            background: #3a3a3c;
            border-color: rgba(255, 255, 255, 0.2);
        }

        /* Floating Table Resizer Overlay */
        .table-resizer-overlay {
            position: absolute;
            border: 2px dashed var(--accent-color, #0071e3);
            pointer-events: none;
            z-index: 98;
            box-sizing: border-box;
            border-radius: 2px;
        }

        .table-resizer-overlay .table-handle {
            position: absolute;
            width: 10px;
            height: 10px;
            background-color: #ffffff;
            border: 2px solid var(--accent-color, #0071e3);
            border-radius: 2px;
            pointer-events: auto;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
            z-index: 99;
        }

        .table-resizer-overlay .table-handle:hover {
            background-color: var(--accent-color, #0071e3);
            transform: scale(1.3);
        }

        .table-resizer-overlay .handle-se {
            bottom: -5px;
            right: -5px;
            cursor: nwse-resize;
        }

        .table-resizer-overlay .handle-sw {
            bottom: -5px;
            left: -5px;
            cursor: nesw-resize;
        }

        .table-resizer-overlay .handle-ne {
            top: -5px;
            right: -5px;
            cursor: nesw-resize;
        }

        .table-resizer-overlay .handle-nw {
            top: -5px;
            left: -5px;
            cursor: nwse-resize;
        }

        /* Floating Table Toolbar */
        .table-resizer-overlay .table-toolbar {
            position: absolute;
            top: -46px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: center;
            gap: 6px;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid rgba(0, 113, 227, 0.25);
            border-radius: 20px;
            padding: 4px 10px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
            pointer-events: auto;
            white-space: nowrap;
            z-index: 100;
            user-select: none;
        }

        .table-resizer-overlay .table-toolbar-group {
            display: flex;
            align-items: center;
            gap: 3px;
        }

        .table-resizer-overlay .table-toolbar-label {
            font-size: 11px;
            font-weight: 700;
            color: var(--text-muted, #86868b);
            padding: 0 4px;
        }

        .table-resizer-overlay .table-toolbar-divider {
            width: 1px;
            height: 16px;
            background: rgba(0, 0, 0, 0.12);
            margin: 0 2px;
        }

        .table-resizer-overlay .table-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 26px;
            height: 26px;
            border: none;
            background: transparent;
            border-radius: 6px;
            color: #1d1d1f;
            cursor: pointer;
            transition: all 0.15s ease;
            font-size: 12px;
            font-weight: 600;
            padding: 0;
        }

        .table-resizer-overlay .table-btn span.material-symbols-rounded {
            font-size: 18px;
        }

        .table-resizer-overlay .table-btn:hover {
            background: rgba(0, 113, 227, 0.12);
            color: #0071e3;
            transform: translateY(-1px);
        }

        .table-resizer-overlay .table-btn:active {
            transform: translateY(0) scale(0.95);
        }

        .table-resizer-overlay .table-btn.danger:hover {
            background: rgba(255, 59, 48, 0.12);
            color: #ff3b30;
        }

        /* Quick Edge Plus Buttons */
        .table-resizer-overlay .table-edge-btn {
            position: absolute;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            background: #0071e3;
            color: #ffffff;
            border: 2px solid #ffffff;
            box-shadow: 0 2px 8px rgba(0, 113, 227, 0.4);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            pointer-events: auto;
            z-index: 100;
            transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
            padding: 0;
        }

        .table-resizer-overlay .table-edge-btn span.material-symbols-rounded {
            font-size: 15px;
            font-weight: 700;
        }

        .table-resizer-overlay .table-edge-btn.edge-bottom {
            bottom: -11px;
            left: 50%;
            transform: translateX(-50%);
        }

        .table-resizer-overlay .table-edge-btn.edge-bottom:hover {
            transform: translateX(-50%) scale(1.2);
            background: #0077ed;
            box-shadow: 0 4px 12px rgba(0, 113, 227, 0.5);
        }

        .table-resizer-overlay .table-edge-btn.edge-right {
            right: -11px;
            top: 50%;
            transform: translateY(-50%);
        }

        .table-resizer-overlay .table-edge-btn.edge-right:hover {
            transform: translateY(-50%) scale(1.2);
            background: #0077ed;
            box-shadow: 0 4px 12px rgba(0, 113, 227, 0.5);
        }

        /* Table cell resize guide line */
        .wysiwyg-editor table td,
        .wysiwyg-editor table th {
            position: relative;
        }

        .wysiwyg-editor table.table-resizing {
            user-select: none;
            -webkit-user-select: none;
        }

        /* Speech input microphone button */
        .mic-btn {
            position: absolute;
            right: 24px;
            top: 24px;
            width: 46px;
            height: 46px;
            border-radius: 50%;
            border: 1px solid var(--border-color);
            background-color: var(--card-bg);
            color: var(--text-muted);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            z-index: 10;
            padding: 0;
        }

        .mic-btn:hover {
            color: var(--accent-color);
            border-color: var(--accent-color);
            transform: translateY(-2px) scale(1.05);
            box-shadow: 0 6px 16px var(--accent-glow);
        }

        .mic-btn:active {
            transform: translateY(0) scale(0.95);
        }

        .mic-btn.recording {
            background: linear-gradient(135deg, #ff3b30 0%, #ff453a 100%);
            border-color: #ff3b30;
            color: #ffffff;
            box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.25), 0 8px 24px rgba(255, 59, 48, 0.4);
            animation: pulse-mic 1.5s infinite alternate;
        }

        @keyframes pulse-mic {
            0% {
                transform: scale(1);
                box-shadow: 0 0 0 0px rgba(255, 59, 48, 0.4), 0 4px 12px rgba(255, 59, 48, 0.2);
            }

            100% {
                transform: scale(1.08);
                box-shadow: 0 0 0 10px rgba(255, 59, 48, 0), 0 8px 20px rgba(255, 59, 48, 0.3);
            }
        }

        /* Apple-style Right Sidebar Inspector */
        .apple-sidebar {
            width: var(--sidebar-width);
            min-width: var(--sidebar-width);
            max-width: var(--sidebar-width);
            background: var(--sidebar-bg);
            border-left: 1px solid var(--border-color);
            padding: 24px 20px;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            gap: 28px;
            transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), margin-right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
            overflow-y: auto;
            z-index: 10;
        }

        .apple-sidebar.collapsed {
            margin-right: calc(-1 * var(--sidebar-width));
            transform: translateX(100%);
            opacity: 0;
            pointer-events: none;
        }

        .sidebar-section {
            display: flex;
            flex-direction: column;
            gap: 12px;
            transition: gap 0.3s ease;
        }

        .sidebar-section.collapsed {
            gap: 0;
        }

        .sidebar-heading {
            font-size: 0.78rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            color: var(--text-muted);
            display: flex;
            align-items: center;
            gap: 6px;
            border-bottom: 1px solid var(--border-color);
            padding-bottom: 8px;
            margin: 0;
        }

        .collapsible-heading {
            cursor: pointer;
            user-select: none;
            display: flex !important;
            justify-content: space-between;
            align-items: center;
            transition: color 0.2s ease;
        }

        .collapsible-heading:hover {
            color: var(--accent-color);
        }

        .collapsible-heading .toggle-chevron {
            transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        .sidebar-section.collapsed .toggle-chevron {
            transform: rotate(-180deg);
        }

        .collapsible-content {
            transition: max-height 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
            max-height: 500px;
            opacity: 1;
            overflow: hidden;
        }

        .sidebar-section.collapsed .collapsible-content {
            max-height: 0;
            opacity: 0;
            pointer-events: none;
        }

        .sidebar-heading span.material-symbols-rounded {
            font-size: 1.1rem;
        }

        .sidebar-content {
            display: flex;
            flex-direction: column;
            gap: 14px;
        }

        .sidebar-desc {
            font-size: 0.82rem;
            color: var(--text-muted);
            margin: 0 0 4px 0;
            line-height: 1.4;
        }

        .sidebar-field {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .sidebar-label {
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--text-color);
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .sidebar-label span.material-symbols-rounded {
            font-size: 1.05rem;
            color: var(--text-muted);
        }

        .sidebar-divider-line {
            height: 1px;
            background-color: var(--border-color);
            margin: 4px 0;
        }

        /* Core Sidebar Inputs & Selects */
        .key-input-container {
            position: relative;
            width: 100%;
        }

        .key-input,
        .model-select,
        .proofread-select,
        .translate-select,
        .custom-command-textarea {
            width: 100%;
            padding: 10px 12px;
            box-sizing: border-box;
            border-radius: var(--radius-sm);
            border: 1px solid var(--border-color);
            background-color: var(--input-bg);
            color: var(--text-color);
            font-size: 0.88rem;
            outline: none;
            transition: border-color 0.2s, box-shadow 0.2s;
            font-family: inherit;
        }

        .key-input {
            padding-right: 36px;
        }

        .key-toggle-visible {
            position: absolute;
            right: 10px;
            top: 50%;
            transform: translateY(-50%);
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 0;
            display: flex;
            align-items: center;
        }

        .key-toggle-visible:hover {
            color: var(--text-color);
        }

        .model-select,
        .proofread-select,
        .translate-select {
            cursor: pointer;
            appearance: none;
            -webkit-appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 10px center;
            background-size: 14px;
            padding-right: 32px;
        }

        .custom-command-textarea {
            min-height: 80px;
            resize: vertical;
            line-height: 1.5;
        }

        .key-input:focus,
        .model-select:focus,
        .proofread-select:focus,
        .translate-select:focus,
        .custom-command-textarea:focus {
            border-color: var(--accent-color);
            box-shadow: 0 0 0 3px var(--accent-glow);
        }

        .sidebar-key-actions {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
            margin-top: 4px;
        }

        .key-status-badge {
            font-size: 0.8rem;
            font-weight: 600;
            padding: 6px 12px;
            border-radius: 99px;
            display: flex;
            align-items: center;
            gap: 4px;
            white-space: nowrap;
            height: 32px;
            box-sizing: border-box;
        }

        .key-status-badge.set {
            background-color: rgba(52, 199, 89, 0.12);
            color: var(--success-color);
            border: 1px solid rgba(52, 199, 89, 0.2);
        }

        .key-status-badge.not-set {
            background-color: rgba(255, 59, 48, 0.12);
            color: var(--error-color);
            border: 1px solid rgba(255, 59, 48, 0.2);
        }

        /* Apple-style Buttons */
        .btn-action-primary {
            background: var(--accent-color);
            color: #ffffff;
            border: none;
            padding: 8px 16px;
            border-radius: var(--radius-sm);
            font-weight: 600;
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.2s ease;
            height: 32px;
            box-sizing: border-box;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .btn-action-primary:hover {
            filter: brightness(1.08);
            box-shadow: 0 2px 8px var(--accent-glow);
        }

        .btn-action-secondary {
            background: var(--btn-secondary-bg);
            color: var(--text-color);
            border: 1px solid var(--border-color);
            padding: 8px 14px;
            border-radius: var(--radius-sm);
            font-weight: 500;
            font-size: 0.85rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
            transition: all 0.2s ease;
            height: 32px;
            box-sizing: border-box;
        }

        .btn-action-secondary:hover {
            background-color: var(--hover-bg);
            border-color: var(--accent-color);
            color: var(--accent-color);
        }

        .btn-sidebar-op {
            background: var(--btn-secondary-bg);
            border: 1px solid var(--border-color);
            color: var(--text-color);
            padding: 10px 14px;
            border-radius: var(--radius-sm);
            font-weight: 600;
            font-size: 0.88rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            transition: all 0.2s ease;
        }

        .btn-sidebar-op:hover {
            background-color: var(--hover-bg);
            border-color: var(--accent-color);
            color: var(--accent-color);
        }

        .btn-sidebar-op span.material-symbols-rounded {
            font-size: 1.15rem;
        }

        .sidebar-row-group {
            display: flex;
            gap: 8px;
            align-items: center;
        }

        .sidebar-row-group select {
            flex: 1;
        }

        .btn-sidebar-op-accent {
            background: var(--accent-color);
            border: none;
            color: #ffffff;
            padding: 10px 14px;
            border-radius: var(--radius-sm);
            font-weight: 600;
            font-size: 0.88rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            transition: all 0.2s ease;
            white-space: nowrap;
        }

        .btn-sidebar-op-accent:hover {
            filter: brightness(1.08);
            box-shadow: 0 4px 12px var(--accent-glow);
        }

        .btn-sidebar-op-accent span.material-symbols-rounded {
            font-size: 1.15rem;
        }

        /* Modal dialog styling (macOS Sheet Style) */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.4);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 9999;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s ease;
        }

        .modal-overlay.show {
            opacity: 1;
            pointer-events: all;
        }

        .modal-content {
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: var(--radius-lg);
            padding: 28px;
            width: 440px;
            max-width: 90%;
            transform: scale(0.95) translateY(-20px);
            transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
            box-shadow: var(--shadow-premium);
        }

        .modal-overlay.show .modal-content {
            transform: scale(1) translateY(0);
        }

        .modal-content h2 {
            margin-top: 0;
            font-size: 1.25rem;
            font-weight: 700;
            color: var(--text-color);
            display: flex;
            align-items: center;
            gap: 8px;
            border-bottom: 1px solid var(--border-color);
            padding-bottom: 12px;
            margin-bottom: 16px;
        }

        .modal-content h2 span.material-symbols-rounded {
            color: var(--accent-color);
        }

        .modal-content p {
            font-size: 0.88rem;
            line-height: 1.5;
            color: var(--text-muted);
            margin-bottom: 20px;
        }

        .modal-steps {
            padding-left: 20px;
            margin-bottom: 20px;
            color: var(--text-color);
        }

        .modal-steps li {
            margin-bottom: 8px;
            font-size: 0.85rem;
            line-height: 1.5;
        }

        .modal-steps a {
            color: var(--accent-color);
            text-decoration: none;
            font-weight: 600;
        }

        .modal-steps a:hover {
            text-decoration: underline;
        }

        .modal-actions {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            border-top: 1px solid var(--border-color);
            padding-top: 16px;
            margin-top: 16px;
        }

        /* Document Template Modal Styling */
        .template-modal-content {
            max-width: 840px !important;
            width: 92% !important;
            max-height: 85vh;
            display: flex;
            flex-direction: column;
        }

        .template-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
            gap: 14px;
            margin-top: 12px;
            margin-bottom: 16px;
            max-height: 58vh;
            overflow-y: auto;
            padding-right: 6px;
        }

        .template-grid::-webkit-scrollbar {
            width: 6px;
        }

        .template-grid::-webkit-scrollbar-thumb {
            background: rgba(0, 0, 0, 0.15);
            border-radius: 4px;
        }

        .template-card {
            background: var(--input-bg);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            padding: 16px;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            flex-direction: column;
            gap: 8px;
            position: relative;
            text-align: left;
        }

        .template-card:hover {
            border-color: var(--accent-color);
            transform: translateY(-2px);
            box-shadow: 0 4px 14px var(--accent-glow);
            background: var(--hover-bg);
        }

        .template-card-header {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .template-card-icon {
            font-size: 22px;
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--accent-glow);
            color: var(--accent-color);
            border-radius: var(--radius-sm);
            flex-shrink: 0;
        }

        .template-card-title {
            font-weight: 700;
            font-size: 0.95rem;
            color: var(--text-color);
            line-height: 1.3;
        }

        .template-card-desc {
            font-size: 0.82rem;
            color: var(--text-muted);
            line-height: 1.45;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            margin: 0;
        }

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

        .input-field-group {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .input-field-group label {
            font-weight: 600;
            font-size: 0.8rem;
            color: var(--text-color);
        }

        .input-field-group input {
            padding: 8px 12px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--border-color);
            background-color: var(--input-bg);
            color: var(--text-color);
            outline: none;
            font-size: 0.88rem;
        }

        .input-field-group input:focus {
            border-color: var(--accent-color);
        }

        /* Clipboard toast feedback */
        .toast-feedback {
            position: fixed;
            bottom: 28px;
            left: 50%;
            transform: translateX(-50%) translateY(100px);
            background-color: rgba(28, 28, 30, 0.95);
            color: #ffffff;
            padding: 10px 24px;
            border-radius: 99px;
            font-weight: 600;
            font-size: 0.88rem;
            display: flex;
            align-items: center;
            gap: 8px;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
            z-index: 10001;
            opacity: 0;
            transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.15);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        [data-theme='dark'] .toast-feedback {
            background-color: rgba(245, 245, 247, 0.95);
            color: #1d1d1f;
            border: 1px solid rgba(0, 0, 0, 0.1);
        }

        .toast-feedback.show {
            transform: translateX(-50%) translateY(0);
            opacity: 1;
        }

        /* Loading backdrop overlay */
        .loading-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.3);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 20px;
            z-index: 10000;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }

        .loading-overlay.show {
            opacity: 1;
            pointer-events: all;
        }

        .spinner-box {
            width: 50px;
            height: 50px;
            position: relative;
        }

        .spinner-ring {
            box-sizing: border-box;
            display: block;
            position: absolute;
            width: 100%;
            height: 100%;
            border: 4px solid transparent;
            border-radius: 50%;
            animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
            border-top-color: var(--accent-color);
        }

        .spinner-ring:nth-child(1) {
            animation-delay: -0.45s;
        }

        .spinner-ring:nth-child(2) {
            animation-delay: -0.3s;
        }

        .spinner-ring:nth-child(3) {
            animation-delay: -0.15s;
        }

        @keyframes spin {
            0% {
                transform: rotate(0deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }

        .loading-text {
            color: var(--text-color);
            font-size: 1.05rem;
            font-weight: 600;
            text-align: center;
        }

        /* Editor content styling inside wysiwyg */
        .wysiwyg-editor font[size="1"] {
            font-size: 0.75rem;
        }

        .wysiwyg-editor font[size="2"] {
            font-size: 0.875rem;
        }

        .wysiwyg-editor font[size="3"] {
            font-size: 1rem;
        }

        .wysiwyg-editor font[size="4"] {
            font-size: 1.25rem;
            font-weight: 600;
        }

        .wysiwyg-editor font[size="5"] {
            font-size: 1.5rem;
            font-weight: 700;
            margin-top: 16px;
            display: inline-block;
        }

        .wysiwyg-editor font[size="6"] {
            font-size: 2rem;
            font-weight: 800;
            margin-top: 20px;
            display: inline-block;
        }

        .wysiwyg-editor font[size="7"] {
            font-size: 2.5rem;
            font-weight: 900;
            margin-top: 24px;
            display: inline-block;
        }

        .wysiwyg-editor table {
            width: 100%;
            border-collapse: collapse;
            margin: 16px 0;
            font-size: 0.95rem;
        }

        .wysiwyg-editor th,
        .wysiwyg-editor td {
            border: 1px solid var(--border-color);
            padding: 10px 12px;
            text-align: left;
        }

        .wysiwyg-editor th {
            background-color: rgba(0, 113, 227, 0.05);
            font-weight: 600;
            color: var(--text-color);
        }

        .wysiwyg-editor img {
            max-width: 100%;
            height: auto;
            border-radius: var(--radius-md);
            margin: 16px 0;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
            display: block;
        }

        .wysiwyg-editor blockquote {
            border-left: 4px solid var(--accent-color);
            margin: 16px 0;
            padding: 8px 16px;
            color: var(--text-muted);
            background-color: var(--hover-bg);
            font-style: italic;
            border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
        }

        .wysiwyg-editor hr {
            border: none;
            border-top: 1px solid var(--border-color);
            margin: 20px 0;
        }

        /* Custom scrollbar for modern scroll indicators */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }

        ::-webkit-scrollbar-track {
            background: transparent;
        }

        ::-webkit-scrollbar-thumb {
            background: rgba(0, 0, 0, 0.15);
            border-radius: 99px;
        }

        [data-theme='dark'] ::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.15);
        }

        ::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 0, 0, 0.3);
        }

        @media (max-width: 1024px) {
            .editor-main-layout {
                flex-direction: column;
            }

            .apple-sidebar {
                width: 100%;
                min-width: 100%;
                max-width: 100%;
                border-left: none;
                border-top: 1px solid var(--border-color);
                max-height: none;
            }

            .apple-sidebar.collapsed {
                margin-right: 0;
                margin-bottom: -500px;
                transform: translateY(100%);
            }

            .editor-paper-container {
                padding: 20px;
            }
        }

        /* Apple-style Dropdown Container */
        .dropdown-container {
            position: relative;
            display: inline-block;
        }

        .dropdown-menu {
            position: absolute;
            top: calc(100% + 8px);
            left: 0;
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: var(--radius-md);
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
            z-index: 1000;
            min-width: 200px;
            display: none;
            flex-direction: column;
            padding: 6px 0;
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            animation: dropdownFadeIn 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        @keyframes dropdownFadeIn {
            from {
                opacity: 0;
                transform: translateY(-8px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .dropdown-menu.show {
            display: flex;
        }

        .dropdown-item {
            background: none;
            border: none;
            color: var(--text-color);
            padding: 10px 16px;
            text-align: left;
            font-size: 0.88rem;
            font-weight: 500;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 10px;
            transition: background-color 0.2s ease, color 0.2s ease;
            width: 100%;
            box-sizing: border-box;
        }

        .dropdown-item:hover {
            background-color: var(--hover-bg);
            color: var(--accent-color);
        }

        .dropdown-item span.material-symbols-rounded {
            font-size: 1.2rem;
            color: var(--text-muted);
        }

        .dropdown-item:hover span.material-symbols-rounded {
            color: var(--accent-color);
        }

        .dropdown-divider {
            height: 1px;
            background-color: var(--border-color);
            margin: 6px 0;
        }

        /* PDF download styling adjustments */
        .pdf-print-container {
            background-color: #ffffff !important;
            color: #000000 !important;
            padding: 40px !important;
            font-family: 'Noto Sans KR', sans-serif !important;
        }

        .dropdown-group-label {
            font-size: 0.72rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-muted);
            padding: 6px 16px 2px 16px;
            user-select: none;
        }

        /* Custom Emoji Dropdown Styles */
        .emoji-dropdown-menu {
            position: absolute;
            top: calc(100% + 8px);
            left: 0;
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: var(--radius-md);
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
            z-index: 1000;
            width: 340px;
            display: none;
            flex-direction: column;
            padding: 12px;
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            animation: dropdownFadeIn 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
            box-sizing: border-box;
        }

        .emoji-dropdown-menu.show {
            display: flex;
        }

        .emoji-grid {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 6px;
            margin-bottom: 8px;
        }

        .emoji-item {
            background: none;
            border: none;
            font-size: 1.35rem;
            padding: 4px;
            cursor: pointer;
            border-radius: var(--radius-sm);
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background-color 0.15s ease, transform 0.15s ease;
        }

        .emoji-item:hover {
            background-color: var(--hover-bg);
            transform: scale(1.15);
        }

        .emoji-tip {
            font-size: 0.72rem;
            color: var(--text-muted);
            border-top: 1px solid var(--border-color);
            padding-top: 8px;
            margin-top: 4px;
            line-height: 1.4;
            text-align: center;
        }

        /* ── Comprehensive Print Styles (Print Document Body Only) ── */
        @media print {
            @page {
                margin: 15mm 15mm 15mm 15mm;
                size: auto;
            }

            :root,
            [data-theme='dark'] {
                --text-color: #000000 !important;
                --bg-color: #ffffff !important;
                --editor-bg: #ffffff !important;
                --border-color: #d2d2d7 !important;
            }

            /* Completely hide all UI Chrome, Toolbars, Menubars, Sidebars, Modals, Overlays, and Buttons */
            site-header,
            footer,
            .app-header,
            .app-window-header,
            .app-menubar,
            .app-toolbar-strip,
            .apple-toolbar,
            .apple-sidebar,
            .mic-btn,
            .image-resizer-overlay,
            .table-resizer-overlay,
            .color-palette-popover,
            .emoji-dropdown-menu,
            .dropdown-menu,
            .win-menu,
            .editor-status-bar,
            .ai-floating-btn,
            .ai-assistant-drawer,
            .ai-drawer-overlay,
            .modal-overlay,
            .toast-feedback,
            .toast-container,
            .loading-overlay,
            .code-block-header-right,
            .code-resize-handle,
            .code-size-badge,
            .code-block-selected::before,
            .code-block-selected::after {
                display: none !important;
                visibility: hidden !important;
                height: 0 !important;
                margin: 0 !important;
                padding: 0 !important;
            }

            html, body {
                background: #ffffff !important;
                color: #000000 !important;
                margin: 0 !important;
                padding: 0 !important;
                width: 100% !important;
                height: auto !important;
                overflow: visible !important;
            }

            #app {
                padding: 0 !important;
                margin: 0 !important;
                max-width: 100% !important;
                width: 100% !important;
                display: block !important;
            }

            .workspace-container,
            .editor-workspace,
            .editor-main-layout,
            .editor-paper-container,
            .editor-wrapper {
                display: block !important;
                border: none !important;
                box-shadow: none !important;
                background: transparent !important;
                padding: 0 !important;
                margin: 0 !important;
                width: 100% !important;
                max-width: 100% !important;
                overflow: visible !important;
            }

            .wysiwyg-editor {
                border: none !important;
                box-shadow: none !important;
                background: #ffffff !important;
                color: #000000 !important;
                padding: 0 !important;
                margin: 0 !important;
                min-height: auto !important;
                max-width: 100% !important;
                width: 100% !important;
                font-size: 11pt !important;
                line-height: 1.6 !important;
                overflow: visible !important;
            }

            .wysiwyg-editor:empty:before {
                display: none !important;
            }

            .wysiwyg-editor img {
                max-width: 100% !important;
                height: auto !important;
                box-shadow: none !important;
                outline: none !important;
                page-break-inside: avoid !important;
                break-inside: avoid !important;
            }

            .wysiwyg-editor table {
                max-width: 100% !important;
                width: 100% !important;
                border-collapse: collapse !important;
                page-break-inside: avoid !important;
                break-inside: avoid !important;
            }

            /* Maintain Code Blocks styling in print */
            .code-block-container {
                page-break-inside: avoid !important;
                break-inside: avoid !important;
                background-color: #1e1e2e !important;
                border: 1px solid #313244 !important;
                border-radius: 8px !important;
                margin: 14px 0 !important;
                box-shadow: none !important;
            }

            .code-block-header {
                background-color: #181825 !important;
                border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
            }

            .code-lang-select {
                background: transparent !important;
                color: #a6adc8 !important;
                border: none !important;
                -webkit-appearance: none !important;
                appearance: none !important;
            }

            .code-block-body {
                background-color: #1e1e2e !important;
                max-height: none !important;
                overflow: visible !important;
            }

            .code-line-numbers {
                background-color: #161622 !important;
                color: #6c7086 !important;
                border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
            }

            .code-editor-area {
                background-color: #1e1e2e !important;
                color: #cdd6f4 !important;
            }
        }

        /* ── Code Block Container & Syntax Highlighting & Resizing ── */
        .code-block-container {
            position: relative;
            display: block;
            width: 100%;
            max-width: 100%;
            min-width: 260px;
            margin: 18px 0;
            background-color: #1e1e2e;
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
            font-family: 'Fira Code', 'Cascadia Code', 'Source Code Pro', Consolas, Monaco, monospace;
            box-sizing: border-box;
            user-select: text;
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }

        .code-block-container:hover,
        .code-block-container.code-block-selected {
            border-color: var(--accent-color, #0071e3);
            box-shadow: 0 6px 24px rgba(0, 113, 227, 0.22);
        }

        /* Code Block Header */
        .code-block-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #181825;
            padding: 8px 12px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
            user-select: none;
            -webkit-user-select: none;
        }

        .code-block-header-left {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .code-block-dots {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .code-block-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            display: inline-block;
        }

        .code-block-dot.dot-red {
            background-color: #ff5f56;
            box-shadow: 0 0 4px rgba(255, 95, 86, 0.4);
        }

        .code-block-dot.dot-yellow {
            background-color: #ffbd2e;
            box-shadow: 0 0 4px rgba(255, 189, 46, 0.4);
        }

        .code-block-dot.dot-green {
            background-color: #27c93f;
            box-shadow: 0 0 4px rgba(39, 201, 63, 0.4);
        }

        .code-lang-select {
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.14);
            color: #cdd6f4;
            font-size: 11.5px;
            font-weight: 500;
            border-radius: 5px;
            padding: 3px 8px;
            cursor: pointer;
            outline: none;
            transition: all 0.15s ease;
            font-family: inherit;
        }

        .code-lang-select:hover,
        .code-lang-select:focus {
            background: rgba(255, 255, 255, 0.14);
            border-color: var(--accent-color, #0071e3);
            color: #ffffff;
        }

        .code-lang-select option {
            background-color: #1e1e2e;
            color: #cdd6f4;
        }

        .code-block-header-right {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .code-btn {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.12);
            color: #cdd6f4;
            font-size: 11px;
            font-weight: 500;
            padding: 3px 8px;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.15s ease;
            font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, sans-serif;
        }

        .code-btn span.material-symbols-rounded {
            font-size: 14px;
        }

        .code-btn:hover {
            background: rgba(255, 255, 255, 0.16);
            color: #ffffff;
            border-color: rgba(255, 255, 255, 0.22);
        }

        .code-btn.danger:hover {
            background: rgba(255, 59, 48, 0.2);
            border-color: #ff3b30;
            color: #ff453a;
        }

        .code-btn.copied {
            background: rgba(52, 199, 89, 0.25);
            border-color: #34c759;
            color: #30d158;
        }

        /* Code Block Body */
        .code-block-body {
            display: flex;
            min-height: 80px;
            max-height: 600px;
            overflow: auto;
            position: relative;
            background-color: #1e1e2e;
            scrollbar-width: thin;
            scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
        }

        .code-block-body::-webkit-scrollbar {
            width: 7px;
            height: 7px;
        }

        .code-block-body::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.18);
            border-radius: 4px;
        }

        .code-block-body::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.28);
        }

        /* Line Numbers Column */
        .code-line-numbers {
            background-color: #161622;
            color: #6c7086;
            padding: 12px 10px 12px 12px;
            text-align: right;
            font-size: 13px;
            line-height: 1.6;
            font-family: inherit;
            user-select: none;
            -webkit-user-select: none;
            border-right: 1px solid rgba(255, 255, 255, 0.06);
            min-width: 32px;
            white-space: pre;
            box-sizing: border-box;
        }

        /* Code Editor / Content Area */
        .code-editor-area {
            flex: 1;
            padding: 12px 14px;
            margin: 0;
            background: transparent;
            overflow-x: auto;
            font-family: 'Fira Code', 'Cascadia Code', 'Source Code Pro', Consolas, Monaco, monospace;
            font-size: 13px;
            line-height: 1.6;
            tab-size: 2;
            -moz-tab-size: 2;
            caret-color: #58a6ff;
            color: #cdd6f4;
            outline: none;
            white-space: pre;
            word-break: normal;
            word-wrap: normal;
            box-sizing: border-box;
        }

        .code-editor-area pre {
            margin: 0;
            padding: 0;
            background: transparent;
            font-family: inherit;
            font-size: inherit;
            line-height: inherit;
            white-space: pre;
            outline: none;
        }

        .code-editor-area code {
            font-family: inherit;
            font-size: inherit;
            background: transparent;
            padding: 0;
            outline: none;
            white-space: pre;
            display: block;
            min-height: 1.6em;
        }

        /* Syntax Highlighting Tokens (VS Code Dark+ Palette) */
        .token-keyword {
            color: #c678dd;
            font-weight: 600;
        }

        .token-function {
            color: #61afef;
            font-weight: 500;
        }

        .token-string {
            color: #98c379;
        }

        .token-number {
            color: #d19a66;
        }

        .token-boolean {
            color: #e5c07b;
            font-weight: 600;
        }

        .token-comment {
            color: #7f848e;
            font-style: italic;
        }

        .token-operator {
            color: #56b6c2;
        }

        .token-variable {
            color: #e06c75;
        }

        .token-property {
            color: #61afef;
        }

        .token-tag {
            color: #e06c75;
            font-weight: 600;
        }

        .token-attr-name {
            color: #d19a66;
        }

        .token-attr-value {
            color: #98c379;
        }

        .token-selector {
            color: #d19a66;
        }

        .token-punctuation {
            color: #abb2bf;
        }

        /* Code Block Corner & Edge Resize Handles */
        .code-resize-handle {
            position: absolute;
            pointer-events: auto;
            z-index: 10;
            opacity: 0.7;
            transition: opacity 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
        }

        .code-block-container:hover .code-resize-handle,
        .code-block-container.code-block-selected .code-resize-handle {
            opacity: 1;
        }

        .code-resize-handle.handle-se {
            bottom: 0;
            right: 0;
            width: 14px;
            height: 14px;
            cursor: nwse-resize;
            background: linear-gradient(135deg, transparent 50%, var(--accent-color, #0071e3) 50%);
            border-bottom-right-radius: 9px;
        }

        .code-resize-handle.handle-se:hover {
            transform: scale(1.15);
            background: linear-gradient(135deg, transparent 40%, #0a84ff 40%);
        }

        .code-resize-handle.handle-e {
            top: 50%;
            right: 0;
            width: 6px;
            height: 36px;
            transform: translateY(-50%);
            cursor: ew-resize;
            background: rgba(0, 113, 227, 0.45);
            border-radius: 3px 0 0 3px;
        }

        .code-resize-handle.handle-e:hover {
            background: var(--accent-color, #0071e3);
            width: 8px;
        }

        .code-resize-handle.handle-s {
            bottom: 0;
            left: 50%;
            width: 36px;
            height: 6px;
            transform: translateX(-50%);
            cursor: ns-resize;
            background: rgba(0, 113, 227, 0.45);
            border-radius: 3px 3px 0 0;
        }

        .code-resize-handle.handle-s:hover {
            background: var(--accent-color, #0071e3);
            height: 8px;
        }

        /* Resizing size indicator badge */
        .code-size-badge {
            position: absolute;
            bottom: 10px;
            right: 20px;
            background: rgba(0, 0, 0, 0.85);
            color: #ffffff;
            font-size: 11px;
            font-weight: 600;
            padding: 3px 8px;
            border-radius: 4px;
            pointer-events: none;
            white-space: nowrap;
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
            z-index: 15;
            font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, sans-serif;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        .code-block-container.is-resizing .code-size-badge {
            opacity: 1;
        }

        /* ── Code Block Print & Color Preservations ── */
        .code-block-container,
        .code-block-header,
        .code-block-body,
        .code-line-numbers,
        .code-editor-area,
        .code-editor-area pre,
        .code-editor-area code,
        .code-block-dot,
        .token-keyword,
        .token-function,
        .token-string,
        .token-number,
        .token-boolean,
        .token-comment,
        .token-operator,
        .token-variable,
        .token-property,
        .token-tag,
        .token-attr-name,
        .token-attr-value,
        .token-selector,
        .token-punctuation {
            -webkit-print-color-adjust: exact !important;
            print-color-adjust: exact !important;
            color-adjust: exact !important;
        }



        /* ── Responsive Styling for Windows Menubar & Quick Toolbar ── */
        @media (max-width: 768px) {
            .app-menubar {
                padding: 3px 8px;
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
            }

            .menubar-left {
                gap: 1px;
            }

            .menubar-btn {
                padding: 4px 7px;
                font-size: 0.78rem;
                white-space: nowrap;
            }

            .menubar-action-link {
                padding: 3px 6px;
                font-size: 0.78rem;
            }

            .app-toolbar-strip {
                padding: 4px 8px;
                gap: 3px;
            }

            .toolbar-btn {
                width: 30px;
                height: 30px;
            }

            .toolbar-btn span.material-symbols-rounded {
                font-size: 1.1rem;
            }

            .font-size-select {
                min-width: 110px;
                font-size: 0.78rem;
                padding: 4px 20px 4px 8px;
            }
        }