/* ================================================================
   ToDoPlan : style papeterie, ambiances chaleureuses
   ================================================================ */

@font-face { font-family: 'Fredoka'; src: url(vendor/fonts/fredoka.woff2) format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url(vendor/fonts/nunito.woff2) format('woff2'); font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url(vendor/fonts/nunito-italic.woff2) format('woff2'); font-weight: 400 800; font-style: italic; font-display: swap; }

/* Ambiance par défaut : automne */
:root, [data-theme="automne"] {
  --cover: #a3462a;          /* couverture du planner */
  --cover-dot: rgba(255, 228, 200, .13);
  --cover-ink: #fbe6d4;
  --page: #fff8ef;           /* pages */
  --page-2: #f7e8d7;         /* zones en creux */
  --card: #fffdf9;
  --ink: #3b2418;
  --ink-soft: #7a5644;
  --line: #ecdac6;
  --accent: #b84d27;
  --accent-ink: #fff8ef;
  --accent-soft: #f6d7c3;
  --today-col: #fbeedf;
  --weekend: #fbf1e5;
  --fixed: #8a7566;
  --shadow: 58, 30, 14;
}
[data-theme="peche"] {
  --cover: #a77fbb;
  --cover-dot: rgba(255, 240, 250, .16);
  --cover-ink: #fff3fb;
  --page: #fff7f3;
  --page-2: #fbe7df;
  --card: #fffdfb;
  --ink: #3e2a3b;
  --ink-soft: #7a5d74;
  --line: #f1dcd5;
  --accent: #bf4f3c;
  --accent-ink: #fff7f3;
  --accent-soft: #f9d6cb;
  --today-col: #fdeee8;
  --weekend: #fdf1ee;
  --fixed: #8f7a8a;
  --shadow: 70, 36, 64;
}
[data-theme="menthe"] {
  --cover: #5f8a6b;
  --cover-dot: rgba(240, 255, 240, .14);
  --cover-ink: #eef6ea;
  --page: #fafaf2;
  --page-2: #eaf0e1;
  --card: #fefefa;
  --ink: #22352a;
  --ink-soft: #587062;
  --line: #dde6d4;
  --accent: #3f7452;
  --accent-ink: #fafaf2;
  --accent-soft: #d5e7d4;
  --today-col: #f0f5e8;
  --weekend: #f4f6ec;
  --fixed: #77857b;
  --shadow: 30, 54, 38;
}
[data-theme="sauge"] {
  --cover: #8a9a7c;
  --cover-dot: rgba(250, 252, 244, .16);
  --cover-ink: #f4f6ee;
  --page: #f8f7f1;
  --page-2: #ebeee2;
  --card: #fdfdf9;
  --ink: #2c3327;
  --ink-soft: #5c6755;
  --line: #dfe3d4;
  --accent: #5a6f4f;
  --accent-ink: #f8f7f1;
  --accent-soft: #dce5d2;
  --today-col: #eff2e7;
  --weekend: #f3f4ec;
  --fixed: #848b7d;
  --shadow: 44, 52, 38;
}
[data-theme="veillee"] {
  --cover: #1f1418;
  --cover-dot: rgba(255, 200, 160, .07);
  --cover-ink: #f0d9c6;
  --page: #33242a;
  --page-2: #2a1d22;
  --card: #3d2c32;
  --ink: #f7e8db;
  --ink-soft: #cdb2a3;
  --line: #4b3840;
  --accent: #e8a062;
  --accent-ink: #2a1a12;
  --accent-soft: #5a3e33;
  --today-col: #3b2a2f;
  --weekend: #2f2126;
  --fixed: #a08f88;
  --shadow: 0, 0, 0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  background-color: var(--cover);
  background-image: radial-gradient(var(--cover-dot) 1.2px, transparent 1.6px);
  background-size: 16px 16px;
  caret-color: var(--accent);
}
::selection { background: var(--accent-soft); color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); font-size: 12.5px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Barres de défilement */
/* Barres de défilement fines et arrondies, sans flèches (Chrome, Edge) ; Firefox : barre fine */
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
/* la barre s'arrête avant les coins arrondis des pages, volets et fenêtres */
::-webkit-scrollbar-track { margin-block: 10px; }
.modal-box::-webkit-scrollbar-track, #drawer::-webkit-scrollbar-track { margin-block: 22px; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--ink-soft) 45%, var(--line)); }
@supports not selector(::-webkit-scrollbar) { * { scrollbar-width: thin; scrollbar-color: var(--line) transparent; } }

