:root {
    --magenta: #e20074;
    --magenta-dark: #b30058;
    --bg: #f4f4f6;
    --card: #ffffff;
    --text: #1c1c1e;
    --text-muted: #6e6e73;
    --border: #d1d1d6;
    --error: #c0392b;
    --success: #237b3a;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1c1e;
        --card: #2c2c2e;
        --text: #f2f2f7;
        --text-muted: #9c9ca1;
        --border: #3a3a3c;
        --shadow: 0 1px 2px rgba(0,0,0,.2), 0 8px 24px rgba(0,0,0,.3);
    }
}

* { box-sizing: border-box; }

/* Make the HTML `hidden` attribute reliably win over component-level
   `display: flex/grid/...` rules. Without this, e.g. `.user-bar { display: flex }`
   would keep an element visible even with `hidden` set. */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

header {
    background: var(--magenta);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4caf50;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

main {
    max-width: 600px;
    margin: 24px auto;
    padding: 0 16px 40px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 4px 0 16px;
}

.field, label.field, form label {
    display: block;
    margin-bottom: 14px;
    font-size: 0.95rem;
    font-weight: 500;
}

input[type="text"],
input[type="tel"],
input[type="password"],
select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    font-size: 1rem;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    appearance: none;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--magenta);
    box-shadow: 0 0 0 3px rgba(226, 0, 116, 0.18);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}

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

.btn-primary:hover { background: var(--magenta-dark); }
.btn-primary:disabled { background: var(--text-muted); cursor: not-allowed; }

.btn-ghost {
    background: transparent;
    color: inherit;
    border-color: var(--border);
}

.btn-ghost:hover { background: rgba(0,0,0,0.04); }
@media (prefers-color-scheme: dark) {
    .btn-ghost:hover { background: rgba(255,255,255,0.06); }
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 8px 0 18px;
    font-weight: 500;
}

.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 30px;
    transition: background 0.18s;
    cursor: pointer;
}

.slider::before {
    content: "";
    position: absolute;
    height: 24px;
    width: 24px;
    top: 3px;
    left: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.18s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.switch input:checked + .slider {
    background: var(--magenta);
}

.switch input:checked + .slider::before {
    transform: translateX(22px);
}

.switch input:focus-visible + .slider {
    box-shadow: 0 0 0 3px rgba(226, 0, 116, 0.18);
}

.error {
    color: var(--error);
    font-size: 0.9rem;
    margin: 12px 0 0;
}

.success {
    color: var(--success);
    font-size: 0.9rem;
    margin: 12px 0 0;
}

.status {
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.loader {
    text-align: center;
    color: var(--text-muted);
    padding: 16px;
    font-size: 0.95rem;
}

footer {
    text-align: center;
    color: var(--text-muted);
    padding: 16px;
    font-size: 0.85rem;
}

.diag {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.diag summary {
    cursor: pointer;
    user-select: none;
}

.diag pre {
    background: rgba(0,0,0,0.04);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.78rem;
    max-height: 320px;
    margin-top: 8px;
}

@media (prefers-color-scheme: dark) {
    .diag pre { background: rgba(255,255,255,0.04); }
}

@media (max-width: 480px) {
    main { padding: 0 12px 30px; margin-top: 16px; }
    .card { padding: 16px; }
    header h1 { font-size: 1.1rem; }
    .actions { flex-direction: column; }
    .btn { width: 100%; }
}
