:root {
    --bg: #f4f4f6;
    --surface: #ffffff;
    --surface-alt: #f1f3f5;
    --border: #d8dbe0;
    --text: #1b1d21;
    --muted: #5d6370;
    --accent: #3858e9;
    --accent-hover: #2b46c2;
    --success: #1f8a4c;
    --warn: #b8630f;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111317;
        --surface: #1a1d23;
        --surface-alt: #22262d;
        --border: #2e333c;
        --text: #e7e9ee;
        --muted: #9098a6;
        --accent: #6f8bff;
        --accent-hover: #8ba3ff;
        --success: #52c281;
        --warn: #e0a65c;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.5);
    }
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

.container {
    width: 100%;
    max-width: 720px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 2rem;
}

header h1 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
}

.subtitle {
    margin: 0 0 1.5rem;
    color: var(--muted);
    font-size: 0.95rem;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin: 1rem 0 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

textarea, #output {
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9rem;
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    line-height: 1.5;
}

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

textarea:focus, #output:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

#output {
    min-height: 120px;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

#output:empty::before {
    content: "Output will appear here as you type.";
    color: var(--muted);
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0 0.5rem;
    flex-wrap: wrap;
}

.mode-switch {
    display: flex;
    gap: 1rem;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.mode-switch label {
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    font-weight: 400;
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
    cursor: pointer;
}

button.copy {
    padding: 0.5rem 1.1rem;
    border: none;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease;
}

button.copy:hover { background: var(--accent-hover); }
button.copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translate(-50%, 1rem);
    background: var(--text);
    color: var(--surface);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

#toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

#toast[data-variant="warn"] { background: var(--warn); color: #fff; }
#toast[data-variant="success"] { background: var(--success); color: #fff; }
