/* ==========================================================================
   todo — feuille de style unique. Concue pour le telephone d'abord.
   Regles : grandes zones tactiles (44px mini), peu de couleurs, rien de
   superflu a l'ecran. L'ordinateur ne fait qu'elargir la meme mise en page.
   ========================================================================== */

:root {
    --c-ink:       #16303d;
    --c-ink-soft:  #5b7180;
    --c-ink-faint: #93a5b1;
    --c-primary:   #0f3d56;
    --c-bg:        #f4f7f9;
    --c-surface:   #ffffff;
    --c-line:      #e4ebef;

    --c-now:       #d97742;
    --c-soon:      #3f7fa8;
    --c-later:     #9aa8b3;
    --c-done:      #4aab86;
    --c-danger:    #c9503f;

    --radius:      14px;
    --shadow:      0 1px 2px rgba(22, 48, 61, .05), 0 3px 12px rgba(22, 48, 61, .05);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--c-bg);
    color: var(--c-ink);
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.4;
    -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }

.app-loading { padding: 90px 20px; text-align: center; color: var(--c-ink-faint); }
.hidden { display: none !important; }

/* ============================================================ ecran du PIN */

.pin-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px calc(24px + var(--safe-bottom));
}

.pin-title {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.6px;
    color: var(--c-primary);
    margin: 0 0 26px;
}

.pin-dots {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
    min-height: 18px;
}

.pin-dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1.5px solid #b9c8d2;
    background: transparent;
    transition: background .12s, transform .12s, border-color .12s;
}

.pin-dot.filled {
    background: var(--c-primary);
    border-color: var(--c-primary);
    transform: scale(1.12);
}

.pin-error {
    min-height: 22px;
    font-size: 14px;
    color: var(--c-danger);
    text-align: center;
    margin: 0 0 14px;
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    width: 100%;
    max-width: 300px;
}

.pin-key {
    height: 68px;
    border-radius: 50%;
    background: var(--c-surface);
    box-shadow: var(--shadow);
    font-size: 26px;
    font-weight: 500;
    color: var(--c-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: background .1s, transform .1s;
}

.pin-key:active { background: #e6eef3; transform: scale(.94); }

.pin-key--fn {
    background: transparent;
    box-shadow: none;
    font-size: 22px;
    color: var(--c-ink-soft);
}

.pin-key--fn:active { background: rgba(22, 48, 61, .07); }

.pin-screen.shake .pin-dots { animation: shake .3s; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-7px); }
    75%      { transform: translateX(7px); }
}

/* ================================================================ en-tete */

.topbar {
    background: var(--c-primary);
    color: #fff;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-title {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin: 0;
    margin-right: auto;
}

.topbar-count {
    font-weight: 400;
    opacity: .65;
    font-size: 14px;
    margin-left: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 17px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.icon-btn:active { background: rgba(255, 255, 255, .3); }

.icon-btn.spinning { animation: spin .7s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================== filtres client / site web */

.chips {
    display: flex;
    gap: 8px;
    padding: 11px 12px;
    overflow-x: auto;
    background: var(--c-bg);
    position: sticky;
    top: 0;
    z-index: 15;
    box-shadow: 0 1px 0 var(--c-line);
    /* Defilement souple au doigt, sans barre visible. */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 15px;
    border-radius: 20px;
    background: var(--c-surface);
    box-shadow: var(--shadow);
    font-size: 14.5px;
    color: var(--c-ink-soft);
    white-space: nowrap;
    transition: background .12s, color .12s;
}

.chip:active { transform: scale(.96); }

.chip.active {
    background: var(--c-primary);
    color: #fff;
    font-weight: 600;
}

.chip-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.chip-count {
    margin-left: 3px;
    font-size: 12.5px;
    opacity: .6;
    font-weight: 600;
}

/* ================================================================== liste */

.main {
    max-width: 720px;
    margin: 0 auto;
    padding: 8px 12px calc(40px + var(--safe-bottom));
}

.group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 22px 6px 9px;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--c-ink-faint);
}

