/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* CSS Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette - Nord-Inspired Cool (Default) */
    --primary: #5E81AC;
    --primary-hover: #4C6A8A;
    --accent: #81A1C1;
    --highlight: #88C0D0;
    --success: #A3BE8C;
    --error: #BF616A;
    --warning: #EBCB8B;

    /* Neutrals - Nord-Inspired Dark Mode */
    --bg-dark: #2E3440;
    --bg-card: #3B4252;
    --bg-input: #434C5E;
    --text-primary: #ECEFF4;
    --text-secondary: #D8DEE9;
    --border: #5E81AC;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #5E81AC 0%, #81A1C1 100%);
    --gradient-accent: linear-gradient(135deg, #81A1C1 0%, #88C0D0 100%);
    --gradient-success: linear-gradient(135deg, #A3BE8C 0%, #8FBCBB 100%);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(94, 129, 172, 0.4);
    --shadow-neopop: 4px 4px 0 rgba(94, 129, 172, 0.3);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border Radius - All removed */
    --radius-sm: 0;
    --radius-md: 0;
    --radius-lg: 0;
    --radius-xl: 0;
    --radius-squircle: 0;

    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
}

/* Light Mode - Nord-Inspired Cool */
body.light-mode {
    --bg-dark: #FFFFFF;
    --bg-card: #F8FAFD;
    --bg-input: #F0F4F8;
    --text-primary: #2E3440;
    --text-secondary: #4C566A;
    --border: #D8DEE9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.15);
    --shadow-glow: 0 0 20px rgba(94, 129, 172, 0.2);
    --shadow-neopop: 4px 4px 0 rgba(94, 129, 172, 0.2);
}

body.light-mode::before {
    background:
        radial-gradient(circle at 20% 50%, rgba(94, 129, 172, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(129, 161, 193, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(136, 192, 208, 0.03) 0%, transparent 50%);
}

/* Light mode overrides for HEADER and FOOTER - EXPLICIT to ensure theme changes work */
body.light-mode .header h1,
body.light-mode .header .logo h1,
body.light-mode .logo h1,
body.light-mode .header-content h1,
body.light-mode .logo-icon {
    color: var(--text-primary) !important;
}

body.light-mode .subtitle,
body.light-mode .header .subtitle,
body.light-mode .header-content .subtitle {
    color: var(--text-secondary) !important;
}

body.light-mode .footer {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

body.light-mode .attribution,
body.light-mode .footer .attribution {
    color: var(--text-primary) !important;
}

body.light-mode .copyright,
body.light-mode .footer .copyright,
body.light-mode .footer-link,
body.light-mode .footer .footer-link {
    color: var(--text-secondary) !important;
}

body.light-mode .logo-icon,
body.light-mode .feature-title,
body.light-mode .feature-desc,
body.light-mode .attribution,
body.light-mode .copyright,
body.light-mode .footer-link,
body.light-mode .user-name,
body.light-mode .modal-title,
body.light-mode .settings-section-title,
body.light-mode .form-label,
body.light-mode .dropdown-title,
body.light-mode .dropdown-item,
body.light-mode .error-title,
body.light-mode .error-message,
body.light-mode .error-tip,
body.light-mode .suggestions-title,
body.light-mode .suggestions-message,
body.light-mode .suggestions-list li,
body.light-mode .status-item,
body.light-mode .validation-indicator,
body.light-mode .token-count,
body.light-mode .format-selector,
body.light-mode .btn,
body.light-mode .btn-primary,
body.light-mode .btn-secondary,
body.light-mode .btn-icon-only,
body.light-mode .theme-preset-btn,
body.light-mode .color-input,
body.light-mode .form-input,
body.light-mode .transform-description,
body.light-mode .transform-preview,
body.light-mode .doc-item-name,
body.light-mode .doc-item-meta,
body.light-mode .plan-price,
body.light-mode .plan-duration,
body.light-mode .plan-features li,
body.light-mode .payment-plan h3,
body.light-mode .header-btn,
body.light-mode .theme-toggle,
body.light-mode .btn-arrow,
body.light-mode .btn-clear,
body.light-mode .btn-text,
body.light-mode .ad-label,
body.light-mode .savings-text,
body.light-mode .savings-number,
body.light-mode .savings-percent {
    color: var(--text-primary);
}

body.light-mode .feature-desc,
body.light-mode .copyright,
body.light-mode .footer-link,
body.light-mode .error-tip,
body.light-mode .suggestions-list li,
body.light-mode .status-item,
body.light-mode .token-count,
body.light-mode .doc-item-meta,
body.light-mode .plan-duration,
body.light-mode .dropdown-title,
body.light-mode .transform-description {
    color: var(--text-secondary);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(236, 72, 153, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: var(--spacing-md) 0;
    z-index: 1;
}

/* Header */
.header {
    text-align: center;
    overflow: visible !important;
    position: relative;
    z-index: 1000;
    margin-bottom: var(--spacing-md);
    animation: fadeInDown 0.6s ease-out;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0 auto var(--spacing-sm);
    padding: 0 var(--spacing-lg);
    gap: var(--spacing-md);
    overflow: visible !important;
    position: relative;
    z-index: 1001;
}

.logo {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: var(--spacing-sm);
}

.logo-icon {
    font-size: 2.5rem;
    animation: bounce 2s infinite;
    color: var(--text-primary);
}

.header h1,
.header .logo h1,
.logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary) !important;
    letter-spacing: -0.025em;
    margin: 0;
    white-space: nowrap;
}

.subtitle,
.header .subtitle,
.header-content .subtitle {
    color: var(--text-secondary) !important;
    font-size: 0.7875rem;
    font-weight: 500;
    margin: 0;
}

/* Header Controls */
.header-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    flex-shrink: 0;
    overflow: visible !important;
    position: relative;
    z-index: 1002;
}

/* Theme dropdown in header */
.header-controls .dropdown {
    position: relative;
    overflow: visible !important;
    z-index: 1003;
}

.header-controls .format-selector.dropdown-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    padding-right: 2.5rem;
    height: auto;
    min-width: fit-content;
    overflow: visible;
}

.header-controls .format-selector.dropdown-toggle:hover {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--primary);
}

