:root {
  --bg: #FFFBEF; --paper: #FFFFFF; --ink: #120D02; --muted: #6B6478; --line: #16121F; --soft: #EFE7DA;
  --accent: #FFD951; --accent-ink: #120D02; --client: #FF5C8A; --ok: #12B886; --warn: #F5A524; --danger: #E5484D;
  --shadow: 4px 4px 0 var(--line); --radius: 16px; --off: repeating-linear-gradient(135deg, #0000 0 5px, #16121F14 5px 7px);
  --font: 'Inter', system-ui, sans-serif; --display: 'Bricolage Grotesque', 'Inter', sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #17141F; --paper: #221E2D; --ink: #F4F0FF; --muted: #A59FB5; --line: #F4F0FF; --soft: #2E2940; --off: repeating-linear-gradient(135deg, #0000 0 5px, #F4F0FF1A 5px 7px);
} }
:root[data-theme="dark"] { --bg: #17141F; --paper: #221E2D; --ink: #F4F0FF; --muted: #A59FB5; --line: #F4F0FF; --soft: #2E2940; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.02em; margin: 0 0 .4em; line-height: 1.1; }
h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 800; }
h2 { font-size: 24px; font-weight: 800; } h3 { font-size: 17px; font-weight: 600; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 80px; }

/* Barre du haut */
.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 2px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 20; }
.brand { font-family: var(--display); font-weight: 800; font-size: 20px; text-decoration: none; display: flex; gap: 8px; align-items: center; }
.top .sp { flex: 1; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line); object-fit: cover; background: var(--soft); display: grid; place-items: center; font-weight: 700; }

/* Boutons */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--line); background: var(--paper); border-radius: 999px; padding: 8px 16px; font-weight: 600; cursor: pointer; box-shadow: 2px 2px 0 var(--line); transition: transform .08s, box-shadow .08s; text-decoration: none; white-space: nowrap; }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--line); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { box-shadow: none; border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--soft); transform: none; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, .tile:focus-visible, .brick:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Cartes */
.card { background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin: 24px 0 32px; }
.tile { text-align: left; cursor: pointer; border: 2px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: var(--shadow); background: var(--paper); transition: transform .12s; }
.tile:hover { transform: translate(-2px, -2px) rotate(-.4deg); }
.tile .big { font-size: 40px; line-height: 1; display: block; margin-bottom: 12px; }
.tile.hero { background: var(--accent); color: var(--accent-ink); }
.tile.hero .muted { color: #120D02B3; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--line); border-radius: 999px; padding: 3px 12px; font-size: 13px; font-weight: 600; background: var(--paper); cursor: pointer; user-select: none; }
.chip.on { background: var(--ink); color: var(--bg); }
.chip.off { opacity: .45; text-decoration: line-through; }
.retro-card { cursor: pointer; display: flex; flex-direction: column; gap: 8px; min-height: 150px; }
.retro-card:hover { transform: translate(-1px, -1px); }
.retro-card .emojis { font-size: 22px; letter-spacing: 2px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft); }
.pill.done { background: #12B88633; } .pill.ongoing { background: #F5A52433; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }

/* Formulaires */
label.f { display: block; font-weight: 600; font-size: 13px; }
label.f > span { display: block; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=date], input[type=number], select, textarea { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--paper); }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 14px; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--ink); color: var(--bg); }
.q { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { max-width: 440px; text-align: center; padding: 36px 28px; }
.login .logo { font-size: 64px; display: block; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-6deg); } }
.gbtn { margin-top: 20px; font-size: 16px; padding: 12px 22px; }

