* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.app-title {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    font-size: 18px;
    opacity: 0.9;
    z-index: 1000;
    font-weight: normal;
    background: rgba(10, 10, 10, 0.9);
    padding: 15px 20px;
    text-align: center;
    border-bottom: 1px solid #333;
}

body.light .app-title {
    background: rgba(245, 245, 245, 0.9);
    border-bottom-color: #ccc;
}

body {
    font-family: 'Courier New', monospace;
    background: #0a0a0a;
    color: #ffffff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 20px 20px 20px;
    transition: all 0.3s ease;
}

body.light {
    background: #f5f5f5;
    color: #333333;
}

/* Main control buttons - match other sections width */
.main-controls {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    margin: 20px 0;
    max-width: 1200px;
    margin: 20px auto;
    width: 100%;
}

.main-controls button {
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1; /* Equal width distribution */
    text-align: center;
}

.main-controls button:hover {
    background: #4a90e2;
    color: white;
    transform: translateY(-1px);
}

.main-controls .theme-toggle {
    background: #4a90e2;
    color: white;
    border: none;
}


/* For smaller screens, make buttons even more compact */
@media (max-width: 768px) {
    .main-controls button {
        padding: 6px 10px;
        font-size: 12px;
        gap: 6px;
    }
}

/* New horizontal layout controls */
.settings-sections {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    min-width: 0;
}

.control-section {
    border: 1px solid #333;
    border-radius: 6px;
    background: rgba(26, 26, 26, 0.5);
    overflow: hidden;
}

body.light .control-section {
    border-color: #ccc;
    background: rgba(255, 255, 255, 0.8);
}

.control-header {
    padding: 10px 15px;
    background: #1a1a1a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #333;
    transition: background 0.2s;
}

.control-header:hover {
    background: #222;
}

body.light .control-header {
    background: #e0e0e0;
    border-bottom-color: #ccc;
}

body.light .control-header:hover {
    background: #d0d0d0;
}

.control-section.collapsed .control-header {
    border-bottom: none;
}

.control-title {
    font-size: 14px;
    color: #4a90e2;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-arrow {
    font-size: 12px;
    transition: transform 0.2s;
}

.control-section.collapsed .dropdown-arrow {
    transform: rotate(-90deg);
}

.section-content {
    padding: 15px;
    display: block;
}

.control-section.collapsed .section-content {
    display: none;
}

.section-preview {
    font-size: 12px;
    opacity: 0.6;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.control-row:last-child {
    margin-bottom: 0;
}

/* Special layout for text input */
.text-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    align-items: start;
}

.text-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.converged-char-highlight {
    background: var(--convergence-color, #4a90e2);
    color: #fff;
    animation: charHighlight 2s ease-out;
}

@keyframes charHighlight {
    0% { 
        background: var(--convergence-color, #4a90e2);
        transform: scale(1.05);
    }
    80% { 
        background: var(--convergence-color, #4a90e2);
        transform: scale(1);
    }
    100% { 
        background: transparent;
        transform: scale(1);
    }
}

.converged-char-underline {
    border-bottom: 2px solid var(--convergence-color, #4a90e2);
    animation: charUnderline 2s ease-out;
}

@keyframes charUnderline {
    0% { 
        border-bottom-width: 3px;
        transform: scale(1.05);
    }
    80% { 
        border-bottom-width: 2px;
        transform: scale(1);
    }
    100% { 
        border-bottom-width: 0px;
        transform: scale(1);
    }
}

label {
    font-size: 11px;
    opacity: 0.8;
    white-space: nowrap;
}

input, button, select, textarea {
    padding: 6px 8px;
    border: 1px solid #333;
    background: #1a1a1a;
    color: #fff;
    border-radius: 3px;
    font-family: inherit;
    font-size: 12px;
    width: 100%;
}

textarea {
    min-height: 60px;
    resize: vertical;
}

input[type="range"] {
    width: 100%;
}

input[type="color"] {
    width: 50px;
    height: 30px;
    padding: 0;
    border: none;
}

input[type="number"] {
    width: 80px;
}

body.light input,
body.light button,
body.light select,
body.light textarea {
    background: #fff;
    color: #333;
    border-color: #ccc;
}

body.light input[type="color"] {
    background: #fff;
    border-color: #ccc;
}

button {
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover {
    background: #4a90e2;
    color: white;
}

.theme-toggle {
    background: #4a90e2;
    color: white;
    border: none;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.animation-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 800px;
    height: 400px;
    position: relative;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 15px;
    margin-bottom: 30px;
    background: #0a0a0a;
}

body.light .animation-container {
    border-color: #ccc;
    background: #f5f5f5;
}

.text-display {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    line-height: 1.4;
    letter-spacing: 2px;
    white-space: pre-line;
    font-family: 'Courier New', monospace;
    position: relative;
    z-index: 2;
}

/* Export Modal Styles */
.export-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.export-modal.visible {
    display: flex;
}

.export-modal-content {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 30px 40px;
    text-align: center;
    min-width: 320px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

body.light .export-modal-content {
    background: #fff;
    border-color: #ccc;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.export-modal-header {
    font-size: 20px;
    margin-bottom: 20px;
    color: #4a90e2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.export-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #4a90e233;
    border-top-color: #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.export-modal-content.complete .export-spinner {
    display: none;
}

.export-modal-tip {
    font-size: 11px;
    opacity: 0.5;
    margin-top: 12px;
    font-style: italic;
}

.export-modal-line {
    font-size: 14px;
    margin-bottom: 15px;
    opacity: 0.8;
}

.export-modal .progress-bar {
    width: 100%;
    height: 8px;
    background: #333;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}

body.light .export-modal .progress-bar {
    background: #ddd;
}

.export-modal .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a90e2, #67a9f0);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.export-modal-status {
    font-size: 13px;
    min-height: 20px;
}

.export-modal-status .success {
    color: #4ade80;
}

body.light .export-modal-status .success {
    color: #16a34a;
}

.progress-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
}

body.light .progress-bar {
    background: #ccc;
}

.progress-fill {
    height: 100%;
    background: #4a90e2;
    width: 0%;
    transition: width 0.3s ease;
}

.status {
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    font-size: 14px;
}

.status.success {
    background: #2d5a2d;
    color: #90ee90;
}

body.light .status.success {
    background: #e8f5e8;
    color: #2d5a2d;
}

.grid-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.grid-background canvas {
    width: 100%;
    height: 100%;
}