.header-controls .dropdown-menu {
    min-width: 280px;
    max-width: 450px;
    width: max-content;
    overflow: visible !important;
    white-space: normal;
    word-wrap: break-word;
}

.header-controls .dropdown-item {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding: 0.75rem 1rem;
    line-height: 1.4;
    min-width: 100%;
    box-sizing: border-box;
    overflow: visible;
    text-overflow: clip;
}

.header-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: var(--transition-fast);
    padding: 0;
}

.header-btn:hover {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

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

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: var(--transition-fast);
    padding: 0;
}

.theme-toggle:hover {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Converter Layout */
.converter {
    display: flex;
    flex-direction: column;
    margin-bottom: var(--spacing-lg);
    animation: fadeIn 0.8s ease-out;
    height: calc(100vh - 300px);
    min-height: 600px;
}

/* Resizable Container - Fixed 50-50 horizontal layout */
.resizable-container {
    display: flex;
    flex-direction: row;
    flex: 1;
    gap: 0;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

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

/* Conversion Controls Panel */
.conversion-controls-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    flex-shrink: 0;
    flex-grow: 0;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    position: relative;
    z-index: 1;
    width: auto;
    min-width: auto;
}

.conversion-buttons {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    justify-content: center;
    position: relative;
    z-index: 1;
}

/* Arrow Buttons */
.btn-arrow {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-primary);
    font-size: 1.25rem;
    padding: 0;
}

.btn-arrow:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: scale(1.05);
}

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

.btn-arrow .arrow-icon {
    display: inline-block;
    font-weight: bold;
}

/* Clear Button */
.btn-clear {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
    font-size: 1.125rem;
    padding: 0;
    margin-left: var(--spacing-xs);
}

.btn-clear:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
    transform: scale(1.05);
}

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

.btn-clear .clear-icon {
    display: inline-block;
    font-weight: bold;
}

/* Resize handle removed - using fixed 50-50 split */

.resize-handle:hover .resize-handle-line,
.resize-handle:active .resize-handle-line {
    opacity: 1;
    background: white;
}

/* Mobile: Stack vertically */
@media (max-width: 1024px) {
    .resizable-container {
        flex-direction: column;
    }
    
    .resizable-panel {
        flex: 1 1 0;
        width: 100%;
        min-height: 300px;
    }
    
    .conversion-controls-panel {
        flex-direction: row;
        border-left: none;
        border-right: none;
        border-top: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
    }
}