/* Contrôles */
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.btn {
  background: var(--page-2); border: none; border-radius: 999px;
  padding: 7px 16px; font-weight: 700; cursor: pointer; color: var(--ink);
  transition: background .15s, transform .15s;
}
.btn:hover { background: var(--line); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn.danger { color: #b3362f; background: transparent; }
[data-theme="veillee"] .btn.danger { color: #f19a8f; }
.btn.danger:hover { background: rgba(179, 54, 47, .1); }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: none; background: transparent; border-radius: 50%; cursor: pointer; color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--page-2); color: var(--ink); }
input[type=text], input[type=email], input:not([type]), input[type=number], input[type=date],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 12px; border: 1.5px solid var(--line);
  border-radius: 12px; background: var(--card);
}
input::placeholder, textarea::placeholder { color: var(--ink-soft); opacity: .85; }
textarea { resize: none; field-sizing: content; min-height: 4.5lh; max-height: 14lh; }

/* Menus déroulants : liste arrondie dans le style de l'app (navigateurs qui le permettent ; sinon menu natif) */
@supports (appearance: base-select) {
  select, ::picker(select) { appearance: base-select; }
  select { display: flex; align-items: center; gap: 8px; cursor: pointer; transition: border-color .15s, background .15s; }
  select:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
  select:open { border-color: var(--accent); }
  select::picker-icon { content: ''; width: 8px; height: 8px; margin: -4px 2px 0 auto; border: solid var(--ink-soft); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .2s; }
  select:open::picker-icon { transform: rotate(225deg); margin-top: 4px; }
  ::picker(select) {
    margin-top: 6px; padding: 6px; border: none; border-radius: 16px;
    background: var(--card); color: var(--ink);
    box-shadow: 0 0 0 1.5px var(--line), 0 10px 28px rgba(var(--shadow), .18);
    max-height: 280px; overflow-y: auto;
    scrollbar-width: none; /* la barre native (grise, à flèches) jurait avec le thème : on défile à la molette ou au clavier */
  }
  option { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; }
  option:hover, option:focus-visible { background: var(--page-2); outline: none; }
  option:checked { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 55%, var(--ink)); font-weight: 800; }
  option::checkmark { content: none; }
  #settings-lists .emoji-select, #settings-routines .emoji-select { justify-content: center; }
  #settings-lists .emoji-select::picker-icon, #settings-routines .emoji-select::picker-icon { display: none; }
  #settings-lists .emoji-select:open::picker(select), #settings-routines .emoji-select:open::picker(select) { display: grid; grid-template-columns: repeat(5, 40px); gap: 2px; }
  #settings-lists .emoji-select option, #settings-routines .emoji-select option { justify-content: center; padding: 6px 0; font-size: 18px; }
}

/* Case ronde (cocher une tâche) */
.check {
  appearance: none; width: 20px; height: 20px; flex: none; margin: 0; cursor: pointer;
  border: 2px solid var(--c, var(--accent)); border-radius: 50%; background: var(--card);
  display: inline-grid; place-items: center; transition: background .15s;
}
.check::after {
  content: ''; width: 9px; height: 5px; margin-top: -2px;
  border: solid var(--card); border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) scale(0);
  transition: transform .22s cubic-bezier(.16, 1, .3, 1);
}
.check:checked { background: var(--c, var(--accent)); }
.check:checked::after { transform: rotate(-45deg) scale(1); }
.check:hover { background: color-mix(in srgb, var(--c, var(--accent)) 18%, var(--card)); }
.check:checked:hover { background: var(--c, var(--accent)); }

/* ================================================================
   Mise en page : deux pages posées sur la couverture
   ================================================================ */

#app { display: flex; height: 100vh; padding: 14px; gap: 14px; }
.page {
  background: var(--page); border-radius: 22px;
  box-shadow: 0 1px 2px rgba(var(--shadow), .12), 0 8px 24px rgba(var(--shadow), .18);
}
#panel {
  position: relative; width: 25%; min-width: 280px; max-width: 380px;
  display: flex; flex-direction: column; gap: 12px; padding: 16px 14px 10px;
}
#app.collapsed #panel { display: none; }
#btn-expand { display: none; color: var(--cover-ink); }
#btn-expand:hover { background: rgba(255, 255, 255, .14); color: var(--cover-ink); }
#app.collapsed #btn-expand { display: inline-grid; }
#calendar-wrap { flex: 1; min-width: 0; padding: 14px 16px 10px; }
#calendar { height: 100%; }

