/* ============================================
   XML File Viewer & Formatter - xml-viewer.css
   Prefix: xfv- (xml file viewer)
   Light mode default, dark mode via [data-theme="dark"]
   Blue theme - code / file-viewer category
   Single solid colors, no gradients, no border-left: 4px
   ============================================ */

:root {
    --xfv-transition: 0.25s;

    /* Primary - blue (code / developer tools) */
    --xfv-primary: #3399cc;
    --xfv-primary-light: #dceff7;
    --xfv-primary-dark: #2b7fa9;

    /* Secondary functional colors (single, flat - no gradients) */
    --xfv-success: #339966;
    --xfv-success-light: #d6efe2;
    --xfv-warning: #d97706;
    --xfv-warning-light: #fef3c7;
    --xfv-danger: #c0392b;
    --xfv-danger-light: #fbe3df;

    /* Structure category accents (single solid colors) */
    --xfv-c-element: #3399cc;
    --xfv-c-attr: #d6608f;
    --xfv-c-ns: #8b5cf6;
    --xfv-c-text: #339966;
    --xfv-c-cdata: #0d9488;
    --xfv-c-comment: #d97706;

    /* Surfaces */
    --xfv-bg: #f5fafd;
    --xfv-bg-elevated: #ffffff;
    --xfv-bg-secondary: #eef6fb;
    --xfv-bg-tertiary: #dcecf5;

    /* Text */
    --xfv-text: #1f2937;
    --xfv-text-secondary: #374151;
    --xfv-text-muted: #6b7280;

    /* Borders */
    --xfv-border: #c7e0ee;
    --xfv-border-light: #e0eef6;

    /* Radius */
    --xfv-radius-sm: 6px;
    --xfv-radius-md: 10px;
    --xfv-radius-lg: 14px;
    --xfv-radius-xl: 18px;

    /* Code syntax (overridden per theme by JS) */
    --xml-bg: #1e1e1e;
    --xml-line-number-bg: #252526;
    --xml-text: #d4d4d4;
    --xml-line-number: #858585;
    --xml-tag: #569cd6;
    --xml-bracket: #808080;
    --xml-attr-name: #9cdcfe;
    --xml-attr-value: #ce9178;
    --xml-content-text: #d4d4d4;
    --xml-comment: #6a9955;
    --xml-cdata: #d16969;
    --xml-declaration: #c586c0;
    --xml-doctype: #c586c0;
}

/* Dark Mode - light remains the default */
[data-theme="dark"] {
    --xfv-primary: #5fb8e0;
    --xfv-primary-light: rgba(95, 184, 224, 0.16);
    --xfv-primary-dark: #3399cc;

    --xfv-success: #4ade80;
    --xfv-success-light: rgba(74, 222, 128, 0.15);
    --xfv-warning: #fbbf24;
    --xfv-warning-light: rgba(251, 191, 36, 0.15);
    --xfv-danger: #f87171;
    --xfv-danger-light: rgba(248, 113, 113, 0.15);

    --xfv-c-element: #5fb8e0;
    --xfv-c-attr: #f0729f;
    --xfv-c-ns: #a78bfa;
    --xfv-c-text: #4ade80;
    --xfv-c-cdata: #2dd4bf;
    --xfv-c-comment: #fbbf24;

    --xfv-bg: #0e1620;
    --xfv-bg-elevated: #16212e;
    --xfv-bg-secondary: #1b2937;
    --xfv-bg-tertiary: #243646;

    --xfv-text: #f3f4f6;
    --xfv-text-secondary: #d1d5db;
    --xfv-text-muted: #9ca3af;

    --xfv-border: #2a3e52;
    --xfv-border-light: #1f3041;
}

/* ============================================
   GLOBAL OVERRIDES (custom_styles.css cascade)
   ============================================ */
* { box-sizing: border-box; }

/* custom_styles.css sets .tool-main { overflow:hidden } which clips overlays */
.tool-main,
.xfv-tool-main { overflow: visible !important; }

