:root {
    --bg: #f2f4f7;
    --surface: #ffffff;
    --ink: #151a23;
    --muted: #5d6676;
    --line: #dde1e8;
    --accent: #2f4bff;
    --accent-ink: #ffffff;
    --accent-soft: #e6eaff;
    --urgent: #c2371d;
    --urgent-soft: #fdebe6;
    --ok: #1d7a4d;
    --ok-soft: #e4f5ec;
    --radius: 10px;
    --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1218;
        --surface: #171c25;
        --ink: #eef1f6;
        --muted: #9aa4b5;
        --line: #283040;
        --accent: #7b8cff;
        --accent-ink: #0e1218;
        --accent-soft: #1f2750;
        --urgent: #ff8a70;
        --urgent-soft: #3a1f19;
        --ok: #62d49a;
        --ok-soft: #153325;
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.5;
}

a { color: var(--accent); text-underline-offset: 3px; }
h1, h2 { line-height: 1.15; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* En-tête */
.site-header {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    max-width: 44rem; margin: 0 auto; padding: 1rem 1rem 0.5rem;
}
.wordmark {
    font-weight: 800; font-size: 1.5rem; letter-spacing: -0.04em;
    color: var(--ink); text-decoration: none; display: inline-flex; align-items: baseline;
}
.wordmark-caret {
    display: inline-block; width: 0.14em; height: 0.85em; margin-left: 0.06em;
    background: var(--accent); transform: translateY(0.1em);
    animation: caret 1.1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.site-nav { display: flex; align-items: center; gap: 0.25rem; }
.site-nav a {
    color: var(--muted); text-decoration: none; font-weight: 500; font-size: 0.95rem;
    padding: 0.4rem 0.6rem; border-radius: 8px;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.nav-account { display: inline-flex; align-items: center; gap: 0.4rem; }
.avatar {
    display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%;
    background: var(--accent); color: var(--accent-ink); font-size: 0.78rem; font-weight: 600;
}

.site-main { max-width: 44rem; margin: 0 auto; padding: 1rem 1rem 4rem; }

/* Messages */
.flash {
    margin: 0 0 1rem; padding: 0.7rem 0.9rem; border-radius: var(--radius);
    background: var(--accent-soft); list-style: none; font-size: 0.95rem;
}
ul.flash { padding-left: 0.9rem; }
.flash-error { background: var(--urgent-soft); color: var(--urgent); }
.flash-success { background: var(--ok-soft); color: var(--ok); }

/* Boutons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
    min-height: 2.75rem; padding: 0 1.1rem; border-radius: var(--radius);
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-small { min-height: 2.25rem; padding: 0 0.8rem; font-size: 0.9rem; }
.btn-danger { background: var(--urgent); border-color: var(--urgent); color: #fff; }
.link-danger {
    background: none; border: 0; padding: 0.25rem 0; font: inherit; font-size: 0.9rem;
    color: var(--urgent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.btn-mic .mic-dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--urgent); }
.btn-mic.is-recording { background: var(--urgent-soft); border-color: var(--urgent); color: var(--urgent); }
.btn-mic.is-recording .mic-dot { animation: pulse 1s ease-in-out infinite; }
.btn-mic:disabled { opacity: 0.6; cursor: progress; }
@keyframes pulse { 50% { transform: scale(1.5); opacity: 0.5; } }

/* Formulaires */
.form { display: grid; gap: 0.9rem; }
.form label { display: grid; gap: 0.3rem; font-weight: 500; font-size: 0.95rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
    width: 100%; font: inherit; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius); padding: 0.65rem 0.8rem;
}
textarea { resize: vertical; min-height: 3rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form .check-line, .check-line { display: flex; align-items: center; gap: 0.6rem; font-weight: 400; }
.check-line input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.hint { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.form-inline { margin-top: 0.6rem; }
.form-inline select { width: auto; }

/* Champ mot de passe avec bouton œil */
.password-field { position: relative; display: block; }
.password-field input { padding-right: 2.9rem; }
.pw-toggle {
    position: absolute; top: 50%; right: 0.35rem; transform: translateY(-50%);
    display: grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0;
    border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); }
.pw-toggle .eye-off { display: none; }
.pw-toggle[aria-pressed="true"] .eye-on { display: none; }
.pw-toggle[aria-pressed="true"] .eye-off { display: block; }

/* Authentification */
.auth { max-width: 24rem; margin: 2rem auto 0; display: grid; gap: 1rem; }
.auth h1, .auth-lead, .auth-switch, .auth .flash { text-align: center; }
.auth-lead { color: var(--muted); }
.auth-switch { color: var(--muted); font-size: 0.95rem; }

/* Jour */
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.day-nav { display: flex; align-items: center; gap: 0.4rem; }
.day-nav a {
    display: inline-grid; place-items: center; min-width: 2.25rem; height: 2.25rem; padding: 0 0.5rem;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
    color: var(--ink); text-decoration: none;
}
.day-nav .day-today { font-size: 0.9rem; }
.day-date { color: var(--muted); margin: 0.25rem 0 1rem; }
.account-mail { color: var(--muted); margin: 0.25rem 0 1.25rem; }

/* Capture */
.capture {
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    padding: 0.75rem; margin: 1rem 0 1.25rem; box-shadow: 0 1px 0 var(--line);
}
.capture:focus-within { border-color: var(--accent); }
.capture textarea { border: 0; padding: 0.4rem; font-size: 1.15rem; line-height: 1.4; background: transparent; }
.capture textarea:focus-visible { outline: none; }
.capture-bar { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.capture-hint { flex: 1; color: var(--muted); font-size: 0.8rem; }
.capture-status { min-height: 1.2rem; margin-top: 0.4rem; font-size: 0.88rem; color: var(--muted); }
.capture-status.is-error { color: var(--urgent); }
@media (pointer: coarse) { .capture-hint { display: none; } .capture-bar { justify-content: flex-end; } }

.sortbar {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
    padding: 0.6rem 0.8rem; margin-bottom: 1rem; border-radius: var(--radius);
    background: var(--accent-soft); font-size: 0.92rem;
}

/* Notes */
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.note {
    display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; align-items: start;
    background: var(--surface); border: 1px solid var(--line); border-left-width: 4px;
    border-radius: var(--radius); padding: 0.8rem 0.9rem;
}
.note.is-urgent { border-left-color: var(--urgent); }
.note.is-later { opacity: 0.8; }
.note.is-done { opacity: 0.6; }
.note.is-done .note-text { text-decoration: line-through; }
.note-check { margin: 0; }
.check {
    width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 2px solid var(--muted);
    background: transparent; cursor: pointer; padding: 0; position: relative; margin-top: 0.1rem;
}
.check:hover { border-color: var(--accent); }
.check[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); }
.check[aria-pressed="true"]::after {
    content: ""; position: absolute; left: 0.42rem; top: 0.17rem; width: 0.35rem; height: 0.7rem;
    border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.note-body { min-width: 0; }
.note-title { font-weight: 600; margin-bottom: 0.15rem; }
.note-text { overflow-wrap: anywhere; }
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin-top: 0.3rem; font-size: 0.8rem; color: var(--muted); }
.cat { padding: 0.05rem 0.5rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.cat-task { background: var(--ok-soft); color: var(--ok); }
.cat-link { background: var(--accent-soft); color: var(--accent); }
.cat-idea { background: #fff2cf; color: #7a5600; }
.cat-info { background: var(--line); color: var(--muted); }
.cat-other { background: #f8e3ee; color: #8a2a5c; }
@media (prefers-color-scheme: dark) { .cat-idea { background: #3a3010; color: #f1cf6a; } .cat-other { background: #3b1f2e; color: #f0a6c9; } }
.prio { color: var(--urgent); font-weight: 600; }
.note-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.25rem 1rem; margin-top: 0.4rem; }
.note-actions form { margin: 0; }
.note-edit summary { cursor: pointer; font-size: 0.9rem; color: var(--muted); list-style: none; padding: 0.25rem 0; }
.note-edit summary::-webkit-details-marker { display: none; }
.note-edit summary:hover { color: var(--ink); text-decoration: underline; }
.note-edit[open] { flex-basis: 100%; }

.done-list { margin-top: 1.25rem; }
.done-list summary { cursor: pointer; color: var(--muted); margin-bottom: 0.5rem; }

.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

/* Liste / filtres */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.filters input[type="search"] { flex: 1 1 14rem; width: auto; }
.filters select { width: auto; flex: 0 1 auto; }
.result-count { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.5rem; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; color: var(--muted); font-size: 0.92rem; }

/* Compte */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; margin-bottom: 1rem; display: grid; gap: 0.8rem; }
.panel-danger { border-color: var(--urgent); }
.devices { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.devices li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.devices li div { display: grid; }

@media (max-width: 34rem) {
    .site-header { flex-wrap: wrap; }
    .nav-account-label { display: none; }
    h1 { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