.panel-head { display: flex; align-items: center; gap: 4px; padding: 0 2px; }
.panel-head h1 { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 24px; margin: 0 0 0 4px; flex: 1; letter-spacing: -.01em; }
.logo { width: 30px; height: 30px; stroke: none; }
/* Logo : une page d'agenda cochée, avec une petite étincelle */
.logo .sheet { fill: var(--accent); }
.logo .rings { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }
.logo .tick { fill: none; stroke: var(--accent-ink); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.logo path.spark { fill: none; stroke: #d29a12; stroke-width: 2.2; stroke-linecap: round; }
.logo circle.spark { fill: #d29a12; }

.quick-add {
  display: flex; align-items: center; gap: 8px; padding: 0 6px 0 14px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 999px;
  color: var(--accent); transition: border-color .15s, box-shadow .15s;
}
.quick-add:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.quick-add input { border: none; background: transparent; padding: 10px 6px; outline: none; }
.quick-add input:focus-visible { outline: none; }

/* Puces de listes */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  position: relative; border: 1.5px solid transparent; border-radius: 999px; cursor: pointer;
  padding: 4px 12px; font-weight: 700; font-size: 13px; background: var(--page-2); color: var(--ink);
  transition: background .15s, border-color .15s;
}
.chip:hover { background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--page-2)); }
.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--c, var(--accent)) 24%, var(--page));
  border-color: var(--c, var(--accent));
}
.chip .count { font-weight: 600; color: var(--ink-soft); margin-left: 2px; font-size: 12px; }