/* Sections */
.input-section,
.output-section {
    background: var(--bg-card);
    border-radius: var(--radius-squircle);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Section Headers - Customizable color like jsoneditor */
.section-header {
    background: var(--header-bg, var(--primary));
    color: white;
    margin: calc(-1 * var(--spacing-md)) calc(-1 * var(--spacing-md)) var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-squircle) var(--radius-squircle) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    min-height: 3rem;
    overflow: visible !important;
    position: relative;
    z-index: 100;
}

.section-header .editor-toolbar,
.section-header .header-actions {
    color: white;
}

.section-header .format-selector {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.section-header .format-selector:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.section-header .format-selector option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.section-header .format-selector.dropdown-toggle {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.section-header .format-selector.dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.section-header .dropdown-arrow {
    color: white;
    opacity: 0.9;
}

.section-header .btn-icon-only {
    color: white;
    opacity: 0.9;
}

.section-header .btn-icon-only:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.section-header .token-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

/* Light mode section headers - use darker text on light background */
body.light-mode .section-header {
    background: var(--header-bg, var(--primary));
    color: white;
}

body.light-mode .section-header .format-selector option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.input-section:hover,
.output-section:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--primary);
}

/* Section header styles are defined above with primary color background */

/* Format Selector */
.format-selector-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.format-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.format-selector {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-squircle);
    padding: 0.4rem 0.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    min-width: fit-content;
    overflow: visible;
}

/* Dropdown toggle buttons styled like format selector */
.format-selector.dropdown-toggle {
    position: relative;
    padding-right: 2.5rem;
    min-width: fit-content;
}

.dropdown-arrow {
    position: absolute;
    right: 0.75rem;
    font-size: 0.7rem;
    opacity: 0.7;
    transition: transform var(--transition-fast);
    pointer-events: none;
    flex-shrink: 0;
}

.dropdown.show .dropdown-toggle .dropdown-arrow,
.dropdown.show .dropdown-arrow {
    transform: rotate(180deg);
}

.format-selector:hover {
    border-color: var(--primary);
}

.format-selector:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.token-count {
    background: var(--bg-input);
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border);
    font-family: 'Fira Code', monospace;
}

/* Code Editor Wrapper */
.code-editor-wrapper {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-squircle);
    background: var(--bg-dark);
    overflow: hidden;
    transition: all var(--transition-base);
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.code-editor-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(255, 46, 99, 0.15);
}

/* CodeMirror Styles */
.code-editor-cm {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.code-editor-cm .CodeMirror {
    height: 100%;
    flex: 1;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    background: var(--bg-dark);
    color: var(--text-primary);
}

.code-editor-cm .CodeMirror-scroll {
    min-height: 0;
}

body.light-mode .code-editor-cm .CodeMirror {
    background: #FAFAFA;
    color: var(--text-primary);
}

/* CodeMirror Theme Override */
.code-editor-cm .CodeMirror-gutters {
    background: var(--bg-input);
    border-right: 1px solid var(--border);
}

body.light-mode .code-editor-cm .CodeMirror-gutters {
    background: #F5F5F5;
}

.code-editor-cm .CodeMirror-linenumber {
    color: var(--text-secondary);
    opacity: 0.7;
}

.code-editor-cm .CodeMirror-cursor {
    border-left: 2px solid var(--primary);
}

.code-editor-cm .CodeMirror-selected {
    background: rgba(255, 46, 99, 0.2);
}

.code-editor-cm .CodeMirror-activeline-background {
    background: rgba(255, 46, 99, 0.05);
}

/* Code Editor with Line Numbers (Legacy) */
.code-editor {
    display: flex;
    gap: 0;
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-squircle);
    background: var(--bg-dark);
    overflow: hidden;
    transition: all var(--transition-base);
    flex: 1;
    min-height: 500px;
}

/* Input section editor - full height when not fullscreen */
.input-section:not(.fullscreen) .code-editor-wrapper {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.input-section:not(.fullscreen) .code-editor-cm .CodeMirror {
    height: 100%;
}

.input-section:not(.fullscreen) .input-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    height: 100%;
    resize: none;
}

.input-section:not(.fullscreen) .line-numbers {
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
}