.group-title::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.group-title[data-bucket="now"]::before   { background: var(--c-now); }
.group-title[data-bucket="soon"]::before  { background: var(--c-soon); }
.group-title[data-bucket="later"]::before { background: var(--c-later); }

.list { display: flex; flex-direction: column; gap: 9px; }

/* --------------------------------------------------------------- la tache */

.task {
    background: var(--c-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 15px 14px;
    /* Toute la carte est cliquable : c'est la cible la plus facile au pouce. */
    cursor: pointer;
    transition: opacity .25s, transform .25s, background .12s;
}

.task:active { background: #eff5f8; }

.task.leaving {
    opacity: 0;
    transform: translateX(45%);
    pointer-events: none;
}

.task.is-new { box-shadow: var(--shadow), inset 3px 0 0 #e8c15f; }

.circle {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    margin-top: 1px;
    border: 2px solid #c3d0d9;
    border-radius: 50%;
    background: #fff;
    position: relative;
    transition: background .15s, border-color .15s;
}

.task.checked .circle {
    background: var(--c-done);
    border-color: var(--c-done);
}

.task.checked .circle::after {
    content: "";
    position: absolute;
    left: 7px;
    top: 4px;
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

.task.checked .task-text { text-decoration: line-through; color: var(--c-ink-faint); }

.task-body { flex: 1 1 auto; min-width: 0; }

.task-text {
    font-size: 16.5px;
    line-height: 1.35;
    word-break: break-word;
}

.task-meta {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.client {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--c-ink-soft);
}

.client-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.task-date {
    font-size: 13px;
    color: var(--c-ink-faint);
}

/* Ligne d'explication discrete, utilisee sur l'ecran « Fait ». */
.hint {
    margin: 4px 6px 14px;
    font-size: 13.5px;
    color: var(--c-ink-faint);
}

.tag-new {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #8a6a12;
    background: #fbf0cf;
    border-radius: 9px;
    padding: 1px 7px;
}

.tag-ai {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .03em;
    color: #2b6f96;
    background: #e4f0f7;
    border-radius: 9px;
    padding: 2px 8px;
}

button.tag-ai { cursor: pointer; }

/* Bouton d'ouverture de la note : la seule action secondaire de l'ecran. */
.note-btn {
    flex: 0 0 auto;
    align-self: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: var(--c-ink-faint);
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.note-btn:active { background: #eaf1f5; }

.note {
    margin: 11px 0 0;
    padding: 11px 13px;
    background: #f6f9fb;
    border-radius: 10px;
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--c-ink-soft);
    white-space: pre-wrap;
    word-break: break-word;
}

.note a { color: #2b6f96; }

/* ================================================================== vides */

.empty {
    text-align: center;
    padding: 70px 24px;
    color: var(--c-ink-faint);
}

.empty-big { font-size: 40px; margin-bottom: 12px; }
.empty p { margin: 0; font-size: 16px; }

/* ================================================================= toasts */

.toasts {
    position: fixed;
    left: 50%;
    bottom: calc(16px + var(--safe-bottom));
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 430px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.toast {
    background: var(--c-ink);
    color: #fff;
    border-radius: 12px;
    padding: 13px 16px;
    font-size: 15px;
    box-shadow: 0 6px 22px rgba(22, 48, 61, .25);
    display: flex;
    align-items: center;
    gap: 14px;
    animation: toast-in .18s ease-out;
}

.toast.error { background: var(--c-danger); }

.toast-text { flex: 1 1 auto; min-width: 0; }

.toast-undo {
    flex: 0 0 auto;
    font-weight: 700;
    color: #8fd4ba;
    padding: 6px 4px;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: .04em;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

/* ============================================================== ordinateur */

@media (min-width: 700px) {
    .main { padding: 14px 20px 60px; }
    .task { padding: 16px 18px; }
    .task:hover { background: #fafcfd; }
}