/* Neutralize the global .upload-area::before gradient overlay */
.xfv-upload-area::before,
.xfv-upload-area::after {
    display: none !important;
    content: none !important;
}

.tool-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
}

.tool-header { text-align: center; margin-bottom: 2rem; }

.tool-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 0 0 0.75rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--xfv-primary);
}
.tool-title i { color: var(--xfv-primary); }

.tool-description {
    max-width: 800px;
    margin: 0 auto;
    color: var(--xfv-text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
}
.tool-description a {
    color: var(--xfv-primary);
    text-decoration: none;
    font-weight: 500;
}
.tool-description a:hover { text-decoration: underline; }

/* ============================================
   MAIN AREA
   ============================================ */
.xfv-tool-main {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0;
}

/* ============================================
   UPLOAD SECTION
   ============================================ */
.xfv-upload-section {
    background: var(--xfv-bg-elevated);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-xl);
    padding: 2rem;
}

.xfv-upload-area {
    border: 2px dashed var(--xfv-border);
    border-radius: var(--xfv-radius-lg);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--xfv-transition), background var(--xfv-transition), box-shadow var(--xfv-transition);
    background: var(--xfv-bg-secondary);
    position: relative;
    overflow: hidden;
    outline: none;
}
.xfv-upload-area:hover {
    border-color: var(--xfv-primary);
    background: var(--xfv-primary-light);
}
.xfv-upload-area:focus-visible {
    border-color: var(--xfv-primary);
    border-style: solid;
    box-shadow: 0 0 0 4px var(--xfv-primary-light);
}
.xfv-upload-area.dragover {
    border-color: var(--xfv-primary);
    border-style: solid;
    background: var(--xfv-primary-light);
    box-shadow: 0 0 0 4px var(--xfv-primary-light);
}

.xfv-upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.xfv-upload-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--xfv-bg-elevated);
    border: 1px solid var(--xfv-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--xfv-primary);
    margin-bottom: 0.5rem;
}

.xfv-upload-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--xfv-text);
}

.xfv-upload-subtitle {
    margin: 0 0 0.75rem;
    color: var(--xfv-text-muted);
    font-size: 0.9rem;
}

.xfv-file-types {
    display: inline-flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    margin: 0.5rem 0;
}

.xfv-file-type-badge {
    padding: 0.25rem 0.65rem;
    background: var(--xfv-bg-elevated);
    border: 1px solid var(--xfv-border);
    border-radius: 9999px;
    color: var(--xfv-primary);
    font-size: 0.75rem;
    font-weight: 600;
}

.xfv-upload-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--xfv-text-muted);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}
.xfv-upload-hint i { color: var(--xfv-success); }

/* Paste section */
.xfv-paste-section { margin-top: 1.25rem; }
.xfv-paste-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--xfv-text-muted);
    font-size: 0.82rem;
    margin: 1rem 0 0.75rem;
}
.xfv-paste-divider::before,
.xfv-paste-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--xfv-border);
}
.xfv-paste-divider span { padding: 0 0.85rem; }
.xfv-paste-textarea {
    width: 100%;
    min-height: 110px;
    resize: vertical;
    padding: 0.85rem 1rem;
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-md);
    color: var(--xfv-text);
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.55;
    outline: none;
    transition: border-color var(--xfv-transition);
}
.xfv-paste-textarea:focus { border-color: var(--xfv-primary); }
.xfv-paste-actions { display: flex; justify-content: center; margin-top: 0.75rem; }

/* ============================================
   EDITOR SECTION
   ============================================ */
.xfv-editor-section {
    background: var(--xfv-bg-elevated);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-xl);
    padding: 1.25rem;
}

/* Tab bar */
.xfv-tab-bar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--xfv-border-light);
}
.xfv-tab-bar::-webkit-scrollbar { height: 4px; }
.xfv-tab-bar::-webkit-scrollbar-thumb { background: var(--xfv-border); border-radius: 4px; }