.toggles { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span {
  width: 30px; height: 18px; border-radius: 99px; background: var(--line); position: relative; flex: none;
  transition: background .2s;
}
.switch span::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--card); box-shadow: 0 1px 2px rgba(var(--shadow), .3); transition: transform .2s cubic-bezier(.2, .8, .3, 1);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(12px); }
.switch input:focus-visible + span { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* Cartes de tâches */
#task-list { list-style: none; margin: 0 -6px; padding: 8px 6px 4px; overflow-y: auto; flex: 1; }
.task-item {
  position: relative; display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px 10px; margin-bottom: 8px; border-radius: 14px;
  background: var(--card); cursor: grab; user-select: none;
  box-shadow: 0 1px 2px rgba(var(--shadow), .08), 0 2px 8px rgba(var(--shadow), .07);
  transition: transform .15s, box-shadow .15s;
}
.task-item:hover { transform: translateY(-1px) rotate(-.3deg); box-shadow: 0 2px 4px rgba(var(--shadow), .1), 0 6px 14px rgba(var(--shadow), .1); }
.task-item:active { cursor: grabbing; }
.task-item .check { margin-top: 1px; }
.task-item .body { flex: 1; min-width: 0; }
.task-item .title { font-weight: 700; word-break: break-word; }
.task-item.done .title { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: color-mix(in srgb, var(--c) 70%, transparent); color: var(--ink-soft); }
.task-item.done { background: color-mix(in srgb, var(--card) 70%, var(--page-2)); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 5px; font-size: 12px; color: var(--ink-soft); }
.meta span { padding: 1px 8px; border-radius: 99px; background: var(--page-2); }
.meta .planned { background: color-mix(in srgb, var(--c) 20%, var(--page)); color: color-mix(in srgb, var(--c) 40%, var(--ink)); font-weight: 700; }
.meta .late { background: rgba(196, 60, 60, .14); color: #a5302b; font-weight: 700; }
[data-theme="veillee"] .meta .late { color: #f19a8f; }

.empty { color: var(--ink-soft); font-size: 13.5px; padding: 18px 10px; text-align: center; }
.empty strong { display: block; font-family: 'Fredoka', sans-serif; font-weight: 500; font-size: 17px; color: var(--ink); margin-bottom: 4px; }

#drop-hint {
  display: none; position: absolute; inset: 6px; align-items: center; justify-content: center; border-radius: 18px;
  background: color-mix(in srgb, var(--accent-soft) 70%, transparent); border: 2px dashed var(--accent);
  color: color-mix(in srgb, var(--accent) 70%, var(--ink)); font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 17px; pointer-events: none;
}
#panel.drop-target #drop-hint { display: flex; }

/* Récompense en cochant : un coup de tampon */
@keyframes stamp {
  0% { transform: scale(1); }
  35% { transform: scale(1.45) rotate(-14deg); }
  70% { transform: scale(.9) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes ring {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c, var(--accent)) 55%, transparent); }
  to { box-shadow: 0 0 0 12px transparent; }
}
.pop .check { animation: stamp .42s cubic-bezier(.2, .8, .3, 1), ring .5s ease-out; }
.fc-event.pop { animation: stamp .42s cubic-bezier(.2, .8, .3, 1); }

/* ================================================================
   Agenda (FullCalendar)
   ================================================================ */

.fc {
  --fc-border-color: var(--line);
  --fc-page-bg-color: var(--page);
  --fc-neutral-bg-color: var(--page-2);
  --fc-today-bg-color: var(--today-col);
  --fc-now-indicator-color: var(--accent);
  --fc-highlight-color: color-mix(in srgb, var(--accent-soft) 70%, transparent);
  font-family: 'Nunito', system-ui, sans-serif;
}
.fc .fc-toolbar.fc-header-toolbar { margin-bottom: 12px; }
.fc .fc-toolbar-title { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 22px; text-transform: capitalize; }
.fc .fc-button {
  background: var(--page-2); color: var(--ink); border: none; border-radius: 999px !important;
  font-weight: 700; padding: 6px 14px; box-shadow: none !important; text-transform: none; margin-left: 4px !important;
  transition: background .15s;
}
.fc .fc-button:hover { background: var(--line); color: var(--ink); }
.fc .fc-button:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active { background: var(--accent); color: var(--accent-ink); }
.fc .fc-button-primary:disabled { background: var(--page-2); color: var(--ink-soft); opacity: .6; }
.fc .fc-prev-button, .fc .fc-next-button { padding: 6px 10px; }
.fc-theme-standard .fc-scrollgrid { border: none; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--line); }
.fc .fc-col-header-cell { border-bottom: none; }
.fc .fc-scrollgrid-section-header > th { border: none; }
.fc .fc-col-header-cell, .fc .fc-col-header-cell.fc-day-today { background: var(--page); }
.fc .fc-col-header-cell-cushion { padding: 4px 2px 8px; text-decoration: none; color: var(--ink); }
.dayhead { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.dayhead .dow { color: var(--ink-soft); text-transform: capitalize; font-size: 13px; }
.dayhead .num {
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 4px; border-radius: 99px;
  background: var(--page-2); font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 15px;
}
.fc-day-today .dayhead .num { background: var(--accent); color: var(--accent-ink); }
.fc-day-today .dayhead .dow { color: var(--accent); }
.fc a.fc-col-header-cell-cushion:hover .num { background: var(--line); }
.fc-day-today a.fc-col-header-cell-cushion:hover .num { background: var(--accent); }

.fc .fc-timegrid-slot { border-top: none; }
.fc .fc-timegrid-slot-lane:not(.fc-timegrid-slot-minor) { border-top: 1px solid var(--line); }
.fc .fc-timegrid-slot-lane[data-time$=":30:00"] { border-top: 1px dashed color-mix(in srgb, var(--line) 70%, transparent); }
.fc .fc-timegrid-slot-label { border: none; }
/* zoom vertical (réglé par app.js) */
#calendar .fc-timegrid-slot { height: var(--slot-h, 20px); padding: 0; line-height: 0; font-size: 0; }
#calendar .fc-timegrid-slot-label { vertical-align: top; }
#calendar .fc-timegrid-slot-label-frame { height: 0; overflow: visible; }
#calendar .fc-timegrid-slot-label-cushion { display: inline-block; line-height: 1; padding-top: 3px; }
#calendar.zoom-tight .fc-timegrid-slot-lane[data-time$=":30:00"] { border-top-color: transparent; }
.fc .fc-zoomOut-button, .fc .fc-zoomIn-button { min-width: 34px; padding: 6px 10px; font-size: 16px; line-height: 1; font-weight: 800; }
.fc .fc-zoomIn-button { margin-right: 10px !important; }
.fc .fc-timegrid-slot-label-cushion { font-size: 12px; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.fc .fc-timegrid-axis { border: none; }
.fc .fc-timegrid-col.fc-day-sat, .fc .fc-timegrid-col.fc-day-sun { background: var(--weekend); }
.fc .fc-timegrid-col.fc-day-today { background: var(--today-col); }

/* Vue mois */
.fc .fc-daygrid-day.fc-day-sat, .fc .fc-daygrid-day.fc-day-sun { background: var(--weekend); }
.fc .fc-daygrid-day.fc-day-today { background: var(--today-col); }
.fc .fc-daygrid-day-top { flex-direction: row; padding: 4px 4px 0; }
.fc .fc-daygrid-day-number {
  display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 4px; border-radius: 99px;
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 14px; color: var(--ink); text-decoration: none;
}
.fc .fc-daygrid-day-number:hover { background: var(--line); }
.fc .fc-day-today .fc-daygrid-day-number { background: var(--accent); color: var(--accent-ink); }
.fc .fc-day-other .fc-daygrid-day-number { color: var(--ink-soft); opacity: .6; }
.fc .fc-daygrid-event { border-radius: 8px; margin: 1px 4px 2px; }
.fc-daygrid-event .ev { padding: 1px 6px; }
.fc-daygrid-event .ev-text { display: flex; gap: 5px; align-items: baseline; white-space: nowrap; overflow: hidden; }
.fc-daygrid-event .ev-time { flex: none; }
.fc-daygrid-event .ev-title { overflow: hidden; text-overflow: ellipsis; }
.fc-daygrid-event .ev-actions { display: none; }
.fc .fc-daygrid-more-link { font-size: 12px; font-weight: 700; color: var(--accent); margin-left: 6px; }
.fc .fc-popover { background: var(--card); border: none; border-radius: 14px; box-shadow: 0 6px 24px rgba(var(--shadow), .18); overflow: hidden; }
.fc .fc-popover-header { background: var(--page-2); font-weight: 700; }
.fc .fc-timegrid-now-indicator-line { border-width: 2px 0 0; }
.fc .fc-timegrid-now-indicator-arrow { border: none; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: -4px; left: auto; right: 0; }

/* Blocs */
.fc-v-event, .fc-daygrid-event {
  --c: var(--accent);
  --ev-bg: color-mix(in srgb, var(--c) 22%, var(--page));
  background: var(--ev-bg);
  border: 1.5px solid color-mix(in srgb, var(--c) 60%, var(--page));
  border-radius: 10px;
  color: color-mix(in srgb, var(--c) 42%, var(--ink));
  box-shadow: 0 1px 2px rgba(var(--shadow), .08);
}
.fc-v-event .fc-event-main, .fc-daygrid-event .fc-event-main { color: inherit; padding: 0; }
.fc-timegrid-event-harness-inset .fc-timegrid-event { box-shadow: 0 0 0 1.5px var(--page), 0 1px 2px rgba(var(--shadow), .08); }
.fc-event-mirror, .fc-event-dragging {
  box-shadow: 0 6px 16px rgba(var(--shadow), .25) !important; transform: rotate(-1.5deg);
}
.fc-v-event.is-fixed, .fc-daygrid-event.is-fixed {
  --c: var(--fixed);
  --ev-bg: color-mix(in srgb, var(--c) 20%, var(--page));
  background: repeating-linear-gradient(-45deg,
    color-mix(in srgb, var(--c) 16%, var(--page)) 0 6px,
    color-mix(in srgb, var(--c) 24%, var(--page)) 6px 12px);
}
.fc-v-event.is-done, .fc-daygrid-event.is-done { opacity: .55; }
.fc-event.is-done .ev-title { text-decoration: line-through; text-decoration-thickness: 2px; }
.fc .fc-timegrid-event .fc-event-resizer-end { height: 10px; bottom: -2px; }
.fc .fc-timegrid-event .fc-event-resizer-end::after {
  content: ''; position: absolute; left: 50%; bottom: 4px; width: 22px; height: 3px; margin-left: -11px;
  border-radius: 9px; background: color-mix(in srgb, var(--c) 60%, var(--page)); opacity: 0; transition: opacity .15s;
}
.fc-event:hover .fc-event-resizer-end::after { opacity: 1; }

.ev { position: relative; height: 100%; overflow: hidden; padding: 3px 5px; font-size: 12px; line-height: 1.25; }
.ev .ev-text { min-width: 0; }
.ev .ev-time { font-size: 11px; font-weight: 700; opacity: .85; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev .ev-title { font-weight: 800; overflow-wrap: break-word; }
/* Blocs courts (30 min et moins) : heure et titre sur une ligne */
.fc-timegrid-event-short .ev { padding: 1px 5px; }
.fc-timegrid-event-short .ev-text { display: flex; gap: 5px; align-items: baseline; white-space: nowrap; overflow: hidden; }
.fc-timegrid-event-short .ev-time { flex: none; }
.fc-timegrid-event-short .ev-time::after { content: none; }
.fc-timegrid-event-short .ev-title { overflow: hidden; text-overflow: ellipsis; }
/* Boutons du bloc : posés sur un fond qui recouvre proprement le texte (fondu à gauche), jamais en travers */
.ev .ev-actions {
  position: absolute; top: 0; right: 0; display: flex; align-items: center; gap: 3px;
  padding: 2px 2px 2px 16px; border-radius: 0 8px 0 0;
  background: linear-gradient(to right, transparent, var(--ev-bg) 14px);
  opacity: 0; transition: opacity .15s; pointer-events: none;
}
.fc-event:hover .ev-actions, .fc-event:focus-within .ev-actions { opacity: 1; pointer-events: auto; }
/* créneau court : les boutons occupent la hauteur du bloc, centrés */
.fc-timegrid-event-short .ev .ev-actions { bottom: 0; border-radius: 0 8px 8px 0; padding-top: 0; padding-bottom: 0; }
.fc-timegrid-event-short .fc-event-resizer-end::after { display: none; }
.ev-actions button {
  display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: none; border-radius: 50%;
  background: var(--card); color: color-mix(in srgb, var(--c) 50%, var(--ink)); cursor: pointer;
  box-shadow: 0 1px 2px rgba(var(--shadow), .15);
}
.ev-actions button:hover { background: var(--c); color: var(--card); }
.ev-actions svg { width: 12px; height: 12px; stroke-width: 2.6; }

/* ================================================================
   Volet d'édition et réglages
   ================================================================ */

#drawer {
  position: fixed; top: 14px; right: 14px; bottom: 14px; width: 350px; z-index: 50;
  background: var(--page); border-radius: 22px; padding: 18px;
  box-shadow: 0 12px 40px rgba(var(--shadow), .3); overflow-y: auto;
  animation: slide-in .28s cubic-bezier(.16, 1, .3, 1);
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 20px; margin: 0; }
#drawer-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
#drawer-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
#drawer-form label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
#drawer-form [data-for] { display: flex; flex-direction: column; gap: 12px; }
/* Pied du volet : Supprimer à gauche, Enregistrer à droite */
.drawer-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1.5px dashed var(--line); }
/* Planification : l'info et son action sur une même ligne */
.planned-row { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-radius: 14px; background: var(--page-2); }
.planned-row .muted { flex: 1; margin: 0; }
.btn.small { padding: 5px 12px; font-size: 13px; background: var(--card); }
.btn.small:hover { background: var(--line); }

.modal { position: fixed; inset: 0; z-index: 60; background: rgba(var(--shadow), .35); display: flex; align-items: center; justify-content: center; }
.modal-box {
  background: var(--page); border-radius: 24px; padding: 22px; width: min(500px, 92vw); max-height: 90vh; overflow-y: auto;
  box-shadow: 0 16px 48px rgba(var(--shadow), .35); animation: rise .3s cubic-bezier(.16, 1, .3, 1);
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.modal-box h3 { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 15px; color: var(--ink); margin: 22px 0 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row label { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink-soft); }
.row select { width: auto; }
#settings-lists { list-style: none; padding: 0; margin: 0 0 10px; }
#settings-lists li { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
#settings-lists .emoji-select { width: 58px; padding: 6px 4px; text-align: center; font-size: 16px; }
#settings-lists input[type=color] { width: 34px; height: 34px; padding: 0; border: none; border-radius: 50%; background: none; cursor: pointer; flex: none; }
#settings-lists input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
#settings-lists input[type=color]::-webkit-color-swatch { border: 2px solid var(--card); border-radius: 50%; box-shadow: 0 0 0 1.5px var(--line); }

.themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 8px; }
.theme {
  border: 2px solid transparent; border-radius: 16px; padding: 8px; cursor: pointer; background: var(--page-2);
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: 12.5px; color: var(--ink);
}
.theme[aria-pressed="true"] { border-color: var(--accent); }
.theme .swatch { width: 100%; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.theme .swatch i { width: 12px; height: 12px; border-radius: 50%; }

#toast {
  pointer-events: none; /* une notification ne doit jamais intercepter un clic */
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--ink); color: var(--page); padding: 9px 18px; border-radius: 999px; font-weight: 700; font-size: 13px;
  box-shadow: 0 6px 18px rgba(var(--shadow), .3); animation: rise .25s cubic-bezier(.16, 1, .3, 1);
}

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

