:root {
    --editor-background: #212121;
    --pane-background: #ffffff;
    --border-color: #e4e4e7;
    --header-color: #3f3f46;
    --bg-color: #fafafa;
    --bg-gradient: linear-gradient(135deg, #fafafa 0%, #f8f8fa 50%, #f5f5f7 100%);
    --text-color: #27272a;
    --main-header-bg: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    --main-header-text: #18181b;
    --input-bg: #ffffff;
    --loader-bg: rgba(255, 255, 255, 0.95);
    --overlay-bg: rgba(250, 250, 250, 0.85);
    --whitespace-color: #71717a;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --success-color: #10b981;
    --logo-color: #111111;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --gradient-border: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.1), rgba(236, 72, 153, 0.15));
    --btn-background: #f4f4f5;
    --btn-hover: #e4e4e7;
    --btn-text: #27272a;
}

/* Dark mode theme */
body.dark-mode {
    --editor-background: #212121;
    --pane-background: #18181b;
    --border-color: #3f3f46;
    --header-color: #d4d4d8;
    --bg-color: #09090b;
    --bg-gradient: linear-gradient(135deg, #09090b 0%, #0f0f12 50%, #18181b 100%);
    --text-color: #e4e4e7;
    --main-header-bg: linear-gradient(135deg, #18181b 0%, #27272a 100%);
    --main-header-text: #fafafa;
    --input-bg: #27272a;
    --loader-bg: rgba(24, 24, 27, 0.95);
    --overlay-bg: rgba(9, 9, 11, 0.85);
    --whitespace-color: #a1a1aa;
    --accent-color: #3b82f6;
    --accent-hover: #60a5fa;
    --success-color: #10b981;
    --logo-color: #d4d4d8;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --gradient-border: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(139, 92, 246, 0.15), rgba(236, 72, 153, 0.25));
    --btn-background: #27272a;
    --btn-hover: #3f3f46;
    --btn-text: #e4e4e7;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--bg-gradient);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: background 0.3s ease;
}

/* Main Header Styling */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--main-header-bg);
    border-bottom: 1px solid transparent;
    padding: 14px 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    position: relative;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    width: 36px;
    height: 36px;
    display: inline-block;
    background-color: var(--logo-color);
    mask-image: url('favicon.svg');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    -webkit-mask-image: url('favicon.svg');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.header-logo:hover {
    transform: rotate(-6deg);
}

.main-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gradient-border);
    opacity: 0.4;
}

.main-header h1 {
    margin: 0;
    color: var(--main-header-text);
    font-weight: 600;
    font-size: 19px;
    letter-spacing: -0.02em;
}

.theme-toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.version-selector-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--btn-background);
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.version-label {
    font-size: 11px;
    color: var(--text-color);
    font-weight: 600;
    opacity: 0.8;
    white-space: nowrap;
}

/* Custom Select Styling */
.custom-select-wrapper {
    position: relative;
}

.hidden-select {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.custom-select {
    position: relative;
    width: 140px;
    user-select: none;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-color);
    transition: all 0.2s ease;
    gap: 6px;
}

.custom-select-trigger:hover {
    border-color: var(--accent-color);
    background: var(--btn-hover);
}

.custom-select.open .custom-select-trigger {
    border-color: var(--accent-color);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.custom-select-trigger span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.select-arrow {
    flex-shrink: 0;
    transition: transform 0.2s ease;
    color: var(--text-color);
    opacity: 0.6;
}

.custom-select.open .select-arrow {
    transform: rotate(180deg);
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--input-bg);
    border: 1px solid var(--accent-color);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
}

.custom-select.open .custom-select-options {
    display: block;
}

.custom-option {
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-color);
    font-size: 11px;
    font-weight: 500;
}

.custom-option:hover {
    background: var(--btn-hover);
    color: var(--accent-color);
}

.custom-option.selected {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    font-weight: 600;
}

.custom-option:last-child {
    border-radius: 0 0 6px 6px;
}

/* Custom scrollbar for options */
.custom-select-options::-webkit-scrollbar {
    width: 6px;
}

.custom-select-options::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 0 0 6px 0;
}

