/* JSON格式化工具样式 */

:root {
    --card-bg: rgba(255, 255, 255, 0.98);
    --bg-secondary: rgba(244, 247, 252, 0.96);
    --input-bg: rgba(255, 255, 255, 0.96);
    --hover-bg: rgba(0, 0, 0, 0.06);
    --active-bg: rgba(0, 0, 0, 0.12);
    --border-color: rgba(15, 23, 42, 0.08);
    --text-primary: #1f2937; /* 浅色模式主要文本颜色 */
    --text-secondary: #4b5563; /* 浅色模式次要文本颜色 */
    --text-muted: #6b7280;
    --primary-hover: #0066d6;
    --primary-color-alpha: rgba(0, 122, 255, 0.18);
    --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 18px 40px rgba(15, 23, 42, 0.12);
    --error-bg: rgba(255, 59, 48, 0.08);
    --json-key-color: #1d4ed8;
    --json-string-color: #0f766e;
    --json-number-color: #b45309;
    --json-boolean-color: #a21caf;
    --json-null-color: #6b7280;
    --json-url-color: #0369a1;
    --fold-placeholder-bg: rgba(59, 130, 246, 0.08);
    --fold-placeholder-border: rgba(59, 130, 246, 0.45);
    --fold-placeholder-hover-bg: rgba(59, 130, 246, 0.14);
    --fold-placeholder-hover-border: rgba(59, 130, 246, 0.6);
    --editor-font-size: 14px;
    --history-panel-width: 260px;
    --history-panel-collapsed-width: 44px;
    --tooltip-bg: rgba(17, 24, 39, 0.92);
    --surface-color: rgba(255, 255, 255, 0.95);
    --page-bg: #f8fafc;
    --panel-radius: 18px;
    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(59, 130, 246, 0.35);
    --scrollbar-thumb-hover: rgba(59, 130, 246, 0.55);
    --indent-guide-color: rgba(0, 122, 255, 0.18);
    --indent-guide-display: block;
}

body[data-theme='dark'] {
    --card-bg: rgba(28, 28, 30, 0.92);
    --bg-secondary: rgba(44, 44, 46, 0.88);
    --input-bg: rgba(28, 28, 30, 0.88);
    --hover-bg: rgba(255, 255, 255, 0.08);
    --active-bg: rgba(255, 255, 255, 0.12);
    --border-color: rgba(148, 163, 184, 0.28);
    --text-primary: #ffffff;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --primary-hover: #3b82f6;
    --indent-guide-color: rgba(59, 130, 246, 0.3);
    --primary-color-alpha: rgba(59, 130, 246, 0.22);
    --shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 28px 60px rgba(0, 0, 0, 0.55);
    --error-bg: rgba(255, 59, 48, 0.12);
    --json-key-color: #60a5fa;
    --json-string-color: #34d399;
    --json-number-color: #facc15;
    --json-boolean-color: #f472b6;
    --json-null-color: #d1d5db;
    --json-url-color: #38bdf8;
    --fold-placeholder-bg: rgba(59, 130, 246, 0.16);
    --fold-placeholder-border: rgba(96, 165, 250, 0.75);
    --fold-placeholder-hover-bg: rgba(96, 165, 250, 0.28);
    --fold-placeholder-hover-border: rgba(147, 197, 253, 0.9);
    --tooltip-bg: rgba(55, 65, 81, 0.95);
    --surface-color: rgba(44, 44, 46, 0.95);
    --page-bg: #1a1a1a;
    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(96, 165, 250, 0.45);
    --scrollbar-thumb-hover: rgba(147, 197, 253, 0.6);
}

/* 全局滚动条样式，保持与 ChatGPT 相似的轻量效果 */
.json-formatter-page,
.json-formatter-page * {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.json-formatter-page::-webkit-scrollbar,
.json-formatter-page *::-webkit-scrollbar {
    width: 6px;
}

.json-formatter-page::-webkit-scrollbar-track,
.json-formatter-page *::-webkit-scrollbar-track {
    background: transparent;
}

.json-formatter-page::-webkit-scrollbar-thumb,
.json-formatter-page *::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 999px;
}

.json-formatter-page::-webkit-scrollbar-thumb:hover,
.json-formatter-page *::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover);
}

html,
body {
    height: 100%;
    scroll-behavior: smooth;
    background-color: var(--page-bg);
    overflow-x: hidden;
}

body[data-theme='dark'] .search-nav-btn {
    background: rgba(59, 130, 246, 0.45);
    color: #e0f2fe;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35);
}

body[data-theme='dark'] .search-nav-btn:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.65);
    color: #ffffff;
}

body[data-theme='dark'] .search-nav-btn:disabled {
    background: rgba(59, 130, 246, 0.22);
    color: rgba(224, 242, 254, 0.65);
    box-shadow: none;
}

