.tsdh-library {
  --tsdh-border: #d9dee5;
  --tsdh-text: #18212b;
  --tsdh-muted: #596675;
  --tsdh-surface: #ffffff;
  --tsdh-soft: #f4f6f8;
  --tsdh-primary: #165d85;
  --tsdh-primary-dark: #104765;
  --tsdh-focus: #0b73b8;
  color: var(--tsdh-text);
  font: inherit;
}

.tsdh-library *,
.tsdh-library *::before,
.tsdh-library *::after {
  box-sizing: border-box;
}

.tsdh-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}

.tsdh-category {
  min-width: 0;
  align-self: start;
  border: 1px solid var(--tsdh-border);
  border-radius: 12px;
  background: var(--tsdh-surface);
  box-shadow: 0 2px 9px rgba(20, 33, 46, .06);
  overflow: hidden;
  transition: box-shadow .18s ease, border-color .18s ease;
}

.tsdh-category.is-open {
  grid-column: 1 / -1;
  border-color: #afc1ce;
  box-shadow: 0 6px 20px rgba(20, 33, 46, .09);
}

.tsdh-category__toggle {
  display: grid;
  width: 100%;
  min-height: 80px;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border: 0;
  background: transparent;
  color: var(--tsdh-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tsdh-category__toggle:hover {
  background: var(--tsdh-soft);
}

.tsdh-category__toggle:focus-visible,
.tsdh-button:focus-visible,
.tsdh-preview-button:focus-visible,
.tsdh-modal__close:focus-visible,
.tsdh-field input:focus-visible,
.tsdh-checkbox input:focus-visible {
  outline: 3px solid var(--tsdh-focus);
  outline: 3px solid color-mix(in srgb, var(--tsdh-focus) 35%, transparent);
  outline-offset: 2px;
}

.tsdh-category__icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 10px;
  background: #e8f1f6;
  color: var(--tsdh-primary);
  font-size: 22px;
}

.tsdh-category__title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}

.tsdh-category__count {
  display: inline-flex;
  min-width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--tsdh-soft);
  color: var(--tsdh-muted);
  font-size: .88rem;
  font-weight: 700;
}

.tsdh-category__chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform .18s ease;
}

.tsdh-category.is-open .tsdh-category__chevron {
  transform: rotate(225deg) translate(-2px, -2px);
}

.tsdh-category__panel {
  padding: 4px 18px 20px;
  border-top: 1px solid var(--tsdh-border);
}

.tsdh-document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 18px;
  padding-top: 18px;
}

.tsdh-document-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--tsdh-border);
  border-radius: 10px;
  background: var(--tsdh-surface);
}

.tsdh-document-card__preview {
  display: grid;
  min-height: 205px;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--tsdh-border);
  background: var(--tsdh-soft);
}

.tsdh-preview-button {
  position: relative;
  display: block;
  width: 100%;
  height: 205px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.tsdh-preview-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform .2s ease;
}

.tsdh-preview-button span {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 9px;
  border-radius: 6px;
  background: rgba(15, 25, 35, .84);
  color: #fff;
  font-size: .78rem;
  font-weight: 650;
}

.tsdh-preview-button:hover img {
  transform: scale(1.025);
}

.tsdh-file-icon {
  display: grid;
  width: 118px;
  height: 148px;
  place-items: end center;
  padding: 18px 10px;
  border-radius: 7px 7px 7px 22px;
  background: #687787;
  color: #fff;
  box-shadow: 0 10px 20px rgba(20, 33, 46, .14);
}