.custom-select-options::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.custom-select-options::-webkit-scrollbar-thumb:hover {
    background: var(--text-color);
    opacity: 0.5;
}

body.dark-mode .custom-select-trigger {
    background: var(--editor-background);
}

body.dark-mode .custom-select-options {
    background: var(--editor-background);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.theme-label {
    font-size: 12px;
    color: var(--text-color);
    font-weight: 500;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d4d4d8;
    transition: all 0.3s ease;
    border-radius: 24px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.theme-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.theme-switch input:checked + .theme-slider {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
}

.theme-switch input:checked + .theme-slider:before {
    transform: translateX(20px);
}
.container {
    display: flex;
    flex-grow: 1;
    gap: 14px;
    padding: 14px;
    min-width: 0; /* Allow flex shrinking */
    overflow: hidden;
}
.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: calc(100vh - 98px); /* Adjusted for header */
    min-width: 0; /* Allow flex shrinking */
    overflow: hidden;
}
.right-panel {
    flex: 1;
    height: calc(100vh - 98px); /* Adjusted for header */
    min-width: 0; /* Allow flex shrinking */
    overflow: hidden;
}
.pane {
    display: flex;
    flex-direction: column;
    background: var(--pane-background);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    min-height: 0; /* Allow flex items to shrink */
    min-width: 0; /* Allow flex items to shrink horizontally */
    width: 100%;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    animation: fadeInUp 0.4s ease-out;
    position: relative;
    background-clip: padding-box;
}

.pane::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    padding: 1px;
    background: var(--gradient-border);
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.pane:hover {
    box-shadow: var(--shadow-lg);
}

.pane:hover::before {
    opacity: 1;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.template-pane {
    flex: 2;
    min-height: 0;
    animation-delay: 0.05s;
}
.variables-pane {
    flex: 1;
    min-height: 0;
    animation-delay: 0.1s;
}
#output-pane {
    animation-delay: 0.15s;
}
.pane h2 {
    margin: 0;
    padding: 14px 16px;
    font-size: 13px;
    background: var(--pane-background);
    border-bottom: 1px solid var(--border-color);
    color: var(--header-color);
    font-weight: 600;
    letter-spacing: -0.01em;
    position: relative;
    z-index: 1;
}
.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--pane-background);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 16px;
    transition: background 0.2s ease;
    position: relative;
    z-index: 1;
}
.pane-header h2 {
    margin: 0;
    padding: 0;
    border-bottom: none;
    background: none;
    font-size: 13px;
}
.pane-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--pane-background);
    border-top: 1px solid var(--border-color);
    padding: 14px 16px;
    transition: background 0.2s ease;
    position: relative;
    z-index: 1;
}
.footer-controls-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.footer-controls-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}
.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d4d4d8;
    transition: all 0.3s ease;
    border-radius: 24px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
input:checked + .slider {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
}
input:checked + .slider:before {
    transform: translateX(20px);
}
.rerender-btn {
    padding: 5.5px 14px;
    background: var(--btn-background);
    color: var(--btn-text);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    position: relative;
    top: 0;
}
.rerender-btn:hover {
    background: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08);
}
.rerender-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.rerender-btn:disabled {
    background: var(--border-color);
    color: #a1a1aa;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.5;
}
.control-label {
    font-size: 12px;
    color: var(--header-color);
    font-weight: 500;
}
.header-btn {
    padding: 6px 12px;
    background: var(--btn-background);
    color: var(--btn-text);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    position: relative;
}
.header-btn:hover {
    background: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08);
}
.header-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.CodeMirror {
    flex-grow: 1;
    height: auto;
    font-size: 12px;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    position: relative;
    z-index: 1;
}
.CodeMirror-scroll {
    overflow-x: auto !important;
    overflow-y: auto !important;
    max-width: 100%;
}
.CodeMirror-lines {
    max-width: 100%;
    padding: 8px 0;
}

/* CodeMirror error line highlighting */
.cm-error-line {
    background-color: rgba(239, 68, 68, 0.2) !important;
    border-left: 3px solid #ef4444 !important;
    padding-left: 5px;
    animation: errorPulse 0.3s ease-in-out;
}