@media (prefers-color-scheme: dark) {
    body:not([data-theme]) {
        --card-bg: rgba(28, 28, 30, 0.92);
        --bg-secondary: rgba(44, 44, 46, 0.88);
        --input-bg: rgba(28, 28, 30, 0.88);
        --hover-bg: rgba(255, 255, 255, 0.08);
        --active-bg: rgba(255, 255, 255, 0.12);
        --border-color: rgba(148, 163, 184, 0.28);
        --text-primary: #ffffff;
        --text-secondary: #d1d5db;
        --text-muted: #9ca3af;
        --primary-hover: #3b82f6;
        --primary-color-alpha: rgba(59, 130, 246, 0.22);
        --shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.45);
        --shadow-md: 0 28px 60px rgba(0, 0, 0, 0.55);
        --error-bg: rgba(255, 59, 48, 0.12);
        --json-key-color: #60a5fa;
        --json-string-color: #34d399;
        --json-number-color: #facc15;
        --json-boolean-color: #f472b6;
        --json-null-color: #d1d5db;
        --json-url-color: #38bdf8;
        --fold-placeholder-bg: rgba(59, 130, 246, 0.16);
        --fold-placeholder-border: rgba(96, 165, 250, 0.75);
        --fold-placeholder-hover-bg: rgba(96, 165, 250, 0.28);
        --fold-placeholder-hover-border: rgba(147, 197, 253, 0.9);
        --tooltip-bg: rgba(55, 65, 81, 0.95);
        --surface-color: rgba(44, 44, 46, 0.95);
        --page-bg: #1a1a1a;
        --scrollbar-track: transparent;
        --scrollbar-thumb: rgba(96, 165, 250, 0.45);
        --scrollbar-thumb-hover: rgba(147, 197, 253, 0.6);
        background-color: #1a1a1a;
    }

    body:not([data-theme]) .search-nav-btn {
        background: rgba(59, 130, 246, 0.45);
        color: #e0f2fe;
        box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35);
    }

    body:not([data-theme]) .search-nav-btn:hover:not(:disabled) {
        background: rgba(59, 130, 246, 0.65);
        color: #ffffff;
    }

    body:not([data-theme]) .search-nav-btn:disabled {
        background: rgba(59, 130, 246, 0.22);
        color: rgba(224, 242, 254, 0.65);
        box-shadow: none;
    }
}

body.resizing {
    cursor: col-resize;
    user-select: none;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.json-formatter-page {
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    color: var(--text-primary);
    overflow: visible;
}

.json-formatter-page .main-content {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 100%;
    gap: 1.5rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
}

.json-formatter-layout {
    display: grid;
    grid-template-rows: auto 1fr;
    width: 100%;
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}

.control-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    box-shadow: none;
    padding: 0 1rem;
}

.control-panel__info {
    flex: 1 1 240px;
    min-width: 0;
}

.control-panel__title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.control-panel__subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.control-panel__actions {
    flex: 1 1 320px;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.control-panel__actions > * {
    flex-shrink: 0;
}


.content-layout {
    display: grid;
    grid-template-columns: minmax(var(--history-panel-width), 320px) minmax(0, 1fr);
    grid-template-areas: 'history workspace';
    align-items: stretch;
    min-width: 0;
    min-height: 0;
    height: 100%;
}

.workspace-area {
    grid-area: workspace;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
    min-height: 0;
    overflow: visible;
}

.history-panel {
    grid-area: history;
    width: 100%;
    padding: 0.75rem 1.25rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    background: var(--surface-color);
    border: none;
    border-right: 1px solid var(--border-color);
    box-shadow: none;
    min-height: 0;
    height: 100%;
}

.history-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.history-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.history-header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.history-clear-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    padding: 0.4rem 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    font-size: 0.85rem;
    font-weight: 500;
    position: relative;
}

.history-clear-btn svg {
    transition: transform 0.2s ease;
}

.history-clear-btn:hover {
    background: var(--hover-bg);
    color: #ef4444;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.history-clear-btn:focus-visible {
    color: #ef4444;
}

.history-clear-btn:hover svg {
    transform: rotate(-6deg);
}

.history-list {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    overflow: auto;
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 999px;
}

.history-list::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover);
}

.history-empty {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.75rem 1.25rem;
    border-radius: 0;
}

.history-body.has-items .history-empty {
    display: none;
}

.history-item {
    display: flex;
    align-items: stretch;
    gap: 0.6rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.history-item:hover {
    transform: translateY(-1px);
    background: var(--hover-bg);
}

.history-item-main {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    text-align: left;
    color: var(--text-primary);
    cursor: pointer;
}

.history-item-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.history-item-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-color);
}

.history-item-snippet {
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
    max-height: 3.2em;
    overflow: hidden;
    word-break: break-all;
}

