/* Veillée — style de base commun (refonte, lot 2-0, B-VEI-105). Charger APRÈS tokens.css et themes.css.
 * Un seul style de bouton (3 variantes), champs, lignes de liste, barre d'outils, fenêtre, menu, tableau des droits, carrousel.
 * Les couleurs, les rayons et la police des titres viennent de l'univers (themes.css) ; rien n'est dessiné ici avec du bois ou de la texture.
 * Tout est préfixé « vs- » : rien d'existant n'est touché tant que le lot 2-1 ne branche pas ce fichier. Thème clair uniquement. */

.vs-root { font: 400 var(--fs-base)/var(--lh-base) -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; color: var(--ink); }
.vs-root *, .vs-root *::before, .vs-root *::after { box-sizing: border-box; }
.vs-root :is(button, input, select, textarea) { font: inherit; color: inherit; margin: 0; }
.vs-root :focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.vs-title { font: 600 var(--fs-title)/var(--lh-title) var(--theme-title-font, inherit); margin: 0; color: var(--ink); }
.vs-title .vs-small { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
.vs-small { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--muted); }
.vs-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- Bouton : un seul style, trois variantes, 22 px ---------- */
.vs-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--btn-h); padding: 0 var(--sp-3); margin: 0;
  border: 1px solid var(--line); border-radius: var(--vs-radius-button);
  background: var(--surface); color: var(--ink);
  font-size: var(--fs-base); line-height: var(--lh-base); font-weight: 500; white-space: nowrap; cursor: pointer;
}
.vs-btn:hover:not(:disabled) { background: var(--green-soft); border-color: var(--green); }
.vs-btn.is-primary { background: var(--green); border-color: var(--green); color: #fff; }
.vs-btn.is-primary:hover:not(:disabled) { background: var(--green); filter: brightness(1.12); }
.vs-btn.is-danger { color: var(--copper); border-color: var(--copper); }
.vs-btn.is-danger:hover:not(:disabled) { background: var(--copper-soft); border-color: var(--copper); }
.vs-btn[aria-pressed="true"] { background: var(--green-soft); border-color: var(--green); }
.vs-btn:disabled { opacity: .5; cursor: default; }
.vs-btn.is-icon { width: var(--btn-h); padding: 0; font-weight: 700; }

/* ---------- Champs ---------- */
.vs-input, .vs-select {
  height: var(--field-h); padding: 0 var(--sp-3); border: 1px solid var(--line); border-radius: var(--vs-radius);
  background: var(--surface); color: var(--ink); font-size: var(--fs-base); line-height: var(--lh-base); min-width: 0;
}
.vs-input::placeholder { color: var(--muted); opacity: 1; }
.vs-input:focus, .vs-select:focus { border-color: var(--green); outline: 2px solid var(--green-soft); outline-offset: 0; }
.vs-select {
  appearance: none; -webkit-appearance: none; padding-right: var(--sp-5); cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-size: 4px 4px, 4px 4px; background-position: calc(100% - 8px) 9px, calc(100% - 4px) 9px; background-repeat: no-repeat;
}
.vs-field { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; column-gap: var(--sp-3); min-height: var(--field-h); }
.vs-field > label, .vs-field > .vs-label { font-size: var(--fs-base); color: var(--muted); }
.vs-check { display: inline-flex; align-items: center; gap: var(--sp-3); min-height: var(--row-h); cursor: pointer; }
.vs-check input { width: 14px; height: 14px; margin: 0; accent-color: var(--green); cursor: pointer; }
.vs-range { display: inline-flex; align-items: center; gap: var(--sp-3); min-height: var(--row-h); }
.vs-range input[type=range] { width: 128px; height: 14px; margin: 0; accent-color: var(--green); cursor: pointer; }
.vs-range output { min-width: 32px; text-align: right; font-size: var(--fs-base); font-variant-numeric: tabular-nums; }
.vs-group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.vs-stack { display: grid; gap: var(--sp-3); }

/* ---------- Liste et arbre : ligne de 22 px maximum ---------- */
.vs-list, .vs-tree, .vs-tree ul { list-style: none; margin: 0; padding: 0; }
.vs-tree ul { padding-left: var(--sp-5); }
.vs-row {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; height: var(--row-h); max-height: var(--row-h); padding: 0 var(--sp-3); margin: 0;
  border: 0; border-radius: var(--vs-radius); background: transparent; color: var(--ink); text-align: left;
  font-size: var(--fs-base); line-height: var(--lh-base); cursor: default; user-select: none;
}
.vs-row:hover { background: color-mix(in srgb, var(--green-soft) 55%, transparent); }
.vs-row[aria-selected="true"], .vs-row[aria-current="true"] { background: var(--green-soft); }   /* teinte de fond, jamais une barre latérale */
.vs-row .vs-num { flex: none; width: 24px; font-size: var(--fs-small); color: var(--muted); font-variant-numeric: tabular-nums; }
.vs-row .vs-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-row .vs-tag { flex: none; font-size: var(--fs-small); color: var(--muted); }
.vs-row.is-group { font-weight: 600; cursor: pointer; }
.vs-row.is-group::before { content: ""; flex: none; width: 8px; height: 8px; background: var(--muted); clip-path: polygon(0 0, 100% 50%, 0 100%); transition: transform var(--dur-fast) var(--ease-out); }
.vs-row.is-group[aria-expanded="true"]::before { transform: rotate(90deg); }
.vs-row.is-group .vs-count { margin-left: auto; font-weight: 400; font-size: var(--fs-small); color: var(--muted); }
.vs-tree li[hidden], .vs-tree ul[hidden] { display: none; }

/* ---------- Barre d'outils : une seule ligne ---------- */
.vs-toolbar { display: flex; align-items: center; gap: var(--sp-3); min-height: 32px; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-radius: var(--vs-radius-panel); background: var(--surface); }
.vs-toolbar .vs-title { flex: none; }
.vs-toolbar .vs-search { flex: 1 1 160px; min-width: 120px; }
.vs-toolbar .vs-filters { display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.vs-toolbar .vs-count { flex: none; }

/* ---------- Fenêtre unique : barre de 24 px, pastilles macOS à gauche ---------- */
.vs-win {
  position: fixed; z-index: 8000; display: flex; flex-direction: column; width: max-content; min-width: var(--window-min); max-width: calc(100vw - 16px);
  border: 1px solid var(--line); border-radius: var(--vs-radius-panel); background: var(--surface); color: var(--ink); box-shadow: var(--vs-shadow-pop); overflow: hidden;
  font: 400 var(--fs-base)/var(--lh-base) -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; transform-origin: var(--ox, 0) var(--oy, 0);
  animation: vs-win-in var(--dur-window) var(--ease-out) both;
}
.vs-win *, .vs-win *::before, .vs-win *::after { box-sizing: border-box; }
.vs-win :is(button, input, select, textarea) { font: inherit; color: inherit; margin: 0; }
.vs-win :focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.vs-win.is-closing { animation: vs-win-out var(--dur-fast) ease-in both; pointer-events: none; }
@keyframes vs-win-in { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
@keyframes vs-win-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(.94); } }
.vs-win__bar {
  display: flex; align-items: center; gap: var(--sp-3); height: var(--bar-h); flex: none; padding: 0 var(--sp-3);
  background: color-mix(in srgb, var(--green-soft) 55%, var(--surface)); border-bottom: 1px solid var(--line); cursor: grab; user-select: none; touch-action: none;
}
.vs-win__bar:active { cursor: grabbing; }
.vs-win__dots { display: flex; align-items: center; gap: var(--sp-3); flex: none; }
.vs-dot {
  position: relative; width: var(--dot-size); height: var(--dot-size); padding: 0; margin: 0; border: 1px solid var(--dot-edge); border-radius: 50%;
  background: var(--dot-bg); color: #00000099; cursor: pointer; font-size: var(--fs-small); line-height: 1; display: grid; place-items: center;
}
.vs-dot.is-close { --dot-bg: var(--dot-close); }
.vs-dot.is-fold { --dot-bg: var(--dot-fold); }
.vs-dot.is-open { --dot-bg: var(--dot-open); }
.vs-dot::before { content: attr(data-glyph); opacity: 0; transition: opacity var(--dur-fast); font-weight: 700; }
.vs-win__bar:hover .vs-dot::before, .vs-dot:focus-visible::before { opacity: 1; }
.vs-dot::after { content: ""; position: absolute; inset: -4px; }   /* zone de clic agrandie sans agrandir la pastille */
.vs-win__title { flex: 1; min-width: 0; font-size: var(--fs-base); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-win__body { display: grid; gap: var(--sp-3); padding: var(--sp-4); overflow: auto; max-height: calc(100vh - 48px); }
.vs-win.is-compact .vs-win__body { padding: var(--sp-2) var(--sp-3); gap: var(--sp-2); }
.vs-win.is-folded .vs-win__body { display: none; }
.vs-win.is-folded .vs-win__bar { border-bottom: 0; }
.vs-win__foot { display: flex; justify-content: flex-end; gap: var(--sp-3); padding-top: var(--sp-2); }

/* ---------- Menu clic droit : même aspect que context-menu.css, largeur unique ---------- */
.vs-menu {
  position: fixed; z-index: 9000; width: var(--menu-w); max-width: calc(100vw - 16px); margin: 0; padding: var(--sp-2);
  border: 1px solid var(--line); border-radius: var(--vs-radius-panel); background: var(--surface); color: var(--ink); box-shadow: var(--vs-shadow-pop);
  font: 400 var(--fs-base)/var(--lh-base) -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  animation: vs-win-in var(--dur-fast) var(--ease-out) both; transform-origin: 0 0;
}
.vs-menu *, .vs-menu *::before { box-sizing: border-box; }
.vs-menu__title { display: block; padding: var(--sp-1) var(--sp-3) var(--sp-2); margin-bottom: var(--sp-2); border-bottom: 1px solid var(--line); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-menu__item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; height: var(--row-h); padding: 0 var(--sp-3); margin: 0; border: 0; border-radius: var(--vs-radius);
  background: transparent; color: var(--ink); text-align: left; font-size: var(--fs-base); line-height: var(--lh-base); cursor: pointer;
}
.vs-menu__item:hover, .vs-menu__item:focus-visible { background: var(--green-soft); outline: none; }
.vs-menu__item .vs-keys { margin-left: auto; font-size: var(--fs-small); color: var(--muted); }
.vs-menu__sep { border: 0; border-top: 1px solid var(--line); margin: var(--sp-2) var(--sp-1); }
.vs-menu__item.is-danger { color: var(--copper); }               /* zone danger : cuivre, toujours en dernier */
.vs-menu__item.is-danger:hover, .vs-menu__item.is-danger:focus-visible { background: var(--copper-soft); }
.vs-menu__text { margin: 0; padding: var(--sp-2) var(--sp-3); font-size: var(--fs-base); color: var(--ink); white-space: normal; }

/* ---------- Tableau des droits (repris de la démonstration validée) ---------- */
.vs-rights { width: 100%; border-collapse: collapse; table-layout: fixed; }
.vs-rights th { height: 16px; padding: 0; font-size: var(--fs-small); font-weight: 600; line-height: var(--lh-small); color: var(--muted); text-align: center; }
.vs-rights th:first-child, .vs-rights td:first-child { text-align: left; padding-left: var(--sp-1); }
.vs-rights td { height: var(--row-h); padding: 0; text-align: center; font-size: var(--fs-base); line-height: var(--lh-base); }
.vs-rights td:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-rights th + th, .vs-rights td + td { width: 48px; }
.vs-rights tr.is-all td { font-weight: 600; border-bottom: 1px solid var(--line); }
.vs-rights tr.is-busy { opacity: .55; }
.vs-rights input[type=radio] { width: 14px; height: 14px; margin: 0; accent-color: var(--green); cursor: pointer; vertical-align: middle; }

/* ---------- Carrousel commun : accès direct + bascule carrousel / liste / arbre ---------- */
.vs-collection { display: grid; gap: var(--sp-3); }
.vs-collection__bar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.vs-collection__bar .vs-goto { flex: 1 1 200px; min-width: 160px; }
.vs-seg { display: inline-flex; flex: none; }
.vs-seg .vs-btn { border-radius: 0; }
.vs-seg .vs-btn + .vs-btn { border-left-width: 0; }
.vs-seg .vs-btn:first-child { border-radius: var(--vs-radius-button) 0 0 var(--vs-radius-button); }
.vs-seg .vs-btn:last-child { border-radius: 0 var(--vs-radius-button) var(--vs-radius-button) 0; }

.vs-stage { position: relative; height: 160px; overflow: hidden; perspective: 720px; border: 1px solid var(--line); border-radius: var(--vs-radius-panel); background: color-mix(in srgb, var(--green-soft) 35%, var(--surface)); outline-offset: 1px; }
.vs-card {
  position: absolute; left: 50%; top: var(--sp-4); width: 112px; height: 132px; margin: 0 0 0 -56px; padding: var(--sp-3); display: grid; align-content: space-between; gap: var(--sp-2); text-align: left;
  border: 1px solid var(--line); border-radius: var(--vs-radius-panel); background: var(--surface); color: var(--ink); cursor: pointer;
  transition: transform var(--dur-slow) var(--ease-out), opacity var(--dur-slow) var(--ease-out); font-size: var(--fs-base); line-height: var(--lh-base);
}
.vs-card[aria-current="true"] { border-color: var(--green); background: var(--surface); }
.vs-card .vs-num { font: 600 var(--fs-title)/var(--lh-title) var(--theme-title-font, inherit); color: var(--green); }
.vs-card .vs-name { display: block; font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.vs-card .vs-tag { font-size: var(--fs-small); color: var(--muted); }
.vs-panel { border: 1px solid var(--line); border-radius: var(--vs-radius-panel); background: var(--surface); padding: var(--sp-2); max-height: 160px; overflow: auto; }
.vs-status { min-height: var(--lh-small); }

@media (prefers-reduced-motion: reduce) {
  .vs-win, .vs-win.is-closing, .vs-menu { animation: none; }
  .vs-card, .vs-row.is-group::before, .vs-dot::before { transition: none; }
}

/* ======================================================================================================
 * Branchement du socle sur l'interface existante (lot 2-1, B-VEI-105).
 * Les classes déjà utilisées par les pages (.button, .icon-button, .vl-button, …) prennent le même aspect que .vs-btn / .vs-input :
 * 22 px, texte 13 px, espacements 2/4/8/12/16, un seul style de bouton en trois variantes. Les couleurs et les rayons restent ceux
 * de l'univers (themes.css). Les règles contradictoires des anciennes feuilles ont été retirées ; ne pas les remettre.
 * Correspondance des variantes : normal = .button, .icon-button, .vl-button, … ; principal = .primary et .copper (« Activer », « Partager » : action principale, pas un danger) ; danger (cuivre) = .vcm-danger, .is-danger.
 * ====================================================================================================== */
:is(.button, .icon-button, .vl-button, .vm-button, .vw-button, .vc-button, .vl-icon-button, .vm-icon-button, .vw-icon-button, .pi-btn, .vsg-btn, .vtw-btn, .vsz-btn, .vsb-btn, .vdl-audience-btn, .vdl-stats-btn, .vlsc-button, .vw-panel-btn, .vfz-pop-btn, .entry-text-button, .vsm-pause, .vsm-stop, .vdl-other, .vat-scope, .vao-trigger) {
  box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--btn-h); min-height: 0; width: auto; min-width: 0; padding: 0 var(--sp-3); margin: 0;
  border: 1px solid var(--line); border-radius: var(--vs-radius-button);
  background: var(--surface); background-image: none; color: var(--ink);
  font-size: var(--fs-base); line-height: var(--lh-base); font-weight: 500; letter-spacing: 0; text-transform: none; text-decoration: none; white-space: nowrap;
  box-shadow: none; text-shadow: none; cursor: pointer;
}
:is(.button, .icon-button, .vl-button, .vm-button, .vw-button, .vc-button, .vl-icon-button, .vm-icon-button, .vw-icon-button, .pi-btn, .vsg-btn, .vtw-btn, .vsz-btn, .vsb-btn, .vdl-audience-btn, .vdl-stats-btn, .vlsc-button, .vw-panel-btn, .vfz-pop-btn, .entry-text-button, .vsm-pause, .vsm-stop, .vdl-other, .vat-scope, .vao-trigger):hover:not(:disabled) { background: var(--green-soft); background-image: none; border-color: var(--green); filter: none; box-shadow: none; }
.dice-native-settings :is(.panel-actions, .save-actions, .io-actions) button {
  box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--btn-h); min-height: 0; width: auto; min-width: 0; padding: 0 var(--sp-3); margin: 0;
  border: 1px solid var(--line); border-radius: var(--vs-radius-button);
  background: var(--surface); background-image: none; color: var(--ink);
  font-size: var(--fs-base); line-height: var(--lh-base); font-weight: 500; letter-spacing: 0; text-transform: none; text-decoration: none; white-space: nowrap;
  box-shadow: none; text-shadow: none; cursor: pointer;
}
.dice-native-settings :is(.panel-actions, .save-actions, .io-actions) button:hover:not(:disabled) { background: var(--green-soft); background-image: none; border-color: var(--green); filter: none; box-shadow: none; }
:is(.button, .vl-button, .vm-button, .vw-button, .pi-btn):is(.primary, .copper, .is-primary) { background: var(--green); background-image: none; border-color: var(--green); color: #fff; }
:is(.button, .vl-button, .vm-button, .vw-button, .pi-btn):is(.primary, .copper, .is-primary):hover:not(:disabled) { background: var(--green); filter: brightness(1.12); }
:is(.button, .vl-button, .vm-button, .vw-button, .pi-btn):is(.vcm-danger, .is-danger) { background: var(--surface); background-image: none; border-color: var(--copper); color: var(--copper); }
:is(.button, .vl-button, .vm-button, .vw-button, .pi-btn):is(.vcm-danger, .is-danger):hover:not(:disabled) { background: var(--copper-soft); border-color: var(--copper); }
:is(.button, .icon-button, .vl-button, .vm-button, .vw-button, .vc-button, .vl-icon-button, .vm-icon-button, .vw-icon-button, .pi-btn):disabled { opacity: .5; cursor: default; }
:is(.icon-button, .vl-icon-button, .vm-icon-button, .vw-icon-button) { width: var(--btn-h); padding: 0; font-size: var(--fs-title); font-weight: 700; }
:is(.button, .icon-button, .vl-button, .vm-button, .vw-button, .vl-icon-button, .vm-icon-button, .vw-icon-button) svg { width: 14px; height: 14px; flex: none; }

/* Boutons génériques sans classe : même gabarit, avec une spécificité nulle pour ne pas écraser les boutons structurels (rail, cartes, pastilles) */
:where(button) { font-size: var(--fs-base); line-height: var(--lh-base); }

/* Champs : 22 px, texte 13 px */
:is(select, input:is([type=text], [type=number], [type=search], [type=email], [type=password], [type=url], [type=tel], [type=date], [type=time], :not([type]))) {
  box-sizing: border-box; height: var(--field-h); min-height: 0; padding: 0 var(--sp-3); margin: 0; min-width: 0;
  border: 1px solid var(--line); border-radius: var(--vs-radius); background-color: var(--surface); color: var(--ink);
  font-size: var(--fs-base); line-height: var(--lh-base);
}
textarea { box-sizing: border-box; min-height: calc(var(--field-h) * 3); padding: var(--sp-2) var(--sp-3); margin: 0; min-width: 0; border: 1px solid var(--line); border-radius: var(--vs-radius); background-color: var(--surface); color: var(--ink); font-size: var(--fs-base); line-height: var(--lh-base); }
select {
  appearance: none; -webkit-appearance: none; padding-right: var(--sp-5); cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-size: 4px 4px, 4px 4px; background-position: calc(100% - 8px) 9px, calc(100% - 4px) 9px; background-repeat: no-repeat;
}
:is(select, input, textarea)::placeholder { color: var(--muted); opacity: 1; }
:is(select, input:not([type=range]):not([type=checkbox]):not([type=radio]), textarea):focus { border-color: var(--green); }
input[type=checkbox], input[type=radio] { width: 14px; height: 14px; margin: 0; accent-color: var(--green); cursor: pointer; }
input[type=range] { height: 14px; margin: 0; accent-color: var(--green); cursor: pointer; }
