/* ==========================================================================
   Atelier PDF — feuille de style
   Parti pris : instrument de mesure, pas application grand public. Fond d'encre,
   accent acide, chiffres en chasse fixe. Ce qui est mesuré doit se lire comme
   une mesure.
   ========================================================================== */

:root {
  --ink:        #0a0b0e;
  --surface:    #121419;
  --surface-2:  #171a20;
  --surface-3:  #1e222a;
  --line:       #262a33;
  --line-soft:  #1c2027;

  --text:       #e9ecf1;
  --dim:        #8b93a1;
  --dimmer:     #5d6472;

  --acid:       #c9f24d;
  --acid-dim:   #93b333;
  --blue:       #6aa9ff;
  --amber:      #ffb340;
  --red:        #ff5f56;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  --r: 10px;
  --panel-w: 400px;
  --top-h: 58px;
  --bottom-h: 66px;
}

* { box-sizing: border-box; }

/* Une classe qui pose display:flex/grid l'emporte sur la règle [hidden] du
   navigateur. Sans ce garde-fou, l'accueil et l'atelier s'affichent en même
   temps. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--ink); color: var(--text);
  font-family: var(--font);
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.02em; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2f39; border-radius: 6px; border: 3px solid var(--ink); }
::-webkit-scrollbar-thumb:hover { background: #3a414e; }

/* ==================== MARQUE ==================== */

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  color: var(--acid); font-size: 22px; line-height: 1;
  transform: rotate(-20deg); display: inline-block;
}
.brand-mark.small { font-size: 17px; }
.brand-name { font-weight: 700; letter-spacing: -0.03em; font-size: 17px; }
.brand-name em { font-style: normal; color: var(--acid); }

/* ==================== ACCUEIL ==================== */

.landing { height: 100%; overflow-y: auto; }
.landing-inner {
  max-width: 780px; margin: 0 auto;
  padding: 56px 28px 80px;
}

.hero {
  font-size: clamp(38px, 7vw, 62px);
  line-height: 1.02; letter-spacing: -0.045em;
  margin: 44px 0 22px; font-weight: 700;
}
.hero-dim { color: var(--dimmer); }

.lede {
  color: var(--dim); font-size: 16.5px; line-height: 1.62;
  max-width: 62ch; margin: 0 0 38px;
}

.drop {
  display: block; text-align: center; cursor: pointer;
  border: 1.5px dashed #313742; border-radius: 16px;
  padding: 46px 24px; background: var(--surface);
  transition: border-color .16s, background .16s, transform .16s;
}
.drop:hover, .drop:focus-visible, .drop.hot {
  border-color: var(--acid); background: #14180f; outline: none;
  transform: translateY(-1px);
}
.drop.hot { border-style: solid; }
.drop-icon { font-size: 30px; color: var(--acid); line-height: 1; margin-bottom: 12px; }
.drop-title { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.drop-sub { color: var(--dimmer); font-size: 13px; margin-top: 7px; }

.landing-status {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  margin-top: 20px; color: var(--dim); font-size: 14px;
}

.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(272px, 1fr));
  gap: 1px; background: var(--line-soft);
  border: 1px solid var(--line-soft); border-radius: var(--r);
  margin-top: 52px; overflow: hidden;
}
.fact { background: var(--surface); padding: 20px 22px; }
.fact-k {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--acid); font-weight: 700; margin-bottom: 9px;
}
.fact-v { color: var(--dim); font-size: 13.5px; line-height: 1.6; }

.legal {
  margin-top: 34px; padding: 16px 18px;
  border-left: 2px solid #3a3320; background: #16150f;
  color: #9a9280; font-size: 12.5px; line-height: 1.6;
  border-radius: 0 8px 8px 0;
}

/* ==================== ATELIER ==================== */

.workspace { height: 100%; display: flex; flex-direction: column; }