.xfv-tab-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.8rem;
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-sm);
    color: var(--xfv-text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all var(--xfv-transition);
}
.xfv-tab-item:hover { color: var(--xfv-text); background: var(--xfv-bg-tertiary); }
.xfv-tab-item.active {
    color: var(--xfv-primary);
    border-color: var(--xfv-primary);
    background: var(--xfv-primary-light);
}
.xfv-tab-item svg,
.xfv-tab-item i { flex-shrink: 0; }

.xfv-tab-close {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 2px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 4px !important;
    color: inherit !important;
    cursor: pointer;
    box-shadow: none !important;
    transform: none !important;
}
.xfv-tab-close:hover { background: var(--xfv-danger-light) !important; color: var(--xfv-danger) !important; transform: none !important; }

.xfv-tab-add-btn,
.xfv-tab-split-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.8rem !important;
    background: var(--xfv-bg-secondary) !important;
    border: 1px solid var(--xfv-border) !important;
    border-radius: var(--xfv-radius-sm) !important;
    color: var(--xfv-text-secondary) !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: none !important;
    transform: none !important;
    transition: all var(--xfv-transition);
}
.xfv-tab-add-btn:hover,
.xfv-tab-split-btn:hover { color: var(--xfv-primary) !important; border-color: var(--xfv-primary) !important; transform: none !important; }
.xfv-tab-split-btn.active { color: var(--xfv-primary) !important; background: var(--xfv-primary-light) !important; border-color: var(--xfv-primary) !important; }

/* File info bar */
.xfv-file-info-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding: 0.65rem 0.9rem;
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-md);
    margin-bottom: 0.75rem;
}
.xfv-file-info-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--xfv-text-secondary);
    font-size: 0.85rem;
}
.xfv-file-info-item i { color: var(--xfv-primary); }
.xfv-file-info-item.xfv-valid i { color: var(--xfv-success); }
.xfv-file-info-item.xfv-valid span { color: var(--xfv-success); font-weight: 600; }
.xfv-file-info-item.xfv-invalid i { color: var(--xfv-danger); }
.xfv-file-info-item.xfv-invalid span { color: var(--xfv-danger); font-weight: 600; }

/* Toolbar */
.xfv-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.xfv-toolbar-left,
.xfv-toolbar-center,
.xfv-toolbar-right { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.xfv-toolbar-center { flex: 1; justify-content: center; min-width: 180px; }

.xfv-toolbar-divider { width: 1px; height: 24px; background: var(--xfv-border); flex-shrink: 0; }

.xfv-view-toggle {
    display: inline-flex;
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-md);
    padding: 0.2rem;
    gap: 0.15rem;
}
.xfv-view-toggle button {
    display: inline-flex !important;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.7rem !important;
    background: transparent !important;
    border: none !important;
    border-radius: var(--xfv-radius-sm) !important;
    color: var(--xfv-text-muted) !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    box-shadow: none !important;
    transform: none !important;
    transition: all var(--xfv-transition);
}
.xfv-view-toggle button:hover { color: var(--xfv-text) !important; transform: none !important; }
.xfv-view-toggle button.active {
    background: var(--xfv-primary) !important;
    color: #fff !important;
}
.xfv-view-toggle button svg,
.xfv-view-toggle button i { flex-shrink: 0; }