.history-item-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.history-item-delete {
    border: none;
    background: transparent;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.history-item-delete:hover {
    background: var(--hover-bg);
    color: #ef4444;
    transform: rotate(-6deg);
}

.history-toggle-bar {
    display: flex;
    justify-content: right;
    width: 100%;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border-color);
}

.history-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    padding: 0.5rem 0.85rem;
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s ease, transform 0.2s ease;
    justify-content: center;
    position: relative;
}

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

.history-toggle svg {
    transition: transform 0.3s ease;
    transform: rotate(180deg);
}

.history-collapsed .history-panel {
    padding: 0.75rem 0 0.75rem 0;
    align-items: center;
    gap: 0;
    border-right: 1px solid var(--border-color);
}

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

.history-collapsed .history-toggle-bar {
    border-bottom: none;
    padding-bottom: 0;
    flex: 1;
    display: flex;
    justify-content: center;
}

.history-collapsed .history-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
}

.history-collapsed .history-toggle span {
    display: none;
}

.history-collapsed .history-toggle svg {
    transform: rotate(0deg);
}

.history-collapsed .content-layout {
    grid-template-columns: minmax(var(--history-panel-collapsed-width), var(--history-panel-collapsed-width)) minmax(0, 1fr);
}

.workspace {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

.editor-panel {
    width: 100%;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    background: var(--surface-color);
    border: none;
    box-shadow: none;
    flex: 1 1 auto;
    min-height: 0;
}

.editor-search {
    position: static;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    max-width: 360px;
    width: 100%;
    margin-left: 0;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.editor-search:focus-within {
    border-color: rgba(0, 122, 255, 0.4);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.editor-search .search-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.editor-search .search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.editor-search .search-icon svg {
    width: 18px;
    height: 18px;
}

.editor-search input {
    border: none !important;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    flex: 1;
    min-width: 0;
    width: 100%;
    box-shadow: none !important;
}

.editor-search input::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

.editor-search input:focus {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

.editor-search .search-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    margin: 0 4px;
}

.editor-search .search-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.search-nav-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(173, 216, 230, 0.6); /* 淡蓝色背景 */
    color: #2563eb; /* 蓝色文字 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.search-nav-btn svg {
    width: 14px;
    height: 14px;
}

.search-nav-btn:hover:not(:disabled) {
    background: rgba(135, 206, 235, 0.8); /* 悬停时颜色加深 */
    color: #1d4ed8; /* 悬停时文字颜色加深 */
}

.search-nav-btn:disabled {
    cursor: not-allowed;
    opacity: 0.4;
    background: rgba(173, 216, 230, 0.3); /* 禁用状态保持淡蓝色但更透明 */
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #f59e0b;
    padding: 0;
    font-size: 0;
    line-height: 1;
    flex-shrink: 0;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, transform 0.2s ease;
    box-shadow: none;
    position: relative;
}

.theme-toggle-btn:hover {
    background: var(--hover-bg);
    transform: translateY(-1px);
}

.theme-toggle-btn:focus-visible {
    outline: none;
    background: var(--hover-bg);
    box-shadow: 0 0 0 3px var(--primary-color-alpha);
}

.theme-toggle-btn .theme-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: inherit;
}

.theme-toggle-btn svg {
    display: block;
    width: 22px;
    height: 22px;
}

.theme-toggle-btn[data-theme='light'] .theme-icon--moon,
.theme-toggle-btn[data-theme='dark'] .theme-icon--sun {
    display: none;
}

.theme-toggle-btn[data-theme='dark'] {
    color: #60a5fa;
}

body[data-theme='dark'] .theme-toggle-btn {
    background: transparent;
    box-shadow: none;
}

body[data-theme='dark'] .theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

body[data-theme='dark'] .theme-toggle-btn:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.35);
}

.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.toolbar-search {
    margin-left: auto;
    flex: 0 1 clamp(240px, 32vw, 360px);
    min-width: 240px;
    max-width: 360px;
    width: 100%;
}

.toolbar-btn {
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    position: relative;
}

.toolbar-btn svg {
    width: 20px;
    height: 20px;
    overflow: visible;
}

.toolbar-btn.with-label {
    width: auto;
    height: auto;
    min-height: 38px;
    padding: 0.35rem 0.9rem;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.toolbar-btn.with-label .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn.with-label .btn-label {
    white-space: nowrap;
}

.toolbar-btn.with-label svg {
    width: 18px;
    height: 18px;
    overflow: visible;
}

[data-tooltip] {
    position: relative;
}

[data-tooltip]::before,
[data-tooltip]::after {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease-out, transform 0.12s ease-out;
    z-index: 1500;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    background: var(--tooltip-bg);
    color: #fff;
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    font-size: 0.75rem;
    line-height: 1.1;
    white-space: nowrap;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
    letter-spacing: 0.01em;
}

[data-tooltip]::before {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--tooltip-bg);
    border-radius: 2px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
    z-index: 1499;
}