.code-editor:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(255, 46, 99, 0.15);
}

body.light-mode .code-editor {
    background: #FAFAFA;
}

body.light-mode .code-editor:focus-within {
    box-shadow: 0 0 0 2px rgba(255, 46, 99, 0.1);
}

.code-editor-wrapper.error,
.code-editor.error {
    border: 1px solid var(--error);
    animation: shake 0.5s ease-in-out;
}

/* Error line highlighting in CodeMirror */
.code-editor-cm .CodeMirror-line.error-line {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--error);
    padding-left: 5px;
}

/* Status Bar */
.status-bar {
    display: flex;
    gap: var(--spacing-md);
    padding: 0.375rem var(--spacing-md);
    background: var(--bg-input);
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Fira Code', monospace;
}

.status-item {
    display: flex;
    align-items: center;
}

.status-item::before {
    content: '';
    width: 1px;
    height: 12px;
    background: var(--border);
    margin-right: var(--spacing-md);
}

.status-item:first-child::before {
    display: none;
}

/* Validation Indicator */
.validation-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 0;
    font-size: 0.75rem;
    line-height: 1;
    cursor: help;
    transition: all var(--transition-fast);
}

.validation-indicator.valid {
    background: var(--success);
    color: var(--text-primary);
    box-shadow: 0 0 4px var(--success);
}

.validation-indicator.invalid {
    background: var(--error);
    color: white;
    box-shadow: 0 0 4px var(--error);
}

.validation-indicator.pending {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* Validation Notifications */
.validation-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-squircle);
    font-size: 0.9375rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 10001;
    max-width: 400px;
    word-wrap: break-word;
    opacity: 0;
    transition: opacity var(--transition-base);
    animation: slideInRight 0.3s ease-out;
}

.validation-success {
    background: var(--gradient-success);
    color: var(--text-primary);
    border: 2px solid var(--success);
}

.validation-error {
    background: rgba(239, 68, 68, 0.95);
    color: white;
    border: 2px solid var(--error);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Transform Modal Styles */
.transform-modal {
    max-width: 700px;
}

.transform-description {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-input);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.transform-description a {
    color: var(--primary);
    text-decoration: none;
}

.transform-description a:hover {
    text-decoration: underline;
}

.transform-query {
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    resize: vertical;
}

.transform-preview {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    background: var(--bg-dark);
    color: var(--text-primary);
    resize: vertical;
}

.transform-preview.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

/* Settings Modal Styles */
.settings-modal {
    max-width: 600px;
}

.settings-section {
    margin-bottom: var(--spacing-lg);
}

.settings-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--border);
}

.color-picker-group {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.color-picker {
    width: 60px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
}

.color-input {
    flex: 1;
    padding: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
}

.theme-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: var(--spacing-sm);
}

.theme-preset-btn {
    padding: var(--spacing-md);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.theme-preset-btn:hover {
    background: var(--bg-card);
    border-color: var(--primary);
    transform: translateY(-2px);
}

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

.line-numbers {
    flex-shrink: 0;
    width: 3.5rem;
    padding: var(--spacing-md) 0;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    text-align: right;
    user-select: none;
    border-right: 1px solid var(--border);
    overflow: hidden;
    white-space: pre !important;
    padding-right: 0.75rem;
    opacity: 0.7;
}

body.light-mode .line-numbers {
    background: #F5F5F5;
}

.code-editor .input-area,
.code-editor .output-area {
    flex: 1;
    border: none;
    border-radius: 0;
    margin: 0;
}

.code-editor .input-area:focus,
.code-editor .output-area:focus {
    border: none;
    box-shadow: none;
}

/* Textarea Styles */
.input-area,
.output-area {
    width: 100%;
    min-height: 500px;
    background: transparent;
    border: none;
    border-radius: var(--radius-squircle);
    padding: var(--spacing-md);
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
    resize: none;
    white-space: pre;
    overflow-x: auto;
    transition: all var(--transition-base);
}

.input-area:focus,
.output-area:focus {
    outline: none;
}


/* Error Display */
.error-display {
    margin-top: var(--spacing-md);
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid var(--error);
    border-radius: var(--radius-squircle);
    padding: var(--spacing-md);
    display: flex;
    gap: var(--spacing-md);
    animation: slideInUp 0.3s ease-out;
}

.error-display.hidden {
    display: none;
}

.error-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.error-content {
    flex: 1;
}

.error-title {
    font-weight: 600;
    color: var(--error);
    margin-bottom: var(--spacing-xs);
    font-size: 1.125rem;
}

.error-message {
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
    font-size: 0.9375rem;
    margin-bottom: var(--spacing-xs);
    background: var(--bg-input);
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
}

.error-tip {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-style: italic;
}

/* Savings Display */
.savings-display {
    margin-top: var(--spacing-md);
    background: var(--gradient-success);
    border-radius: var(--radius-squircle);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--text-primary);
    animation: slideInUp 0.3s ease-out;
    box-shadow: var(--shadow-neopop), var(--shadow-glow);
    border: 2px solid var(--success);
    min-height: auto;
}