.xfv-search-box {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.7rem;
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-md);
    width: 100%;
    max-width: 340px;
}
.xfv-search-box i { color: var(--xfv-text-muted); flex-shrink: 0; }
.xfv-search-box input {
    flex: 1;
    min-width: 0;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: var(--xfv-text) !important;
    font-size: 0.85rem;
    box-shadow: none !important;
}
.xfv-search-box input::placeholder { color: var(--xfv-text-muted); }
.xfv-search-results { font-size: 0.78rem; color: var(--xfv-text-muted); white-space: nowrap; }
.xfv-search-regex {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 3px 6px !important;
    background: transparent !important;
    border: 1px solid var(--xfv-border) !important;
    border-radius: 4px !important;
    color: var(--xfv-text-muted) !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    cursor: pointer;
    box-shadow: none !important;
    transform: none !important;
}
.xfv-search-regex.active { background: var(--xfv-primary) !important; border-color: var(--xfv-primary) !important; color: #fff !important; }

.xfv-toolbar-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0 !important;
    background: var(--xfv-bg-secondary) !important;
    border: 1px solid var(--xfv-border) !important;
    border-radius: var(--xfv-radius-sm) !important;
    color: var(--xfv-text-secondary) !important;
    cursor: pointer;
    box-shadow: none !important;
    transform: none !important;
    transition: all var(--xfv-transition);
}
.xfv-toolbar-btn:hover { color: var(--xfv-primary) !important; border-color: var(--xfv-primary) !important; transform: none !important; }
.xfv-toolbar-btn.active-state { color: var(--xfv-primary) !important; background: var(--xfv-primary-light) !important; border-color: var(--xfv-primary) !important; }

/* Theme picker */
.xfv-theme-picker { position: relative; }
.xfv-theme-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--xfv-bg-elevated);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-md);
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 170px;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.xfv-theme-dropdown.hidden { display: none; }
.xfv-theme-option {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem !important;
    background: transparent !important;
    border: none !important;
    border-radius: var(--xfv-radius-sm) !important;
    color: var(--xfv-text-secondary) !important;
    font-size: 0.83rem !important;
    cursor: pointer;
    text-align: left;
    box-shadow: none !important;
    transform: none !important;
}
.xfv-theme-option:hover { background: var(--xfv-bg-secondary) !important; transform: none !important; }
.xfv-theme-option.active { background: var(--xfv-primary-light) !important; color: var(--xfv-primary) !important; }
.xfv-theme-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* ============================================
   SPLIT / VIEWER CONTENT
   ============================================ */
.xfv-split-container { display: grid; grid-template-columns: 1fr; gap: 0.85rem; }
.xfv-split-container.split { grid-template-columns: 1fr 1fr; }
.xfv-split-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--xfv-text-muted);
    padding: 0.35rem 0.5rem;
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-bottom: none;
    border-radius: var(--xfv-radius-md) var(--xfv-radius-md) 0 0;
}

.xfv-viewer-content {
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-md);
    overflow: hidden;
    background: var(--xml-bg);
}
.xfv-preview-panel { display: none; }
.xfv-preview-panel.active { display: block; }

.xfv-code-scroll {
    max-height: 540px;
    overflow: auto;
}
.xfv-code-scroll pre,
.xfv-xml-body {
    margin: 0;
    padding: 1rem 1.15rem;
    font-family: 'JetBrains Mono', Consolas, 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.65;
    color: var(--xml-text);
    background: var(--xml-bg);
    white-space: pre;
    tab-size: 2;
}
.xfv-xml-body.wrap,
.xfv-code-scroll pre.wrap { white-space: pre-wrap; word-break: break-word; }

.xfv-xml-line { display: block; }
.xfv-xml-line.xfv-highlight { background: rgba(255, 213, 0, 0.18); }
.xfv-xml-line.xfv-current { background: rgba(255, 213, 0, 0.32); }

/* XML token colors */
.xfv-tk-tag { color: var(--xml-tag); }
.xfv-tk-bracket { color: var(--xml-bracket); }
.xfv-tk-attr-name { color: var(--xml-attr-name); }
.xfv-tk-attr-value { color: var(--xml-attr-value); }
.xfv-tk-text { color: var(--xml-content-text); }
.xfv-tk-comment { color: var(--xml-comment); font-style: italic; }
.xfv-tk-cdata { color: var(--xml-cdata); }
.xfv-tk-decl { color: var(--xml-declaration); }
.xfv-tk-doctype { color: var(--xml-doctype); }

