:root {
  --bg: #111113;
  --surface: #1a1a1d;
  --surface-2: #232327;
  --border: #2e2e33;
  --text: #ececee;
  --muted: #8b8b93;
  --accent: #3b82f6;
  --urgent: #b4483f;
  --ok: #3f8f5c;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* Les règles de classe ci-dessous (.panel, .screen…) écrasent le display:none
   que le navigateur applique à [hidden]. Sans ce !important, le voile du
   panneau latéral reste affiché en permanence et avale tous les clics. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }

.screen { min-height: 100dvh; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.error { color: #e5817a; margin: 0; }

/* --- Boutons --- */
button {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 8px 14px;
  cursor: pointer;
}
button:hover { border-color: #43434a; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.1); }
button.ghost { background: transparent; }
button.danger { background: transparent; border-color: #5a2e2b; color: #e5817a; }
button.small { padding: 6px 10px; font-size: 13px; }

/* --- Connexion --- */
#login { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); }
.login-card h1 { margin: 0 0 20px; font-size: 20px; letter-spacing: -0.02em; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }

/* --- Barre du haut --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

/* --- Bandeau notifications --- */
.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 14px 18px 0;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.banner .muted { font-size: 13px; }

/* --- Variantes livrées --- */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 9px;
}
.asset { margin: 0; }
.asset img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  background: var(--bg);
}
.asset figcaption {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 12px;
}
.asset figcaption .muted {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag.done { background: var(--ok); color: #fff; }

/* --- Textes publicitaires --- */
.copy-grid { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.copy-grid > label { margin: 8px 0 0; font-size: 12px; }
.copy-grid > label:first-child { margin-top: 0; }
.copy-grid input { margin-top: 0; text-transform: uppercase; }

/* --- Board --- */
.board {
  display: flex;
  gap: 14px;
  padding: 18px;
  overflow-x: auto;
  align-items: flex-start;
}

.column {
  flex: 0 0 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.column.drop-target { border-color: var(--accent); }
.column h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  gap: 8px;
}

.brief {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.brief:hover { border-color: #43434a; }
.brief h3 { margin: 0 0 8px; font-size: 14px; font-weight: 500; }
.brief-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }

.tag {
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
  background: var(--border);
  color: var(--muted);
}

/* --- Vignettes sur les cartes du board --- */
.brief-cover {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 10px;
  display: block;
}
.thumb-row { display: flex; gap: 5px; margin-bottom: 9px; }
.thumb-mini {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 5px;
  background: var(--border);
}

/* --- Fiches produit --- */
.product-list { display: flex; flex-direction: column; gap: 7px; }
.product {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}
a.product:hover { border-color: var(--accent); }
.product-img {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--border);
}
.product-img.placeholder { display: grid; place-items: center; color: var(--muted); }
.product-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.product-info strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-info .muted { font-size: 12px; }

/* --- Inspiration --- */
.inspi-img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  margin-bottom: 8px;
}
.link-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}
.link-card:hover { border-color: var(--accent); }
.favicon { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 4px; }

/* --- Champs composés du formulaire --- */
.image-field { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.image-field .muted { font-size: 12px; }

.product-field { display: flex; flex-direction: column; gap: 8px; }
.chosen { display: flex; flex-direction: column; gap: 7px; }
.chosen .product { cursor: default; }
.results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px;
}
.result {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  width: 100%;
}
.result:hover { background: var(--surface-2); }
.result.picked { background: var(--surface-2); }
.check {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}
.result.picked .check { background: var(--ok); border-color: var(--ok); color: #fff; }

/* --- Panneau latéral --- */
.panel { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: flex-end; }
.panel-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.panel-body {
  position: relative;
  width: min(560px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 22px;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
.panel-body h2 { margin: 0 0 4px; font-size: 18px; }
.panel-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.panel-section { margin-bottom: 22px; }
.panel-section > h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.panel-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font: inherit;
}
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

a { color: var(--accent); word-break: break-all; }

ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 7px 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: 0; }

.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment.revision { border-left: 2px solid var(--urgent); padding-left: 10px; }
.comment-head { font-size: 12px; color: var(--muted); margin-bottom: 3px; }

@media (max-width: 720px) {
  .board { flex-direction: column; padding: 12px; }
  .column { flex: 1 1 auto; width: 100%; }
  .panel-body { width: 100%; border-left: 0; }
  #whoami { display: none; }
}

/* --- Récapitulatif avant publication --- */
.plan-table { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.plan-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.plan-row .product-img { width: 38px; height: 38px; flex-basis: 38px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:disabled:hover { border-color: var(--border); filter: none; }
.prompt-box { width: 100%; min-height: 220px; font-family: ui-monospace, monospace; font-size: 12px; margin-top: 8px; }

/* --- Sélection multiple pour la publication --- */
.banner.selection { border-color: var(--accent); }
.brief { position: relative; }
.brief .pick {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.adset-block { margin-bottom: 16px; }
.adset-block h5 { margin: 0 0 7px; font-size: 13px; font-weight: 600; }
.meta-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; }