/* Assistant */
.steps { display: flex; gap: 8px; margin: 8px 0 24px; flex-wrap: wrap; }
.steps span { padding: 4px 12px; border-radius: 999px; border: 2px solid var(--line); font-weight: 600; font-size: 13px; opacity: .45; }
.steps span.on { opacity: 1; background: var(--ink); color: var(--bg); }
.drop { border: 3px dashed var(--line); border-radius: 22px; padding: 48px 16px; text-align: center; cursor: pointer; background: var(--paper); transition: background .15s, transform .15s; }
.drop.hover { background: var(--soft); transform: scale(1.01); }
.drop .big { font-size: 56px; }
.devis { display: flex; gap: 14px; align-items: flex-start; }
.devis .handle { cursor: grab; font-size: 22px; padding: 4px; user-select: none; }
.devis .n { font-family: var(--display); font-weight: 800; font-size: 28px; min-width: 28px; }
.devis.dragging { opacity: .4; }
.question { border-left: 4px solid var(--warn); padding: 4px 10px; margin: 6px 0; font-size: 14px; background: #F5A5241A; border-radius: 0 8px 8px 0; }
.evidence { font-size: 12px; color: var(--muted); margin: 4px 0 0; padding-left: 16px; }

/* Éditeur */
.editor { display: grid; grid-template-columns: 250px 1fr; height: calc(100vh - 60px); }
.palette { border-right: 2px solid var(--line); overflow: auto; padding: 14px; background: var(--paper); }
.palette h3 { margin-top: 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.brick { display: flex; align-items: center; gap: 8px; border: 2px solid var(--line); border-radius: 12px; padding: 7px 10px; margin: 6px 0; cursor: grab; background: var(--paper); box-shadow: 2px 2px 0 var(--line); font-size: 14px; font-weight: 600; user-select: none; }
.brick:hover { transform: rotate(-1deg); }
.brick .dot { width: 12px; height: 12px; border-radius: 4px; border: 2px solid var(--line); flex: none; }
.brick small { margin-left: auto; font-weight: 500; color: var(--muted); }
.main { display: flex; flex-direction: column; min-width: 0; }
.bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 2px solid var(--line); flex-wrap: wrap; background: var(--bg); }
.bar input.title { font-family: var(--display); font-weight: 800; font-size: 22px; border: 0; background: transparent; padding: 2px 4px; width: auto; min-width: 180px; max-width: 360px; border-radius: 8px; }
.bar input.title:hover, .bar input.title:focus { background: var(--paper); outline: none; }
.bar input.client { border: 0; background: transparent; color: var(--muted); width: 180px; padding: 2px 4px; border-radius: 8px; }
.bar input.client:hover, .bar input.client:focus { background: var(--paper); outline: none; }
.gauge { display: flex; align-items: center; gap: 6px; border: 2px solid var(--line); border-radius: 999px; padding: 3px 12px 3px 6px; background: var(--paper); cursor: pointer; font-weight: 700; }
.gauge .meter { width: 70px; height: 10px; border-radius: 99px; background: var(--soft); overflow: hidden; border: 1.5px solid var(--line); }
.gauge .meter i { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; cursor: pointer; user-select: none; }
.toggle input { width: 34px; height: 20px; appearance: none; border: 2px solid var(--line); border-radius: 99px; background: var(--soft); position: relative; cursor: pointer; }
.toggle input::after { content: ''; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); top: 2px; left: 2px; transition: left .15s; }
.toggle input:checked { background: var(--accent); } .toggle input:checked::after { left: 16px; background: var(--ink); }
.saved { font-size: 12px; color: var(--muted); min-width: 90px; }