/* Tree view */
.xfv-tree-content {
    max-height: 540px;
    overflow: auto;
    padding: 1rem;
    background: var(--xfv-bg-elevated);
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 0.84rem;
}
.xfv-tree-node { margin-left: 0; }
.xfv-tree-children { margin-left: 1.1rem; border-left: 1px dashed var(--xfv-border); padding-left: 0.5rem; display: none; }
.xfv-tree-children.expanded { display: block; }
.xfv-tree-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1.7;
}
.xfv-tree-item:hover { background: var(--xfv-bg-secondary); }
.xfv-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--xfv-text-muted);
    transition: transform var(--xfv-transition);
}
.xfv-tree-toggle.expanded { transform: rotate(90deg); }
.xfv-tree-icon { color: var(--xfv-primary); flex-shrink: 0; }
.xfv-tree-tag { color: var(--xfv-c-element); font-weight: 600; }
.xfv-tree-attr-name { color: var(--xfv-c-attr); }
.xfv-tree-attr-value { color: var(--xfv-c-text); }
.xfv-tree-text { color: var(--xfv-text-muted); font-style: italic; }

/* Structure view */
.xfv-structure-content {
    max-height: 540px;
    overflow: auto;
    padding: 1rem 1.15rem;
    background: var(--xfv-bg-elevated);
}
.xfv-struct-group { margin-bottom: 1.1rem; }
.xfv-struct-group h4 {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--xfv-text);
}
.xfv-struct-group h4 i { color: var(--xfv-primary); }
.xfv-struct-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.xfv-struct-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: 9999px;
    font-size: 0.78rem;
    color: var(--xfv-text-secondary);
    font-family: 'JetBrains Mono', Consolas, monospace;
    cursor: pointer;
    transition: all var(--xfv-transition);
}
.xfv-struct-chip:hover { border-color: var(--xfv-primary); color: var(--xfv-primary); }
.xfv-struct-chip .xfv-chip-count {
    background: var(--xfv-primary-light);
    color: var(--xfv-primary);
    border-radius: 9999px;
    padding: 0 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
}
.xfv-empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--xfv-text-muted);
}
.xfv-empty-state i { color: var(--xfv-text-muted); opacity: 0.6; }
.xfv-empty-state h3 { margin: 0.75rem 0 0.35rem; font-size: 1rem; color: var(--xfv-text-secondary); }
.xfv-empty-state p { margin: 0; font-size: 0.85rem; }

/* Stats bar */
.xfv-stats-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    margin: 0.85rem 0;
}
.xfv-stat-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 0.85rem;
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-md);
    min-width: 0;
}
.xfv-stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--xfv-primary-light);
    color: var(--xfv-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.xfv-stat-info { display: flex; flex-direction: column; min-width: 0; }
.xfv-stat-label { font-size: 0.72rem; color: var(--xfv-text-muted); }
.xfv-stat-value { font-size: 1.05rem; font-weight: 700; color: var(--xfv-text); }

/* Action bar */
.xfv-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.85rem;
}
.xfv-action-group { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.xfv-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: var(--xfv-radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--xfv-transition);
}
.xfv-btn:hover { transform: translateY(-1px); }
.xfv-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.xfv-btn-primary {
    background: var(--xfv-primary) !important;
    border-color: var(--xfv-primary) !important;
    color: #fff !important;
}
.xfv-btn-primary:hover { background: var(--xfv-primary-dark) !important; border-color: var(--xfv-primary-dark) !important; color: #fff !important; }

.xfv-btn-success {
    background: var(--xfv-success) !important;
    border-color: var(--xfv-success) !important;
    color: #fff !important;
}
.xfv-btn-success:hover { filter: brightness(0.93); color: #fff !important; }

.xfv-btn-secondary {
    background: var(--xfv-bg-secondary) !important;
    border-color: var(--xfv-border) !important;
    color: var(--xfv-text-secondary) !important;
}
.xfv-btn-secondary:hover { background: var(--xfv-bg-tertiary) !important; color: var(--xfv-text) !important; }

/* ============================================
   PROCESSING OVERLAY (compress-gif pattern)
   ============================================ */
.xfv-processing-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}
.xfv-processing-card {
    background: var(--xfv-bg-elevated);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-lg);
    padding: 1.75rem 2rem;
    min-width: 340px;
    max-width: 90vw;
}
.xfv-stage-row { display: flex; align-items: center; justify-content: center; margin-bottom: 1.25rem; }
.xfv-stage { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.xfv-stage-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--xfv-text-muted);
    padding: 6px;
    transition: all var(--xfv-transition);
}
.xfv-stage.active .xfv-stage-dot {
    background: var(--xfv-primary);
    border-color: var(--xfv-primary);
    color: #fff;
}
.xfv-stage.done .xfv-stage-dot {
    background: var(--xfv-success);
    border-color: var(--xfv-success);
    color: #fff;
}
.xfv-stage-label { font-size: 0.72rem; color: var(--xfv-text-muted); }
.xfv-stage.active .xfv-stage-label { color: var(--xfv-primary); font-weight: 600; }
.xfv-stage.done .xfv-stage-label { color: var(--xfv-success); }
.xfv-stage-connector { width: 28px; height: 2px; background: var(--xfv-border); margin: 0 4px; align-self: flex-start; margin-top: 15px; }
.xfv-stage-connector.done { background: var(--xfv-success); }

