.formation-library {
  width: min(1000px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 18px;
  box-sizing: border-box;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: #ebebdf;
  background: #18252a;
  border: 1px solid #758276;
  border-radius: 20px;
  box-shadow: 0 24px 90px #0009;
}
.formation-library::backdrop { background: #07100ed4; }
.formation-library [hidden] { display: none !important; }
.formation-library-header,
.formation-library-footer,
.formation-library-actions { display: flex; align-items: center; gap: 12px; }
.formation-library-header { gap: 10px; margin-bottom: 10px; }
.formation-library h2 { margin: 0; color: #f0e6c7; font-size: 22px; white-space: nowrap; }
.formation-library-close {
  min-width: 44px; min-height: 44px; background: transparent;
  color: #e4dfca; border: 1px solid #778477; border-radius: 12px; font-size: 26px; cursor: pointer;
}
.formation-library-count { color: #d4be83; font-size: 13px; white-space: nowrap; }
.formation-library-refresh {
  min-width: 44px; min-height: 44px; padding: 6px;
  border: 0; background: transparent; color: #d7c597; cursor: pointer;
}
.formation-library-message { margin: 0 0 10px; color: #b9c4bf; font-size: 13px; line-height: 1.5; }
.formation-library-message:empty { display: none; }
.formation-library-message.is-error { color: #ffb9a9; }
.formation-library-hint { margin-left: auto; color: #aebbb4; font-size: 12px; white-space: nowrap; }
.formation-library-slots {
  display: flex; gap: 12px; overflow-x: auto; overscroll-behavior-inline: contain;
  padding: 4px 2px 10px; scroll-snap-type: x mandatory; scrollbar-color: #9b895c #202f31;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch;
  cursor: grab; user-select: none; -webkit-user-select: none;
}
.formation-library-slots.is-dragging { scroll-snap-type: none; cursor: grabbing; }
.formation-library-slots.is-dragging .formation-slot { cursor: grabbing; }
.formation-slot {
  box-sizing: border-box; display: flex; flex: 0 0 310px; flex-direction: column;
  align-items: stretch; gap: 8px; min-width: 0; min-height: 0; padding: 10px;
  border: 1px solid #4a5b55; border-radius: 14px; background: #223237;
  color: #ebebdf; text-align: left; cursor: grab; scroll-snap-align: start;
}
.formation-slot[aria-pressed="true"] { border-color: #d1b876; background: #3b4034; }
.formation-slot:hover:not(:disabled) { border-color: #d1b876; }
.formation-slot-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.formation-slot-index { color: #d4be83; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.formation-slot-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.formation-slot-copy small { margin-top: auto; }
.formation-slot-copy strong { overflow-wrap: anywhere; font-size: 15px; }
.formation-slot-copy small { color: #b9c4bf; font-size: 11px; }
.formation-slot-mark { font-size: 12px; color: #d4be83; flex-shrink: 0; }
.formation-slot-preview {
  box-sizing: border-box; display: grid; place-items: center; width: 100%; aspect-ratio: 5 / 6;
  overflow: hidden; border: 1px solid #465b50; border-radius: 10px;
  background: #14231f;
}
.formation-slot-preview > svg { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.formation-slot-empty { color: #99aaa0; font-size: 13px; }
.formation-slot-local { background: linear-gradient(155deg, #2e403c, #1c2c2e); }
.formation-slot-local-icon {
  box-sizing: border-box; display: grid; place-items: center; width: 100%; aspect-ratio: 5 / 6; border: 1px dashed #75816f;
  border-radius: 10px; color: #d4be83; background: #172723; font-size: 58px;
}
.formation-library-footer { gap: 10px; margin-top: 12px; }
.formation-library-name {
  display: flex; align-items: center; gap: 10px; flex: 0 1 370px; min-width: 0;
  margin: 0 auto 0 0; font-size: 13px; color: #cdd2c5;
}
.formation-library-name > span { flex-shrink: 0; }
.formation-library-name input {
  box-sizing: border-box; width: 100%; min-width: 0; height: 44px; padding: 10px 12px;
  border: 1px solid #778477; border-radius: 10px; color: #f5f0df;
  background: #111e23; font: inherit; font-size: 16px;
}
.formation-library-footer > .button { flex-shrink: 0; height: 44px; padding: 0 14px; white-space: nowrap; }
.formation-library-footer > .button-primary { margin-left: auto; }
.formation-library-actions { flex-wrap: wrap; margin-top: 14px; justify-content: flex-end; }
.formation-library .button { min-height: 44px; color: #eee8d2; background: #2c3c3e; border-color: #6c7968; }
.formation-library .button:hover:not(:disabled) { background: #3c4a43; color: #fff8e4; }
.formation-library .button-primary { background: #c6ad70; border-color: #d7be81; color: #17242a; }
.formation-library .button-primary:hover:not(:disabled) { background: #e0c68b; color: #17242a; }
.formation-library .button-danger { background: #5c3430; color: #ffd7c7; border-color: #aa6e5e; }
.formation-library :is(button, input):focus-visible { outline: 3px solid #f0d592; outline-offset: 3px; }
.formation-library button:disabled { opacity: .5; cursor: default; }
.formation-library-confirm { margin-top: 14px; padding: 14px; border: 1px solid #b29361; border-radius: 12px; background: #37372f; }
.formation-library-confirm p { margin: 0; line-height: 1.6; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .formation-library {
    width: 100%; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .formation-library-header { gap: 8px; }
  .formation-library h2 { font-size: 20px; }
  .formation-library-hint { display: none; }
  .formation-library-refresh { margin-left: auto; }
  .formation-library-slots { margin-right: -2px; }
  .formation-slot { flex-basis: min(calc(100% - 24px), 326px); }
  .formation-library-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .formation-library-name { width: 100%; margin: 0; gap: 6px; }
  .formation-library-name > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .formation-library-name input { padding-inline: 8px; }
  .formation-library-footer > .button { padding-inline: 10px; }
  .formation-library-footer > .button-primary { grid-column: 2; grid-row: 1; }
  .formation-library-footer > .button-danger { grid-column: 2; grid-row: 2; justify-self: end; }
  .formation-library-actions .button { flex: 1; }
}