@keyframes errorPulse {
    0% {
        background-color: rgba(239, 68, 68, 0.4);
    }
    100% {
        background-color: rgba(239, 68, 68, 0.2);
    }
}

.cm-error-widget {
    color: #ef4444;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    margin-top: 2px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 4px;
    display: inline-block;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.dark-mode .cm-error-line {
    background-color: rgba(239, 68, 68, 0.15) !important;
}

body.dark-mode .cm-error-widget {
    background: rgba(239, 68, 68, 0.2);
}

#output-pane {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.output-content {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
    z-index: 1;
}
#output {
    flex-grow: 1;
    padding: 18px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: auto;
    font-family: "Menlo", "Consolas", monospace;
    font-size: 12px;
    line-height: 1.7;
    min-height: 0;
    position: relative;
    z-index: 1;
}
.error {
    color: #ef4444;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.1);
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid #ef4444;
}

/* Error message formatting */
.error-message-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.error-details {
    font-family: "Menlo", "Consolas", monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    margin-top: 8px;
}

.error-location {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(239, 68, 68, 0.15);
    border-radius: 4px;
    font-weight: 700;
    font-size: 11px;
    margin: 4px 0;
}
.variable-input {
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}
.variable-input label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--header-color);
    font-size: 12px;
}
.variable-input input, .variable-input textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    font-family: "Menlo", "Consolas", monospace;
    background: var(--input-bg);
    color: var(--text-color);
    box-sizing: border-box;
    transition: all 0.2s ease;
}
.variable-input textarea {
    min-height: 60px;
    resize: vertical;
}
.variable-input input:focus, .variable-input textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.variable-input input:hover, .variable-input textarea:hover {
    border-color: var(--accent-color);
}

/* Variable input with type selector styling */
.variable-input .variable-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.variable-input .type-selector {
    font-size: 11px;
    padding: 2px 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.variable-input .type-selector:hover {
    border-color: var(--accent-color);
}

.variable-input .type-selector:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Dark mode specific adjustments for selects */
body.dark-mode .variable-input .type-selector {
    background: var(--input-bg);
    border-color: var(--border-color);
}
.form-mode-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--pane-background);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
}
.mode-switch {
    background: var(--btn-background);
    color: var(--btn-text);
    cursor: pointer;
    text-decoration: none;
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    position: relative;
}
.mode-switch:hover {
    background: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08);
}
.mode-switch:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Resize handles */
.resize-handle {
    background: transparent;
    transition: all 0.3s ease;
    position: relative;
}
.resize-handle:hover {
    background: rgba(59, 130, 246, 0.15);
}
.resize-handle:active {
    background: rgba(59, 130, 246, 0.3);
}
.resize-handle-horizontal {
    height: 4px;
    cursor: row-resize;
    width: 100%;
}
.resize-handle-vertical {
    width: 4px;
    cursor: col-resize;
    height: 100%;
}

/* Container adjustments for resizing */
.resizable-container {
    display: flex;
    flex-grow: 1;
    gap: 0;
    padding: 14px;
    min-width: 0;
    box-sizing: border-box; /* Include padding in height calculation */
    overflow: hidden; /* Prevent container from overflowing */
}
.resizable-left-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 200px;
    max-width: calc(100vw - 250px);
    height: 100%; /* Use full container height */
}
.resizable-right-panel {
    min-width: 200px;
    height: 100%; /* Use full container height */
}
.resizable-template-pane {
    min-height: 100px;
    overflow: hidden;
}
.resizable-variables-pane {
    min-height: 100px;
    overflow: hidden;
}

/* Loading state */
#loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2em;
    background: var(--loader-bg);
    color: var(--text-color);
    padding: 24px 32px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    z-index: 999;
    display: none;
    backdrop-filter: blur(8px);
}

/* --- UPDATED WHITESPACE STYLING --- */
.whitespace-char {
    /* Use relative positioning to anchor the pseudo-element */
    position: relative;
}
.whitespace-char::before {
    /* Position the symbol absolutely so it doesn't affect layout */
    position: absolute;
    color: var(--whitespace-color);
    opacity: 0.6;
    /* Prevent the symbols from being selected with the text */
    pointer-events: none;
}
.whitespace-char.space::before {
    content: '·';
}
.whitespace-char.tab::before {
    content: '→';
}
.whitespace-char.newline::before {
    content: '↵';
}

