/* ===== ÑÏÈÑÎÊ ÐÎËÅÉ ===== */

#roles {
  color: var(--text1);
  font: 400 12px/1.5 var(--font), sans-serif;
}

#roles,
#roles * {
  box-sizing: border-box;
}

#roles .roles-header > h2 {
  display: none;
}

#roles .roles-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

#roles .roles-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ===== ÏÎÈÑÊ ===== */

#roles .roles-search {
  display: block;
  flex: 1 1 270px;
  min-width: 0;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--borders);
  border-radius: 7px;
  background: var(--cover);
  color: var(--text1);
  font: 400 13px/1.4 var(--font), sans-serif;
}

#roles .roles-search::placeholder {
  color: var(--text2);
}

#roles .roles-search:focus,
#roles .roles-search:focus-visible {
  outline: none;
  box-shadow: none;
}

#roles .roles-search-status {
  margin: 0 0 10px;
  color: var(--text2);
  font-size: 11px;
}

#roles .roles-search-empty {
  padding: 20px 12px;
  border: 1px solid var(--borders);
  border-radius: 8px;
  background: var(--cover);
  color: var(--text2);
  text-align: center;
}

/* ===== ÑÅÒÊÀ ÊÀÑÒÎÂ ===== */

#roles .roles-casts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

#roles .roles-cast {
  display: flex;
  flex-direction: column;
  height: 270px;
  min-height: 0;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--borders);
  border-radius: 8px;
  background: var(--cover);
}

/* ===== ØÀÏÊÀ ÔÀÍÄÎÌÀ ===== */

#roles .fandom-col {
  position: relative;
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  min-height: 76px;
  margin: 0;
  padding: 10px 42px 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--borders);
  border-left: 4px solid var(--accent);
  border-radius: 0;
  background: var(--cover2);
  color: var(--text1);
  text-align: left;
}

#roles .fandom-en {
  margin: 0;
  color: var(--text1);
  font: 500 11px/1.6 var(--font2), var(--font), sans-serif;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

#roles .fandom-ru {
  margin: 3px 0 0;
  color: var(--text2);
  font: 400 11px/1.4 var(--font), sans-serif;
  text-transform: none;
  opacity: 1;
  overflow-wrap: anywhere;
}

/* ===== ÏÅÐÑÎÍÀÆÈ ===== */

#roles .chars-col {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-self: stretch;
  justify-content: flex-start;
  gap: 0;
  min-height: 0;
  min-width: 0;
  margin: 0;
  padding: 3px 0 7px;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background: var(--cover);
  columns: auto;
  column-rule: none;
  scrollbar-width: thin;
  scrollbar-color: var(--borders) var(--cover);
}

#roles .chars-col .char-line {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 7px 12px !important;
  border: 0;
  border-bottom: 1px solid var(--borders);
  border-radius: 0;
  background: transparent;
  transition: background .15s ease;
}

#roles .chars-col .char-line:last-child {
  border-bottom: 0;
}

#roles .chars-col .char-line:hover {
  background: var(--pun);
}

#roles .chars-col .char-line > a {
  display: block;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  color: var(--links);
  font: 500 12px/1.6 var(--font), sans-serif;
  font-size: 12px !important;
  text-align: left;
  text-decoration: none;
  text-transform: lowercase !important;
  white-space: normal;
  overflow-wrap: anywhere;
}

#roles .char-en {
  color: inherit;
}

#roles .char-ru,
#roles .char-separator {
  color: var(--text2);
  font-weight: 400;
}

#roles .char-ru {
  font-size: 11px;
}

#roles .chars-col .char-line > a:hover {
  color: var(--accent);
}

#roles .roles-cast-empty {
  padding: 10px 12px;
  color: var(--text2);
  font-size: 11px;
}

/* ===== ÐÅÄÀÊÒÈÐÎÂÀÍÈÅ ===== */

#roles button.edit-btn,
#roles button.edit-cast {
  flex: 0 0 auto;
  width: 24px;
  min-width: 24px;
  height: 24px;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid var(--borders);
  border-radius: 5px;
  background: var(--cover2);
  color: var(--text2);
  font-size: 0;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  opacity: 1;
  pointer-events: auto;
  transition:
    background .15s ease,
    color .15s ease;
}

#roles .fandom-col button.edit-cast {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--cover);
}

#roles button.edit-btn::before {
  content: "\f303";
  font: normal 11px/1 FontAwesome;
}

#roles button.edit-cast::before {
  content: "\f0ad";
  font: normal 11px/1 FontAwesome;
}

