/* ============================================================
   TDV Hub — habillage Boréa
   Deux thèmes : Aube (clair, défaut) et Nocturne, bascule par
   l'attribut data-theme sur <body>.

   Les valeurs viennent de l'identité Boréa telle qu'elle tourne
   en production (travel-planner/app/globals.css et les pages
   -borea-v4 du site) — copiées, pas réinterprétées.

   Ce fichier n'habille QUE le chrome de l'outil. Le visuel des
   stories exportées est écrit en dur dans app.js et reste sur la
   charte Tips de Voyageur (marine / orange).
   ============================================================ */

:root {
  /* --- Aube (clair) --- */
  --bg: #F8F3EA;
  --surface: linear-gradient(180deg, #FFFFFF 0%, #FFFCF5 100%);
  --surface-flat: #FFFDF7;
  --chip: linear-gradient(180deg, #FFFFFF 0%, #FFF7EC 100%);
  --sunken: rgba(133, 84, 38, 0.07);
  --hair: rgba(154, 92, 40, 0.16);
  --hair-strong: rgba(154, 92, 40, 0.3);

  --ink: #241708;
  --muted: rgba(78, 56, 36, 0.74);
  --eyebrow: #C05E12;
  --lab: #B06018;

  --g1: #FFB259;
  --g2: #FF6B00;
  --orange: #FF6B00;
  --orange-deep: #E85D00;
  --orange-soft: rgba(255, 107, 0, 0.12);

  --ok: #1B8A50;
  --ok-soft: rgba(27, 138, 80, 0.12);
  --warn: #C2410C;
  --warn-soft: rgba(194, 65, 12, 0.12);
  --danger: #B91C1C;
  --danger-soft: rgba(185, 28, 28, 0.1);

  --shadow-card:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(120, 66, 20, 0.05),
    0 24px 48px -34px rgba(140, 86, 34, 0.5);
  --shadow-raise: 0 22px 48px -22px rgba(140, 86, 34, 0.45);
  --shadow-ink:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 16px 34px -18px rgba(31, 26, 18, 0.55);

  /* le panorama de la sidebar */
  --sky-a: #FFFAF1;
  --sky-b: #FFE7C2;
  --sky-c: #FFCD92;
  --r1: #F2E0C2;
  --r2: #DFB988;
  --r3: #B7834A;
  --star: rgba(206, 136, 44, 0.7);
  --route: rgba(172, 90, 26, 0.62);
  --orbit: rgba(196, 118, 42, 0.4);
  --glow: rgba(255, 148, 52, 0.5);
  --aur1: rgba(255, 170, 66, 0.55);
  --aur2: rgba(255, 130, 72, 0.36);
  --aur3: rgba(240, 168, 118, 0.42);

  --sidebar-w: 232px;
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);

  /* la charte des stories exportées — ne pas mélanger avec le chrome */
  --marine: #0F1B3D;
  --brand: #F26B2A;
}

body[data-theme="dark"] {
  --bg: #070B1A;
  --surface: rgba(20, 28, 60, 0.92);
  --surface-flat: rgba(20, 28, 60, 0.92);
  --chip: rgba(255, 255, 255, 0.06);
  --sunken: rgba(255, 255, 255, 0.05);
  --hair: rgba(255, 255, 255, 0.12);
  --hair-strong: rgba(255, 255, 255, 0.26);

  --ink: #E8EEFF;
  --muted: rgba(190, 204, 238, 0.72);
  --eyebrow: #FFB259;
  --lab: #FFB259;

  --g1: #FFB259;
  --g2: #FF7A1A;
  --orange-soft: rgba(255, 148, 52, 0.16);

  --ok: #5FD99B;
  --ok-soft: rgba(95, 217, 155, 0.14);
  --warn: #FFB259;
  --warn-soft: rgba(255, 178, 89, 0.14);
  --danger: #FF8080;
  --danger-soft: rgba(255, 128, 128, 0.14);

  --shadow-card:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 34px -16px rgba(255, 148, 52, 0.25);
  --shadow-raise: 0 0 40px -12px rgba(255, 148, 52, 0.34);
  --shadow-ink: 0 0 34px -8px rgba(255, 107, 0, 0.6), 0 10px 26px -14px rgba(0, 0, 0, 0.5);

  --sky-a: #0A1130;
  --sky-b: #0D1840;
  --sky-c: #17265C;
  --r1: #16224F;
  --r2: #0D1637;
  --r3: #070C1F;
  --star: rgba(228, 238, 255, 0.9);
  --route: rgba(228, 238, 255, 0.5);
  --orbit: rgba(228, 238, 255, 0.22);
  --glow: rgba(255, 148, 52, 0.4);
  --aur1: rgba(255, 148, 52, 0.34);
  --aur2: rgba(255, 130, 72, 0.26);
  --aur3: rgba(255, 170, 66, 0.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'General Sans', 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Le champ d'aube — sans lui, le clair retombe sur du crème plat */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(64% 36% at 50% -8%, rgba(255, 190, 110, 0.22), transparent 62%),
    radial-gradient(44% 26% at 90% -2%, rgba(255, 146, 52, 0.1), transparent 58%),
    radial-gradient(70% 42% at 8% 110%, rgba(236, 166, 120, 0.13), transparent 60%),
    radial-gradient(56% 36% at 94% 108%, rgba(255, 178, 84, 0.1), transparent 58%);
}
body[data-theme="dark"]::before {
  background:
    radial-gradient(52% 44% at 10% 104%, rgba(255, 148, 52, 0.17), transparent 62%),
    radial-gradient(44% 38% at 88% 96%, rgba(255, 130, 72, 0.13), transparent 60%),
    radial-gradient(50% 34% at 72% -6%, rgba(255, 146, 52, 0.1), transparent 58%),
    radial-gradient(30% 24% at 30% -4%, rgba(255, 107, 0, 0.07), transparent 55%);
}

.fd, h1, h2, h3, h4 {
  font-family: 'Clash Display', 'Plus Jakarta Sans', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.1;
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--hair);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 0;
  z-index: 100;
  overflow: hidden;
}
body[data-theme="dark"] .sidebar {
  background: rgba(14, 21, 51, 0.72);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 30px;
  padding: 0 6px;
}
/* Le compas — toujours orange, dans les deux thèmes */
.logo-circle {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
}
.logo-circle svg { width: 34px; height: 34px; display: block; }
.logo-text {
  font-family: 'Clash Display', system-ui, sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.logo-text em {
  font-style: normal;
  font-weight: 600;
  background-image: linear-gradient(96deg, var(--orange-deep) 10%, #FF9D4D 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
body[data-theme="dark"] .logo-text em {
  background-image: linear-gradient(96deg, #FFB259 10%, #FF7A1A 90%);
}

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 11px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  transition: transform 0.18s var(--ease-pop), border-color 0.2s, color 0.2s, background 0.2s;
}
.nav-item:hover { color: var(--ink); background: var(--sunken); }
.nav-item.active {
  background: var(--chip);
  border-color: var(--hair);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 1px 2px rgba(120, 66, 20, 0.06);
}
body[data-theme="dark"] .nav-item.active {
  box-shadow: none;
  border-color: rgba(255, 148, 52, 0.4);
  color: #FFB259;
}
.nav-item.active::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--g1), var(--g2));
  flex-shrink: 0;
  margin-left: -2px;
}
.nav-ico { font-size: 16px; line-height: 1; }
.nav-item.active .nav-ico { display: none; }

.sidebar-footer {
  font-size: 10.5px;
  color: var(--muted);
  padding: 0 6px 14px;
  position: relative;
  z-index: 2;
}
.theme-toggle {
  width: 100%;
  background: var(--chip);
  border: 1px solid var(--hair);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  transition: transform 0.18s var(--ease-pop), border-color 0.2s;
}
.theme-toggle:hover { border-color: var(--hair-strong); }
.theme-toggle:active { transform: scale(0.96); }

/* Le panorama en pied de rail */
.sidebar-pano {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 120px;
  pointer-events: none;
  opacity: 0.85;
  z-index: 0;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 38%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 38%);
}
.sidebar-pano svg { width: 100%; height: 100%; display: block; }

