/* Coque commune des outils plein écran (Pages/Shared/_ToolLayout.cshtml) : barre haute, zone de travail, barre basse,
   boutons et fenêtres. Une page d'outil ne restyle pas ces éléments, elle n'écrit que son contenu : d'un outil à
   l'autre, la même barre et les mêmes boutons. Toute valeur vient des tokens --eki-* (docs/design-guidelines.md). */
* { box-sizing: border-box; }
body.tool { margin: 0; font: var(--eki-fs-sm)/1.45 var(--eki-font-body); color: var(--eki-text); background: var(--eki-bg-alt);
            height: 100vh; height: 100dvh; display: grid; grid-template-rows: minmax(56px, auto) minmax(0, 1fr) 40px; overflow: hidden; }
:where(.tool) :where(select, input, button) { font: inherit; }
:where(.tool) :focus-visible { outline: 3px solid var(--eki-accent); outline-offset: 2px; }
:where(.tool) h1, :where(.tool) h2, :where(.tool) h3, .tool-brand { font-family: var(--eki-font-display); }
:where(.tool) [hidden] { display: none !important; }
:where(.tool) a { color: var(--eki-accent); }
:where(.tool) a:hover { color: var(--eki-accent-strong); }
@media (prefers-reduced-motion: reduce) { .tool *, :where(.tool) ::before, :where(.tool) ::after { transition: none !important; animation: none !important; } }

/* barre haute : marque et nom de l'outil, réglages, « Signaler… », actions */
/* Trop de réglages pour la largeur : la barre passe sur deux lignes plutôt que de rogner les actions. */
.tool-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 16px; min-width: 0;
            background: var(--eki-bg-elev); border-bottom: 1px solid var(--eki-border); }
.tool-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; min-width: 0; flex: 0 1 auto; }
.tool-brand a { display: flex; flex: none; }
/* le titre de la page : la taille d'un libellé de barre, tronqué plutôt que masqué quand la place manque */
.tool-name { margin: 0; font-size: inherit; font-weight: inherit; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tool-brand img { height: 22px; width: auto; display: block; }
.tool-spacer { flex: 1; }
/* réglage de la barre : libellé et champ sur une ligne */
.tool-field { display: flex; align-items: center; gap: 6px; color: var(--eki-text-muted); white-space: nowrap; }
.tool-field :is(select, input) { padding: 4px 6px; border: 1px solid var(--eki-border); border-radius: var(--eki-radius-sm);
                                 background: var(--eki-bg); color: var(--eki-text); }
.tool-field input[type="number"] { width: 5.5em; }
.tool-bar :is(button, .tool-button) { white-space: nowrap; flex: none; }
.tool-bar .primary { height: 36px; padding: 0 16px; }

/* boutons */
/* .tool-button : un lien (<a>) habillé en bouton */
:where(.tool) :where(button, .tool-button) { cursor: pointer; text-decoration: none; padding: 5px 10px; border: 1px solid var(--eki-border); border-radius: var(--eki-radius-md);
               background: var(--eki-bg-elev); color: var(--eki-text);
               transition: border-color var(--eki-transition-fast, .1s), background var(--eki-transition-fast, .1s); }
:where(.tool) :where(button, .tool-button):hover:not(:disabled) { border-color: var(--eki-accent); }
:where(.tool) button:disabled { opacity: .4; cursor: default; }
/* le rouge de marque, pas l'accent : éclairci en sombre, l'accent ne laisse au blanc que 3,98:1 (seuil 4,5) */
:where(.tool) :where(button, .tool-button).primary { background: var(--eki-red); border-color: var(--eki-red); color: var(--eki-white); font-weight: 600; }
:where(.tool) button.icon { height: 34px; min-width: 34px; padding: 0 10px; }
:where(.tool) button.link { border: 0; background: none; color: var(--eki-accent); font-weight: 600; padding: 0; }

/* Un lien prend la couleur des liens (règle a ci-dessus, plus spécifique que :where) : le bouton-lien la reprend,
   sinon le libellé d'un .primary passait en rouge sur fond rouge au survol. Survol du .primary : le rouge foncé de
   marque, sous lequel le blanc reste lisible dans les deux thèmes (comme .btn-primary du site). */
a.tool-button { display: inline-flex; align-items: center; color: var(--eki-text); }
a.tool-button:hover { color: var(--eki-text); }
.tool :is(button, .tool-button).primary, .tool :is(button, .tool-button).primary:hover { color: var(--eki-white); }
.tool :is(button, .tool-button).primary:hover:not(:disabled) { background: var(--eki-red-dark); border-color: var(--eki-red-dark); }

/* zone de travail : panneau gauche | surface | panneau droit */
.tool-workspace { display: grid; grid-template-columns: 268px minmax(0, 1fr) 340px; min-height: 0; }
.tool-workspace > aside { background: var(--eki-bg-elev); overflow-y: auto; min-height: 0; }
.tool-workspace > aside:first-child { border-right: 1px solid var(--eki-border); }
.tool-workspace > aside:last-child { border-left: 1px solid var(--eki-border); }
.tool-workspace > main { position: relative; overflow: hidden; min-width: 0; background: var(--eki-bg-alt); }
.tool-panel-title { font-size: 11px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--eki-text-muted); }