/* --- MARKDOWN CONTENT STYLING --- */
.markdown-content {
    flex-grow: 1;
    padding: 24px;
    overflow: auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-color);
    background-color: var(--pane-background);
    min-height: 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-color);
}

.markdown-content h1 {
    font-size: 2em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}

.markdown-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}

.markdown-content h3 {
    font-size: 1.25em;
}

.markdown-content h4 {
    font-size: 1em;
}

.markdown-content h5 {
    font-size: 0.875em;
}

.markdown-content h6 {
    font-size: 0.85em;
    color: var(--header-color);
}

.markdown-content p {
    margin-top: 0;
    margin-bottom: 16px;
}

.markdown-content a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.markdown-content a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.markdown-content ul,
.markdown-content ol {
    margin-top: 0;
    margin-bottom: 16px;
    padding-left: 2em;
}

.markdown-content li {
    margin-top: 0.25em;
}

.markdown-content blockquote {
    margin: 0 0 16px 0;
    padding: 0 1em;
    color: var(--header-color);
    border-left: 4px solid var(--border-color);
}

.markdown-content code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(127, 127, 127, 0.2);
    border-radius: 3px;
    font-family: "Menlo", "Consolas", monospace;
}

.markdown-content pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: rgba(127, 127, 127, 0.15);
    border-radius: 6px;
    margin-bottom: 16px;
}

.markdown-content pre code {
    display: inline;
    padding: 0;
    margin: 0;
    overflow: visible;
    line-height: inherit;
    background-color: transparent;
    border: 0;
}

.markdown-content table {
    border-spacing: 0;
    border-collapse: collapse;
    margin-top: 0;
    margin-bottom: 16px;
    width: 100%;
    overflow: auto;
}

.markdown-content table th,
.markdown-content table td {
    padding: 6px 13px;
    border: 1px solid var(--border-color);
}

.markdown-content table th {
    font-weight: 600;
    background-color: rgba(127, 127, 127, 0.1);
}

.markdown-content table tr {
    background-color: var(--pane-background);
    border-top: 1px solid var(--border-color);
}

.markdown-content table tr:nth-child(2n) {
    background-color: rgba(127, 127, 127, 0.05);
}

.markdown-content img {
    max-width: 100%;
    box-sizing: content-box;
}

.markdown-content hr {
    height: 0.25em;
    padding: 0;
    margin: 24px 0;
    background-color: var(--border-color);
    border: 0;
}

.markdown-content strong {
    font-weight: 600;
}

.markdown-content em {
    font-style: italic;
}

/* Mermaid diagram styling */
.markdown-content .mermaid {
    background-color: transparent;
    margin: 16px 0;
    text-align: center;
}

/* Dark mode specific adjustments for better mermaid visibility */
body.dark-mode .markdown-content .mermaid svg {
    background-color: transparent;
}

/* Mermaid text wrapping support */
/* Target the actual node shapes */
.markdown-content .mermaid .node rect,
.markdown-content .mermaid .node circle,
.markdown-content .mermaid .node ellipse,
.markdown-content .mermaid .node polygon,
.markdown-content .mermaid .node path {
    min-width: 100px !important;
}

.markdown-content .mermaid .node {
    min-width: 100px !important;
}

.markdown-content .mermaid .node .label,
.markdown-content .mermaid .edgeLabel .label {
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    min-width: 100px;
    max-width: 200px;
}

.markdown-content .mermaid .nodeLabel,
.markdown-content .mermaid .edgeLabel {
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    min-width: 100px;
    max-width: 200px;
}

.markdown-content .mermaid foreignObject {
    overflow: visible !important;
    min-width: 100px !important;
}

.markdown-content .mermaid foreignObject div {
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    min-width: 100px;
    max-width: 200px;
    padding: 5px;
}

