        /* ========== CSS Variables ========== */
        :root,
        [data-theme="dark"] {
            --bg-primary: #0d1117;
            --bg-secondary: #0b0f14;
            --bg-surface: #131921;
            --bg-elevated: #1a2028;
            --bg-hover: #1c2633;
            --bg-input: #0d1117;
            --bg-input-translucent: rgba(13, 17, 23, 0.82);
            --bg-secondary-translucent: rgba(11, 15, 20, 0.82);
            --border: #3a424d;
            --border-light: #2b313a;
            --border-focus: #58a6ff;
            --text-primary: #e6edf3;
            --text-secondary: #99a4af;
            --text-muted: #6e7681;
            --accent: #58a6ff;
            --accent-hover: #79c0ff;
            --accent-subtle: rgba(88, 166, 255, 0.1);
            --green: #3fb950;
            --green-bg: rgba(63, 185, 80, 0.1);
            --green-border: rgba(63, 185, 80, 0.25);
            --red: #f85149;
            --red-bg: rgba(248, 81, 73, 0.1);
            --red-border: rgba(248, 81, 73, 0.25);
            --yellow: #d29922;
            --yellow-bg: rgba(210, 153, 34, 0.12);
            --orange: #db6d28;
            --purple: #a371f7;
            --radius: 6px;
            --radius-md: 8px;
            --radius-lg: 12px;
            --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
            --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
            --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
            --shadow: 0 4px 12px rgba(0,0,0,0.4);
            --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
            --shadow-glow: 0 0 0 1px rgba(88, 166, 255, 0.15);
            --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            --transition-fast: 0.12s ease;
            color-scheme: dark;
        }

        [data-theme="light"] {
            --bg-primary: #ffffff;
            --bg-secondary: #eef1f5;
            --bg-surface: #f6f8fa;
            --bg-elevated: #ffffff;
            --bg-hover: #e1e5ea;
            --bg-input: #ffffff;
            --bg-input-translucent: rgba(255, 255, 255, 0.82);
            --bg-secondary-translucent: rgba(238, 241, 245, 0.82);
            --border: #b3bcc5;
            --border-light: #c5cdd6;
            --border-focus: #0969da;
            --text-primary: #1f2328;
            --text-secondary: #57606a;
            --text-muted: #6e7681;
            --accent: #0969da;
            --accent-hover: #0550ae;
            --accent-subtle: rgba(9, 105, 218, 0.08);
            --green: #1a7f37;
            --green-bg: rgba(26, 127, 55, 0.10);
            --green-border: rgba(26, 127, 55, 0.25);
            --red: #cf222e;
            --red-bg: rgba(207, 34, 46, 0.10);
            --red-border: rgba(207, 34, 46, 0.25);
            --yellow: #9a6700;
            --yellow-bg: rgba(154, 103, 0, 0.12);
            --orange: #bc4c00;
            --purple: #8250df;
            --shadow-sm: 0 1px 2px rgba(31,35,40,0.08);
            --shadow: 0 4px 12px rgba(31,35,40,0.10);
            --shadow-lg: 0 12px 40px rgba(31,35,40,0.12);
            --shadow-glow: 0 0 0 1px rgba(9, 105, 218, 0.10);
            color-scheme: light;
        }

        /* ========== Reset & Base ========== */
        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

        /* ========== Reduced Motion ========== */
        @media (prefers-reduced-motion: reduce) {
            *, *::before, *::after {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
                scroll-behavior: auto !important;
            }
        }

        html, body {
            height: 100%;
            overflow: hidden;
        }

        body {
            font-family: var(--font-sans);
            background: var(--bg-primary);
            color: var(--text-primary);
            display: flex;
            flex-direction: column;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            -webkit-text-size-adjust: 100%;
            text-size-adjust: 100%;
        }

        /* ========== SVG Icon Styles ========== */
        .svg-icon {
            width: 16px;
            height: 16px;
            flex-shrink: 0;
            display: inline-block;
            vertical-align: middle;
        }

        .svg-icon-sm { width: 13px; height: 13px; }

        .svg-icon-lg { width: 20px; height: 20px; }

        /* ========== Scrollbar ========== */
        ::-webkit-scrollbar { width: 10px; height: 10px; }

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

        ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; min-height: 40px; min-width: 40px; }

        ::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

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

        /* macOS: prevent window drag from eating clicks on header/toolbar/scrollable areas */
        header, .toolbar, .toolbar .btn, .panel, .panel-body, #input, .output-wrap, .output-content, .sidebar, .history-list, .statusbar, .modal-backdrop, .modal, .compare-container, .toast { -webkit-app-region: no-drag; }

        /* ========== Header ========== */
        header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 16px;
            height: 44px;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border);
            gap: 12px;
            flex-shrink: 0;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 13px;
            font-weight: 600;
            color: var(--text-primary);
            white-space: nowrap;
            letter-spacing: -0.2px;
            user-select: none;
        }

        .logo-icon {
            width: 22px;
            height: 22px;
            flex-shrink: 0;
            border-radius: 5px;
            /* 品牌图标自带奶油底色, 暗色模式下用轻微描边与背景区分 */
            box-shadow: 0 0 0 1px rgba(128, 128, 128, 0.15);
            object-fit: contain;
            display: block;
        }

        /* ========== Toolbar ========== */
        .toolbar {
            display: flex;
            align-items: center;
            gap: 4px;
            /* 长语言(如德语/西语)下按钮总宽可能超出窗口: 允许顶栏横向滚动保证尾部按钮可达,
               zh/en/ja 一屏放得下时无滚动条, 视觉与原先一致。
               语言下拉菜单挂在 body 层(v1.5.69), 不受此滚动容器裁剪影响。 */
            min-width: 0;
            overflow-x: auto;
            scrollbar-width: thin;
        }

        .toolbar::-webkit-scrollbar { height: 3px; }

        .toolbar .sep {
            width: 1px;
            height: 20px;
            background: var(--border);
            margin: 0 6px;
        }

        .btn-lang {
            min-width: 36px;
            padding: 4px 8px !important;
            font-size: 11px !important;
            font-weight: 600 !important;
            letter-spacing: 0.5px;
        }

        /* ========== Language switcher popup ========== */
        .lang-menu {
            position: fixed;
            z-index: 1000;
            display: none;
            min-width: 132px;
            padding: 6px;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            box-shadow: var(--shadow-lg);
        }
        .lang-menu-item {
            display: block;
            width: 100%;
            text-align: left;
            padding: 8px 10px;
            border: none;
            background: transparent;
            color: var(--text-primary);
            border-radius: var(--radius);
            cursor: pointer;
            font-size: 13px;
            font-family: var(--font-sans);
        }
        .lang-menu-item:hover {
            background: var(--bg-hover);
        }
        .lang-menu-item.active {
            background: var(--accent);
            color: #fff;
        }
        [data-theme="dark"] .lang-menu-item.active {
            color: #0d1117;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 4px 10px;
            height: 30px;
            border: 1px solid var(--border);
            border-radius: var(--radius);
            background: var(--bg-surface);
            color: var(--text-secondary);
            font-size: 12px;
            font-family: var(--font-sans);
            font-weight: 500;
            cursor: pointer;
            transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
            white-space: nowrap;
            line-height: 1;
        }

        .btn:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: 2px;
        }

        .btn:hover {
            background: var(--bg-hover);
            border-color: var(--text-muted);
            color: var(--text-primary);
        }

        .btn:active {
            background: var(--bg-elevated);
            transform: scale(0.97);
            transform-origin: center;
        }

        .btn:disabled {
            opacity: 0.35;
            cursor: not-allowed;
            transform: none;
            color: var(--text-muted);
        }

        .btn-primary {
            background: #1f6feb;
            color: #ffffff;
            border-color: #1f6feb;
            font-weight: 600;
        }

        .btn-primary:hover {
            background: #388bfd;
            border-color: #388bfd;
            color: #ffffff;
        }

        .btn-primary:active {
            background: #1a5dcc;
        }

        .btn-danger {
            border-color: rgba(248, 81, 73, 0.2);
            color: var(--red);
        }

        .btn-danger:hover {
            background: var(--red-bg);
            border-color: rgba(248, 81, 73, 0.4);
            color: #ff7b72;
        }

        .btn .shortcut {
            font-size: 10px;
            color: var(--text-muted);
            font-family: var(--font-mono);
            padding: 1px 4px;
            background: rgba(72, 79, 88, 0.15);
            border-radius: 3px;
            letter-spacing: 0;
        }

        .btn-primary .shortcut {
            color: rgba(255, 255, 255, 0.6);
            background: rgba(255, 255, 255, 0.12);
        }

        .btn .svg-icon { color: currentColor; }

        /* ========== Indent Select ========== */
        /* ========== Validation Indicator ========== */
        .validation-indicator {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            font-size: 11px;
            font-family: var(--font-mono);
            padding: 1px 6px;
            border-radius: 3px;
            margin-left: 4px;
        }

        .validation-indicator.valid {
            color: var(--green);
        }

        .validation-indicator.invalid {
            color: var(--red);
        }

        .validation-indicator .dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            display: inline-block;
        }

        .validation-indicator.valid .dot {
            background: var(--green);
        }

        .validation-indicator.invalid .dot {
            background: var(--red);
        }

        /* ========== Main Layout ========== */
        .main-layout {
            display: flex;
            flex: 1;
            min-height: 0;
            overflow: hidden;
        }

        /* ========== Editor Area ========== */
        .editor-area {
            flex: 1;
            display: flex;
            min-width: 0;
            min-height: 0;
        }

        .panel {
            display: flex;
            flex-direction: column;
            flex: 1;
            min-width: 0;
            min-height: 0;
        }

        .panel-left { border-right: 2px solid var(--border); flex: 0.54; }

        .panel-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 14px;
            height: 32px;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border-light);
            font-size: 11px;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            flex-shrink: 0;
            user-select: none;
        }

        .panel-header .label {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .panel-header .label .svg-icon-xs {
            width: 12px;
            height: 12px;
            opacity: 0.7;
        }

        .panel-header-right {
            display: flex;
            align-items: center;
            gap: 6px;
            min-width: 0;
        }

        .panel-icon-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 24px;
            height: 24px;
            border: none;
            background: transparent;
            color: var(--text-muted);
            border-radius: 4px;
            cursor: pointer;
            flex-shrink: 0;
            transition: color var(--transition-fast), background var(--transition-fast);
        }

        .panel-icon-btn:hover {
            color: var(--text-primary);
            background: var(--bg-hover);
        }

        .panel-icon-btn:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: 1px;
        }

        .panel-icon-btn.active {
            color: var(--accent);
        }

        .panel-body {
            flex: 1;
            position: relative;
            overflow: hidden;
            min-height: 0;
        }

        /* ========== Input Panel ========== */
        #input-body {
            display: flex;
            flex-direction: column;
            min-height: 0;
        }

        #input {
            flex: 1 1 0%;
            min-height: 0;
            width: 100%;
            white-space: pre-wrap;
            padding: 12px 16px;
            border: none;
            outline: none;
            background: var(--bg-input);
            color: var(--text-primary);
            font-family: var(--font-mono);
            font-size: 13px;
            line-height: 1.65;
            resize: none;
            tab-size: 2;
            overflow: auto;
            transition: box-shadow var(--transition-fast);
        }

        #input:focus-visible {
            box-shadow: inset 0 0 0 1px var(--border-focus);
            outline: 2px solid var(--border-focus);
            outline-offset: -2px;
        }

        #input::placeholder {
            color: var(--text-muted);
        }

        #input::selection {
            background: rgba(88, 166, 255, 0.25);
        }

        /* ========== Output Area ========== */
        .output-wrap {
            position: absolute;
            inset: 0;
            width: auto;
            height: auto;
            overflow: hidden;
            background: var(--bg-input);
            display: flex;
            flex-direction: column;
        }

        .output-linenos {
            flex-shrink: 0;
            padding: 12px 0;
            background: var(--bg-secondary);
            border-right: 1px solid var(--border-light);
            user-select: none;
            overflow: hidden;
            text-align: right;
            font-family: var(--font-mono);
            font-size: 13px;
            line-height: 1.65;
            color: var(--text-muted);
            min-width: 48px;
        }

        .output-linenos span {
            display: block;
            padding: 0 12px 0 8px;
        }

        .output-content {
            flex: 1;
            min-width: 0;
            min-height: 0;
            overflow: auto;
        }

        .output-content pre {
            margin: 0;
            padding: 12px 16px;
            background: transparent !important;
        }

        .output-content code {
            font-family: var(--font-mono) !important;
            font-size: 13px !important;
            line-height: 1.65 !important;
            background: transparent !important;
        }

        .output-error {
            padding: 12px 16px;
            color: var(--red);
            font-family: var(--font-mono);
            font-size: 12px;
            line-height: 1.6;
            border-left: 3px solid var(--red);
            margin: 8px;
            background: var(--red-bg);
            border-radius: 0 var(--radius) var(--radius) 0;
        }

        .output-warning {
            margin: 8px;
            padding: 8px 12px;
            background: var(--yellow-bg);
            border: 1px solid rgba(210, 153, 34, 0.15);
            border-left: 3px solid var(--yellow);
            border-radius: 0 var(--radius) var(--radius) 0;
            color: var(--yellow);
            font-size: 11.5px;
            font-family: var(--font-sans);
        }

        /* ========== Output Notifications ========== */
        .output-notifications {
            flex-shrink: 0;
            overflow-y: auto;
        }

        .output-notifications:empty {
            display: none;
        }

        .output-notification {
            padding: 6px 14px;
            font-size: 12px;
            line-height: 1.5;
            border-bottom: 1px solid rgba(255,255,255,0.04);
            font-family: var(--font-sans);
        }

        .output-notification.error {
            background: var(--red-bg);
            color: var(--red);
            border-left: 3px solid var(--red);
        }

        .output-notification.warning {
            background: var(--yellow-bg);
            color: var(--yellow);
            border-left: 3px solid var(--yellow);
        }

        .error-display {
            padding: 20px 24px;
            flex: 1;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .error-display .error-title {
            font-size: 14px;
            font-weight: 600;
            color: var(--red);
            font-family: var(--font-sans);
        }

        .error-display .error-msg {
            font-size: 13px;
            line-height: 1.7;
            color: var(--text-secondary);
            font-family: var(--font-sans);
        }

        .error-display .error-snippet {
            background: var(--bg-secondary);
            border-radius: 8px;
            padding: 12px 16px;
            font-family: var(--font-mono);
            font-size: 12px;
            line-height: 1.6;
            color: var(--text-primary);
            white-space: pre-wrap;
            word-break: break-all;
        }

        .error-display .error-marker {
            color: var(--red);
            font-weight: bold;
        }

        .error-display .error-hint {
            font-size: 12px;
            color: var(--text-muted);
            font-family: var(--font-sans);
            line-height: 1.6;
        }

        .output-content-area {
            flex: 1;
            position: relative;
            display: flex;
            min-height: 0;
            min-width: 0;
            overflow: hidden;
        }

        /* ========== Output Search Bar ========== */
        .output-search-bar {
            display: none;
            flex-shrink: 0;
            align-items: center;
            gap: 6px;
            padding: 6px 10px;
            background: var(--bg-surface);
            border-bottom: 1px solid var(--border-light);
        }

        .output-search-bar.open {
            display: flex;
        }

        .output-search-bar .search-icon {
            width: 14px;
            height: 14px;
            color: var(--text-muted);
            flex-shrink: 0;
        }

        .output-search-bar input {
            flex: 1;
            min-width: 0;
            height: 28px;
            padding: 0 10px;
            border: 1px solid var(--border);
            border-radius: var(--radius);
            background: var(--bg-input);
            color: var(--text-primary);
            font-size: 13px;
            font-family: var(--font-sans);
            outline: none;
            transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
        }

        .output-search-bar input::placeholder {
            color: var(--text-muted);
        }

        .output-search-bar input:focus {
            border-color: var(--border-focus);
            box-shadow: 0 0 0 1px var(--border-focus);
        }

        .search-count {
            font-size: 12px;
            font-family: var(--font-mono);
            color: var(--text-muted);
            white-space: nowrap;
            min-width: 30px;
            text-align: center;
            user-select: none;
        }

        .search-count.no-match {
            color: var(--red);
        }

        .search-nav-btn,
        .search-close-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 26px;
            height: 26px;
            border: none;
            background: transparent;
            color: var(--text-secondary);
            border-radius: 4px;
            cursor: pointer;
            flex-shrink: 0;
            transition: color var(--transition-fast), background var(--transition-fast);
        }

        .search-nav-btn:hover,
        .search-close-btn:hover {
            color: var(--text-primary);
            background: var(--bg-hover);
        }

        .search-nav-btn:focus-visible,
        .search-close-btn:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: 1px;
        }

        /* ========== List View (Array) ========== */
        .list-view {
            display: flex;
            flex: 1;
            min-height: 0;
            min-width: 0;
            position: relative;
        }

        .list-panel {
            width: 240px;
            min-width: 160px;
            border-right: 1px solid var(--border);
            overflow: hidden;
            flex-shrink: 0;
            background: var(--bg-secondary);
            display: flex;
            flex-direction: column;
            transition: width var(--transition), min-width var(--transition), border-color var(--transition);
        }

        .list-panel.collapsed {
            width: 0;
            min-width: 0;
            border-right-color: transparent;
        }

        .list-panel-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 10px;
            height: 30px;
            border-bottom: 1px solid var(--border-light);
            flex-shrink: 0;
        }

        .list-panel-header .list-title {
            font-size: 11px;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            white-space: nowrap;
        }

        .list-panel-toggle {
            width: 22px;
            height: 22px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 12px;
            border-radius: 4px;
            transition: color var(--transition-fast), background var(--transition-fast);
            flex-shrink: 0;
        }

        .list-panel-toggle:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: 1px;
        }

        .list-panel-toggle:hover {
            color: var(--text-primary);
            background: var(--bg-hover);
        }

        .list-panel-body {
            flex: 1;
            overflow-y: auto;
        }

        .list-panel.collapsed .list-panel-header,
        .list-panel.collapsed .list-panel-body {
            display: none;
        }

        .list-expand-tab {
            display: none;
            flex-shrink: 0;
            width: 20px;
            cursor: pointer;
            background: var(--bg-elevated);
            align-items: center;
            justify-content: center;
            border-right: 1px solid var(--border);
            touch-action: manipulation;
        }

        .list-expand-tab:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: -2px;
        }

        .list-expand-tab:hover {
            background: var(--bg-hover);
        }

        .list-expand-tab svg {
            width: 12px;
            height: 12px;
            color: var(--text-secondary);
        }

        .list-view.list-collapsed .list-expand-tab {
            display: flex;
        }

        .list-item {
            display: flex;
            flex-direction: column;
            padding: 7px 12px;
            cursor: pointer;
            border-bottom: 1px solid rgba(48, 54, 61, 0.4);
            transition: background var(--transition-fast), border-left-color var(--transition-fast);
            border-left: 2px solid transparent;
            user-select: none;
        }

        .list-item:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: -2px;
        }

        .list-item:hover {
            background: var(--bg-hover);
        }

        .list-item.active {
            background: var(--accent-subtle);
            border-left-color: var(--accent);
        }

        .list-item-index {
            font-family: var(--font-mono);
            font-size: 11px;
            font-weight: 600;
            color: var(--accent);
            margin-bottom: 2px;
        }

        .list-item-preview {
            font-family: var(--font-mono);
            font-size: 11px;
            color: var(--text-secondary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .list-detail {
            flex: 1;
            min-width: 0;
            overflow: hidden;
            background: var(--bg-primary);
            display: flex;
        }

        .list-detail-linenos {
            flex-shrink: 0;
            padding: 12px 0;
            background: var(--bg-secondary);
            border-right: 1px solid var(--border-light);
            user-select: none;
            overflow: hidden;
            text-align: right;
            font-family: var(--font-mono);
            font-size: 13px;
            line-height: 1.65;
            color: var(--text-muted);
            min-width: 48px;
        }

        .list-detail-linenos span {
            display: block;
            padding: 0 12px 0 8px;
        }

        .list-detail-content {
            flex: 1;
            min-width: 0;
            min-height: 0;
            overflow: auto;
        }

        .list-detail-content pre {
            margin: 0;
            padding: 12px 16px;
            background: transparent !important;
        }

        .list-detail-content code {
            font-family: var(--font-mono) !important;
            font-size: 13px !important;
            line-height: 1.65 !important;
            background: transparent !important;
        }

        /* ========== JSON Tree View ========== */
        .json-tree {
            padding: 12px 16px;
            font-family: var(--font-mono);
            font-size: 13px;
            line-height: 1.65;
            white-space: pre-wrap;
            word-break: break-all;
        }

        .jt-line {
            display: block;
            min-height: 21px;
        }

        .jt-key {
            color: #79c0ff;
        }

        .jt-string {
            color: #a5d6ff;
        }

        .jt-number {
            color: #79c0ff;
        }

        .jt-bool {
            color: #ff7b72;
        }

        .jt-null {
            color: #8b949e;
            font-style: italic;
        }

        .jt-bracket {
            color: #c9d1d9;
        }

        .jt-comma {
            color: #c9d1d9;
        }

        .jt-toggle {
            display: inline-block;
            width: 16px;
            cursor: pointer;
            user-select: none;
            color: var(--text-muted);
            font-size: 10px;
            text-align: center;
            transition: color var(--transition-fast);
            transform-origin: center;
        }

        .jt-toggle:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: 1px;
            border-radius: 2px;
        }

        .jt-toggle:hover {
            color: var(--text-primary);
        }

        .jt-children {
            padding-left: 20px;
            border-left: 1px solid rgba(48, 54, 61, 0.5);
            margin-left: 8px;
        }

        .jt-collapsed-summary {
            display: none;
            color: var(--text-muted);
            font-style: italic;
        }

        .jt-group.collapsed .jt-collapsed-summary {
            display: inline;
        }

        .jt-group.collapsed .jt-children,
        .jt-group.collapsed .jt-closing {
            display: none;
        }

        .jt-group.collapsed .jt-toggle {
            transform: none;
        }

        /* ========== Search Match Highlight ========== */
        mark.jt-match {
            background: rgba(255, 193, 7, 0.35);
            color: inherit;
            border-radius: 2px;
            padding: 0 1px;
        }

        mark.jt-match.active {
            background: #ffb300;
            color: #1f2328;
            box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
        }

        mark.jt-match.active.jt-key {
            color: #1f2328;
        }

        /* 列表视图中命中项行高亮（搜索提示） */
        .list-item.has-match {
            background: var(--accent-subtle);
            border-left-color: var(--accent);
        }

        @media (max-width: 900px) {
            .list-panel { width: 40%; min-width: 120px; }
        }

        @media (max-width: 600px) {
            .list-panel { width: 45%; min-width: 100px; }
            .list-item { padding: 5px 8px; }
            .list-item-index, .list-item-preview { font-size: 10px; }
        }

        /* ========== Drag & Drop Overlay ========== */
        .drop-overlay {
            display: flex;
            position: absolute;
            inset: 0;
            background: rgba(88, 166, 255, 0.06);
            border: 2px dashed var(--accent);
            border-radius: 0;
            z-index: 10;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            color: var(--accent);
            font-weight: 600;
            pointer-events: none;
            gap: 8px;
            opacity: 0;
            transform: scale(0.98);
            transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
        }

        .drop-overlay.active {
            opacity: 1;
            transform: scale(1);
            -webkit-backdrop-filter: blur(2px);
            backdrop-filter: blur(2px);
        }

        .drop-overlay .svg-icon {
            width: 24px;
            height: 24px;
            transition: transform 0.3s cubic-bezier(0.32, 1.2, 0, 1);
        }

        .drop-overlay.active .svg-icon {
            transform: translateY(-2px) scale(1.1);
        }

        /* ========== Sidebar ========== */
        .sidebar {
            width: 280px;
            background: var(--bg-secondary);
            border-left: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
            transition: width var(--transition), opacity var(--transition), border-color var(--transition);
            overflow: hidden;
        }

        .sidebar.collapsed {
            width: 0;
            border-left-color: transparent;
            opacity: 0;
        }

        .sidebar-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 14px;
            height: 32px;
            border-bottom: 1px solid var(--border-light);
            flex-shrink: 0;
        }

        .sidebar-header h2 {
            font-size: 11px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: var(--text-secondary);
        }

        .sidebar-toggle {
            width: 24px;
            height: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 12px;
            border-radius: 4px;
            transition: color var(--transition-fast), background var(--transition-fast);
            touch-action: manipulation;
        }

        .sidebar-toggle:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: 1px;
        }

        .sidebar-toggle:hover {
            color: var(--text-primary);
            background: var(--bg-hover);
        }

        .history-list {
            flex: 1;
            overflow-y: auto;
            padding: 6px;
        }

        .history-empty {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 40px 16px;
            color: var(--text-muted);
            text-align: center;
            font-size: 12px;
            gap: 8px;
            height: 100%;
        }

        .history-empty .svg-icon {
            width: 28px;
            height: 28px;
            opacity: 0.3;
        }

        .history-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
            border-radius: var(--radius);
            cursor: pointer;
            transition: background var(--transition-fast), border-color var(--transition-fast);
            margin-bottom: 2px;
            border: 1px solid transparent;
        }

        .history-item:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: -2px;
        }

        .history-item:hover {
            background: var(--bg-hover);
        }

        .history-item.selected {
            background: var(--accent-subtle);
            border-color: rgba(88, 166, 255, 0.25);
        }

        .history-checkbox {
            accent-color: var(--accent);
            width: 14px;
            height: 14px;
            cursor: pointer;
            flex-shrink: 0;
            touch-action: manipulation;
        }

        .history-info {
            flex: 1;
            min-width: 0;
            display: block;
            text-align: left;
            background: transparent;
            border: none;
            padding: 0;
            margin: 0;
            color: inherit;
            font: inherit;
            cursor: pointer;
            touch-action: manipulation;
        }

        .history-info:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: -2px;
            border-radius: 2px;
        }

        .history-name {
            display: block;
            font-size: 12px;
            font-weight: 500;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .history-snippet {
            display: block;
            font-size: 11px;
            color: var(--text-muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            margin-top: 2px;
            font-family: var(--font-mono);
        }

        .history-delete {
            width: 22px;
            height: 22px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 14px;
            border-radius: 3px;
            opacity: 0;
            transition: color var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast);
            flex-shrink: 0;
            touch-action: manipulation;
        }

        .history-delete:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: 1px;
            opacity: 1;
        }

        .history-item:hover .history-delete { opacity: 1; }

        .history-delete:hover { color: var(--red); background: var(--red-bg); }

        .sidebar-footer {
            padding: 8px;
            border-top: 1px solid var(--border-light);
            flex-shrink: 0;
        }

        .compare-actions {
            display: flex;
            /* 保险: 长语言按钮行放不下时换行, 保证按钮完整可点 */
            flex-wrap: wrap;
            gap: 6px;
        }

        .compare-actions .btn { flex: 1; justify-content: center; font-size: 11px; padding: 4px 8px; height: 28px; }

        /* ========== Modal ========== */
        .modal-backdrop {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(1, 4, 9, 0.7);
            z-index: 1000;
            align-items: center;
            justify-content: center;
            animation: fade-in 0.15s ease;
            overscroll-behavior: contain;
        }

        @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

        .modal-backdrop.active { display: flex; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

        .modal {
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: 24px;
            width: 360px;
            box-shadow: var(--shadow-lg), var(--shadow-glow);
            animation: modal-slide-up 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        }

        @keyframes modal-slide-up {
            from { transform: translateY(16px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }

        .modal h3 {
            font-size: 15px;
            font-weight: 600;
            margin-bottom: 16px;
            color: var(--text-primary);
            letter-spacing: -0.2px;
            text-wrap: balance;
        }

        .sidebar-header h2 {
            text-wrap: balance;
        }

        .modal input[type="text"] {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid var(--border);
            border-radius: var(--radius);
            background: var(--bg-primary);
            color: var(--text-primary);
            font-size: 13px;
            font-family: var(--font-sans);
            outline: none;
            transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
        }

        .modal input[type="text"]:focus-visible {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px var(--accent-subtle);
            outline: 2px solid var(--accent);
            outline-offset: 1px;
        }

        .modal-actions {
            display: flex;
            /* 保险: 长语言按钮行放不下时换行, 保证按钮完整可点 */
            flex-wrap: wrap;
            justify-content: flex-end;
            gap: 8px;
            margin-top: 18px;
        }

        .save-as-new {
            display: flex;
            align-items: center;
            gap: 6px;
            margin-top: 10px;
            font-size: 12px;
            color: var(--text-secondary);
            cursor: pointer;
            user-select: none;
        }

        .save-as-new input[type="checkbox"] { accent-color: var(--accent); }

        .modal-actions .btn { height: 32px; padding: 6px 14px; }

        /* ========== Compare View ========== */
        .compare-container {
            position: fixed;
            inset: 0;
            background: var(--bg-primary);
            z-index: 900;
            display: none;
            flex-direction: column;
            animation: fade-in 0.15s ease;
            overscroll-behavior: contain;
            /* iOS safe area: 上下避开刘海/灵动岛/Home 指示条。
               左右不在这里加 —— 否则横屏时对比内容区两侧会出现空白,
               横屏状态栏的避让由 .compare-header 自己处理 */
            padding-top: env(safe-area-inset-top, 0px);
            padding-bottom: env(safe-area-inset-bottom, 0px);
        }

        .compare-container.active { display: flex; }

        .compare-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            /* 横屏时状态栏出现在左侧(刘海侧), 标题/按钮需避让 */
            padding: 0 16px;
            padding-left: calc(16px + env(safe-area-inset-left, 0px));
            padding-right: calc(16px + env(safe-area-inset-right, 0px));
            height: 44px;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
        }

        .compare-header .title {
            font-size: 14px;
            font-weight: 600;
            color: var(--text-primary);
            letter-spacing: -0.2px;
        }

        .compare-header .actions {
            display: flex;
            gap: 6px;
        }

        .compare-body {
            flex: 1;
            display: flex;
            position: relative;
            min-height: 0;
        }

        .compare-col {
            flex: 1;
            display: flex;
            flex-direction: column;
            min-width: 0;
            overflow: hidden;
        }

        .compare-col-header {
            padding: 0 14px;
            height: 30px;
            display: flex;
            align-items: center;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border-light);
            font-size: 12px;
            font-weight: 600;
            color: var(--accent);
            flex-shrink: 0;
        }

        .compare-content {
            flex: 1;
            overflow: auto;
            font-family: var(--font-mono);
            font-size: 13px;
            line-height: 1.65;
        }

        .compare-divider {
            width: 1px;
            background: var(--border);
            flex-shrink: 0;
        }

        /* Diff tree highlight styles */
        .jt-diff-added > .jt-line:first-child,
        .jt-diff-added > .jt-line.jt-closing,
        .jt-diff-added.jt-line {
            background: rgba(63, 185, 80, 0.12);
        }

        .jt-diff-removed > .jt-line:first-child,
        .jt-diff-removed > .jt-line.jt-closing,
        .jt-diff-removed.jt-line {
            background: rgba(248, 81, 73, 0.12);
        }

        .jt-diff-changed > .jt-line:first-child,
        .jt-diff-changed > .jt-line.jt-closing,
        .jt-diff-changed.jt-line {
            background: rgba(210, 153, 34, 0.12);
        }

        .jt-diff-removed > .jt-line:first-child,
        .jt-diff-removed.jt-line {
            background: rgba(248, 81, 73, 0.12);
        }

        .jt-diff-changed > .jt-line:first-child,
        .jt-diff-changed.jt-line {
            background: rgba(210, 153, 34, 0.12);
        }

        .jt-diff-placeholder {
            color: var(--text-muted);
            font-style: italic;
        }

        .diff-empty {
            opacity: 0.35;
        }

        /* ========== Toast ========== */
        .toast {
            position: fixed;
            bottom: 24px;
            left: 50%;
            transform: translateX(-50%) translateY(20px);
            background: var(--bg-elevated);
            color: var(--text-primary);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            padding: 8px 18px;
            font-size: 12.5px;
            box-shadow: var(--shadow-lg);
            z-index: 2000;
            transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease;
            pointer-events: none;
            opacity: 0;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 6px;
            will-change: transform, opacity;
        }

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

        .toast .svg-icon-sm { flex-shrink: 0; }

        /* ========== Status Bar ========== */
        .statusbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 14px;
            height: 24px;
            background: var(--bg-secondary);
            border-top: 1px solid var(--border);
            font-size: 11px;
            color: var(--text-muted);
            flex-shrink: 0;
            user-select: none;
            transition: background 0.3s ease;
        }

        .statusbar.flash {
            background: var(--accent-subtle);
        }

        .statusbar-left, .statusbar-right {
            display: flex;
            align-items: center;
            gap: 14px;
            /* 长语言(如德语)下允许收缩, 配合子级省略号截断, 避免撑破 24px 状态栏 */
            min-width: 0;
        }

        .statusbar-left { font-family: var(--font-mono); }

        #status-msg {
            transition: opacity 0.15s ease, transform 0.15s ease;
        }

        /* 状态栏文案超宽时省略号截断(如德语快捷键提示), 保证单行不溢出;
           子项 overflow:hidden 同时使 flex min-width:auto 归零, 让收缩生效 */
        #status-msg,
        #status-shortcuts {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        #status-msg.updating {
            opacity: 0;
            transform: translateY(-4px);
        }

        /* ========== Sidebar Toggle Buttons ========== */
        #sidebar-open-btn {
            transition: background var(--transition), color var(--transition);
        }

        #sidebar-open-btn:focus-visible {
            outline: 2px solid var(--border-focus);
            outline-offset: 1px;
        }

        #sidebar-open-btn:hover {
            background: var(--bg-hover) !important;
            color: var(--text-primary) !important;
        }

        /* ========== Responsive ========== */
        @media (max-width: 900px) {
            /* 设备层保持 desktop 的窄窗口布局 (v1.5.62 起):
               输入/输出纵向堆叠, 历史侧栏变底部区域(可折叠), 状态栏常驻贴底。
               main-layout 必须一起转纵向, 否则 100% 宽的 sidebar 会把编辑区挤碎。 */
            .main-layout { flex-direction: column; }
            .editor-area { flex-direction: column; }
            .panel-left { border-right: none; border-bottom: 2px solid var(--border); }
            .sidebar {
                width: 100%;
                border-left: none;
                border-top: 1px solid var(--border);
                max-height: 260px;
            }
            .sidebar.collapsed { max-height: 0; width: 100%; }
            .btn .shortcut { display: none; }
            .btn { padding: 4px 8px; font-size: 11px; }
            header { padding: 0 12px; }
            /* 顶栏溢出滚动已提升到 .toolbar 基础规则(全宽度生效) */
        }

        [data-device="desktop"] .mobile-only { display: none !important; }

        [data-device="desktop"] .sidebar-overlay { display: none; }

        /* ========== Background Image Layer ========== */
        .bg-image-layer {
            position: fixed;
            inset: 0;
            z-index: 0;
            pointer-events: none;
            background-repeat: no-repeat;
            background-position: center center;
            background-size: cover;
            opacity: 0;
            transition: opacity var(--transition);
        }

        .bg-image-layer.has-image {
            opacity: var(--bg-image-opacity, 0.25);
        }

        /* When background image is active, make editor panels translucent so bg shows through */
        body.has-bg-image #input,
        body.has-bg-image .output-wrap {
            background: var(--bg-input-translucent);
            backdrop-filter: blur(2px);
            -webkit-backdrop-filter: blur(2px);
        }

        body.has-bg-image .output-linenos {
            background: var(--bg-secondary-translucent);
            backdrop-filter: blur(2px);
            -webkit-backdrop-filter: blur(2px);
        }

        /* Ensure app content sits above the background image.
           Only target elements that don't already have position set. */
        header, .mobile-only, .main-layout, .statusbar {
            position: relative;
            z-index: 1;
        }

        /* compare-container (.900), modal-backdrop (.1000), toast (.2000)
           already use position: fixed and higher z-index — left untouched. */

        /* ========== Watermark Layer ==========
           Sits above content (z-index 950) but below modal (1000) and toast (2000),
           so screenshots of the working area always carry the watermark. */
        .watermark-layer {
            position: fixed;
            inset: 0;
            z-index: 950;
            pointer-events: none;
            background-repeat: repeat;
            background-size: auto;
            background-position: 0 0;
            /* 横屏刘海屏：安全区内也能铺满而不是两边留白 */
            padding-left: env(safe-area-inset-left, 0px);
            padding-right: env(safe-area-inset-right, 0px);
            padding-top: env(safe-area-inset-top, 0px);
            padding-bottom: env(safe-area-inset-bottom, 0px);
            background-origin: content-box;
            opacity: 0;
            transition: opacity var(--transition);
            will-change: opacity;
            box-sizing: border-box;
        }

        .watermark-layer.active {
            opacity: var(--watermark-opacity, 0.15);
        }

        /* ========== Settings Modal ========== */
        .settings-modal {
            width: 380px;
            max-height: calc(100dvh - 48px);
            overflow-y: auto;
        }

        .settings-section {
            padding: 12px 0;
            border-bottom: 1px solid var(--border-light);
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .settings-section:last-of-type { border-bottom: none; }

        .settings-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin: 0;
        }

        .settings-label {
            font-size: 12px;
            font-weight: 500;
            color: var(--text-secondary);
            flex-shrink: 0;
        }

        .settings-hint {
            font-size: 11px;
            color: var(--text-muted);
        }

        .settings-row input[type="text"] {
            flex: 1;
            min-width: 0;
        }

        .settings-row input[type="range"] {
            flex: 1;
            min-width: 0;
            accent-color: var(--accent);
            cursor: pointer;
        }

        .bg-image-row {
            justify-content: flex-start;
            /* 保险: 长语言按钮行放不下时换行 */
            flex-wrap: wrap;
        }

        .bg-image-row .btn {
            flex: 0 0 auto;
        }

        .settings-modal .modal-actions {
            justify-content: flex-end;
            gap: 8px;
        }

        /* Range input theming for cross-browser consistency */
        input[type="range"] {
            height: 4px;
            background: var(--bg-input);
            border-radius: 2px;
            border: 1px solid var(--border-light);
        }