/* barre basse : état, options, aide */
.tool-status { display: flex; align-items: center; gap: 18px; padding: 0 16px; min-width: 0; font-size: 13px;
               background: var(--eki-bg-elev); border-top: 1px solid var(--eki-border); }
.tool-status label { display: flex; align-items: center; gap: 6px; color: var(--eki-text-muted); }
/* cibles tactiles : 32 px de haut au moins, sans grossir la barre */
.tool-status :is(button, label, a) { min-height: 32px; display: inline-flex; align-items: center; }
.tool-legal { display: flex; gap: 12px; font-size: 12px; white-space: nowrap; }
.tool-legal a { color: var(--eki-text-muted); }
/* le lien est en inline-flex (barre basse) : sa suite y deviendrait un élément flex, privé de son espace de tête */
.tool-legal-more { white-space: pre; }
:where(.tool) kbd { border: 1px solid var(--eki-border); border-radius: var(--eki-radius-sm); font-family: var(--eki-font-mono);
            padding: 0 4px; font-size: 11px; background: var(--eki-bg-alt); }

/* fenêtres */
:where(.tool) dialog { border: 1px solid var(--eki-border); border-radius: var(--eki-radius-md); padding: var(--eki-space-6); width: min(760px, 92vw);
               max-height: 86vh; background: var(--eki-bg-elev); color: var(--eki-text); box-shadow: var(--eki-shadow-lg); }
:where(.tool) dialog::backdrop { background: rgba(0, 0, 0, .55); }
:where(.tool) dialog h2 { margin: 0 0 4px; font-size: var(--eki-fs-xl); }
/* le titre reçoit le focus à l'ouverture (point de départ de la lecture), il n'est pas une commande : pas de cadre */
:where(.tool) dialog h2[tabindex="-1"]:focus { outline: none; }
:where(.tool) dialog p { margin: 6px 0; }
.tool-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
/* une fenêtre longue (la fiche d'un plan chargé) défile : ses actions restent visibles en bas */
:where(.tool) dialog .tool-dialog-actions { position: sticky; bottom: calc(-1 * var(--eki-space-6)); background: var(--eki-bg-elev);
                                            padding: 8px 0; }

/* Petit écran : un seul seuil pour tous les outils (899 px, celui que lit le JS du plan de bridage). La mise en page
   de la zone de travail reste propre à chaque outil ; la coque y rend les fenêtres plein écran, actions à portée. */
@media (max-width: 899px) {
  .tool-bar { padding: 8px 10px; gap: 8px; }
  /* le lien reste (obligation d'accès aux mentions), raccourci */
  .tool-legal-more, .tool-feedback-more { display: none; }
  :where(.tool) dialog { padding: var(--eki-space-4); width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
                         margin: 0; border-radius: 0; }
  :where(.tool) dialog .tool-dialog-actions { flex-wrap: wrap; bottom: calc(-1 * var(--eki-space-4)); }
  :where(.tool) dialog .tool-dialog-actions button { flex: 1 1 auto; min-height: 44px; }
}
