:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #94a3b8;
    --secondary-hover: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --border-color: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    padding: 10px;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    width: 100%;
    max-width: 1200px;
    background-color: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 20px;
    align-self: flex-start;
    transition: background-color 0.3s ease;
}

header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-text {
    text-align: center;
    flex: 1;
}

.header-text h1 {
    font-size: 24px;
    margin: 0;
    color: var(--text-primary);
}

.header-text p {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0.5rem 0 0 0;
}

.theme-toggle {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 20px;
}

.theme-toggle:hover {
    background: var(--background-color);
    transform: scale(1.1);
}

.theme-icon {
    transition: transform 0.3s ease;
}

[data-theme="dark"] .theme-icon {
    transform: rotate(180deg);
}

main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    main {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        grid-template-areas: 
            "input output"
            "status status";
    }
    
    .input-section {
        grid-area: input;
    }
    
    .output-section {
        grid-area: output;
    }
    
    .status-section {
        grid-area: status;
    }
}

.input-section, .output-section {
    display: flex;
    flex-direction: column;
}

label {
    font-weight: 600;
    margin-bottom: 8px;
}

@font-face {
    src: url(fonts/regular.woff2) format("woff2");
    font-family: ml;
    font-weight: 100 900;
    font-style: normal;
    unicode-range: U+0020-007F;
}

textarea {
    width: 100%;
    min-height: 150px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: monolisa, "Courier New", Courier, monospace;
    font-size: 14px;
    resize: vertical;
    box-sizing: border-box;
    background-color: var(--surface-color);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

textarea::placeholder {
    color: var(--text-secondary);
}

#demangled-output {
    background-color: var(--background-color);
    color: var(--text-primary);
}

.controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

button {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-btn {
    background-color: var(--primary-color);
    color: #fff;
}

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

.secondary-btn {
    background-color: var(--secondary-color);
    color: #fff;
}

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

button:disabled {
    background-color: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.output-container {
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 18px;
    padding: 5px 8px;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

.status-section {
    min-height: 20px;
}

.status {
    font-style: italic;
    color: var(--text-secondary);
}

.status.error {
    color: var(--error-color);
    font-weight: bold;
}

footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-secondary);
}

footer h3 {
    font-size: 16px;
    margin-top: 0;
    color: var(--text-primary);
}

footer ul {
    padding-left: 20px;
}

footer code {
    background-color: var(--background-color);
    color: var(--text-primary);
    font-family: monolisa, "Courier New", Courier, monospace;
    padding: 2px 4px;
    border-radius: 3px;
    white-space: nowrap;
}

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

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@media (max-width: 767px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 15px;
        border-radius: 0;
        min-height: 100vh;
        box-shadow: none;
    }

    header {
        padding-bottom: 15px;
        margin-bottom: 15px;
    }

    header h1 {
        font-size: 20px;
    }

    header p {
        font-size: 14px;
    }

    main {
        gap: 15px;
    }

    textarea {
        min-height: 120px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .controls {
        flex-direction: column;
        gap: 8px;
    }

    .controls button {
        width: 100%;
        padding: 12px 15px;
    }

    .copy-btn {
        position: static;
        margin-top: 10px;
        width: 100%;
    }

    footer {
        margin-top: 15px;
        padding-top: 15px;
        font-size: 13px;
    }

    footer h3 {
        font-size: 15px;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 90%;
    }

    textarea {
        min-height: 180px;
    }
}

@media (min-width: 1025px) {
    .container {
        padding: 30px;
    }

    textarea {
        min-height: 200px;
    }

    .controls {
        flex-wrap: wrap;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #0f172a;
        --surface-color: #1e293b;
        --border-color: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
    }

    textarea {
        background-color: var(--surface-color);
        color: var(--text-primary);
    }

    #demangled-output {
        background-color: #0f172a;
    }
}