/* Réglages : interrupteurs empilés */
.stack { display: grid; gap: 8px; }

/* Champ date : bouton qui ouvre le calendrier maison */
.date-field {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; text-align: left; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); transition: border-color .15s;
}
.date-field:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.date-field:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.date-field svg { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.date-field span::first-letter { text-transform: uppercase; }
.date-field.empty span { color: var(--ink-soft); }

.datepop {
  position: fixed; z-index: 80; width: 286px; padding: 12px; border-radius: 18px;
  background: var(--card); color: var(--ink);
  box-shadow: 0 0 0 1.5px var(--line), 0 12px 32px rgba(var(--shadow), .2);
  animation: pop-in .16s cubic-bezier(.16, 1, .3, 1);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dp-head strong { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 16px; text-transform: capitalize; }
.dp-head svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { text-align: center; font-size: 11px; font-weight: 800; color: var(--ink-soft); padding: 4px 0; text-transform: capitalize; }
.dp-day {
  aspect-ratio: 1; display: grid; place-items: center; border: none; border-radius: 50%;
  background: transparent; cursor: pointer; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums;
  transition: background .12s;
}
.dp-day:hover { background: var(--page-2); }
.dp-day:focus-visible { outline: 2.5px solid var(--accent); outline-offset: -2px; }
.dp-day.other { color: var(--ink-soft); opacity: .55; }
.dp-day.today { box-shadow: inset 0 0 0 2px var(--accent-soft); color: var(--accent); }
.dp-day.sel { background: var(--accent); color: var(--accent-ink); box-shadow: none; opacity: 1; }
.dp-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1.5px dashed var(--line); }
.dp-foot .muted { margin: 0; }
.dp-foot .dp-time { width: auto; margin-left: auto; padding: 6px 10px; }

/* Confirmation */
#ask { z-index: 90; }
.ask-box { width: min(380px, calc(100vw - 32px)); padding: 22px 22px 18px; }
.ask-box p { margin: 0 0 18px; font-weight: 700; font-size: 15px; line-height: 1.45; }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; }
.fc .fc-daygrid-event { display: block; padding: 0; white-space: nowrap; }
.fc .fc-daygrid-event:hover { background: color-mix(in srgb, var(--c) 30%, var(--page)); }
.fc .fc-daygrid-event.is-fixed:hover { filter: brightness(.97); }

