@font-face {
  font-family: "Scripte";
  src: url("../fonts/scripte.woff2") format("woff2");
  font-display: block;
}
/* Polices libres (SIL Open Font License) utilisées par les styles */
@font-face { font-family: "Playfair Display"; src: url("../fonts/playfair-display-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "Playfair Display"; src: url("../fonts/playfair-display-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: block; }
@font-face { font-family: "Playfair Display"; src: url("../fonts/playfair-display-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: block; }
@font-face { font-family: "Great Vibes"; src: url("../fonts/great-vibes-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "Montserrat"; src: url("../fonts/montserrat-latin-300-normal.woff2") format("woff2"); font-weight: 300; font-style: normal; font-display: block; }
@font-face { font-family: "Montserrat"; src: url("../fonts/montserrat-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "Montserrat"; src: url("../fonts/montserrat-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: block; }
@font-face { font-family: "Josefin Sans"; src: url("../fonts/josefin-sans-latin-300-normal.woff2") format("woff2"); font-weight: 300; font-style: normal; font-display: block; }
@font-face { font-family: "Josefin Sans"; src: url("../fonts/josefin-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: block; }
@font-face { font-family: "Pacifico"; src: url("../fonts/pacifico-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "Dancing Script"; src: url("../fonts/dancing-script-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: block; }
@font-face { font-family: "Abril Fatface"; src: url("../fonts/abril-fatface-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "Amatic SC"; src: url("../fonts/amatic-sc-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: block; }
@font-face { font-family: "Lobster"; src: url("../fonts/lobster-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "Cormorant Garamond"; src: url("../fonts/cormorant-garamond-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: block; }
@font-face { font-family: "Cormorant Garamond"; src: url("../fonts/cormorant-garamond-latin-600-italic.woff2") format("woff2"); font-weight: 600; font-style: italic; font-display: block; }

:root { --ink: #2b2b2b; --muted: #6b6b6b; --line: #dcdcd4; --accent: #494e2a; --bg: #f6f5f0; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }

.top { padding: 20px 24px 8px; max-width: 1180px; margin: 0 auto; }
.top h1 { margin: 0; font-size: 1.6rem; }
.top p { margin: 4px 0 0; color: var(--muted); }

.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; max-width: 1180px; margin: 0 auto; padding: 16px 24px 40px; align-items: start; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
label { display: block; font-size: .92rem; color: var(--muted); margin-bottom: 10px; }
.row { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }
select, input[type="number"], input[type="text"] { width: 100%; padding: 8px 10px; font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); }
.check input { margin-top: 5px; }
.upload-titre { margin: 14px 0 6px; font-size: .92rem; color: var(--muted); }
.upload-zone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; margin: 0 0 8px; padding: 16px 10px; text-align: center; border: 2px dashed var(--line); border-radius: 10px; background: #faf9f5; cursor: pointer; transition: border-color .15s, background .15s; }
.upload-zone:hover, .upload-zone:focus-within { border-color: var(--accent); background: #f3f2ea; }
.upload-zone.chargee { border-style: solid; border-color: var(--accent); }
.upload-ico { font-size: 28px; line-height: 1; }
.upload-txt { color: var(--ink); font-size: .9rem; font-weight: 600; word-break: break-all; }
.upload-aide { color: var(--muted); font-size: .75rem; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 260px; overflow: auto; margin: 6px 0 12px; padding: 2px; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; line-height: 0; }
.thumbs button[aria-selected="true"] { border-color: var(--accent); }
.thumbs img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 4px; }

/* Choix de la carte postale (comme les illustrations de faux-diplomes) */
.cp-search { position: relative; margin-bottom: 2px; }
.cp-search input { width: 100%; padding-right: 34px; }
.cp-clear { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 19px; line-height: 1; display: none; align-items: center; justify-content: center; }
.cp-clear.visible { display: flex; }
.cp-clear:hover { background: rgba(0, 0, 0, .06); }
.cp-status { min-height: 15px; margin: 2px 1px 4px; color: var(--muted); font-size: .75rem; }
.cp-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 300px; }
.cp-grid img { aspect-ratio: 1; object-fit: contain; background: #f3f2ec; }
.cp-msg { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: .85rem; padding: 16px; line-height: 1.4; }

button { font: inherit; cursor: pointer; }
.primary, .secondary { display: block; width: 100%; padding: 11px 14px; border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--accent); }
.primary { background: var(--accent); color: #fff; }
.secondary { background: #fff; color: var(--accent); }
.link { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 0; font-size: .9rem; }
#status { min-height: 1.4em; margin: 6px 0 0; font-size: .9rem; color: var(--muted); }

.preview { background: #e9e8e1; border-radius: 12px; padding: 20px; display: flex; justify-content: center; }
.preview canvas { width: 100% !important; max-width: 560px; height: auto !important; background: #fff; box-shadow: 0 2px 14px rgba(0, 0, 0, .18); }

/* Choix du style : miniatures */
.styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 430px; overflow: auto; padding: 2px; }
.styles button { padding: 4px; border: 2px solid transparent; border-radius: 8px; background: #f3f2ec; font-size: .78rem; color: var(--ink); line-height: 1.2; }
.styles button[aria-selected="true"] { border-color: var(--accent); background: #fff; }
.styles img { display: block; width: 100%; aspect-ratio: 210 / 297; object-fit: cover; background: #fff; border-radius: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); margin-bottom: 4px; }

/* Mensuel / annuel */
.kind { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; margin-bottom: 10px; background: #f3f2ec; border-radius: 9px; }
.kind label { margin: 0; text-align: center; padding: 6px; border-radius: 7px; cursor: pointer; color: var(--ink); font-size: .92rem; }
.kind label:has(input:checked) { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); font-weight: 600; }
.kind input { position: absolute; opacity: 0; pointer-events: none; }
.row.annuel { grid-template-columns: 110px; }
.kind.trois { grid-template-columns: repeat(3, 1fr); }


/* Planning */
.pl-label { font-size: .92rem; color: var(--muted); margin-bottom: 6px; }
.pl-jours { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px; }
.pl-jours label { margin: 0; cursor: pointer; }
.pl-jours input { position: absolute; opacity: 0; pointer-events: none; }
.pl-jours span { display: block; text-align: center; padding: 7px 0; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); font-size: .88rem; background: #fff; }
.pl-jours input:checked + span { background: #f3f2ec; color: var(--ink); font-weight: 600; border-color: #bdb9ac; }
.pl-jours input:focus-visible + span { outline: 2px solid #8a8577; outline-offset: 1px; }
.row.pl-row { grid-template-columns: 1fr 1fr; }

/* Couleurs */
.palettes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.palettes button { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 5px; border: 1px solid var(--line); border-radius: 20px; background: #fff; font-size: .82rem; color: var(--ink); }
.palettes button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.palettes .sw { display: flex; }
.palettes .sw i { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .15); margin-left: -4px; }
.palettes .sw i:first-child { margin-left: 0; }
.colors { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-bottom: 6px; }
.colors label { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); font-size: .88rem; }
.colors input[type="color"] { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .preview { order: -1; padding: 12px; }
}

/* Onglets du panneau : une seule rubrique visible à la fois */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 3px; margin-bottom: 14px; background: #f3f2ec; border-radius: 10px; }
.tabs .tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: .8rem; line-height: 1.2; white-space: nowrap; }
.tabs .tab span { font-size: 1.05rem; }
.tabs .tab.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.tab-pane { display: none; }
.tab-pane.on { display: block; }
.tab-pane > legend { display: none; }
.styles { max-height: none; }
.cp-grid { max-height: 360px; }

/* L'aperçu reste visible pendant qu'on règle le calendrier */
@media (min-width: 821px) {
  .preview { position: sticky; top: 16px; align-self: start; }
  .preview canvas { max-height: calc(100vh - 150px); width: auto !important; max-width: min(100%, 560px); }
}

/* Mobile : l'aperçu reste collé en haut, en plus petit, pendant qu'on règle en dessous */
@media (max-width: 820px) {
  .preview { position: sticky; top: 0; z-index: 5; padding: 8px; border-radius: 0 0 12px 12px; }
  .preview canvas { max-height: 42vh; width: auto !important; max-width: 100%; }
}