.savings-display.hidden {
    display: none;
}

.savings-icon {
    font-size: 1.25rem;
    animation: pulse 2s infinite;
    flex-shrink: 0;
    line-height: 1;
}

.savings-text {
    font-weight: 500;
    font-size: 0.9375rem;
    line-height: 1.4;
}

.savings-number,
.savings-percent {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

/* Controls - Hidden on desktop, shown on mobile */
.controls {
    display: none;
    flex-direction: row;
    gap: var(--spacing-sm);
    justify-content: center;
    padding: var(--spacing-md);
    flex-wrap: wrap;
}

.controls.mobile-only {
    display: flex;
}

@media (min-width: 1025px) {
    .controls.mobile-only {
        display: none;
    }
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: 0.875rem 1.5rem;
    border: 2px solid transparent;
    border-radius: var(--radius-squircle);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-neopop);
    white-space: nowrap;
    position: relative;
}

.btn-icon {
    font-size: 1.25rem;
}

.btn-primary {
    background: var(--gradient-primary);
    color: var(--text-primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 rgba(255, 46, 99, 0.3), 0 0 20px rgba(255, 46, 99, 0.4);
}

.btn-primary:active {
    transform: translate(4px, 4px);
    box-shadow: none;
}

.btn-secondary {
    background: var(--gradient-accent);
    color: var(--text-primary);
    border-color: var(--accent);
    box-shadow: 4px 4px 0 rgba(236, 72, 153, 0.3);
}

.btn-secondary:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 rgba(236, 72, 153, 0.3), 0 0 20px rgba(236, 72, 153, 0.4);
}

.btn-secondary:active {
    transform: translate(4px, 4px);
    box-shadow: none;
}

/* .btn-clear styles are defined above in conversion controls panel section */

/* Icon-only Buttons (Minimalistic) */
.btn-icon-only {
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.375rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--text-secondary);
    min-width: 2rem;
    min-height: 2rem;
}

.btn-icon-only:hover {
    background: var(--bg-input);
    color: var(--primary);
    transform: scale(1.1);
}

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

.btn-icon-only.dropdown-toggle::after {
    display: none;
}

.copy-icon {
    font-size: 1.25rem;
}

.btn-icon-only.copied {
    background: var(--success);
    border-color: var(--success);
}

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

/* Arrow Buttons (non-circular, like jsoneditor) */
.btn-arrow {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border);
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-squircle);
    /* square-ish corners; keep a little rounding for style */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    padding: 0;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.btn-arrow:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

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

.btn-arrow .btn-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.btn-arrow:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-arrow:disabled:hover {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-primary);
    transform: none;
}

.btn-text {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    margin-right: var(--spacing-xs);
}

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

/* Feature Cards */
.features {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    padding: 0;
}

.feature {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-squircle);
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: center;
    transition: all var(--transition-base);
    flex: 1;
    max-width: 300px;
}

.feature:hover {
    background: var(--bg-card);
    border-color: var(--primary);
}

.feature-icon {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.feature-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--text-primary);
}

.feature-desc {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: var(--spacing-xl) 0;
    border-top: 1px solid var(--border);
    margin-top: var(--spacing-xl);
    background: var(--bg-card);
    color: var(--text-primary) !important;
}

.attribution,
.footer .attribution {
    font-size: 1.125rem;
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary) !important;
}

.heart {
    color: var(--error);
    animation: heartbeat 1.5s infinite;
    display: inline-block;
}

