:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-light: #d1fae5;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    /* Aliases */
    --bg: var(--bg-primary);
    --text: var(--text-primary);
    --primary: var(--accent);
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #34d399;
    --accent-hover: #10b981;
    --accent-light: #064e3b;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    /* Aliases */
    --bg: var(--bg-primary);
    --text: var(--text-primary);
    --primary: var(--accent);
}

.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    font-size: 1.25rem;
    transition: transform 0.2s;
    z-index: 100;
}
.theme-toggle:hover { transform: scale(1.1); }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

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

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary), #f97316);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.badges {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.badge-green {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-blue {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-purple {
    background: rgba(139, 92, 246, 0.15);
    color: #7c3aed;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.generator-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 3rem;
}

.mode-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.input-section {
    margin-bottom: 1.5rem;
}

.input-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.input-section textarea {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    border: 2px solid var(--border);
    border-radius: 8px;
    resize: vertical;
    transition: border-color 0.2s;
}

.input-section textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.options-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
}

.option-group label:first-child {
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: block;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.radio-label:hover {
    background: white;
}

.radio-label input {
    cursor: pointer;
}

.radio-label span {
    font-weight: 500;
}

.radio-label small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.btn-primary {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

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

.output-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.output-header label {
    font-weight: 600;
}

.copy-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    background: white;
    border: 2px solid var(--primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: var(--primary);
    color: white;
}

#output-text {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    resize: vertical;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.reference-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.reference-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.encoding-table {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
}

.encoding-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--background);
    border-radius: 6px;
    font-size: 0.85rem;
}

.encoding-row code {
    font-family: 'SF Mono', Monaco, monospace;
    color: var(--primary);
}

.features {
    margin-bottom: 3rem;
}

.features h2, .faq h2 {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: 2rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
}

.feature {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.feature-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.75rem;
}

.feature h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.feature p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.faq {
    margin-bottom: 3rem;
}

.faq-category {
    margin-bottom: 2rem;
}

.faq-category-title {
    font-size: 1.2rem;
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.faq-item {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.faq-item h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.faq-item p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.7;
}

.faq-item code {
    background: var(--background);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.85rem;
}

footer {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 0;
}

@media (max-width: 600px) {
    header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary), #f97316);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
    .generator-card { padding: 1.5rem; }
    .mode-tabs { flex-direction: column; }
    .encoding-table { grid-template-columns: 1fr; }
}

/* Theme Toggle Button */

/* Dark Mode - Variable Overrides */

[data-theme="dark"] body {
    background: #0f172a;
    color: #f1f5f9;
}

[data-theme="dark"] .container {
    color: #f1f5f9;
}

[data-theme="dark"] .generator-card,
[data-theme="dark"] .feature,
[data-theme="dark"] .faq-item {
    background: #1e293b;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: #0f172a;
    color: #f1f5f9;
    border-color: #334155;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #64748b;
}

[data-theme="dark"] .tab-btn {
    background: #0f172a;
    color: #94a3b8;
    border-color: #334155;
}

[data-theme="dark"] .tab-btn:hover {
    color: #f1f5f9;
}

[data-theme="dark"] code {
    background: #0f172a;
    color: #f1f5f9;
}

[data-theme="dark"] .badge {
    background: #1e293b;
}

[data-theme="dark"] .subtitle,
[data-theme="dark"] .faq-item p,
[data-theme="dark"] .feature p {
    color: #94a3b8;
}

[data-theme="dark"] footer {
    color: #64748b;
}

[data-theme="dark"]