@keyframes hubAurora {
  from { transform: translateX(-6px) skewX(-2deg); }
  to { transform: translateX(8px) skewX(2.5deg); }
}
.p-aur {
  transform-origin: 50% 100%;
  animation: hubAurora 13s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes hubTwinkle { from { opacity: 0.25; } to { opacity: 1; } }
.p-star { animation: hubTwinkle 3s ease-in-out infinite alternate; }
@keyframes hubRoute { to { stroke-dashoffset: -13; } }
.p-route {
  stroke-dasharray: 0.1 12.9;
  stroke-dashoffset: 0;
  animation: hubRoute 3.2s linear infinite;
}

/* ========== MAIN ========== */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}
.view { display: none; }
.view.active { display: block; }

/* ========== VIEW HEADER ========== */
.view-header {
  background: var(--surface);
  padding: 20px 32px;
  border-bottom: 1px solid var(--hair);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
}
body[data-theme="dark"] .view-header {
  background: rgba(14, 21, 51, 0.72);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.view-header h1 {
  font-size: 27px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.022em;
}
.view-header h1 .accent {
  background-image: linear-gradient(96deg, var(--orange-deep) 10%, #FF9D4D 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
body[data-theme="dark"] .view-header h1 .accent {
  background-image: linear-gradient(96deg, #FFB259 10%, #FF7A1A 90%);
}
.subtitle { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ========== BOUTONS ==========
   À l'Aube le primaire est en ENCRE avec la pastille orange ;
   l'orange ne devient un fond qu'en Nocturne. */
.btn-pill {
  background: var(--chip);
  border: 1px solid var(--hair);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.18s var(--ease-pop), border-color 0.2s, color 0.2s;
}
.btn-pill:hover { transform: translateY(-1px); border-color: rgba(255, 107, 0, 0.5); color: var(--orange-deep); }
.btn-pill:active { transform: scale(0.96); }
body[data-theme="dark"] .btn-pill:hover { color: #FFB259; border-color: rgba(255, 148, 52, 0.55); }

.btn-pill.primary {
  background: linear-gradient(180deg, #1D242F 0%, #10161E 100%);
  color: #F5F1E8;
  border-color: transparent;
  box-shadow: var(--shadow-ink);
}
.btn-pill.primary:hover { color: #FFF; transform: translateY(-1px); }
body[data-theme="dark"] .btn-pill.primary {
  background: linear-gradient(180deg, #FF7A1A, #E85D00);
  color: #fff;
}

.btn-primary {
  position: relative;
  background: linear-gradient(180deg, #1D242F 0%, #10161E 100%);
  color: #F5F1E8;
  border: none;
  padding: 13px 22px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-ink);
  transition: transform 0.18s var(--ease-pop), box-shadow 0.25s;
}
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: scale(0.975); }
body[data-theme="dark"] .btn-primary {
  background: linear-gradient(180deg, #FF7A1A, #E85D00);
  color: #fff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.4);
  border: 1.5px solid var(--hair-strong);
  color: #7A4A18;
  padding: 12px 22px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.18s var(--ease-pop), border-color 0.2s, color 0.2s;
}
.btn-secondary:hover { transform: translateY(-2px); border-color: rgba(255, 107, 0, 0.55); color: #E25E00; }
.btn-secondary:active { transform: scale(0.975); }
body[data-theme="dark"] .btn-secondary {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.06);
}
body[data-theme="dark"] .btn-secondary:hover { border-color: rgba(255, 148, 52, 0.6); color: #FFB259; }
.btn-secondary.active {
  background: var(--orange-soft);
  border-color: rgba(255, 107, 0, 0.55);
  color: var(--orange-deep);
}
body[data-theme="dark"] .btn-secondary.active { color: #FFB259; }

.btn-lg { padding: 14px 26px; font-size: 15px; }

.btn-mini {
  background: var(--chip);
  border: 1px solid var(--hair);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
  transition: transform 0.15s var(--ease-pop), border-color 0.15s;
}
.btn-mini:hover { border-color: rgba(255, 107, 0, 0.5); }
.btn-mini:active { transform: scale(0.94); }

.btn-warn { background: var(--danger-soft); color: var(--danger); border-color: rgba(185, 28, 28, 0.28); }
.btn-warn:hover { background: var(--danger); color: #FFF; border-color: transparent; }

button:disabled, .btn-primary:disabled {
  background: rgba(133, 84, 38, 0.08);
  color: rgba(107, 74, 44, 0.52);
  box-shadow: none;
  cursor: not-allowed;
}
body[data-theme="dark"] button:disabled {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(232, 238, 255, 0.4);
}

/* ========== VUE PLAN ========== */
.view-plan { max-width: 1600px; margin: 0 auto; }

/* ========== NAVIGATEUR DE SEMAINE ========== */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 22px;
  padding: 14px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}
.week-nav-btn {
  background: var(--chip);
  border: 1px solid var(--hair);
  color: var(--ink);
  padding: 9px 18px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.18s var(--ease-pop), border-color 0.2s, color 0.2s;
}
.week-nav-btn:hover { border-color: rgba(255, 107, 0, 0.5); color: var(--orange-deep); transform: translateY(-1px); }
.week-current {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.week-current .week-label {
  font-family: 'Clash Display', system-ui, sans-serif;
  font-weight: 600;
  font-size: 21px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.week-current .week-iso {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 600;
}
.week-today-btn {
  background: linear-gradient(160deg, var(--g1), var(--g2));
  border: none;
  color: #FFF;
  padding: 4px 13px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
  margin-top: 2px;
  box-shadow: 0 4px 12px -4px rgba(255, 107, 0, 0.5);
}
.week-today-btn:hover { filter: brightness(1.05); }
.week-today-btn.current {
  background: var(--sunken);
  color: var(--muted);
  cursor: default;
  box-shadow: none;
}

.week-status {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-left: 8px;
}
.week-status.past { background: var(--sunken); color: var(--muted); }
.week-status.current { background: var(--ok-soft); color: var(--ok); }
.week-status.future { background: var(--orange-soft); color: #B8560E; }
body[data-theme="dark"] .week-status.future { color: #FFB259; }

.week-fill { width: 220px; margin-top: 6px; }
.week-fill-bar {
  width: 100%;
  height: 6px;
  background: rgba(140, 86, 34, 0.13);
  border-radius: 999px;
  overflow: hidden;
}
body[data-theme="dark"] .week-fill-bar { background: rgba(255, 255, 255, 0.1); }
.week-fill-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--g2) 0%, var(--g1) 100%);
  border-radius: 999px;
  transition: width 0.4s var(--ease-soft);
}
.week-fill-text { display: block; font-size: 10px; color: var(--muted); margin-top: 5px; text-align: center; }

/* ========== CHECK-LIST DU JOUR ========== */
.today-card { border-color: rgba(255, 107, 0, 0.35); }
.today-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--hair);
  border-radius: 14px;
  margin-bottom: 8px;
  background: var(--chip);
  transition: transform 0.18s var(--ease-pop), border-color 0.2s, background 0.2s;
  cursor: pointer;
}
.today-checklist-item:hover { border-color: rgba(255, 107, 0, 0.5); transform: translateY(-1px); }
.today-checklist-item.done { background: var(--ok-soft); border-color: rgba(27, 138, 80, 0.3); opacity: 0.72; }
.today-checklist-item.done .today-item-title { text-decoration: line-through; color: var(--muted); }
.today-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--hair-strong);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: transparent;
  background: transparent;
  transition: transform 0.2s var(--ease-pop), background 0.2s, border-color 0.2s;
}
.today-checklist-item.done .today-check {
  background: linear-gradient(135deg, var(--g1), var(--g2));
  border-color: transparent;
  color: #FFF;
  box-shadow: 0 4px 12px -4px rgba(255, 107, 0, 0.5);
}
.today-item-time {
  font-size: 10px;
  font-weight: 700;
  color: var(--lab);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  margin-bottom: 3px;
}
.today-item-title { font-weight: 600; color: var(--ink); font-size: 14px; }
.today-item-action {
  font-size: 11px;
  color: var(--orange-deep);
  font-weight: 600;
  margin-left: auto;
  align-self: center;
  white-space: nowrap;
  /* c'est un <button> : sans ça il garde le fond gris du navigateur,
     très visible en Nocturne */
  background: transparent;
  border: none;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}
body[data-theme="dark"] .today-item-action { color: #FFB259; }

.section-title {
  font-family: 'Clash Display', system-ui, sans-serif;
  font-weight: 600;
  font-size: 23px;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-top: 36px;
  margin-bottom: 8px;
}
.section-hint { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

/* ========== KPI ========== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 12px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 22px;
  padding: 18px 22px;
  box-shadow: var(--shadow-card);
}
.kpi-card.highlighted { border-color: rgba(255, 107, 0, 0.35); }
.kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--lab);
}
.kpi-value {
  font-family: 'Clash Display', system-ui, sans-serif;
  font-weight: 600;
  font-size: 33px;
  letter-spacing: -0.022em;
  line-height: 1.15;
  margin: 5px 0;
  background-image: linear-gradient(96deg, var(--orange-deep) 10%, #FF9D4D 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
body[data-theme="dark"] .kpi-value {
  background-image: linear-gradient(96deg, #FFB259 10%, #FF7A1A 90%);
}
.kpi-sub { font-size: 11.5px; color: var(--muted); }

/* ========== TABLEAUX ========== */
.planning-table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border-radius: 22px;
  border: 1px solid var(--hair);
  box-shadow: var(--shadow-card);
}
.planning-table, .feed-table, .bench-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.feed-table, .bench-table {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 22px;
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}
.planning-table th, .planning-table td,
.feed-table th, .feed-table td,
.bench-table th, .bench-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--hair);
}
.planning-table th, .feed-table th, .bench-table th {
  background: var(--sunken);
  font-weight: 700;
  color: var(--lab);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  white-space: nowrap;
}
.planning-table tr:last-child td,
.feed-table tr:last-child td,
.bench-table tr:last-child td { border-bottom: none; }
.planning-table .day-cell {
  font-weight: 700;
  color: var(--ink);
  background: var(--sunken);
  white-space: nowrap;
}
.planning-table td.story-cell { cursor: pointer; transition: background 0.15s, color 0.15s; }
.planning-table td.story-cell:hover { background: var(--orange-soft); color: var(--orange-deep); }
body[data-theme="dark"] .planning-table td.story-cell:hover { color: #FFB259; }

/* ========== SÉQUENCE ========== */
.seq-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.seq-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.seq-step-num {
  background: linear-gradient(135deg, var(--g1), var(--g2));
  color: #FFF;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px -4px rgba(255, 107, 0, 0.5);
}
.seq-card h4 { font-size: 13.5px; color: var(--ink); margin-bottom: 6px; }
.seq-card p { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* ========== RÈGLES ========== */
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.rule {
  background: var(--surface);
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13px;
  border: 1px solid var(--hair);
  border-left: 4px solid;
}
.rule-no { border-left-color: var(--danger); }
.rule-yes { border-left-color: var(--ok); }

/* ========== HIGHLIGHTS ========== */
.highlights-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 12px; }
.highlight-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 18px;
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.hl-num {
  background: linear-gradient(135deg, var(--g1), var(--g2));
  color: #FFF;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 8px;
}
.hl-name { font-weight: 700; color: var(--ink); margin-bottom: 6px; font-size: 13px; }
.hl-content { font-size: 11px; color: var(--muted); line-height: 1.45; }

.footer-note { margin-top: 36px; font-size: 11px; color: var(--muted); }
.footer-note a { color: var(--orange-deep); text-decoration: none; }
.footer-note a:hover { text-decoration: underline; }

/* ========== ONGLETS DU PLAN ========== */
.plan-tabs {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 999px;
  margin: 0 0 24px;
  padding: 5px;
  display: flex;
  gap: 3px;
  box-shadow: var(--shadow-card);
  overflow-x: auto;
  scrollbar-width: none;
}
.plan-tabs::-webkit-scrollbar { display: none; }
.plan-tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  transition: transform 0.18s var(--ease-pop), color 0.2s, background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.plan-tab:hover { color: var(--ink); background: var(--sunken); }
.plan-tab.active {
  color: var(--orange-deep);
  background: var(--orange-soft);
  border-color: rgba(255, 107, 0, 0.3);
}
body[data-theme="dark"] .plan-tab.active { color: #FFB259; border-color: rgba(255, 148, 52, 0.4); }

.plan-panel { display: none; }
.plan-panel.active { display: block; animation: boRise 0.5s var(--ease-soft) backwards; }

@keyframes boRise {
  from { opacity: 0; transform: translateY(16px) scale(0.992); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========== CARTES ========== */
.card {
  background: var(--surface);
  border-radius: 22px;
  padding: 24px 28px;
  margin-bottom: 20px;
  border: 1px solid var(--hair);
  box-shadow: var(--shadow-card);
}
.card h2 {
  font-family: 'Clash Display', system-ui, sans-serif;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card h2 .badge {
  background: var(--chip);
  border: 1px solid var(--hair);
  color: var(--lab);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-family: 'General Sans', system-ui, sans-serif;
}
.card .sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.card h3 {
  font-family: 'Clash Display', system-ui, sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.018em;
  margin-top: 22px;
  margin-bottom: 10px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 9px;
}
.card h3::before {
  content: '';
  width: 4px;
  height: 17px;
  background: linear-gradient(180deg, var(--g1), var(--g2));
  border-radius: 999px;
  flex-shrink: 0;
}
.card p { margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.card ul { margin-left: 22px; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.card ul li { margin-bottom: 6px; }
.card strong { color: var(--ink); font-weight: 600; }

.card table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 13px;
}
.card thead { background: var(--sunken); }
.card th, .card td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--hair);
  color: var(--muted);
}
.card th {
  font-weight: 700;
  color: var(--lab);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
}
.card tr:last-child td { border-bottom: none; }
.card tbody tr:hover { background: var(--sunken); }

/* Cellules éditables */
[contenteditable="true"] {
  background: var(--orange-soft);
  border: 1px dashed rgba(255, 107, 0, 0.3);
  border-radius: 6px;
  padding: 2px 6px;
  outline: none;
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
[contenteditable="true"]:focus {
  background: var(--surface-flat);
  border-color: var(--orange);
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.16);
}

.helper {
  background: var(--orange-soft);
  border-left: 3px solid var(--orange);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin: 12px 0;
  color: var(--ink);
}

.kpi-cp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.kpi-cp-card {
  background: var(--chip);
  border: 1px solid var(--hair);
  border-radius: 18px;
  padding: 18px 22px;
  box-shadow: var(--shadow-card);
}
.kpi-cp-card .label {
  font-size: 10px;
  color: var(--lab);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-weight: 700;
}
.kpi-cp-card .value {
  font-family: 'Clash Display', system-ui, sans-serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.022em;
  margin-top: 5px;
  background-image: linear-gradient(96deg, var(--orange-deep) 10%, #FF9D4D 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
body[data-theme="dark"] .kpi-cp-card .value {
  background-image: linear-gradient(96deg, #FFB259 10%, #FF7A1A 90%);
}
.kpi-cp-card .note { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.sources {
  background: var(--sunken);
  border-radius: 14px;
  padding: 14px 18px;
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
}
.sources strong { display: block; margin-bottom: 6px; color: var(--ink); }
.sources a { color: var(--orange-deep); text-decoration: none; font-weight: 500; }
.sources a:hover { text-decoration: underline; }

/* ========== GRILLE HEBDO ========== */
.week-grid {
  display: grid;
  grid-template-columns: 76px repeat(7, 1fr);
  gap: 6px;
  margin-top: 16px;
}
.week-grid > .wg-head {
  background: var(--chip);
  border: 1px solid var(--hair);
  color: var(--lab);
  padding: 10px 8px;
  text-align: center;
  font-weight: 700;
  border-radius: 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
}
.week-grid > .wg-head.time { background: transparent; border-color: transparent; color: var(--muted); }
.week-cell {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 10px;
  min-height: 80px;
  font-size: 12px;
  color: var(--muted);
  transition: transform 0.18s var(--ease-pop), border-color 0.2s, background 0.2s;
  position: relative;
}
.week-cell:hover { border-color: rgba(255, 107, 0, 0.45); }
.week-cell.feed { background: linear-gradient(135deg, var(--surface-flat) 0%, rgba(255, 107, 0, 0.07) 100%); }
.week-cell.story { cursor: pointer; }
.week-cell.story:hover { background: var(--orange-soft); transform: translateY(-2px); }
.week-cell.story .open-link {
  position: absolute;
  bottom: 5px;
  right: 7px;
  font-size: 9px;
  color: var(--orange-deep);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0;
  transition: opacity 0.15s;
}
.week-cell.story:hover .open-link { opacity: 1; }

.pub-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  margin-bottom: 5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.tag-reel { background: var(--orange-soft); color: #B8560E; }
.tag-carrousel { background: var(--sunken); color: var(--ink); }
.tag-story { background: var(--ok-soft); color: var(--ok); }
body[data-theme="dark"] .tag-reel { color: #FFB259; }

.legend { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 4px; }

.sequence-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 14px; }
.sequence-grid .seq-step {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 16px;
  padding: 14px 12px;
  text-align: center;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
}
.sequence-grid .seq-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
  box-shadow: 0 4px 12px -4px rgba(255, 107, 0, 0.5);
}
.sequence-grid .seq-type {
  font-weight: 700;
  font-size: 10px;
  color: var(--lab);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  margin-bottom: 6px;
}
.sequence-grid .seq-ex {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auto-item { display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--hair); }
.auto-item:last-child { border-bottom: none; }
.auto-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--chip);
  border: 1px solid var(--hair);
  color: var(--orange-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.auto-content { flex: 1; }
.auto-content h4 { font-weight: 600; font-size: 15px; color: var(--ink); margin-bottom: 4px; }
.auto-content p { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.priority {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.priority.p1 { background: var(--ok-soft); color: var(--ok); }
.priority.p2 { background: var(--warn-soft); color: var(--warn); }
.priority.p3 { background: var(--sunken); color: var(--muted); }

/* ========== GÉNÉRATEUR — LAYOUT ========== */
.story-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 380px;
  min-height: calc(100vh - 74px);
}

.ctrl-panel {
  background: var(--surface);
  border-right: 1px solid var(--hair);
  padding: 18px;
  overflow-y: auto;
  max-height: calc(100vh - 74px);
}
.ctrl-panel h3, .library-panel h3 {
  font-family: 'General Sans', system-ui, sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--lab);
  margin-bottom: 8px;
  margin-top: 20px;
  font-weight: 700;
}
.ctrl-panel h3:first-of-type { margin-top: 0; }
.muted { text-transform: none; font-weight: 400; color: var(--muted); font-size: 10px; letter-spacing: 0; }

.seq-indicator {
  background: var(--orange-soft);
  border: 1px solid rgba(255, 107, 0, 0.35);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--ink);
}
.seq-indicator strong { display: block; margin-bottom: 6px; }
.seq-nav { display: flex; gap: 6px; margin-top: 8px; }

.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.template-btn {
  background: var(--chip);
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 10px 6px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.18s var(--ease-pop), border-color 0.2s, background 0.2s;
  font-family: inherit;
  position: relative;
}
.template-btn:hover { border-color: rgba(255, 107, 0, 0.5); transform: translateY(-2px); }
.template-btn:active { transform: scale(0.96); }
.template-btn.active {
  border-color: rgba(255, 107, 0, 0.6);
  background: var(--orange-soft);
}
.template-btn .ico { font-size: 19px; display: block; margin-bottom: 4px; }
.template-btn .name { font-size: 10px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.template-btn .sticker-flag {
  position: absolute;
  top: 3px;
  right: 3px;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  color: #FFF;
  font-size: 7px;
  padding: 1px 4px;
  border-radius: 999px;
  font-weight: 700;
}

.form-group { margin-bottom: 10px; }
.form-group label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--lab);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  margin-bottom: 5px;
}
.form-group input, .form-group textarea, .form-group select,
.lib-controls input, .lib-controls select {
  width: 100%;
  background: var(--surface-flat);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
body[data-theme="dark"] .form-group input,
body[data-theme="dark"] .form-group textarea,
body[data-theme="dark"] .form-group select,
body[data-theme="dark"] .lib-controls input,
body[data-theme="dark"] .lib-controls select {
  background: rgba(13, 20, 48, 0.6);
  border-color: rgba(255, 255, 255, 0.13);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus,
.lib-controls input:focus, .lib-controls select:focus {
  border-color: rgba(255, 107, 0, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.12);
}
.form-group input::placeholder, .lib-controls input::placeholder { color: var(--muted); }
.form-group textarea { resize: vertical; min-height: 46px; }
.form-group select, .lib-controls select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23B06018' d='M5 6L0 0h10z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.sugg-list { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.sugg-label {
  width: 100%;
  font-size: 9px;
  color: var(--lab);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 700;
  margin-bottom: 3px;
}
.sugg-pill {
  background: var(--chip);
  border: 1px solid var(--hair);
  color: var(--ink);
  padding: 5px 10px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s var(--ease-pop), border-color 0.15s, color 0.15s;
  line-height: 1.2;
}
.sugg-pill:hover { border-color: rgba(255, 107, 0, 0.55); color: var(--orange-deep); }
.sugg-pill:active { transform: scale(0.94); }
body[data-theme="dark"] .sugg-pill:hover { color: #FFB259; }

.sticker-hint {
  background: var(--orange-soft);
  border-left: 3px solid var(--orange);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 11px;
  margin-bottom: 12px;
  color: var(--ink);
  line-height: 1.45;
}

.ctrl-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 8px; }
.ctrl-row.three { grid-template-columns: repeat(3, 1fr); }
.ctrl-btn {
  background: var(--chip);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s var(--ease-pop), border-color 0.15s, background 0.15s, color 0.15s;
}
.ctrl-btn:hover { border-color: rgba(255, 107, 0, 0.5); }
.ctrl-btn:active { transform: scale(0.94); }
.ctrl-btn.active {
  background: var(--orange-soft);
  color: var(--orange-deep);
  border-color: rgba(255, 107, 0, 0.55);
}
body[data-theme="dark"] .ctrl-btn.active { color: #FFB259; border-color: rgba(255, 148, 52, 0.55); }
.ctrl-btn.full { grid-column: 1 / -1; padding: 9px; font-size: 12px; }

.slider-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.slider-row label { font-size: 11px; font-weight: 600; color: var(--muted); min-width: 54px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--orange); }
.slider-row .val {
  font-size: 10px;
  color: var(--muted);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.palette-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-top: 4px; }
.mockup-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.mockup-thumb {
  background: var(--sunken);
  border: 2px solid transparent;
  border-radius: 10px;
  aspect-ratio: 9/13;
  cursor: pointer;
  overflow: hidden;
  background-size: cover;
  background-position: top center;
  position: relative;
  transition: transform 0.15s var(--ease-pop), border-color 0.15s;
}
.mockup-thumb:hover { transform: scale(1.05); border-color: rgba(255, 107, 0, 0.6); }
.mockup-thumb.active { border-color: var(--orange); transform: scale(1.05); }
.mockup-thumb .mockup-label {
  position: absolute;
  bottom: 2px;
  left: 2px;
  right: 2px;
  background: rgba(36, 23, 8, 0.82);
  color: #FFF;
  font-size: 8px;
  padding: 2px 4px;
  border-radius: 5px;
  text-align: center;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.swatch {
  aspect-ratio: 9/16;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s var(--ease-pop), border-color 0.15s;
  background-size: cover;
  background-position: center;
  background-color: var(--sunken);
  position: relative;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--orange); transform: scale(1.05); }
.swatch-delete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(185, 28, 28, 0.95);
  color: #FFF;
  border: 1.5px solid #FFF;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.swatch:hover .swatch-delete { display: flex; }
.swatch-delete:hover { background: #DC2626; transform: scale(1.15); }

.upload-btn {
  background: var(--sunken);
  border: 1.5px dashed var(--hair-strong);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  transition: border-color 0.2s, color 0.2s;
  display: block;
}
.upload-btn:hover { border-color: rgba(255, 107, 0, 0.55); color: var(--orange-deep); }

/* ========== APERÇU ========== */
.preview-panel {
  background: transparent;
  padding: 24px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  max-height: calc(100vh - 74px);
  min-width: 0;
}
.preview-wrap {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.preview-actions { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.preview-actions .btn-primary, .preview-actions .btn-secondary { width: 100%; }
.preview-info { font-size: 11px; color: var(--muted); text-align: center; }
.insta-safe-zones {
  width: 100%;
  background: var(--chip);
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}
.insta-safe-zones strong { color: var(--ink); }

/* ========== COUCHE D'ÉDITION ==========
   Tout est posé en coordonnées ÉCRAN au-dessus du canevas réduit : le canevas
   travaille en 1080×1920, la couche en pixels affichés. Le facteur de
   conversion vit dans app.js (CANVAS_SCALE). */
.editor-stage { position: relative; flex-shrink: 0; }
.editor-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

/* Le cadre de sélection */
.ed-sel {
  position: absolute;
  border: 1.5px solid #0A84FF;
  border-radius: 2px;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55);
}
.ed-sel i {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #FFF;
  border: 1.5px solid #0A84FF;
  border-radius: 2px;
  pointer-events: auto;
  margin: -5px 0 0 -5px;
}
.ed-sel i[data-h="nw"] { top: 0; left: 0; cursor: nwse-resize; }
.ed-sel i[data-h="n"]  { top: 0; left: 50%; cursor: ns-resize; }
.ed-sel i[data-h="ne"] { top: 0; left: 100%; cursor: nesw-resize; }
.ed-sel i[data-h="w"]  { top: 50%; left: 0; cursor: ew-resize; }
.ed-sel i[data-h="e"]  { top: 50%; left: 100%; cursor: ew-resize; }
.ed-sel i[data-h="sw"] { top: 100%; left: 0; cursor: nesw-resize; }
.ed-sel i[data-h="s"]  { top: 100%; left: 50%; cursor: ns-resize; }
.ed-sel i[data-h="se"] { top: 100%; left: 100%; cursor: nwse-resize; }

/* Les guides d'alignement, le temps du geste */
.ed-guides { position: absolute; inset: 0; }
.ed-guide {
  position: absolute;
  background: repeating-linear-gradient(var(--g-dir, to right), #0A84FF 0 4px, transparent 4px 10px);
}
.ed-guide.v { width: 1px; top: -12px; bottom: -12px; --g-dir: to bottom; }
.ed-guide.h { height: 1px; left: -12px; right: -12px; --g-dir: to right; }

/* Les bandes que l'interface d'Instagram recouvre */
.ed-safe { position: absolute; inset: 0; }
.ed-safe-band {
  position: absolute;
  left: 0;
  right: 0;
  background: repeating-linear-gradient(45deg, rgba(10, 132, 255, 0.1) 0 8px, rgba(10, 132, 255, 0.02) 8px 16px);
  border-color: rgba(10, 132, 255, 0.35);
  border-style: dashed;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ed-safe-band span {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #FFF;
  background: rgba(10, 132, 255, 0.85);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.ed-safe-top { top: 0; border-bottom-width: 1px; }
.ed-safe-bottom { bottom: 0; border-top-width: 1px; }

.story-canvas.ed-armed { cursor: default; }
.story-canvas [data-eid] { cursor: pointer; }
.story-canvas [data-eid].ed-hot { outline: 1.5px dashed rgba(10, 132, 255, 0.55); outline-offset: 3px; }
.story-canvas.ed-dragging, .story-canvas.ed-dragging [data-eid] { cursor: grabbing; }

/* La barre contextuelle de l'élément sélectionné */
.ed-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 6px 12px;
  box-shadow: var(--shadow-card);
  animation: boRise 0.28s var(--ease-soft) backwards;
}
.ed-bar[hidden] { display: none; }
.ed-bar-name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lab);
  white-space: nowrap;
}
.ed-bar-sep { width: 1px; height: 16px; background: var(--hair); flex-shrink: 0; }
.ed-bar-btn, .ed-tool {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  width: 28px;
  height: 26px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s var(--ease-pop), background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.ed-bar-btn:hover, .ed-tool:hover:not(:disabled) { background: var(--orange-soft); border-color: rgba(255, 107, 0, 0.4); }
.ed-bar-btn:active, .ed-tool:active:not(:disabled) { transform: scale(0.9); }

.ed-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0 2px;
}
.ed-tool:disabled { opacity: 0.3; cursor: not-allowed; }
.ed-tool.on { background: var(--orange-soft); border-color: rgba(255, 107, 0, 0.45); }
.ed-hint {
  font-size: 10.5px;
  color: var(--muted);
  margin-left: auto;
  text-align: right;
  line-height: 1.3;
}

/* --- Le canevas de story : format publié, ne pas rhabiller --- */
.story-canvas {
  width: 1080px;
  height: 1920px;
  /* Origine en haut À GAUCHE : avec « top center », la boîte de 1080 px
     restait centrée sur elle-même et l'aperçu sortait de sa colonne par
     la droite. Le débordement de la boîte non transformée est masqué par
     l'overflow du shell. */
  transform-origin: top left;
  transform: scale(0.32);
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  box-shadow: 0 18px 44px -16px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  background: var(--marine);
  --size-mult: 1;
  --text-x: 0px;
  --text-y: 0px;
  --tag-x: 0px;
  --tag-y: 0px;
  --overlay-opacity: 0.6;
  --text-color: #FFFFFF;
  --text-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  cursor: move;
  user-select: none;
}
.story-canvas .story-tag { transform: translate(var(--tag-x, 0px), var(--tag-y, 0px)); }
.story-canvas.dragging { cursor: grabbing; }
.story-canvas-shell {
  width: calc(1080px * 0.32);
  height: calc(1920px * 0.32);
  margin-bottom: 6px;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 22px;
}
.story-canvas-shell::before, .story-canvas-shell::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), transparent);
  pointer-events: none;
  z-index: 1000;
  border-radius: 8px;
}
.story-canvas-shell::before { top: 0; height: 18%; }
.story-canvas-shell::after { bottom: 0; height: 13%; background: linear-gradient(0deg, rgba(255, 255, 255, 0.15), transparent); }

.s-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: var(--bg-x, 50%) var(--bg-y, 50%);
  transform: scale(var(--bg-zoom, 1));
  transform-origin: center center;
}
.s-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(0, 0, 0, calc(var(--overlay-opacity) * 0.35)) 0%,
    rgba(0, 0, 0, calc(var(--overlay-opacity) * 0.5)) 50%,
    rgba(0, 0, 0, calc(var(--overlay-opacity) * 1.0)) 100%);
}
#story-canvas.hide-tag .story-tag { display: none !important; }

/* ========== BANQUE ========== */
.library-panel {
  background: var(--surface);
  border-left: 1px solid var(--hair);
  padding: 18px;
  overflow-y: auto;
  max-height: calc(100vh - 74px);
}
.library-panel h3 { margin-top: 0; }

.lib-tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 12px;
  background: var(--sunken);
  border-radius: 999px;
  padding: 4px;
}
.lib-tab {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  flex: 1;
  text-align: center;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.lib-tab:hover { color: var(--ink); }
.lib-tab.active {
  background: var(--surface-flat);
  color: var(--orange-deep);
  box-shadow: 0 1px 2px rgba(120, 66, 20, 0.08);
}
body[data-theme="dark"] .lib-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: #FFB259;
  box-shadow: none;
}
.lib-view { display: none; }
.lib-view.active { display: block; }
.lib-fav-item { position: relative; }
.lib-fav-meta {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 3px;
}
.lib-fav-actions { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }
.lib-fav-btn { padding: 3px 8px; font-size: 10px; }

.lib-controls { display: flex; gap: 6px; margin-bottom: 10px; }
.lib-controls input { flex: 1; }
.lib-controls select { flex: 0 0 auto; max-width: 140px; }

.batch-bar {
  background: var(--orange-soft);
  border: 1px solid rgba(255, 107, 0, 0.35);
  border-radius: 12px;
  padding: 9px 12px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink);
  flex-wrap: wrap;
}
.batch-bar strong { color: var(--orange-deep); }
body[data-theme="dark"] .batch-bar strong { color: #FFB259; }

.lib-count { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.lib-list { display: flex; flex-direction: column; gap: 5px; }
.lib-item {
  background: var(--chip);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.45;
  cursor: pointer;
  transition: transform 0.15s var(--ease-pop), border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lib-item:hover { border-color: rgba(255, 107, 0, 0.5); transform: translateX(2px); }
.lib-item.batch-mode { padding: 10px 10px 10px 12px; }
.lib-item .lib-cat {
  display: inline-block;
  background: var(--sunken);
  color: var(--lab);
  font-size: 8.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  margin-right: 6px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.lib-item .lib-text { flex: 1; }
.lib-item input[type=checkbox] { accent-color: var(--orange); cursor: pointer; }
.lib-item.selected { background: var(--orange-soft); border-color: rgba(255, 107, 0, 0.55); }
.lib-empty { text-align: center; padding: 30px 20px; color: var(--muted); font-size: 13px; }

.lib-dup-btn {
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 8px;
  font-size: 13px;
  padding: 3px 8px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.lib-item:hover .lib-dup-btn { opacity: 1; }
.lib-dup-btn:hover { border-color: rgba(255, 107, 0, 0.5); }
.lib-ph-badge { display: inline-block; margin-right: 4px; font-size: 12px; }

.export-format-row { display: flex; gap: 6px; width: 100%; }
.export-format-row .ctrl-btn { flex: 1; font-size: 12px; padding: 9px 6px; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: linear-gradient(180deg, #1D242F 0%, #10161E 100%);
  color: #F5F1E8;
  padding: 14px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 18px 40px -18px rgba(31, 26, 18, 0.7);
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.35s var(--ease-pop), opacity 0.3s;
  z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.warn { background: linear-gradient(180deg, #C2410C, #9A3412); color: #FFF; }
body[data-theme="dark"] .toast {
  background: linear-gradient(180deg, #FF7A1A, #E85D00);
  color: #fff;
  box-shadow: 0 0 34px -8px rgba(255, 107, 0, 0.6);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1280px) {
  .story-layout { grid-template-columns: 300px minmax(0, 1fr) 320px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .seq-cards, .sequence-grid { grid-template-columns: repeat(3, 1fr); }
  .highlights-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1080px) {
  .story-layout { grid-template-columns: 1fr; min-height: 0; }
  .ctrl-panel, .library-panel {
    border: none;
    border-bottom: 1px solid var(--hair);
    max-height: none;
    overflow: visible;
  }
  .preview-panel { max-height: none; order: -1; padding: 18px 12px; }
  .preview-wrap { max-width: 100%; }
  .rules-grid { grid-template-columns: 1fr; }
  .week-grid { grid-template-columns: 60px repeat(7, 1fr); font-size: 11px; }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 66px; }
  .nav-label, .logo-text, .sidebar-footer .version { display: none; }
  .sidebar { padding: 18px 10px 0; }
  .sidebar-logo { justify-content: center; padding: 0; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .nav-item.active::before { display: none; }
  .nav-item.active .nav-ico { display: block; }
  .sidebar-pano { display: none; }
  .theme-toggle { padding: 8px 0; }
  .theme-toggle span { display: none; }
  .view-header { padding: 16px 18px; }
  .view-header h1 { font-size: 22px; }
  .view-plan > div { padding: 18px !important; }
  .card { padding: 18px 16px; border-radius: 18px; }
  .kpi-grid, .seq-cards, .sequence-grid, .highlights-grid { grid-template-columns: 1fr 1fr; }
  .kpi-cp-grid { grid-template-columns: 1fr; }
  .week-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .week-grid > .wg-head.time { display: none; }
}

@media (max-width: 560px) {
  .kpi-grid, .seq-cards, .sequence-grid, .highlights-grid { grid-template-columns: 1fr; }
  .view-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .view-actions { width: 100%; }
  .template-grid { grid-template-columns: 1fr 1fr; }
  .toast { left: 16px; right: 16px; bottom: 16px; text-align: center; }

  /* La ligne de check-list passe en colonne : à cette largeur, l'action
     « Ouvrir template » venait se poser par-dessus le titre. */
  .today-checklist-item { flex-wrap: wrap; }
  .today-item-action { margin-left: 34px; align-self: flex-start; width: 100%; }

  /* Les tableaux larges scrollent dans leur propre boîte, jamais la page.
     `width:100%` est indispensable : en display:block une table prend sinon
     la largeur de son contenu et ressort du conteneur au lieu de scroller. */
  .card table, .feed-table, .bench-table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
  }
  .card table td, .card table th { min-width: 110px; }
}

/* Rien ne doit faire déborder la page sur le côté. `clip` et non `hidden` :
   `hidden` créerait un conteneur de défilement qui casserait le sticky de
   l'en-tête de vue. */
html { overflow-x: clip; }
body { overflow-x: clip; max-width: 100vw; }
.main { min-width: 0; }
.view-plan { min-width: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