/* Bloc haut : au survol, l'heure se raccourcit pour laisser la place aux boutons, le titre n'est jamais recouvert */
.fc-timegrid-event:not(.fc-timegrid-event-short) .ev .ev-actions { top: 1px; padding-top: 0; padding-bottom: 0; }
.fc-timegrid-event:not(.fc-timegrid-event-short) .ev-actions button { width: 18px; height: 18px; }
.fc-timegrid-event:not(.fc-timegrid-event-short) .ev-time { min-height: 18px; }
.fc-timegrid-event:not(.fc-timegrid-event-short):hover .ev-time,
.fc-timegrid-event:not(.fc-timegrid-event-short):focus-within .ev-time { padding-right: 44px; }

/* Carte dont la fiche est ouverte */
.task-item.open { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 70%, var(--page)), 0 2px 8px rgba(var(--shadow), .1); }

/* Routines du jour, en bas du panneau */
#routines { flex: none; margin: 0 -4px; padding: 10px 4px 2px; border-top: 1.5px dashed var(--line); }
#routines[hidden] { display: none; }
.routines-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 2px 6px 8px; border: none; background: none;
  cursor: pointer; color: var(--ink); text-align: left;
}
.routines-head h2 { margin: 0; flex: 1; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 16px; }
.routines-head .count { font-size: 12px; font-weight: 800; color: var(--ink-soft); padding: 1px 8px; border-radius: 99px; background: var(--page-2); font-variant-numeric: tabular-nums; }
.routines-head .count.all { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 60%, var(--ink)); }
.routines-head .chev { width: 16px; height: 16px; fill: none; stroke: var(--ink-soft); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
#routines.collapsed .chev { transform: rotate(-90deg); }
#routines.collapsed #routine-list { display: none; }
#routines.collapsed { padding-bottom: 0; }
.routines-head:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 10px; }

