:root{
  --bg:#0f1320; --card:#161a2a; --muted:#a6b0cf; --text:#e6e9f5;
  --accent:#6ee7b7; --danger:#f87171; --radius:14px;
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family:ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background:linear-gradient(180deg,#0b0e18,#11162a 45%, #0b0e18);
  color:var(--text);
}

.wrap{max-width:980px; margin:40px auto; padding:0 16px}

header{
  display:flex; gap:16px; align-items:center;
  justify-content:space-between; margin-bottom:18px;
}
h1{font-size:32px; margin:0}
.small{color:var(--muted); font-size:12px}

.card{
  background:var(--card);
  border:1px solid rgba(255,255,255,.06);
  border-radius:var(--radius);
  box-shadow:0 10px 20px rgba(0,0,0,.25);
}

.row{
  display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end;
}

label{
  font-size:12px; color:var(--muted);
  display:flex; flex-direction:column; gap:6px;
}

select, input[type="text"], textarea{
  width:100%; padding:12px;
  border-radius:10px;
  background:#0e1221;
  border:1px solid rgba(255,255,255,.08);
  color:var(--text); outline:none;
}

textarea{
  min-height:180px; resize:vertical; line-height:1.5;
}

.controls{
  display:flex; gap:10px; align-items:center; flex-wrap:wrap;
}

button,.btn{
  appearance:none; text-decoration:none; border:none;
  background:var(--accent); color:#05140d;
  padding:12px 16px; border-radius:10px;
  font-weight:700; cursor:pointer;
}

.secondary{
  background:#10172a; color:#fff;
  border:1px solid rgba(255,255,255,.1);
}

button:disabled{opacity:.6; cursor:not-allowed}

.panel{padding:16px}
.sep{height:1px; background:rgba(255,255,255,.06)}

.danger{color:var(--danger)}

.badge{
  display:inline-flex; align-items:center; gap:6px;
  font-size:12px; padding:6px 8px; border-radius:999px;
  background:#0d1222;
  border:1px solid rgba(255,255,255,.08);
}

.muted{color:var(--muted)}
.footer{margin-top:14px; font-size:12px; color:var(--muted)}

code.inline{
  background:#0d1222; padding:2px 6px; border-radius:6px;
  border:1px solid rgba(255,255,255,.08);
}

.flashes{list-style:none; padding:0 16px; margin:0}
.flash{
  padding:10px 12px; margin:10px 0;
  border-radius:10px; background:#0e1221;
  border:1px solid rgba(255,255,255,.08);
}
.flash.error{border-color:#f87171; color:#fca5a5}

/* ====== Responsive tweaks ====== */

/* <= 900px : on passe en colonne, champs à 100% */
@media (max-width: 900px) {
  .wrap { margin: 24px auto; padding: 0 12px; }
  header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .row { flex-direction: column; align-items: stretch; gap: 12px; }
  label { width: 100%; }
  select, input[type="text"], textarea { width: 100%; }
  .controls { justify-content: flex-start; }
  .card { border-radius: 12px; }
}

/* <= 600px : tailles de police et paddings plus compacts */
@media (max-width: 600px) {
  h1 { font-size: 18px; }
  .small { font-size: 11px; }
  .panel { padding: 12px; }
  button, .btn { padding: 10px 12px; border-radius: 8px; font-weight: 600; }
  textarea { min-height: 140px; }
}

/* Evite les débordements horizontaux */
html, body { max-width: 100%; overflow-x: hidden; }

/* Les textarea doivent vraiment prendre toute la largeur disponible */
textarea { width: 100%; }

/* ===== Centrage global ===== */
/* ===== Page layout (horiz. center, pas de centrage vertical global) ===== */
body {
  display: flex;
  justify-content: center;
  align-items: flex-start;   /* au top, plus robuste si contenu long */
  min-height: 100vh;
  padding: 24px 0;           /* respire en haut/bas */
  margin: 0;
}

/* Le conteneur principal : structure (pas de fond). C'est .card qui style. */
.wrap {
  width: min(100%, 1000px);
  margin: 0 16px;
  padding: 0;
}

/* La carte fait l'habillage visuel */
.card{
  background: var(--card);
  border:1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  box-shadow:0 10px 20px rgba(0,0,0,.25);
}

/* Éditeur : 2 colonnes sur desktop, 1 colonne sur mobile */
.editor{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:16px;
  margin-top:8px;
  align-items:start;
}
@media (max-width: 900px){
  .editor{ grid-template-columns: 1fr; }
}

/* Panneaux et champs */
.pane{ display:flex; flex-direction:column; gap:8px }
.pane textarea{ width:100%; min-height:220px; }

/* Harmonise les champs – une seule règle suffit */
select, input[type="text"], textarea{
  width: 100%;
}

/* Actions sous l’éditeur */
.actions{
  display:flex; gap:10px; align-items:center; flex-wrap:wrap;
  margin-top:12px;
}

/* États de focus accessibles */
select:focus-visible,
input[type="text"]:focus-visible,
textarea:focus-visible,
button:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ====== Responsive tweaks ====== */
@media (max-width: 900px) {
  .wrap { margin: 0 12px; }
  header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .row { flex-direction: column; align-items: stretch; gap: 12px; }
  .controls { justify-content: flex-start; }
  .card { border-radius: 12px; }
}
@media (max-width: 600px) {
  h1 { font-size: 18px; }
  .small { font-size: 11px; }
  .panel { padding: 12px; }
  button, .btn { padding: 10px 12px; border-radius: 8px; font-weight: 600; }
  textarea { min-height: 160px; }
}

/* Evite les débordements horizontaux */
html, body { max-width: 100%; overflow-x: hidden; }

/* ===== Ads – réserve anti-CLS ===== */
.adsbygoogle { display:block; margin:16px 0; }
.ad-wrap{
  display:block;
  min-height: clamp(120px, 24vw, 280px);  /* un peu plus compact */
  margin:16px 0;
  position:relative;
}
.ad-wrap::before{
  content:"";
  position:absolute; inset:0;
  border-radius:10px;
  background: linear-gradient(135deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
}
.ad-wrap.loaded::before{ display:none; }

/* Barre des sélecteurs (au-dessus) */
.toolbar{
  display:grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap:12px;
  margin-bottom:14px;
}
.toolbar label{ width:100% }

@media (max-width: 900px){
  .toolbar{ grid-template-columns: 1fr; }
}

/* Grille des textareas : déjà en place si tu as .editor / .pane */
.editor{
  display:grid;
  grid-template-columns: 1fr 1fr;   /* 50/50 */
  gap:16px;
  align-items:start;
}
.pane{ display:flex; flex-direction:column; gap:8px }
.pane-title{ font-size:12px; color:var(--muted) }
.pane textarea{ width:100%; min-height:220px; }

@media (max-width: 900px){
  .editor{ grid-template-columns: 1fr; }
}

.ad-wrap.loaded::before{ display:none }
.ad-wrap.empty{ min-height:0 } /* replie l’espace si aucune pub */

/* --- CMP minimal --- */
#cmp-root { position: fixed; inset: 0; z-index: 9999; pointer-events: none; }
#cmp-root.cmp-open { pointer-events: auto; }

.cmp-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
}

.cmp-panel {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  width: min(720px, calc(100vw - 24px));
  background: #141922; color: #e9eef7;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px; padding: 16px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.cmp-panel h3 { margin: 0 0 6px; font-size: 1.1rem; }
.cmp-text { margin: 6px 0 14px; line-height: 1.4; color: #cbd5e1; }

.cmp-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.cmp-form { display: grid; gap: 12px; margin: 10px 0 6px; }
.cmp-toggle { display: flex; align-items: center; gap: 10px; }
.cmp-toggle input { transform: translateY(1px); }

.btn {
  appearance: none; border: 0; padding: 10px 14px; border-radius: 10px;
  background: #4ade80; color: #0b1220; font-weight: 600; cursor: pointer;
}
.btn.secondary { background: #1f2937; color: #e5e7eb; }
.btn.ghost { background: transparent; color: #e5e7eb; border: 1px solid #374151; }
.btn:hover { filter: brightness(1.05); }
