:root {
    color-scheme: light dark;
    --bg: #f7f7fb;
    --card-bg: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --ring: rgba(37, 99, 235, 0.35);
    --border: #e5e7eb;
    --input-bg: #ffffff;
    --surface-1: #f3f4f6; /* subtle panel like result background */
    --error-bg: #fee2e2; /* red-100 */
    --error-border: #fca5a5; /* red-300 */
    --error-text: #991b1b; /* red-800 */
    --space-1: 6px;
    --space-2: 10px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
}

html, body {
    height: 100%;
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    color: var(--text);
    background: radial-gradient(1200px 600px at 10% -10%, #e0e7ff55, transparent),
                radial-gradient(1200px 600px at 110% 10%, #fde68a66, transparent),
                var(--bg);
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    place-items: center;
    padding: var(--space-5) var(--space-3);
    box-sizing: border-box;
}

.container {
    width: min(680px, 80vw);
    background-color: var(--card-bg);
    padding: clamp(18px, 3.5vw, 28px);
    border-radius: 16px;
    box-shadow:
        0 20px 25px -5px rgba(0,0,0,0.08),
        0 8px 10px -6px rgba(0,0,0,0.06);
    display: grid;
    grid-auto-flow: row;
    gap: var(--space-4);
}

label { margin-bottom: var(--space-2); }

input[type="text"] {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    line-height: 1.4;
    width: 100%;
    box-sizing: border-box;
    background: var(--input-bg, #fff);
    transition: box-shadow .15s ease, border-color .15s ease, background-color .15s ease;
}

input[type="text"]::placeholder { color: #9ca3af; }

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--ring);
}

button {
    background-color: var(--primary);
    color: #fff;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
    transition: transform .06s ease, background-color .15s ease, box-shadow .15s ease;
}

button:hover { background-color: var(--primary-600); }
button:active { transform: translateY(1px); }
button:focus { outline: none; box-shadow: 0 0 0 4px var(--ring); }

#resultDiv {
    display: block;
    padding: 12px 14px;
    background: var(--surface-1, #f3f4f6);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    word-break: break-all;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}


#generateButton {
    /*width: 50%;*/
    justify-self: center;
}
#copyButton {
    /*width: %;*/
    justify-self: center;
}

a {
    color: var(--muted);
    text-decoration: none;
    justify-self: center;
    cursor: pointer;
}

a:hover { text-decoration: underline; }

/* Dark mode — follow system preference */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #2e3137; 
        --card-bg: #151b28;
        --text: #e5e7eb; /* gray-200 */
        --muted: #9ca3af; /* gray-400 */
        --primary: #3b82f6; /* slightly lighter blue for dark */
        --primary-600: #60a5fa;
        --ring: rgba(59, 130, 246, 0.35);
        --border: #334155; /* slate-700 for clearer edges */
        --input-bg: #232f42;
        --surface-1: #0f172a; /* subtle elevated panel */
        --error-bg: #2a0f13; /* deep red tint */
        --error-border: #7f1d1d; /* red-900 */
        --error-text: #fecaca; /* red-200 */
    }

    body {
        background:
            radial-gradient(1200px 600px at 10% -10%, rgba(30, 58, 138, 0.25), transparent),
            radial-gradient(1200px 600px at 110% 10%, rgba(120, 53, 15, 0.22), transparent),
            var(--bg);
    }

    input[type="text"]::placeholder { color: #6b7280; }

    button:hover { background-color: var(--primary-600); }

    /* Keep spinner visible on dark buttons */
    button.loading::after {
        border: 2.5px solid rgba(255,255,255,0.45);
        border-top-color: #fff;
    }

    .container {
        box-shadow:
            0 20px 25px -5px rgba(0,0,0,0.45),
            0 8px 10px -6px rgba(0,0,0,0.4),
            0 0 0 1px rgba(255,255,255,0.06);
    }

    input[type="text"] {
        background: var(--input-bg);
        border-color: var(--border);
    }
}