.xfv-progress-bar-wrapper {
    width: 100%;
    height: 8px;
    background: var(--xfv-bg-secondary);
    border-radius: 9999px;
    overflow: hidden;
}
.xfv-progress-bar {
    height: 100%;
    width: 0;
    background: var(--xfv-primary);
    border-radius: 9999px;
    transition: width 0.3s ease;
}
.xfv-progress-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.6rem;
}
.xfv-progress-percent { font-size: 0.95rem; font-weight: 700; color: var(--xfv-primary); }
.xfv-progress-text { font-size: 0.82rem; color: var(--xfv-text-muted); }

/* ============================================
   ERROR / TOAST / MODAL
   ============================================ */
.xfv-error-container {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.9rem 1.1rem;
    background: var(--xfv-danger-light);
    border: 1px solid var(--xfv-danger);
    border-radius: var(--xfv-radius-md);
    color: var(--xfv-danger);
}
.xfv-error-container i { flex-shrink: 0; }
.xfv-error-body { flex: 1; min-width: 0; }
.xfv-error-body p { margin: 0 0 0.25rem; font-weight: 600; }
.xfv-error-body small { font-size: 0.82rem; opacity: 0.9; }
.xfv-error-container a {
    color: var(--xfv-danger);
    font-weight: 700;
    text-decoration: underline;
}
.xfv-error-close {
    background: transparent !important;
    border: none !important;
    color: var(--xfv-danger) !important;
    cursor: pointer;
    padding: 2px !important;
    box-shadow: none !important;
    transform: none !important;
    flex-shrink: 0;
}
.xfv-error-close:hover { background: rgba(192, 57, 43, 0.15) !important; transform: none !important; }

.xfv-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9100;
}
.xfv-modal-overlay.hidden { display: none; }
.xfv-modal-box {
    background: var(--xfv-bg-elevated);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-lg);
    padding: 1.5rem;
    width: 420px;
    max-width: 92vw;
    position: relative;
}
.xfv-modal-box h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    font-size: 1.05rem;
    color: var(--xfv-text);
}
.xfv-modal-box h3 i { color: var(--xfv-primary); }
.xfv-modal-row { display: flex; gap: 1rem; margin-bottom: 1rem; }
.xfv-modal-field { flex: 1; min-width: 0; }
.xfv-modal-field label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--xfv-text-secondary); margin-bottom: 0.35rem; }
.xfv-modal-field input {
    width: 100%;
    padding: 0.5rem 0.7rem;
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-sm);
    color: var(--xfv-text);
    font-size: 0.85rem;
    outline: none;
}
.xfv-modal-field input:focus { border-color: var(--xfv-primary); }
.xfv-modal-preview {
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-sm);
    padding: 0.6rem 0.75rem;
    font-size: 0.78rem;
    color: var(--xfv-text-muted);
    font-family: 'JetBrains Mono', Consolas, monospace;
    max-height: 130px;
    overflow: auto;
    margin-bottom: 1rem;
    white-space: pre-wrap;
}
.xfv-modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.xfv-modal-close-btn {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    background: transparent !important;
    border: none !important;
    color: var(--xfv-text-muted) !important;
    cursor: pointer;
    padding: 4px !important;
    box-shadow: none !important;
    transform: none !important;
}
.xfv-modal-close-btn:hover { background: var(--xfv-bg-secondary) !important; color: var(--xfv-text) !important; transform: none !important; }