.tsdh-file-icon span {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.tsdh-file-icon--pdf { background: #a73333; }
.tsdh-file-icon--docx { background: #285b94; }
.tsdh-file-icon--xlsx,
.tsdh-file-icon--xlsm { background: #28724d; }

.tsdh-document-card__body {
  display: flex;
  min-height: 220px;
  flex: 1;
  flex-direction: column;
  padding: 16px;
}

.tsdh-document-card__format {
  margin-bottom: 7px;
  color: var(--tsdh-primary);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.tsdh-document-card h3 {
  margin: 0 0 12px;
  color: var(--tsdh-text);
  font-size: 1.04rem;
  line-height: 1.38;
}

.tsdh-document-card__meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
  color: var(--tsdh-muted);
  font-size: .87rem;
}

.tsdh-document-card .tsdh-button {
  width: 100%;
  margin-top: auto;
}

.tsdh-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
}

.tsdh-button--primary {
  background: var(--tsdh-primary);
  color: #fff;
}

.tsdh-button--primary:hover {
  background: var(--tsdh-primary-dark);
  color: #fff;
}

.tsdh-button:disabled {
  opacity: .58;
  cursor: wait;
}

.tsdh-empty {
  padding: 24px;
  border: 1px solid #d9dee5;
  border-radius: 8px;
  background: #f4f6f8;
}

.tsdh-modal[hidden] {
  display: none;
}

.tsdh-modal {
  position: fixed;
  z-index: 999999;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  opacity: 0;
  transition: opacity .12s ease;
}

.tsdh-modal.is-open {
  opacity: 1;
}

.tsdh-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 24, 33, .72);
  backdrop-filter: blur(2px);
}

.tsdh-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: min(900px, calc(100vh - 36px));
  overflow: auto;
  padding: 26px;
  border-radius: 12px;
  background: #fff;
  color: #18212b;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
  transform: translateY(8px);
  transition: transform .12s ease;
}

.tsdh-modal.is-open .tsdh-modal__dialog {
  transform: translateY(0);
}

.tsdh-modal__dialog--preview {
  width: min(980px, 100%);
}

.tsdh-modal__dialog h2 {
  margin: 0 42px 20px 0;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  line-height: 1.25;
}

.tsdh-modal__close {
  position: absolute;
  top: 15px;
  right: 15px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid #d9dee5;
  border-radius: 999px;
  background: #fff;
  color: #18212b;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.tsdh-preview-large {
  display: grid;
  min-height: 260px;
  place-items: center;
  overflow: auto;
  border: 1px solid #d9dee5;
  border-radius: 8px;
  background: #f4f6f8;
}

.tsdh-preview-large img {
  display: block;
  max-width: 100%;
  height: auto;
}

.tsdh-modal__note,
.tsdh-required-note {
  color: #596675;
  font-size: .84rem;
}

.tsdh-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 17px;
  font-weight: 700;
}

.tsdh-field input {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  border: 1px solid #98a5b2;
  border-radius: 7px;
  background: #fff;
  color: #18212b;
  font: inherit;
}

.tsdh-privacy-notice {
  max-height: 220px;
  overflow: auto;
  margin: 8px 0 16px;
  padding: 14px;
  border: 1px solid #d9dee5;
  border-radius: 7px;
  background: #f7f8f9;
  color: #364453;
  font-size: .85rem;
  line-height: 1.52;
}

.tsdh-privacy-notice p {
  margin: 0 0 9px;
}

.tsdh-privacy-notice p:last-child {
  margin-bottom: 0;
}

.tsdh-checkbox {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  margin: 14px 0;
  color: #25313d;
  font-size: .92rem;
  line-height: 1.45;
}

.tsdh-checkbox input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}

.tsdh-checkbox--optional {
  padding: 12px;
  border: 1px solid #cdd7df;
  border-radius: 7px;
  background: #f5f8fa;
}

.tsdh-disclaimer-box {
  margin-top: 17px;
  padding: 14px;
  border-left: 4px solid #a66711;
  background: #fff8e8;
  color: #3d3324;
}

.tsdh-disclaimer-box h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.tsdh-disclaimer-box p {
  margin: 0;
  white-space: pre-line;
}

.tsdh-form-status {
  min-height: 24px;
  margin: 10px 0;
  font-weight: 650;
}

.tsdh-form-status.is-error { color: #a12622; }
.tsdh-form-status.is-success { color: #176b3b; }
.tsdh-form-status.is-loading { color: #596675; }

.tsdh-honeypot {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

html.tsdh-modal-open,
html.tsdh-modal-open body {
  overflow: hidden !important;
}

@media (max-width: 640px) {
  .tsdh-category__toggle {
    grid-template-columns: auto 1fr auto;
  }

  .tsdh-category__count {
    display: none;
  }

  .tsdh-category__chevron {
    grid-column: 3;
  }

  .tsdh-modal {
    padding: 8px;
  }

  .tsdh-modal__dialog {
    max-height: calc(100vh - 16px);
    padding: 20px;
    border-radius: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tsdh-library *,
  .tsdh-library *::before,
  .tsdh-library *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