[data-tooltip]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

[data-tooltip]:not([data-tooltip-position])::after,
[data-tooltip][data-tooltip-position="top"]::after {
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translate(-50%, 6px);
}

[data-tooltip]:not([data-tooltip-position])::before,
[data-tooltip][data-tooltip-position="top"]::before {
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translate(-50%, 10px) rotate(45deg);
}

[data-tooltip][data-tooltip-position="right"]::after {
    top: 50%;
    left: calc(100% + 12px);
    transform: translate(6px, -50%);
}

[data-tooltip][data-tooltip-position="right"]::before {
    top: 50%;
    left: calc(100% + 6px);
    transform: translate(2px, -50%) rotate(45deg);
}

[data-tooltip][data-tooltip-position="left"]::after {
    top: 50%;
    right: calc(100% + 12px);
    transform: translate(-6px, -50%);
}

[data-tooltip][data-tooltip-position="left"]::before {
    top: 50%;
    right: calc(100% + 6px);
    transform: translate(-2px, -50%) rotate(45deg);
}

[data-tooltip][data-tooltip-position="bottom"]::after {
    top: calc(100% + 12px);
    left: 50%;
    transform: translate(-50%, -6px);
}

[data-tooltip][data-tooltip-position="bottom"]::before {
    top: calc(100% + 6px);
    left: 50%;
    transform: translate(-50%, -10px) rotate(45deg);
}

[data-tooltip]:not([data-tooltip-position]):hover::after,
[data-tooltip]:not([data-tooltip-position]):focus-visible::after,
[data-tooltip][data-tooltip-position="top"]:hover::after,
[data-tooltip][data-tooltip-position="top"]:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, -2px);
}

[data-tooltip]:not([data-tooltip-position]):hover::before,
[data-tooltip]:not([data-tooltip-position]):focus-visible::before,
[data-tooltip][data-tooltip-position="top"]:hover::before,
[data-tooltip][data-tooltip-position="top"]:focus-visible::before {
    opacity: 1;
    transform: translate(-50%, -2px) rotate(45deg);
}

[data-tooltip][data-tooltip-position="right"]:hover::after,
[data-tooltip][data-tooltip-position="right"]:focus-visible::after {
    opacity: 1;
    transform: translate(-2px, -50%);
}

[data-tooltip][data-tooltip-position="right"]:hover::before,
[data-tooltip][data-tooltip-position="right"]:focus-visible::before {
    opacity: 1;
    transform: translate(-4px, -50%) rotate(45deg);
}

[data-tooltip][data-tooltip-position="left"]:hover::after,
[data-tooltip][data-tooltip-position="left"]:focus-visible::after {
    opacity: 1;
    transform: translate(2px, -50%);
}

[data-tooltip][data-tooltip-position="left"]:hover::before,
[data-tooltip][data-tooltip-position="left"]:focus-visible::before {
    opacity: 1;
    transform: translate(4px, -50%) rotate(45deg);
}

[data-tooltip][data-tooltip-position="bottom"]:hover::after,
[data-tooltip][data-tooltip-position="bottom"]:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 2px);
}

[data-tooltip][data-tooltip-position="bottom"]:hover::before,
[data-tooltip][data-tooltip-position="bottom"]:focus-visible::before {
    opacity: 1;
    transform: translate(-50%, 4px) rotate(45deg);
}

.toolbar-btn svg {
    pointer-events: none;
}

.toolbar-btn.primary {
    background: var(--primary-color);
    color: #fff;
    box-shadow: none;
}

.toolbar-btn.primary:hover {
    background: var(--primary-hover);
}

.toolbar-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.toolbar-btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}

.color-settings-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.color-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.color-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.color-input-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
}

@media (max-width: 520px) {
    .color-input-grid {
        grid-template-columns: 1fr;
    }
}

.color-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.color-input span {
    flex: 0 0 60px;
    text-align: left;
}

.color-input input {
    flex: 0 0 110px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    cursor: pointer;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.1rem;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 18px rgba(15, 23, 42, 0.12);
}

.action-btn.accent {
    background: var(--primary-color);
    color: #fff;
    box-shadow: none;
}

.action-btn.accent:hover {
    box-shadow: 0 12px 24px rgba(0, 122, 255, 0.25);
}

.action-btn.ghost {
    background: transparent;
    color: var(--text-muted);
}

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

.action-btn.danger {
    background: #ef4444;
    color: #fff;
    box-shadow: none;
}

.action-btn.danger:hover {
    box-shadow: 0 12px 24px rgba(239, 68, 68, 0.3);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

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

.confirm-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(2px);
    z-index: 1200;
    padding: 1.5rem;
}

body.modal-open {
    overflow: hidden;
}

.confirm-modal[hidden] {
    display: none;
}