#roles button.edit-btn:hover,
#roles button.edit-cast:hover {
  background: var(--pun);
  color: var(--accent);
}

/* ===== ÌÎÄÀËÜÍÛÅ ÎÊÍÀ ===== */

.nc-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 20px;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .2s ease;
}

.nc-modal-backdrop.visible {
  opacity: 1;
}

.nc-modal {
  position: relative;
  z-index: 10000;
  box-sizing: border-box;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 20px 24px;
  border: 1px solid var(--borders);
  border-radius: 10px;
  background: var(--cover);
  color: var(--text1);
  box-shadow: 0 10px 35px rgba(0, 0, 0, .2);
  font: 400 12px/1.5 var(--font), sans-serif;
}

.nc-modal *,
.nc-modal *::before,
.nc-modal *::after {
  box-sizing: border-box;
}

.nc-modal .nc-field {
  margin-bottom: 14px;
}

.nc-modal label {
  display: block;
  margin-bottom: 5px;
  color: var(--text1);
  font-size: 12px;
  font-weight: 500;
}

.nc-modal input,
.nc-modal select,
.nc-modal textarea {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--borders) !important;
  border-radius: 7px;
  background: var(--cover2) !important;
  color: var(--text1) !important;
  font: 400 12px/1.4 var(--font), sans-serif;
}

.nc-modal textarea {
  resize: vertical;
}

.nc-modal input:focus,
.nc-modal select:focus,
.nc-modal textarea:focus {
  outline: 2px solid var(--links);
  outline-offset: 2px;
}

.nc-modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 16px;
}

/* ===== ÎÁÙÈÅ ÊÍÎÏÊÈ ===== */

.nc-btn {
  box-sizing: border-box;
  height: auto;
  margin: 0 !important;
  padding: 6px 12px !important;
  border: 1px solid var(--borders);
  border-radius: 6px;
  background: var(--cover2);
  color: var(--text1);
  font: 500 11px/1.4 var(--font), sans-serif;
  cursor: pointer;
  transition: filter .15s ease;
}

.nc-btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--cover);
}

.nc-btn.warn {
  border-color: #8a1f1f;
  background: #8a1f1f;
  color: var(--cover);
}

.nc-btn:hover {
  filter: brightness(1.08);
}

.nc-btn:disabled {
  cursor: default;
  opacity: .65;
}

/* ===== ÓÂÅÄÎÌËÅÍÈß ===== */

.nc-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: 99999999;
  box-sizing: border-box;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border: 1px solid var(--borders);
  border-radius: 8px;
  background: var(--cover);
  color: var(--text1);
  box-shadow: 0 5px 20px rgba(0, 0, 0, .15);
  font: 400 13px/1.4 var(--font), sans-serif;
  text-align: center;
  overflow-wrap: anywhere;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}

.nc-toast.visible {
  opacity: 1;
}

/* ===== ÏËÀÍØÅÒÛ: ÄÂÀ ÊÀÑÒÀ Â ÐßÄ ===== */

@media (max-width: 900px) {
  #roles .roles-casts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ===== ÑÅÍÑÎÐÍÛÅ ÝÊÐÀÍÛ ===== */

@media (pointer: coarse) {
  #roles button.edit-btn,
  #roles button.edit-cast {
    width: 44px;
    min-width: 44px;
    height: 44px;
    line-height: 42px;
  }

  #roles .fandom-col {
    min-height: 76px;
    padding-right: 64px;
  }

  .nc-btn {
    min-height: 44px;
  }
}

/* ===== ÒÅËÅÔÎÍÛ: ÎÄÈÍ ÊÀÑÒ, ÂÛÑÎÒÀ 200PX ===== */

@media (max-width: 600px) {
  #roles .roles-casts-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #roles .roles-cast {
    height: 250px;
    min-height: 0;
  }

  #roles .fandom-col {
    flex: 0 0 auto;
    min-height: 66px;
  }

  #roles .chars-col {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--borders) var(--cover);
  }

  #roles .chars-col::-webkit-scrollbar {
    width: 5px;
  }

  #roles .chars-col::-webkit-scrollbar-track {
    background: var(--cover);
  }

  #roles .chars-col::-webkit-scrollbar-thumb {
    border-radius: 5px;
    background: var(--borders);
  }

  #roles .roles-search,
  .nc-modal input,
  .nc-modal select,
  .nc-modal textarea {
    font-size: 16px;
  }

  .nc-modal {
    padding: 18px;
  }
}