/* Signatures — interface d'administration. Aucune ressource externe. */
:root {
  --ink: #1d2327;
  --muted: #59636c;
  --line: #d9d4cc;
  --line-soft: #ebe7e1;
  --paper: #f6f4f0;
  --card: #ffffff;
  --accent: #00747b;
  --accent-hover: #005e64;
  --accent-soft: #e2f3f4;
  --accent-bright: #00b0b9;
  --orange: #c23c04;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1d6f37;
  --ok-soft: #e6f4ea;
  --info-soft: #eef4fb;
  --info: #1f4f86;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(29, 35, 39, .06), 0 2px 8px rgba(29, 35, 39, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--paper); }
img { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
p { margin: 0 0 .8rem; }
code { font-family: var(--mono); font-size: .92em; background: var(--line-soft); padding: .05em .35em; border-radius: 4px; }
:focus-visible { outline: 3px solid var(--accent-bright); outline-offset: 2px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: .5rem .8rem; z-index: 100; }
.skip:focus { left: .5rem; top: .5rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.lead { color: var(--muted); max-width: 70ch; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- barre du haut ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  padding: .6rem 1.2rem; background: var(--ink); color: #fff;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .01em; }
.brand:hover { color: #fff; }
.brand-lg { font-size: 1.3rem; color: var(--ink); justify-content: center; margin-bottom: 1.2rem; }
.mainnav ul { list-style: none; display: flex; gap: .2rem; margin: 0; padding: 0; flex-wrap: wrap; }
.mainnav a { color: #d7dde1; text-decoration: none; padding: .35rem .7rem; border-radius: 6px; display: block; }
.mainnav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.mainnav a[aria-current="page"] { color: #fff; background: rgba(0, 176, 185, .28); }
.usermenu { margin-left: auto; display: flex; align-items: center; gap: .9rem; font-size: .9rem; flex-wrap: wrap; }
.usermenu a, .usermenu .linklike { color: #d7dde1; }
.usermenu .who small { color: #9aa6ae; margin-left: .25rem; }
.usermenu form { margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* ---------- contenu ---------- */
.main { max-width: 1120px; margin: 0 auto; padding: 1.6rem 1.2rem 4rem; outline: none; }
.main.wide { max-width: none; padding: 1rem 1rem 2rem; }
.narrow { max-width: 620px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pagehead h1 { margin: 0; }
.pagehead-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { margin: 0 0 .3rem; font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card > :last-child { margin-bottom: 0; }
.narrow-card { max-width: 620px; }
.callout { border-left: 4px solid var(--accent-bright); }
.danger-zone { border-color: #efc2bd; }
.danger-zone h2 { color: var(--danger); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-top: 1rem; }
.empty { color: var(--muted); padding: 1.4rem; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; background: rgba(255, 255, 255, .5); }
.plain { list-style: none; padding: 0; margin: 0 0 .8rem; }
.plain li { padding: .2rem 0; }
.tag { display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 99px; background: var(--line-soft); color: var(--muted); vertical-align: middle; }

/* ---------- messages ---------- */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); border-color: #b9dfc4; color: #14532d; }
.flash-error { background: var(--danger-soft); border-color: #f2c1bb; color: #7a1a12; }
.flash-info { background: var(--info-soft); border-color: #c9d9ee; color: var(--info); }
.flash p:last-child { margin-bottom: 0; }
.newpw .pw { font-size: 1.15rem; padding: .25rem .6rem; background: #fff; border: 1px solid #b9dfc4; user-select: all; }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 600; font-size: .92rem; line-height: 1.2;
  padding: .55rem .95rem; min-height: 38px; border-radius: 6px; cursor: pointer; text-decoration: none;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
}
.btn:hover { background: #f1eee9; color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--danger); border-color: #e9b4ad; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: .3rem .6rem; min-height: 32px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }

/* ---------- formulaires ---------- */
.form { margin: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
legend { font-weight: 700; font-size: 1.05rem; margin-bottom: .6rem; padding: 0; }
.field { margin-bottom: .9rem; }
.field label, .field .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field.inline { display: flex; align-items: center; gap: .5rem; }
.field.inline label { margin: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="url"],
input[type="number"], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #bfb8ae; border-radius: 6px; padding: .5rem .65rem; min-height: 40px;
}
textarea { resize: vertical; }
input[type="number"] { width: auto; max-width: 6.5rem; }
input[type="file"] { font: inherit; max-width: 100%; }
input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid #bfb8ae; border-radius: 6px; background: #fff; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .86rem; margin: .3rem 0 0; }
.check { display: flex; align-items: center; gap: .45rem; margin-bottom: .8rem; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.prefixed { display: flex; align-items: stretch; }
.prefixed span { display: flex; align-items: center; padding: 0 .55rem; background: var(--line-soft); border: 1px solid #bfb8ae; color: var(--muted); font-size: .88rem; white-space: nowrap; }
.prefixed span:first-child { border-radius: 6px 0 0 6px; border-right: 0; }
.prefixed span:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.prefixed input { border-radius: 0; min-width: 6rem; }
.prefixed input:last-child { border-radius: 0 6px 6px 0; }
.formbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; margin-top: 1rem; }
.inline-form .field { margin: 0; flex: 1 1 200px; }
.row-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.row-actions form { margin: 0; }
details.disclosure > summary { list-style: none; cursor: pointer; display: inline-block; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure[open] > summary .btn { background: var(--accent-hover); }
details > summary { cursor: pointer; }

/* ---------- authentification ---------- */
.page-auth { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-box { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 2rem 1.6rem; box-shadow: var(--shadow); }
.auth-box h1 { font-size: 1.3rem; text-align: center; }

/* ---------- onglets ---------- */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; overflow-x: auto; }
.tabs a, .tabs button {
  padding: .6rem .9rem; color: var(--muted); text-decoration: none; border: 0; background: none; font: inherit; font-weight: 600;
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer;
}
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs a[aria-current="page"], .tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent-bright); }

/* ---------- tuiles ---------- */
.tiles { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.tile a { display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.1rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); border-top: 4px solid var(--accent-bright); }
.tile a:hover { border-color: var(--accent); }
.tile-title { font-weight: 700; font-size: 1.1rem; }
.tile-meta { color: var(--muted); font-size: .88rem; }
.tile-slug { font-family: var(--mono); font-size: .8rem; color: var(--muted); }

/* ---------- tableaux ---------- */
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.list { width: 100%; border-collapse: collapse; font-size: .93rem; }
.list th, .list td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #faf9f7; }
.list tr:last-child td { border-bottom: 0; }
.list tr.inactive td { color: var(--muted); }
.list td.actions { text-align: right; white-space: nowrap; }
.list td.actions form { display: inline; margin: 0; }

/* ---------- images ---------- */
.upload-row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
.upload-row .field { flex: 1 1 180px; margin-bottom: 0; }
.upload p.small { margin: .7rem 0 0; }
.imggrid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; }
.imgcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.imgthumb {
  height: 120px; display: grid; place-items: center; padding: .6rem;
  background-color: #fff;
  background-image: linear-gradient(45deg, #eee 25%, transparent 25%), linear-gradient(-45deg, #eee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee 75%), linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.imgthumb img { max-height: 100px; max-width: 100%; object-fit: contain; }
.imgmeta { padding: .55rem .7rem; display: flex; flex-direction: column; gap: .1rem; font-size: .9rem; word-break: break-word; }
.imgedit { border-top: 1px solid var(--line-soft); padding: .4rem .7rem .6rem; font-size: .9rem; }
.imgedit summary { color: var(--accent); font-weight: 600; }
.imgedit form { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--line-soft); }
.imgedit .field { margin-bottom: .5rem; }

.imgpick { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.imgopt { position: relative; display: block; cursor: pointer; }
.imgopt input { position: absolute; opacity: 0; }
.imgopt img, .imgopt-none {
  display: grid; place-items: center; width: 64px; height: 64px; object-fit: contain; padding: 4px;
  border: 2px solid var(--line); border-radius: 8px; background: #fff; font-size: .78rem; color: var(--muted);
}
.imgopt input:checked + img, .imgopt input:checked + .imgopt-none { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.imgopt input:focus-visible + img, .imgopt input:focus-visible + .imgopt-none { outline: 3px solid var(--accent-bright); outline-offset: 2px; }

/* ---------- fiche signature ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 1.4rem; align-items: start; }
.sticky { position: sticky; top: 1rem; }
.h-small { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.previewbox { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.preview-frame { display: block; width: 100%; height: 360px; border: 0; }
.copybar { display: flex; gap: .5rem; flex-wrap: wrap; margin: .8rem 0 .5rem; }

/* ---------- fenêtre modale ---------- */
.modal { position: fixed; inset: 0; background: rgba(20, 24, 27, .55); display: grid; place-items: center; padding: 1rem; z-index: 50; }
.modal-box { background: var(--card); border-radius: 12px; padding: 1.3rem; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }

/* ---------- notifications éphémères ---------- */
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 60; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }

/* ---------- page d'erreur ---------- */
.page-error { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.error-box { max-width: 480px; text-align: center; background: var(--card); padding: 2rem; border-radius: 12px; border: 1px solid var(--line); }
.error-code { font-size: 3rem; font-weight: 800; color: var(--accent-bright); margin: 0; }

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .split-side { order: -1; }
  .sticky { position: static; }
  .preview-frame { height: 300px; }
}
@media (max-width: 560px) {
  .topbar { padding: .5rem .8rem; gap: .5rem; }
  .usermenu { margin-left: 0; width: 100%; }
  .main { padding: 1rem .8rem 3rem; }
  .list th:nth-child(n+4), .list td:nth-child(n+4):not(.actions) { display: none; }
  h1 { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