.confirm-modal__overlay {
    position: absolute;
    inset: 0;
    cursor: pointer;
}

.confirm-modal__dialog {
    position: relative;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 2rem 2.25rem;
    width: min(420px, 100%);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
}

.confirm-modal__icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.confirm-modal__icon svg {
    width: 42px;
    height: 42px;
}

.confirm-modal__title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.confirm-modal__message {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.confirm-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.editor-wrapper {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
    padding-top: 0;
    flex: 1;
    min-height: 0;
    display: flex;
}

.json-formatter-page .CodeMirror {
    height: 100%;
    flex: 1;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, Menlo, Monaco, 'Courier New', monospace;
    font-size: var(--editor-font-size);
    background: transparent !important;
    color: var(--text-primary);
    border-radius: inherit;
}

.json-formatter-page .CodeMirror-scroll {
    border-radius: inherit;
}

.json-formatter-page .CodeMirror pre,
.json-formatter-page .CodeMirror-linenumber {
    color: inherit;
}

/* 括号配对线 */
.CodeMirror-lines {
    position: relative;
}

.bracket-pair-guide {
    position: absolute;
    width: 1px;
    background-color: var(--indent-guide-color);
    pointer-events: none;
    z-index: 1;
    opacity: 0.5;
    left: 0;
    transform-origin: left top;
    transition: opacity 0.15s ease, width 0.15s ease, background-color 0.15s ease;
}

/* 活跃的缩进线（当前光标所在行的缩进层级） */
.bracket-pair-guide.active {
    opacity: 1;
    background-color: #007aff;
}

body[data-theme='dark'] .bracket-pair-guide {
    opacity: 0.4;
}

body[data-theme='dark'] .bracket-pair-guide.active {
    opacity: 1;
    background-color: #60a5fa;
}

.json-formatter-page:not(.show-indent-guides) .bracket-pair-guide {
    display: none !important;
}

/* 当前行高亮背景 */
.json-formatter-page .CodeMirror-activeline-background {
    background-color: rgba(0, 122, 255, 0.08) !important;
}

body[data-theme='dark'] .json-formatter-page .CodeMirror-activeline-background {
    background-color: rgba(59, 130, 246, 0.12) !important;
}

/* 当前行号高亮 */
.json-formatter-page .CodeMirror-activeline-gutter .CodeMirror-linenumber {
    color: #007aff !important;
    font-weight: 700 !important;
    background-color: rgba(0, 122, 255, 0.05);
}

body[data-theme='dark'] .json-formatter-page .CodeMirror-activeline-gutter .CodeMirror-linenumber {
    color: #60a5fa !important;
    background-color: rgba(59, 130, 246, 0.08);
}

.CodeMirror-scroll {
    min-height: 0;
}

.json-formatter-page .CodeMirror-gutters {
    background: var(--input-bg) !important;
    border-right: 1px solid var(--border-color);
}

.json-formatter-page .CodeMirror-cursor {
    border-left: 2px solid var(--text-primary) !important;
}

.json-formatter-page .CodeMirror-selected {
    background: rgba(59, 130, 246, 0.2) !important;
}

.CodeMirror .cm-search-active {
    background: rgba(59, 130, 246, 0.28);
    border-radius: 3px;
}

.CodeMirror-foldgutter-open,
.CodeMirror-foldgutter-folded {
    color: var(--json-url-color);
}

.cm-line-error {
    background-color: rgba(248, 113, 113, 0.18) !important;
}

.cm-error-line-widget {
    position: relative;
    z-index: 5;
}

.cm-error-bubble {
    position: relative;
    margin: 4px 0 6px;
    padding: 10px 12px;
    background: rgba(254, 226, 226, 0.95);
    border-left: 3px solid #ef4444;
    border-radius: 10px;
    box-shadow: 0 8px 18px rgba(248, 113, 113, 0.25);
    color: #b91c1c;
    font-size: 0.85rem;
    line-height: 1.5;
    pointer-events: none;
    max-width: min(420px, calc(100% - 24px));
    white-space: normal;
}

.cm-error-bubble::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    border-width: 0 8px 8px 8px;
    border-style: solid;
    border-color: transparent transparent rgba(254, 226, 226, 0.95) transparent;
}

.cm-error-bubble__content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cm-error-bubble__line {
    white-space: pre-wrap;
    word-break: break-word;
}

.cm-error-bubble__line--primary {
    font-weight: 600;
}