.xfv-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--xfv-bg-elevated);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-md);
    padding: 0.7rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--xfv-text);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
    opacity: 0;
    z-index: 9200;
    transition: all 0.3s ease;
}
.xfv-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.xfv-toast.success svg { color: var(--xfv-success); }
.xfv-toast.error { color: var(--xfv-danger); }
.xfv-toast.error svg { color: var(--xfv-danger); }

/* Fullscreen */
.xfv-viewer-content:fullscreen,
.xfv-editor-section:fullscreen {
    background: var(--xfv-bg);
    padding: 1.5rem;
    overflow: auto;
}

/* In full mode, expand the scrollable panels to fill the screen instead of
   staying capped at the default 540px. Leaves headroom for the toolbar,
   search, stats and action bars. */
.xfv-editor-section:fullscreen .xfv-code-scroll,
.xfv-editor-section:fullscreen .xfv-tree-content,
.xfv-editor-section:fullscreen .xfv-structure-content,
.xfv-viewer-content:fullscreen .xfv-code-scroll,
.xfv-viewer-content:fullscreen .xfv-tree-content,
.xfv-viewer-content:fullscreen .xfv-structure-content {
    max-height: calc(100vh - 240px);
}

/* ============================================
   RELATED TOOLS - capped at 5
   ============================================ */
.xfv-related-tools { margin: 1.75rem 0; }
.xfv-related-tools-box {
    background: var(--xfv-bg-elevated);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-md);
    padding: 1rem 1.15rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.xfv-related-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--xfv-text-secondary);
    font-size: 0.85rem;
}
.xfv-related-label i { color: var(--xfv-primary); }
.xfv-related-links { display: inline-flex; gap: 0.5rem; flex-wrap: wrap; }
.xfv-related-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: 9999px;
    color: var(--xfv-text-secondary);
    text-decoration: none;
    font-size: 0.83rem;
    font-weight: 500;
    transition: all var(--xfv-transition);
}
.xfv-related-link:hover { background: var(--xfv-primary); border-color: var(--xfv-primary); color: #fff; }
.xfv-related-link i { flex-shrink: 0; }

/* ============================================
   INFO SECTIONS
   ============================================ */
.xfv-info-sections {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}
.xfv-info-card {
    background: var(--xfv-bg-elevated);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-lg);
    padding: 1.5rem;
}
.xfv-info-card h2 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 0.9rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--xfv-text);
}
.xfv-info-card h2 i { color: var(--xfv-primary); }
.xfv-info-card h3 {
    margin: 1.1rem 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--xfv-text);
}
.xfv-info-card p {
    margin: 0.6rem 0;
    line-height: 1.7;
    color: var(--xfv-text-secondary);
    font-size: 0.92rem;
}
.xfv-info-card a {
    color: var(--xfv-primary);
    text-decoration: none;
    font-weight: 500;
}
.xfv-info-card a:hover { text-decoration: underline; }
.xfv-info-card ul {
    margin: 0.6rem 0;
    padding-left: 1.4rem;
    line-height: 1.75;
    color: var(--xfv-text-secondary);
}
.xfv-info-card li { margin: 0.4rem 0; }
.xfv-info-card code {
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.85em;
    font-family: 'JetBrains Mono', Consolas, monospace;
    color: var(--xfv-primary);
}