#routine-list { list-style: none; margin: 0; padding: 0 0 4px; display: grid; gap: 6px; max-height: 34vh; overflow-y: auto; }
.routine { position: relative; display: flex; align-items: center; }
.routine-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: none; border-radius: 14px;
  background: var(--card); cursor: pointer; text-align: left; color: var(--ink);
  box-shadow: 0 1px 2px rgba(var(--shadow), .07); transition: background .15s, transform .1s;
}
.routine-main:hover { background: color-mix(in srgb, var(--accent-soft) 45%, var(--card)); }
.routine-main:active { transform: scale(.985); }
.routine-main:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.r-emoji {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: var(--page-2); font-size: 16px; transition: background .2s;
}
.routine.ok .r-emoji { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.r-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.r-name { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.routine.ok .r-name { color: var(--ink-soft); }
.r-dots { display: flex; gap: 3px; flex-wrap: wrap; }
.r-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); transition: background .2s, transform .2s; }
.r-dots i.on { background: var(--accent); }
.r-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.r-num { font-size: 11.5px; font-weight: 800; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.r-streak { font-size: 11.5px; font-weight: 800; color: color-mix(in srgb, var(--accent) 70%, var(--ink)); }
/* « − » : dans la carte, à droite du compteur (la liste défile, donc rien ne doit dépasser) */
.routine:has(.r-minus) .routine-main { padding-right: 40px; }
.r-minus {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: none; border-radius: 50%;
  background: var(--page-2); color: var(--ink-soft); font-size: 16px; font-weight: 800; line-height: 1; cursor: pointer;
  opacity: .6; transition: opacity .15s, background .15s, color .15s;
}
.routine:hover .r-minus, .r-minus:focus-visible { opacity: 1; }
.r-minus:hover { background: var(--accent); color: var(--accent-ink); }
.r-minus:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.routine.pop .r-emoji { animation: stamp .42s cubic-bezier(.2, .8, .3, 1); }

/* Réglages : routines */
#settings-routines { list-style: none; padding: 0; margin: 0 0 10px; }
#settings-routines li { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
#settings-routines input:not([type]) { flex: 1; min-width: 0; }
#settings-routines .goal { width: 58px; flex: none; text-align: center; padding-inline: 6px; }
#settings-routines input.unit { flex: 0 0 82px; }
#settings-routines .emoji-select { width: 58px; flex: none; padding: 6px 4px; text-align: center; font-size: 16px; }
.hint { margin: -4px 0 10px; }
.ideas { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.ideas .muted { margin-right: 2px; }

/* Synchronisation : petit point à côté du nom */
#sync-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin-right: auto; background: var(--line); transition: background .3s; }
#sync-dot[data-state="ok"] { background: #6f9467; }
#sync-dot[data-state="pending"] { background: #d29a12; }
#sync-dot[data-state="offline"], #sync-dot[data-state="error"] { background: #c2456a; }
.panel-head:has(#sync-dot:not([hidden])) h1 { flex: none; }

/* Compte (réglages) */
.account-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.account-row > div { display: grid; gap: 2px; min-width: 0; }
.account-row strong { overflow: hidden; text-overflow: ellipsis; }

/* Écran de connexion */
#login { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 16px;
  background: var(--cover); background-image: radial-gradient(var(--cover-dot) 1.2px, transparent 1.3px); background-size: 18px 18px; }
#login.hidden { display: none; }
.login-card { width: min(400px, 100%); padding: 30px 28px 22px; animation: rise .3s cubic-bezier(.16, 1, .3, 1); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-brand h2 { margin: 0; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 28px; }
.logo.big { width: 40px; height: 40px; }
.login-lead { margin: 0 0 22px !important; color: var(--ink-soft); }
.login-card form { display: grid; gap: 12px; }
.login-card label { display: grid; gap: 6px; font-weight: 700; font-size: 13.5px; }
.login-card .btn.primary { justify-self: start; }
.login-card p { margin: 0; }
#login-step-code > p { line-height: 1.5; }
#login-code { font-size: 20px; letter-spacing: 4px; font-variant-numeric: tabular-nums; }
#login-msg { margin-top: 12px; color: #b3362f; font-weight: 700; font-size: 13.5px; min-height: 1em; }
[data-theme="veillee"] #login-msg { color: #f19a8f; }