.gantt { flex: 1; overflow: auto; position: relative; background: var(--paper); }
.gantt-inner { position: relative; min-width: max-content; }
.ghead { position: sticky; top: 0; z-index: 6; display: flex; background: var(--paper); border-bottom: 2px solid var(--line); }
.ghead .corner { position: sticky; left: 0; z-index: 7; background: var(--paper); border-right: 2px solid var(--line); display: flex; align-items: flex-end; padding: 6px 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.cols { position: relative; }
.months, .dnums { display: flex; }
.months div { font-family: var(--display); font-weight: 800; font-size: 13px; padding: 4px 6px; border-left: 1.5px solid var(--line); white-space: nowrap; overflow: hidden; }
.dnums div { text-align: center; font-size: 10px; color: var(--muted); padding: 2px 0 4px; border-left: 1px solid var(--soft); }
.dnums div.mon { border-left-color: var(--muted); color: var(--ink); font-weight: 700; }
.dnums div.off { background: var(--off); }
.grow { display: flex; position: relative; height: 34px; }
.grow .lab { position: sticky; left: 0; z-index: 4; background: var(--paper); border-right: 2px solid var(--line); display: flex; align-items: center; gap: 6px; padding: 0 8px 0 6px; font-size: 13px; border-bottom: 1px solid var(--soft); cursor: pointer; }
.grow .lab:hover { background: var(--soft); }
.grow .lab .grip { cursor: grab; color: var(--muted); opacity: .5; padding: 0 2px; }
.grow .lab .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.grow .lab .who { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; border: 1.5px solid var(--line); flex: none; }
.grow .lab .who.CLIENT { background: var(--client); color: #fff; border-color: var(--client); }
.grow .lab .who.BOTH { background: var(--soft); }
.grow.sel .lab { background: var(--soft); box-shadow: inset 4px 0 0 var(--accent); }
.grow.phase { height: 30px; }
.grow.phase .lab { font-family: var(--display); font-weight: 800; font-size: 14px; cursor: pointer; white-space: nowrap; overflow: hidden; }
.grow.phase .lab .sw { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--line); }
.grow.dropline { box-shadow: inset 0 -3px 0 var(--accent); }
.track { position: relative; border-bottom: 1px solid var(--soft); }
.track .offcol { position: absolute; top: 0; bottom: 0; background: var(--off); pointer-events: none; }
.task { position: absolute; top: 6px; height: 22px; border-radius: 8px; border: 2px solid var(--line); display: flex; align-items: center; padding: 0 8px; font-size: 11px; font-weight: 700; color: #fff; cursor: grab; white-space: nowrap; overflow: hidden; box-shadow: 2px 2px 0 var(--line); user-select: none; touch-action: none; }
.task.client { background-image: repeating-linear-gradient(135deg, #FFFFFF33 0 6px, #0000 6px 12px); }
.task.dragging { cursor: grabbing; box-shadow: 4px 6px 0 var(--line); transform: translateY(-2px); z-index: 3; }
.task .rs { position: absolute; right: 0; top: 0; bottom: 0; width: 10px; cursor: ew-resize; }
.task .rs::after { content: ''; position: absolute; right: 3px; top: 5px; bottom: 5px; width: 2px; background: #FFFFFFAA; border-radius: 2px; }
.task.ms { width: 22px !important; padding: 0; justify-content: center; border-radius: 6px; transform: rotate(45deg) scale(.8); color: var(--ink); background: var(--warn); }
.task.ms span { transform: rotate(-45deg); font-size: 12px; }
.task.ms.pv { background: var(--ink); color: var(--bg); } .task.ms.milestone { background: var(--accent); }
.today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.today::before { content: 'Aujourd’hui'; position: absolute; top: 2px; left: 4px; font-size: 10px; font-weight: 700; color: var(--danger); white-space: nowrap; }
.empty-gantt { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-gantt .big { font-size: 56px; display: block; margin-bottom: 8px; }

/* Panneau latéral */
.side { position: fixed; right: 16px; top: 76px; width: 320px; max-height: calc(100vh - 100px); overflow: auto; z-index: 30; }
.side .x { position: absolute; right: 10px; top: 10px; }
.tips li { margin: 8px 0; font-size: 14px; }
.tips .warn::marker { content: '⚠️ '; } .tips .danger::marker { content: '🚨 '; } .tips .info::marker { content: '💡 '; } .tips .ok::marker { content: '✅ '; }

/* Modale */
.modal-bg { position: fixed; inset: 0; background: #16121F66; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { max-width: 520px; width: 100%; max-height: 90vh; overflow: auto; }
.link-box { display: flex; gap: 8px; } .link-box input { font-size: 12px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(120px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; transition: transform .25s; z-index: 60; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { transform: translateX(-50%) translateY(0); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; width: 100vw; height: 100vh; }

@media (max-width: 800px) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .palette { border-right: 0; border-bottom: 2px solid var(--line); max-height: 220px; }
  .palette .bricks { display: flex; flex-wrap: wrap; gap: 6px; } .brick { margin: 0; }
  .gantt { height: 70vh; }
  .side { left: 16px; right: 16px; width: auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