/* Steps */
.xfv-steps { display: grid; gap: 14px; margin: 0.6rem 0; }
.xfv-step { display: flex; gap: 14px; align-items: flex-start; }
.xfv-step-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--xfv-primary);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.xfv-step-content { min-width: 0; }
.xfv-step-content h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 600; color: var(--xfv-text); }
.xfv-step-content p { margin: 0; color: var(--xfv-text-secondary); line-height: 1.65; }

/* Features grid */
.xfv-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.85rem;
    margin-top: 0.5rem;
}
.xfv-feature-item {
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-md);
    padding: 1rem;
    min-width: 0;
}
.xfv-feature-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--xfv-primary-light);
    color: var(--xfv-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}
.xfv-feature-icon i,
.xfv-feature-icon svg { width: 18px; height: 18px; }
.xfv-feature-item h4 { margin: 0 0 0.35rem; font-size: 0.95rem; font-weight: 700; color: var(--xfv-text); }
.xfv-feature-item p { margin: 0; font-size: 0.85rem; color: var(--xfv-text-muted); line-height: 1.55; }

/* ============================================
   FAQ - global _footer.php handler with .faq-item.open
   ============================================ */
.xfv-info-card .faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.xfv-info-card .faq-item {
    background: var(--xfv-bg-secondary);
    border: 1px solid var(--xfv-border);
    border-radius: var(--xfv-radius-md);
    overflow: hidden;
}
.xfv-info-card .faq-question {
    width: 100%;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.05rem !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer;
    text-align: left;
    color: var(--xfv-text) !important;
    font-weight: 600;
    font-size: 0.92rem;
    box-shadow: none !important;
    transform: none !important;
    transition: background var(--xfv-transition);
}
.xfv-info-card .faq-question:hover { background: var(--xfv-bg-tertiary) !important; transform: none !important; }
.xfv-info-card .faq-question i {
    color: var(--xfv-primary);
    transition: transform var(--xfv-transition);
    flex-shrink: 0;
}
.xfv-info-card .faq-item.open .faq-question i { transform: rotate(180deg); }
.xfv-info-card .faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--xfv-transition) ease;
    padding: 0 1.05rem;
}
.xfv-info-card .faq-item.open .faq-answer { max-height: 600px; padding: 0 1.05rem 0.95rem; }
.xfv-info-card .faq-answer p {
    margin: 0;
    color: var(--xfv-text-secondary);
    font-size: 0.88rem;
    line-height: 1.65;
}
.xfv-info-card .faq-answer strong { color: var(--xfv-text); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .xfv-split-container.split { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .tool-container { padding: 1rem 0.75rem; }
    .tool-title { font-size: 1.4rem; }
    .tool-description { font-size: 0.9rem; }

    .xfv-upload-section { padding: 1.25rem; }
    .xfv-upload-area { padding: 2rem 1rem; }
    .xfv-upload-title { font-size: 1.1rem; }

    .xfv-editor-section { padding: 1rem; }

    .xfv-view-toggle button span { display: none; }
    .xfv-action-bar { flex-direction: column; align-items: stretch; }
    .xfv-action-group { width: 100%; }
    .xfv-action-group .xfv-btn { flex: 1; justify-content: center; }

    .xfv-stage-connector { max-width: 18px; }
    .xfv-stage-label { font-size: 0.65rem; }
    .xfv-processing-card { padding: 1.25rem 1rem; min-width: 0; }

    .xfv-info-card { padding: 1.15rem; }
    .xfv-info-card h2 { font-size: 1.1rem; }

    .xfv-stats-bar { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .xfv-related-tools-box { padding: 0.85rem; }
    .xfv-file-info-bar { gap: 0.75rem; }
    .xfv-stats-bar { grid-template-columns: 1fr; }
}

@media print {
    .xfv-viewer-toolbar,
    .xfv-tab-bar,
    .xfv-action-bar,
    .xfv-related-tools,
    .xfv-info-sections,
    .xfv-stats-bar { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
