/* Dark theme is the factory default; light theme via html[data-theme="light"] */
:root {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #334155;
    --input-bg: #0f172a;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success-bg: #064e3b;
    --success-text: #6ee7b7;
    --error-bg: #450a0a;
    --error-text: #fca5a5;
}

html[data-theme="light"] {
    --bg: #f4f5f7;
    --card-bg: #ffffff;
    --text: #1f2933;
    --muted: #6b7280;
    --border: #d1d5db;
    --input-bg: #ffffff;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success-bg: #ecfdf5;
    --success-text: #047857;
    --error-bg: #fef2f2;
    --error-text: #b91c1c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.2s, color 0.2s;
}

main {
    display: flex;
    justify-content: center;
    padding: 3rem 1rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 520px;
}

.card.narrow {
    max-width: 360px;
}

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

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

label {
    display: block;
    margin: 1rem 0 0.3rem;
    font-weight: 600;
    font-size: 0.9rem;
}

input,
textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}

input:focus,
textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
}

textarea {
    resize: vertical;
}

button[type="submit"] {
    margin-top: 1.25rem;
    width: 100%;
    padding: 0.6rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

button[type="submit"]:hover {
    background: var(--primary-hover);
}

.link-button {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.4rem 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

.counter {
    text-align: right;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.alert {
    padding: 0.7rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    word-break: break-word;
}

.alert.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.alert.error {
    background: var(--error-bg);
    color: var(--error-text);
}

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

.diag h2 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.diag pre {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.8rem;
    font-size: 0.78rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.field-error {
    display: block;
    color: var(--error-text);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}
