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

/* CSS Variables for theming */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #333;
    --border-color: #3a3a3a;
    --border-hover: #4a4a4a;
    --text-primary: #e0e0e0;
    --text-secondary: #aaa;
    --text-muted: #888;
    --text-disabled: #666;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --button-bg: #444;
    --button-hover: #555;
    --preview-bg: #1a1a1a;
}

body.light-theme {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --border-color: #dee2e6;
    --border-hover: #adb5bd;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --text-disabled: #adb5bd;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --button-bg: #e9ecef;
    --button-hover: #dee2e6;
    --preview-bg: #ffffff;
}

/* Loading and error states for code display */
.loading, .error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    font-style: italic;
    opacity: 0.7;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    margin: 20px;
}

.loading {
    color: var(--accent-primary);
}

.loading::before {
    content: "⟳";
    display: inline-block;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    font-size: 1.2em;
}

.error {
    color: #ff6b6b;
    border-color: #ff6b6b;
}

.error::before {
    content: "⚠";
    margin-right: 8px;
    font-size: 1.2em;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.hidden {
    display: none;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    padding: 10px 20px;
    text-align: center;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Logo and title layout */
.title-with-logo {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.logo {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

body.light-theme .logo {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* Disabled states for front page */
select:disabled, button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.title-text {
    flex: 1;
}

h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    display: none;
}

.description-section {
    padding: 20px;
    margin: 10px auto;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    max-width: 1200px;
}

.description {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
    text-align: left;
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin: 0;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

.status {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    transition: color 0.3s ease;
}

.comparison-container {
    flex: 1;
    display: flex;
    align-items: stretch;
    padding: 8px;
    gap: 12px;
    min-height: 0;
}

.code-panel {
    flex: 1;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: border-color 0.3s ease, background-color 0.3s ease;
    min-width: 0;
    width: 0;
}

.code-panel:hover {
    border-color: var(--border-hover);
}

.panel-label {
    position: absolute;
    top: 10px;
    left: 15px;
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    z-index: 10;
}

.code-panel:last-child .panel-label {
    background: #764ba2;
}

.panel-summary {
    position: absolute;
    top: 10px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: #ccc;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    z-index: 10;
    max-width: 200px;
    text-align: right;
    line-height: 1.3;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

body.show-summaries .panel-summary {
    opacity: 1;
    visibility: visible;
}

.code-panel pre {
    flex: 1;
    padding: 30px 20px 20px;
    overflow: auto;
    margin: 0;
    min-width: 0;
}

.code-panel code {
    display: block;
    white-space: pre;
    tab-size: 4;
    overflow-x: auto;
    width: 100%;
}

.divider {
    display: flex;
    align-items: center;
    justify-content: center;
}

.vs {
    background: var(--bg-tertiary);
    color: var(--text-disabled);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.controls {
    padding: 12px;
    display: flex;
    gap: 12px;
    justify-content: center;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.choice-btn {
    padding: 10px 24px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
}

.choice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.choice-btn.neutral {
    background: var(--button-bg);
    transition: all 0.3s ease;
}

.choice-btn.neutral:hover {
    background: var(--button-hover);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.1);
}

.key-hint {
    opacity: 0.8;
    font-size: 12px;
}

/* Floating choice buttons */
.floating-choice-btn {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: 500;
    transition: all 0.3s ease;
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.floating-choice-btn:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.floating-choice-btn:active {
    transform: translateX(-50%) translateY(0);
}

.floating-choice-btn.neutral {
    background: var(--button-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.floating-choice-btn.neutral:hover {
    background: var(--button-hover);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.1);
}

.divider .floating-choice-btn {
    bottom: 20px;
}

.footer {
    padding: 8px 15px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.about-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    padding: 4px 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.about-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

#languageSelect {
    padding: 5px 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.reset-btn {
    padding: 5px 12px;
    background: var(--button-bg);
    color: var(--text-primary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    font-size: 13px;
}

.reset-btn:hover {
    background: var(--button-hover);
}

.comparison-count {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
    transition: color 0.3s ease;
}

/* Theme toggle switch */
.theme-toggle {
    display: flex;
    align-items: center;
}

.toggle-switch {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 10px;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    width: 40px;
    height: 20px;
    background: var(--button-bg);
    border-radius: 20px;
    position: relative;
    transition: background 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-label {
    color: var(--text-secondary);
    font-size: 13px;
    user-select: none;
    transition: color 0.3s ease;
}

/* Font family selector */
.font-family-selector {
    flex: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: auto;
}

.font-family-selector.hidden {
    display: none;
}

.font-family-selector h2 {
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 24px;
}

.selector-subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
    text-align: center;
    transition: color 0.3s ease;
}

.font-families-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1200px;
}

.font-family-option {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.font-family-option:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.font-family-option.selected {
    border-color: #667eea;
    background: #2d2d3a;
}

.font-family-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
    transition: color 0.3s ease;
}

.font-family-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 15px;
    line-height: 1.4;
    transition: color 0.3s ease;
}

.font-family-preview {
    background: var(--preview-bg);
    padding: 15px;
    border-radius: 4px;
    font-size: 16px !important;
    line-height: 1.5 !important;
    color: var(--text-primary);
    overflow: hidden;
    white-space: pre;
    margin: 0;
    display: block;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.results {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 100;
    padding: 40px;
    overflow: auto;
    transition: background-color 0.3s ease;
}

.results.hidden {
    display: none;
}

.results h2 {
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-details {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.result-details p {
    margin: 10px 0;
    font-size: 14px;
}

.family-description {
    font-style: italic;
    color: #888 !important;
    font-size: 13px !important;
    margin: 5px 0 15px 0 !important;
}

.result-details strong {
    color: #667eea;
    display: inline-block;
    width: 150px;
}

.result-preview {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.result-preview h3 {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 16px;
    transition: color 0.3s ease;
}

.result-preview pre {
    overflow: auto;
    max-height: 300px;
}

.result-actions {
    text-align: center;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.result-actions button {
    padding: 12px 30px;
    font-size: 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.result-actions button:first-child {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.result-actions button:last-child {
    background: #444;
    color: white;
}

.result-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--button-bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--button-hover);
}

/* Results page styling */
.results-section h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.re-compare-btn {
    padding: 4px 12px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s ease;
}

.re-compare-btn:hover {
    background: var(--accent-secondary);
}

.export-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.export-section h4 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.compact-export {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.compact-export label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.compact-export input {
    width: 70%;
    padding: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.compact-export button {
    padding: 8px 16px;
    margin-left: 10px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.compact-export button:hover {
    background: var(--accent-secondary);
}

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

.export-buttons button {
    padding: 12px 16px;
    background: var(--button-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.export-buttons button:hover {
    background: var(--button-hover);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

/* Import field styling */
.import-section {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.import-section-inline {
    margin-top: 30px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.import-section h4,
.import-section-inline h4 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.import-field {
    display: flex;
    gap: 10px;
    align-items: center;
}

.import-field input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.import-field button {
    padding: 8px 16px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.import-field button:hover {
    background: var(--accent-secondary);
}

/* Instruction Modal Styles */
.instruction-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.instruction-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease;
}

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

.instruction-header h3 {
    margin: 0;
    color: var(--accent-primary);
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

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

.instruction-body {
    padding: 20px;
}

.instruction-body ol {
    margin: 0;
    padding-left: 20px;
}

.instruction-body li {
    margin: 12px 0;
    line-height: 1.6;
    color: var(--text-primary);
}

.instruction-body li code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Fira Code', 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    color: var(--accent-primary);
}

.instruction-body li strong {
    color: var(--accent-primary);
    font-weight: 600;
}

.instruction-footer {
    padding: 15px 20px 20px 20px;
    text-align: center;
}

.instruction-footer button {
    padding: 10px 24px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.3s ease;
}

.instruction-footer button:hover {
    background: var(--accent-secondary);
}

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

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