.topbar {
  height: var(--top-h); flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 14px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.doc-id { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.doc-name {
  font-weight: 600; font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 30ch;
}
.doc-meta { font-size: 11.5px; color: var(--dimmer); font-family: var(--mono); }

.icon-btn {
  width: 30px; height: 30px; border-radius: 7px; color: var(--dim);
  display: grid; place-items: center; font-size: 16px;
  transition: background .13s, color .13s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }

.viewtabs {
  display: flex; gap: 2px; background: var(--ink);
  padding: 3px; border-radius: 9px; border: 1px solid var(--line);
}
.viewtabs button {
  padding: 5px 15px; border-radius: 6px; font-size: 13px; font-weight: 550;
  color: var(--dim); transition: background .13s, color .13s;
}
.viewtabs button:hover:not(:disabled):not(.on) { color: var(--text); }
.viewtabs button.on { background: var(--acid); color: #10130a; font-weight: 650; }
.viewtabs button:disabled { opacity: .3; cursor: default; }

.pager { display: flex; align-items: center; gap: 3px; font-size: 13px; color: var(--dim); }

.btn {
  padding: 7px 17px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  transition: background .13s, opacity .13s, transform .1s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--acid); color: #10130a; }
.btn-primary:hover:not(:disabled) { background: #d6ff5e; }
.btn-ghost { background: var(--surface-3); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover:not(:disabled) { background: #262b34; }
.btn:disabled { opacity: .38; cursor: default; }

.layout { flex: 1; display: flex; min-height: 0; }

/* ---------- scène ---------- */

.stage {
  flex: 1; min-width: 0; position: relative;
  background:
    radial-gradient(1100px 520px at 50% -10%, #131720 0%, transparent 70%),
    var(--ink);
  display: flex; flex-direction: column;
}
.stage-scroll { flex: 1; overflow: auto; padding: 26px; display: grid; place-items: start center; }

.sheet {
  position: relative; display: inline-block; line-height: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.5), 0 20px 60px rgba(0,0,0,.55);
  border-radius: 3px; overflow: hidden; background: #fff;
}
.sheet-img { display: block; max-width: 100%; height: auto; }
.sheet-img-top { position: absolute; inset: 0; width: 100%; }

.wipe-handle {
  position: absolute; top: 0; bottom: 0; width: 2px; background: var(--acid);
  cursor: ew-resize; z-index: 5; box-shadow: 0 0 14px rgba(201,242,77,.6);
}
.wipe-handle span {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%; background: var(--acid);
  display: grid; place-items: center; box-shadow: 0 3px 12px rgba(0,0,0,.5);
}
.wipe-handle span::before {
  content: "‹ ›"; color: #10130a; font-size: 15px; font-weight: 700; letter-spacing: -1px;
}

.wipe-tag {
  position: absolute; top: 14px; font-style: normal; font-family: var(--mono);
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px; white-space: nowrap; line-height: 1.4;
}
.wipe-tag-l { right: 8px; background: rgba(10,11,14,.85); color: #b6bcc8; }
.wipe-tag-r { left: 8px; background: var(--acid); color: #10130a; font-weight: 700; }

.overlay { position: absolute; inset: 0; pointer-events: none; }
.hl {
  position: absolute; pointer-events: auto; cursor: pointer;
  border: 1.5px solid rgba(201,242,77,.85);
  background: rgba(201,242,77,.17);
  border-radius: 3px; transition: background .13s, box-shadow .13s;
}
.hl:hover { background: rgba(201,242,77,.32); }
.hl.off { border-color: rgba(139,147,161,.5); background: rgba(139,147,161,.12); }
.hl.bad { border-color: rgba(255,95,86,.9); background: rgba(255,95,86,.2); }
.hl.sel { box-shadow: 0 0 0 3px rgba(201,242,77,.35), 0 0 22px rgba(201,242,77,.5); }
.hl-tag {
  position: absolute; bottom: 100%; left: -1px; margin-bottom: 3px;
  background: var(--ink); color: var(--acid); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 10.5px; padding: 2px 6px;
  border-radius: 4px; white-space: nowrap; line-height: 1.4;
}
.hl.bad .hl-tag { color: var(--red); }

.stage-legend {
  flex: none; padding: 9px 18px; border-top: 1px solid var(--line-soft);
  background: var(--surface); font-size: 12px; color: var(--dimmer);
  display: flex; gap: 20px; align-items: center; min-height: 36px;
}
.legend-dot { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ---------- panneau ---------- */

.panel {
  width: var(--panel-w); flex: none; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--line);
  padding: 14px; display: flex; flex-direction: column; gap: 13px;
}

.card {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 15px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 10px;
}
.card-head h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .11em;
  color: var(--dim); font-weight: 700;
}
.count, .pill {
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: var(--surface-3); color: var(--dim); border: 1px solid var(--line);
}

.hint { color: var(--dimmer); font-size: 12.5px; margin: 0 0 12px; line-height: 1.55; }

.seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  background: var(--ink); padding: 3px; border-radius: 8px;
  border: 1px solid var(--line); margin-bottom: 13px;
}
.seg button {
  padding: 6px 4px; border-radius: 5px; font-size: 12.5px; font-weight: 550;
  color: var(--dim); transition: background .13s, color .13s;
}
.seg button.on { background: var(--surface-3); color: var(--text); }

.map-list { display: flex; flex-direction: column; gap: 7px; max-height: 260px; overflow-y: auto; }
.map-row {
  display: grid; grid-template-columns: 1fr auto 118px; align-items: center;
  gap: 8px; padding: 7px 9px; background: var(--ink);
  border: 1px solid var(--line-soft); border-radius: 7px;
}
.map-src { font-family: var(--mono); font-size: 12.5px; }
.map-src small { color: var(--dimmer); margin-left: 6px; font-size: 10.5px; }
.map-arrow { color: var(--dimmer); font-size: 12px; }
.map-row input {
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 5px;
  padding: 4px 7px; font-family: var(--mono); font-size: 12px; width: 100%;
  color-scheme: dark;
}
.map-row input:focus { outline: none; border-color: var(--acid); }
.map-row.done { border-color: #38431f; background: #10130a; }

.steppers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stepper { display: flex; flex-direction: column; gap: 5px; }
.stepper span {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--dimmer);
}
.stepper input {
  background: var(--ink); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 9px; font-family: var(--mono); font-size: 14px; width: 100%;
  text-align: center;
}
.stepper input:focus { outline: none; border-color: var(--acid); }

.presets { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.presets button {
  padding: 4px 10px; border-radius: 20px; font-size: 11.5px;
  background: var(--ink); border: 1px solid var(--line); color: var(--dim);
  font-family: var(--mono); transition: border-color .13s, color .13s;
}
.presets button:hover { border-color: var(--acid); color: var(--acid); }

.check {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 11px;
  font-size: 12.5px; color: var(--dim); cursor: pointer; line-height: 1.45;
}
.check input { accent-color: var(--acid); margin-top: 2px; flex: none; }

.occ-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.link {
  color: var(--dim); font-size: 11.5px; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: #333a45;
}
.link:hover { color: var(--acid); }
#occFilter {
  flex: 1; background: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 9px; font-size: 12px; min-width: 0;
}
#occFilter:focus { outline: none; border-color: var(--acid); }

.occ-list { display: flex; flex-direction: column; gap: 6px; max-height: 44vh; overflow-y: auto; }

.occ {
  padding: 9px 10px; background: var(--ink); border: 1px solid var(--line-soft);
  border-radius: 8px; cursor: pointer; transition: border-color .13s, background .13s;
}
.occ:hover { border-color: #333a45; }
.occ.sel { border-color: var(--acid); background: #12150c; }
.occ.unchecked { opacity: .48; }

.occ-top { display: flex; align-items: center; gap: 8px; }
.occ-top input { accent-color: var(--acid); flex: none; }
.occ-raw { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.occ-arrow { color: var(--dimmer); font-size: 11px; }
.occ-new { font-family: var(--mono); font-size: 12.5px; color: var(--acid); }
.occ-new.bad { color: var(--red); text-decoration: line-through; text-decoration-thickness: 1px; }
.occ-page {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px;
  color: var(--dimmer); flex: none;
}

.occ-ctx {
  margin-top: 5px; font-size: 11.5px; color: var(--dimmer);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.occ-ctx b { color: var(--dim); font-weight: 600; }

.occ-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.badge {
  font-size: 10px; padding: 1.5px 7px; border-radius: 20px;
  font-weight: 600; letter-spacing: .01em; white-space: nowrap;
}
.b-aligne  { background: #1c2a0c; color: var(--acid);  border: 1px solid #33461a; }
.b-regroupe{ background: #101f33; color: var(--blue);  border: 1px solid #1e3a5c; }
.b-refus   { background: #2a1210; color: var(--red);   border: 1px solid #4a1f1c; }
.b-warn    { background: #2a2110; color: var(--amber); border: 1px solid #4a3a1c; }
.b-info    { background: var(--surface-3); color: var(--dim); border: 1px solid var(--line); }

.occ-manual { margin-top: 7px; }
.occ-manual input {
  width: 100%; background: var(--surface-3); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 8px; font-family: var(--mono); font-size: 12px;
}
.occ-manual input:focus { outline: none; border-color: var(--acid); }

.warn-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.warn-list li {
  font-size: 12.5px; color: #b9a97e; line-height: 1.5;
  padding-left: 18px; position: relative;
}
.warn-list li::before {
  content: "▲"; position: absolute; left: 0; top: 1px;
  color: var(--amber); font-size: 9px;
}

/* ---------- rapport ---------- */

.seal {
  display: flex; align-items: center; gap: 14px; padding: 14px;
  border-radius: 9px; margin-bottom: 13px;
  background: #10130a; border: 1px solid #38431f;
}
.seal.bad { background: #1a0f0e; border-color: #4a1f1c; }
.seal-score {
  font-family: var(--mono); font-size: 25px; font-weight: 700;
  color: var(--acid); line-height: 1; letter-spacing: -0.03em;
}
.seal.bad .seal-score { color: var(--red); }
.seal-label { font-size: 12.5px; font-weight: 650; }
.seal-sub { font-size: 11.5px; color: var(--dim); margin-top: 2px; line-height: 1.4; }

.stat-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row span:first-child { color: var(--dim); }
.stat-row span:last-child { font-family: var(--mono); }

.bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin: 11px 0 5px; background: var(--surface-3); }
.bar i { display: block; height: 100%; }

.repair {
  margin-top: 11px; padding: 10px; border-radius: 8px;
  background: var(--ink); border: 1px solid var(--line-soft); font-size: 12px;
}
.repair-k { color: var(--acid); font-weight: 650; margin-bottom: 4px; }
.repair-v { color: var(--dim); line-height: 1.5; }
.repair.bad .repair-k { color: var(--amber); }

/* ---------- barre d'action ---------- */

.actionbar {
  height: var(--bottom-h); flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 16px; background: var(--surface); border-top: 1px solid var(--line);
}
.action-summary { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 14px; }
.action-btns { display: flex; gap: 9px; }

/* ---------- divers ---------- */

.spinner {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 2px solid #2a303b; border-top-color: var(--acid);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--line);
  color: var(--text); padding: 11px 18px; border-radius: 9px;
  font-size: 13.5px; z-index: 90; box-shadow: 0 10px 34px rgba(0,0,0,.6);
  max-width: 80vw;
}
.toast.err { border-color: #4a1f1c; background: #1a0f0e; color: #ffb0ab; }

.empty { color: var(--dimmer); font-size: 12.5px; text-align: center; padding: 22px 8px; }

@media (max-width: 1080px) {
  .layout { flex-direction: column; }
  .panel { width: 100%; border-left: none; border-top: 1px solid var(--line); max-height: 52vh; }
  .viewtabs button { padding: 5px 10px; font-size: 12px; }
  .doc-name { max-width: 16ch; }
}