.attribution strong {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.copyright,
.footer .copyright {
    color: var(--text-secondary) !important;
    font-size: 0.875rem;
}

.footer-links {
    margin: var(--spacing-xs) 0;
}

.footer-link,
.footer .footer-link {
    color: var(--text-secondary) !important;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color var(--transition-base);
}

.footer-link:hover,
.footer .footer-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Advertisement Containers */
.ad-container {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-squircle);
    padding: var(--spacing-xs);
    text-align: center;
    overflow: hidden;
}

.ad-label {
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.ad-horizontal {
    margin-bottom: var(--spacing-xs);
    min-height: 90px;
    min-width: 728px;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .ad-horizontal {
        min-width: 320px;
        width: 100%;
    }
}

.ad-bottom {
    margin: var(--spacing-lg) auto;
    max-width: 728px;
    min-width: 728px;
    width: 100%;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .ad-bottom {
        min-width: 320px;
        width: 100%;
        max-width: 100%;
    }
}

.ad-vertical {
    min-height: 200px;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Control Buttons Wrapper */
.control-buttons {
    display: flex;
    flex-direction: row;
    gap: var(--spacing-md);
    align-items: center;
    justify-content: center;
}

/* Suggestions Display */
.suggestions-display {
    margin-top: var(--spacing-md);
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid var(--warning);
    border-radius: var(--radius-squircle);
    padding: var(--spacing-md);
    display: flex;
    gap: var(--spacing-md);
    animation: slideInUp 0.3s ease-out;
}

.suggestions-display.hidden {
    display: none;
}

.suggestions-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.suggestions-content {
    flex: 1;
}

.suggestions-title {
    font-weight: 600;
    color: var(--warning);
    margin-bottom: var(--spacing-xs);
    font-size: 1.125rem;
}

.suggestions-message {
    color: var(--text-primary);
    font-size: 0.9375rem;
    margin-bottom: var(--spacing-sm);
}

.suggestions-list {
    list-style: none;
    padding-left: 0;
}

.suggestions-list li {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-xs);
    padding-left: var(--spacing-md);
    position: relative;
}

.suggestions-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--warning);
    font-weight: bold;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    25% {
        transform: scale(1.2);
    }

    40% {
        transform: scale(1);
    }

    60% {
        transform: scale(1.1);
    }
}

/* Responsive Design - Tablet (already defined above) */

/* Responsive Design - Mobile */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-sm);
    }

    .header h1 {
        font-size: 1.12rem;
    }

    .subtitle {
        font-size: 0.7rem;
    }

    .converter {
        height: auto;
        min-height: 500px;
    }

    .resizable-container {
        min-height: 500px;
    }

    .resizable-panel {
        min-height: 250px;
    }

    .input-area,
    .output-area {
        min-height: 250px;
        font-size: 0.875rem;
    }
    
    .section-header {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
    }
    
    .editor-toolbar {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: var(--spacing-xs);
    }

    .ad-horizontal {
        min-height: 100px;
    }

    .ad-vertical {
        min-height: 100px;
        min-width: 100%;
        margin-top: var(--spacing-md);
    }
    
    .token-count {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    .btn-icon-only {
        font-size: 0.9rem;
        padding: 0.3rem;
        min-width: 1.75rem;
        min-height: 1.75rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1rem;
    }

    .features {
        grid-template-columns: 1fr;
    }

    .ad-horizontal {
        min-height: 50px;
    }
}

/* Authentication & Payment Styles */
.auth-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
}

.payment-plan {
    text-align: center;
    padding: 1rem 0;
}

.payment-plan h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.plan-price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}

.plan-duration {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.plan-features {
    list-style: none;
    text-align: left;
    margin: 1.5rem 0;
    padding: 0;
}

.plan-features li {
    padding: 0.5rem 0;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.plan-features li:last-child {
    border-bottom: none;
}

.payment-methods {
    margin-top: 1.5rem;
}

/* Hide ads for premium users */
.premium-user [id^="ad-"],
.premium-user [id^="adsterra-"] {
    display: none !important;
}

/* Responsive auth buttons */
@media (max-width: 768px) {
    .auth-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .auth-buttons .btn {
        width: 100%;
    }
    
    .user-menu {
        flex-direction: column;
        width: 100%;
    }
}