@media (prefers-color-scheme: dark) {
    .cm-line-error {
        background-color: rgba(248, 113, 113, 0.28) !important;
    }

    .cm-error-bubble {
        background: rgba(127, 29, 29, 0.95);
        border-left-color: #f87171;
        box-shadow: 0 12px 24px rgba(127, 29, 29, 0.32);
        color: #fecaca;
    }

    .cm-error-bubble::before {
        border-color: transparent transparent rgba(127, 29, 29, 0.95) transparent;
    }

    .editor-wrapper {
        box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
    }

    .json-formatter-page .editor-wrapper {
        background: rgba(17, 24, 39, 0.88);
        border-color: rgba(148, 163, 184, 0.35);
        box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
    }

    .json-formatter-page .CodeMirror {
        color: #e5e7eb;
    }

    .json-formatter-page .CodeMirror pre,
    .json-formatter-page .CodeMirror-linenumber {
        color: #e5e7eb;
    }

    .json-formatter-page .CodeMirror-gutters {
        background: rgba(15, 23, 42, 0.9) !important;
        border-right: 1px solid rgba(148, 163, 184, 0.4);
    }

    .json-formatter-page .CodeMirror-linenumber {
        color: #9ca3af;
    }

    .json-formatter-page .CodeMirror-cursor {
        border-left-color: #f9fafb !important;
    }


    .json-formatter-page .CodeMirror-selected {
        background: rgba(59, 130, 246, 0.35) !important;
    }

    .success-hint {
        background: rgba(34, 197, 94, 0.2);
        border: 1px solid rgba(74, 222, 128, 0.45);
        color: #bbf7d0;
    }

    .success-hint[data-state="default"] {
        background: rgba(99, 102, 241, 0.26);
        border: 1px solid rgba(129, 140, 248, 0.45);
        color: #e0e7ff;
    }
}

.editor-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.status-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
}

.cursor-text {
    white-space: nowrap;
}

.status-text {
    font-weight: 500;
}

.status-text.valid {
    color: var(--primary-color);
}

.status-text.invalid {
    color: #ef4444;
}

.status-text.processing {
    color: #f59e0b;
}

.length-text {
    color: var(--text-muted);
}

.panel-resizer {
    width: 4px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: col-resize;
    position: relative;
    touch-action: none;
}

.resizer-grip {
    width: 2px;
    height: 48px;
    border-radius: 999px;
    background: var(--border-color);
    position: relative;
}

.panel-resizer:hover .resizer-grip,
.panel-resizer:focus-visible .resizer-grip,
body.resizing .panel-resizer .resizer-grip {
    background: var(--primary-color);
}


.utility-overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    backdrop-filter: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 90;
}

.utility-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

body.utility-panel-open {
    overflow: hidden;
}

.utility-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(420px, 100%);
    background: var(--card-bg);
    border-radius: 18px 0 0 18px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
}

.utility-panel.is-open {
    transform: translateX(0);
    pointer-events: auto;
    opacity: 1;
    box-shadow: -16px 0 40px rgba(15, 23, 42, 0.18);
}

.utility-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.utility-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.utility-close-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 0.25rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
    cursor: pointer;
}

.utility-close-btn:hover,
.utility-close-btn:focus-visible {
    background: var(--hover-bg);
    color: var(--primary-color);
    outline: none;
}

.utility-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.35rem;
}

.utility-body.custom-settings {
    gap: 1.5rem;
    padding-right: 0.15rem;
}

/* 设置面板内的tooltip向左显示，避免超出边界 */
.utility-panel [data-tooltip]::after {
    left: auto;
    right: calc(100% + 12px);
    transform: translate(6px, -50%);
}

.utility-panel [data-tooltip]::before {
    left: auto;
    right: calc(100% + 6px);
    transform: translate(2px, -50%) rotate(45deg);
}

.utility-panel [data-tooltip]:hover::after,
.utility-panel [data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translate(-2px, -50%);
}

.utility-panel [data-tooltip]:hover::before,
.utility-panel [data-tooltip]:focus-visible::before {
    opacity: 1;
    transform: translate(-4px, -50%) rotate(45deg);
}

.settings-block {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-block__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.settings-block__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-block + .settings-block {
    padding-top: 0.5rem;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

body[data-theme='dark'] .settings-block + .settings-block {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.utility-section {
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    padding: 1.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.utility-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.utility-section-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.validation-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.validation-group .success-hint {
    margin: 0;
}

.font-size-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.font-size-control label {
    font-weight: 600;
    color: var(--text-primary);
}

.toggle-control {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.toggle-control input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    margin-right: 8px;
}

.font-size-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.font-size-input input[type="range"] {
    flex: 1;
    cursor: pointer;
}

#fontSizeValue {
    min-width: 42px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.font-size-input input[type="range"]::-webkit-slider-thumb {
    cursor: pointer;
}

.font-size-input input[type="range"]::-moz-range-thumb {
    cursor: pointer;
}

.font-size-input input[type="range"]::-ms-thumb {
    cursor: pointer;
}

.indent-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.indent-controls label {
    font-weight: 600;
    color: var(--text-primary);
}

.indent-controls select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.indent-controls select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-color-alpha);
}

.settings-divider {
    height: 1px;
    background: rgba(15, 23, 42, 0.08);
    margin: 0.5rem 0;
}

body[data-theme='dark'] .settings-divider {
    background: rgba(255, 255, 255, 0.08);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.icon-btn:hover {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-primary);
}

body[data-theme='dark'] .icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn svg {
    display: block;
}

.error-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #ef4444;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.error-content {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

#errorText {
    white-space: pre-wrap;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, Menlo, Monaco, 'Courier New', monospace;
    line-height: 1.4;
}

.success-hint {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: rgba(52, 199, 89, 0.12);
    color: #15803d;
    font-size: 0.9rem;
    border: 1px solid rgba(52, 199, 89, 0.35);
}

.success-hint[data-state="default"] {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.22);
    color: var(--text-muted);
}


