:root {
    --red: #E31E24;
    --red-dark: #b91519;
    --red-light: #fdecea;
    --charcoal: #2D3748;
    --charcoal-light: #4a5568;
    --bg: #f4f5f7;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #2D3748;
    --muted: #718096;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

/* ── Header ── */
.header {
    background: var(--charcoal);
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.header img {
    height: 56px;
    width: auto;
}
.header-title {
    display: flex;
    flex-direction: column;
}
.header-title span:first-child {
    font-size: 1.4rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: .04em;
    text-transform: uppercase;
    line-height: 1.1;
}
.header-title span:first-child em {
    color: var(--red);
    font-style: normal;
}
.header-title span:last-child {
    font-size: .75rem;
    color: #a0aec0;
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* ── Layout ── */
.page {
    max-width: 860px;
    margin: 2rem auto;
    padding: 0 1rem 4rem;
}

/* ── Cards ── */
.card {
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1.75rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    margin-bottom: 1.25rem;
}
.card-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--charcoal);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.card-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1.1em;
    background: var(--red);
    border-radius: 2px;
}

/* ── Labels & textareas ── */
label {
    display: block;
    font-size: .8rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .4rem;
}
textarea {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: .9em;
    transition: border-color .2s;
    resize: vertical;
    font-family: inherit;
}
textarea:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(227,30,36,.1);
}
#inputText  { height: 180px; }
#outputJson {
    height: 380px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: .82em;
    background: #f9fafb;
}
#outputJson.error { color: #c53030; background: #fff5f5; border-color: #fc8181; }
#outputJson.valid { background: #f0fff4; border-color: #68d391; }

/* ── Buttons ── */
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .65rem 1.25rem;
    font-size: .9rem;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, transform .1s, opacity .15s;
    font-family: inherit;
    white-space: nowrap;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--red);
    color: #fff;
    width: 100%;
    padding: .8rem;
    font-size: 1rem;
    margin-bottom: .75rem;
}
.btn-primary:hover:not(:disabled) { background: var(--red-dark); }

.btn-warning {
    background: #fef3c7;
    color: #92400e;
    flex: 1;
}
.btn-warning:hover:not(:disabled) { background: #fcd34d; }

.btn-success {
    background: #2D3748;
    color: #fff;
    flex: 1;
}
.btn-success:hover:not(:disabled) { background: #1a202c; }




.button-group {
    display: flex;
    gap: .75rem;
    margin-bottom: .75rem;
}

/* ── Messages ── */
.validation-message {
    padding: 10px 14px;
    margin-bottom: .75rem;
    border-radius: 8px;
    font-size: .88rem;
    display: none;
}
.validation-message.success {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    color: #276749;
    display: block;
}
.validation-message.error {
    background: #fff5f5;
    border: 1px solid #fc8181;
    color: #c53030;
    display: block;
}


/* ── Vikunja (optionnel) ── */
.vk-check {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.4;
    margin-bottom: .9rem;
    cursor: pointer;
}
.vk-check input {
    margin-top: .2rem;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--red);
    cursor: pointer;
}
.vk-note {
    font-size: .82rem;
    color: var(--muted);
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .65rem .85rem;
    margin-bottom: 1.1rem;
    line-height: 1.45;
}
.vk-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: .9em;
    font-family: inherit;
    margin-bottom: .9rem;
    transition: border-color .2s;
}
.vk-input:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(227,30,36,.1);
}
#vikunjaButton,
#vkSaveButton { width: 100%; margin-top: .25rem; }

/* ── Bandeau utilisateur (header) ── */
.header-user {
    margin-left: auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .5rem;
}
.header-user a {
    color: #fff;
    background: var(--red);
    font-size: .75rem;
    font-weight: 700;
    text-decoration: none;
    padding: .35rem .75rem;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}
.header-user a:hover { background: var(--red-dark); }
/* Lien Paramètres / navigation : gris pour le distinguer de Déconnexion (rouge) */
.header-user a.header-link { background: var(--charcoal-light); }
.header-user a.header-link:hover { background: #1a202c; }

/* ── Page de connexion ── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}
.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 12px 40px rgba(0,0,0,.12);
}
.login-logo { text-align: center; margin-bottom: 1rem; }
.login-logo img { height: 64px; width: auto; }
.login-card h2 {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--charcoal);
    margin-bottom: .2rem;
}
.login-card h2 em { color: var(--red); font-style: normal; }
.login-sub {
    text-align: center;
    color: var(--muted);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 1.5rem;
}
.login-form .btn-primary { margin-top: .5rem; }

/* ── Bouton secondaire (découverte CalDAV) ── */
.btn-secondary {
    background: #ebf8ff;
    color: #2b6cb0;
    flex: 1;
}
.btn-secondary:hover:not(:disabled) { background: #bee3f8; }

/* ── Chips de collections découvertes ── */
.vk-collections {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .75rem;
}
.btn-collection {
    background: #edf2f7;
    color: var(--charcoal);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: .4rem .85rem;
    font-size: .83rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
    flex: none;
    font-family: inherit;
}
.btn-collection:hover { background: #e2e8f0; border-color: var(--charcoal-light); }
.btn-collection.selected { background: var(--red-light); border-color: var(--red); color: var(--red-dark); }

/* ── Responsive ── */
@media (max-width: 520px) {
    .header { padding: 1rem; }
    .header img { height: 42px; }
    .button-group { flex-direction: column; }
    .button-group button { width: 100%; }
    .email-row { flex-direction: column; }
    .email-row button { width: 100%; }
}