/* --- MODAL STYLING --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal {
    background: var(--pane-background);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    animation: slideUp 0.3s ease-out;
    border: 1px solid var(--border-color);
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--header-color);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--btn-hover);
    color: var(--text-color);
}

.modal-body {
    padding: 24px;
}

.modal-body label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--header-color);
    font-size: 13px;
}

.modal-body input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--input-bg);
    color: var(--text-color);
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.modal-body input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--header-color);
    opacity: 0.7;
}

.modal-input-hint {
    margin-top: 6px;
    font-size: 11px;
    min-height: 16px;
    font-weight: 500;
}

.modal-input-hint.error {
    color: #ef4444;
}

.modal-input-hint.success {
    color: var(--success-color);
}

.modal-input-hint.info {
    color: var(--accent-color);
    opacity: 0.7;
}

.modal-warning {
    font-size: 14px;
    color: var(--text-color);
    margin: 0 0 12px 0;
    line-height: 1.5;
}

.modal-warning strong {
    color: var(--accent-color);
    font-weight: 600;
}

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

.modal-footer-vertical {
    flex-direction: column;
}

.modal-footer-vertical .modal-btn {
    width: 100%;
}

.modal-btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.modal-btn-cancel {
    background: var(--btn-background);
    color: var(--btn-text);
    border: 1px solid var(--border-color);
}

.modal-btn-cancel:hover {
    background: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.modal-btn-save {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
    color: white;
}

.modal-btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.modal-btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.modal-btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.modal-btn:active {
    transform: translateY(0);
}

/* --- BURGER MENU STYLING --- */
.burger-menu {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.burger-menu:hover {
    background: var(--btn-hover);
}

.burger-line {
    width: 24px;
    height: 2.5px;
    background: var(--text-color);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.burger-menu.active .burger-line:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}

.burger-menu.active .burger-line:nth-child(2) {
    opacity: 0;
}

.burger-menu.active .burger-line:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

/* --- DRAWER STYLING --- */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    left: -400px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: var(--pane-background);
    box-shadow: var(--shadow-lg);
    z-index: 1600;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.drawer.active {
    left: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--main-header-bg);
}

.drawer-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.drawer-close {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--header-color);
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    line-height: 1;
}

.drawer-close:hover {
    background: var(--btn-hover);
    color: var(--text-color);
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.drawer-empty-message {
    text-align: center;
    color: var(--header-color);
    opacity: 0.7;
    padding: 40px 20px;
    font-size: 14px;
    line-height: 1.6;
}

/* --- CONFIG CARD STYLING --- */
.config-card {
    background: var(--pane-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.config-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    padding: 1px;
    background: var(--gradient-border);
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.config-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.config-card:hover::before {
    opacity: 0.5;
}

.config-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.config-card-name-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.config-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.config-rename-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.config-card:hover .config-rename-icon {
    opacity: 0.6;
}

.config-rename-icon:hover {
    opacity: 1 !important;
    background: var(--btn-hover);
    transform: scale(1.1);
}

.config-card-date {
    font-size: 11px;
    color: var(--header-color);
    opacity: 0.7;
    white-space: nowrap;
    margin-left: 12px;
}

.config-card-version {
    font-size: 10px;
    color: var(--accent-color);
    font-weight: 600;
    padding: 2px 6px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 3px;
    white-space: nowrap;
    border: 1px solid var(--accent-color);
}

body.dark-mode .config-card-version {
    background: rgba(59, 130, 246, 0.15);
}

.config-card-section {
    margin-bottom: 10px;
}

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

.config-card-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--header-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.config-card-content {
    font-size: 12px;
    color: var(--text-color);
    font-family: "Menlo", "Consolas", monospace;
    background: rgba(127, 127, 127, 0.1);
    padding: 8px 10px;
    border-radius: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.config-card-switches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.config-switch-badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-color);
    border: 1px solid rgba(59, 130, 246, 0.3);
    font-weight: 500;
}

.config-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.config-action-btn {
    flex: 1;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    background: var(--btn-background);
    color: var(--btn-text);
}

.config-action-btn:hover {
    background: var(--btn-hover);
    transform: translateY(-1px);
}

.config-action-btn.load-btn {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
    color: white;
    border: none;
}

.config-action-btn.load-btn:hover {
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.config-action-btn.share-btn {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, 0.3);
}

.config-action-btn.share-btn:hover {
    background: rgba(139, 92, 246, 0.2);
}

.config-action-btn.delete-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.config-action-btn.delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}