.cm-fold-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.15rem;
    margin: 0 0.25rem;
    border: 1px dashed var(--fold-placeholder-border);
    background: var(--fold-placeholder-bg);
    color: var(--json-url-color);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    vertical-align: middle;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.cm-fold-placeholder:hover,
.cm-fold-placeholder:focus {
    background: var(--fold-placeholder-hover-bg);
    border-color: var(--fold-placeholder-hover-border);
    outline: none;
}

/* 折叠预览气泡 */
.fold-preview-bubble {
    position: fixed;
    z-index: 10001;
    max-width: 600px;
    max-height: 400px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25), 0 4px 12px rgba(15, 23, 42, 0.15);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: auto;
}

body[data-theme='dark'] .fold-preview-bubble {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: var(--primary-color);
}

.fold-preview-bubble.visible {
    opacity: 1;
    transform: translateY(0);
}

.fold-preview-content {
    margin: 0;
    padding: 12px;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
    overflow: auto;
    max-height: 360px;
    white-space: pre;
    tab-size: 4;
}

.fold-preview-more {
    padding: 8px 12px;
    background: var(--hover-bg);
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.CodeMirror .cm-string:not(.cm-property) {
    color: var(--json-string-color) !important;
}

.CodeMirror .cm-string.cm-url {
    color: var(--json-url-color) !important;
}

.CodeMirror .cm-property {
    color: var(--json-key-color) !important;
}

.CodeMirror .cm-number {
    color: var(--json-number-color) !important;
}

.CodeMirror .cm-atom {
    color: var(--json-boolean-color) !important;
}

.CodeMirror .cm-json-boolean-token {
    color: var(--json-boolean-color) !important;
}

.CodeMirror .cm-json-null-token {
    color: var(--json-null-color) !important;
}

.CodeMirror .cm-url {
    color: var(--json-url-color) !important;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    cursor: pointer;
}

.CodeMirror .cm-url:hover {
    filter: brightness(0.9);
}

@media (max-width: 1200px) {
    .control-panel__actions {
        justify-content: flex-start;
    }

    .content-layout {
        grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
    }
}

@media (max-width: 1024px) {
    .json-formatter-page {
        height: auto;
        overflow: visible;
    }

    .json-formatter-page .main-content,
    .json-formatter-layout,
    .content-layout,
    .history-panel {
        height: auto;
        overflow: visible;
    }

    .control-panel {
        align-items: flex-start;
        padding: 1rem 1.5rem 0.75rem;
    }

    .control-panel__info {
        display: none;
    }

    .control-panel__actions {
        width: 100%;
        justify-content: flex-end;
        gap: 0.75rem;
        flex-wrap: nowrap;
        align-items: center;
    }

    .editor-toolbar {
        gap: 0.75rem;
    }

    .editor-toolbar .toolbar-group--primary,
    .editor-toolbar .toolbar-search,
    .editor-toolbar .toolbar-group--secondary {
        flex: 1 1 100%;
    }

    .editor-toolbar .toolbar-search {
        margin-left: 0;
        max-width: none;
        min-width: 0;
    }

    .editor-toolbar .toolbar-group--secondary {
        justify-content: flex-start;
    }

    .content-layout,
    .history-collapsed .content-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            'workspace'
            'history';
    }

    .history-panel {
        border-top: 1px solid var(--border-color);
        border-right: none;
    }

}

@media (max-width: 768px) {
    .json-formatter-page .main-content {
        padding: 0.75rem;
        gap: 1rem;
    }

    .control-panel {
        padding: 0.75rem 0.75rem 0.5rem;
        gap: 1rem;
    }

    .control-panel__title {
        font-size: 1.3rem;
    }

    .control-panel__actions {
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 0.75rem;
    }

    .editor-toolbar .toolbar-group--primary,
    .editor-toolbar .toolbar-search,
    .editor-toolbar .toolbar-group--secondary {
        flex: 1 1 100%;
    }

    .theme-toggle-btn {
        width: 40px;
        height: 40px;
    }

    .history-list {
        max-height: 220px;
        overflow-y: auto;
        padding-right: 0.25rem;
    }

    .history-toggle {
        display: none !important;
    }

    .utility-panel {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        padding: 1rem;
    }

    .editor-toolbar,
    .toolbar-group {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .search-nav-btn {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .json-formatter-page .CodeMirror {
        font-size: 14px;
        min-height: 300px;
    }

    .confirm-modal__dialog {
        margin: 1rem;
        padding: 1.5rem;
        width: calc(100% - 2rem);
        max-width: 400px;
    }
}

@media (max-width: 600px) {
    .control-panel__subtitle {
        font-size: 0.85rem;
    }

}

/* 全屏弹窗样式 */
.fullscreen-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.fullscreen-modal:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
}

.fullscreen-modal__overlay {
    position: absolute;
    inset: 0;
    cursor: pointer;
}

.fullscreen-modal__content {
    position: relative;
    width: 95vw;
    height: 95vh;
    max-width: 1800px;
    max-height: 1200px;
    background: var(--card-bg);
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.fullscreen-modal:not([hidden]) .fullscreen-modal__content {
    transform: scale(1);
}

.fullscreen-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
}

.fullscreen-modal__title-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.fullscreen-modal__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.fullscreen-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fullscreen-modal__info-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.fullscreen-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.fullscreen-info .info-text {
    white-space: nowrap;
}

.fullscreen-info .info-separator {
    color: var(--border-color);
}

.fullscreen-close-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

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

.fullscreen-modal__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.5rem;
    overflow: hidden;
    background: var(--page-bg);
}

.fullscreen-editor-wrapper {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
    min-height: 0;
    position: relative;
}

.fullscreen-editor-wrapper .CodeMirror {
    height: 100% !important;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.fullscreen-editor-wrapper .CodeMirror-scroll {
    height: 100%;
    overflow-y: auto !important;
}

body.fullscreen-modal-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .fullscreen-modal__content {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .fullscreen-modal__header {
        padding: 1rem 1.5rem;
    }

    .fullscreen-modal__title {
        font-size: 1.1rem;
    }

    .fullscreen-modal__body {
        padding: 1rem 1.5rem;
    }
}

body[data-theme='dark'] .fullscreen-editor-wrapper {
    background: rgba(17, 24, 39, 0.88);
    border-color: rgba(148, 163, 184, 0.35);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
    .fullscreen-editor-wrapper {
        background: rgba(17, 24, 39, 0.88);
        border-color: rgba(148, 163, 184, 0.35);
        box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
    }
}

/* 折叠按钮右键菜单 */
.fold-context-menu {
    position: fixed;
    min-width: 150px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
    z-index: 10000;
    padding: 0.25rem 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.fold-context-menu:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
}

.fold-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: background-color 0.15s ease;
    user-select: none;
}

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

.fold-menu-item:active {
    background: var(--active-bg);
}

.fold-menu-item[hidden] {
    display: none;
}

body[data-theme='dark'] .fold-context-menu {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(148, 163, 184, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
    .fold-context-menu {
        background: rgba(30, 41, 59, 0.95);
        border-color: rgba(148, 163, 184, 0.2);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }
}

/* 文档按钮样式 */
.doc-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.doc-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    transform: scale(1.05);
}

.doc-btn:active {
    transform: scale(0.95);
}

/* 文档弹窗样式 */
.doc-panel {
    position: fixed;
    inset: 0;
    z-index: 3000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.doc-panel:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
}

.doc-panel__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.doc-panel__content {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(600px, 90vw);
    background: var(--card-bg);
    box-shadow: -4px 0 24px rgba(15, 23, 42, 0.2);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.doc-panel:not([hidden]) .doc-panel__content {
    transform: translateX(0);
}

.doc-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
}

.doc-panel__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.doc-panel__close {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.doc-panel__close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.doc-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: var(--page-bg);
}

/* 文档内容样式 */
.doc-content {
    color: var(--text-primary);
}

.doc-section {
    margin-bottom: 2.5rem;
}

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

.doc-section__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.doc-subsection {
    margin-bottom: 1.5rem;
}

.doc-subsection__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.doc-subsection__icon {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
}

.doc-feature-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.doc-feature-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.doc-feature-item:last-child {
    border-bottom: none;
}

.doc-feature-item::before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.doc-feature-name {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 100px;
}

.doc-feature-desc {
    color: var(--text-muted);
    flex: 1;
}

.doc-kbd {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    font-size: 0.875em;
    font-family: monospace;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

body[data-theme='dark'] .doc-panel__content {
    background: rgba(30, 41, 59, 0.95);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
    .doc-panel__content {
        background: rgba(30, 41, 59, 0.95);
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
    }
}

@media (max-width: 768px) {
    .doc-panel__content {
        width: 100vw;
    }

    .doc-panel__header {
        padding: 1rem 1.5rem;
    }

    .doc-panel__body {
        padding: 1.5rem;
    }
}

