/* «Мои расшифровки» — плавающая кнопка рядом с «Поддержкой» + панель со списком карт. */

/* Нижний док: очки и «Поддержка» в один ряд; поиск — чуть выше, не под поддержкой. */
.display-tools {
  bottom: max(20px, env(safe-area-inset-bottom)) !important;
  right: calc(max(16px, env(safe-area-inset-right)) + 142px) !important;
  z-index: 9010 !important;
}
.display-tools.is-open {
  z-index: 10080 !important;
}

.support-widget {
  bottom: max(20px, env(safe-area-inset-bottom)) !important;
  right: max(16px, env(safe-area-inset-right)) !important;
  z-index: 9020 !important;
}
.support-widget.is-open {
  z-index: 10080 !important;
}

.drafts-widget {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  right: min(210px, calc(100vw - 230px));
  z-index: 9020;
  font-family: inherit;
}
.drafts-widget.is-open {
  z-index: 10080 !important;
}

.drafts-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: #4b3ba8;
  border: 1.5px solid rgba(104, 71, 245, .28);
  border-radius: 24px;
  padding: 8px 14px 8px 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  box-shadow: 0 4px 18px rgba(40, 20, 100, .14);
  white-space: nowrap;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.drafts-toggle:hover {
  border-color: #6847f5;
  box-shadow: 0 6px 22px rgba(104, 71, 245, .22);
  transform: translateY(-1px);
}
.drafts-toggle-icon { font-size: 16px; line-height: 1 }

.drafts-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #6847f5;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.drafts-count[hidden] { display: none }

.drafts-panel {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  width: 340px;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(104, 71, 245, .14);
  box-shadow: 0 14px 48px rgba(40, 20, 100, .2);
  z-index: 9001;
}
.drafts-panel[hidden] { display: none }

.drafts-panel-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid #f0ecfa;
  position: sticky;
  top: 0;
  background: #fff;
  border-radius: 18px 18px 0 0;
}
.drafts-panel-head b { display: block; font-size: 15px; color: #1a1530 }
.drafts-panel-head span { font-size: 12px; color: #8b84a0 }

.drafts-panel-body { padding: 10px 12px 14px }

.drafts-list { display: grid; gap: 8px }

.drafts-item {
  position: relative;
  border: 1px solid #ece7fa;
  border-radius: 14px;
  background: #faf9ff;
  padding: 10px 34px 10px 12px;
}
.drafts-item-main { display: block; text-decoration: none }
.drafts-item-main b { display: block; font-size: 14px; color: #1a1530; line-height: 1.3 }
.drafts-item-main small { display: block; margin-top: 2px; font-size: 11.5px; color: #8b84a0 }

.drafts-tag {
  display: inline-block;
  margin: 5px 0 2px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .01em;
  white-space: nowrap;
}
/* Что именно оплачено — отдельной строкой, с переносом: в бейдж список не влезал. */
.drafts-what {
  display: block;
  margin: 3px 0 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: #4a4460;
  white-space: normal;
  overflow-wrap: anywhere;
}
.drafts-tag--paid { background: #e8f7ee; border: 1px solid #bfe8cc; color: #157347 }
.drafts-tag--free { background: #f3f0fb; border: 1px solid #e0d9f5; color: #6b6580 }

.drafts-item-pages { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px }
.drafts-item-pages a {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e5deff;
  color: #5c3be8;
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drafts-item-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: #efeaff;
  color: #6b6580;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.drafts-item-del:hover { background: #e0d7ff; color: #3a2f6b }

.drafts-empty { padding: 16px 6px 10px; text-align: center }
.drafts-empty b { display: block; font-size: 14px; color: #1a1530; margin-bottom: 6px }
.drafts-empty p { margin: 0 0 14px; font-size: 12.5px; color: #6b6580; line-height: 1.5 }
.drafts-cta {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 12px;
  background: #6847f5;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
}

.drafts-note { margin: 12px 2px 10px; font-size: 11px; color: #9a93ad; line-height: 1.45 }
.drafts-clear {
  width: 100%;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #ece7fa;
  background: #fff;
  color: #8b84a0;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.drafts-clear:hover { color: #c0392b; border-color: #f5c6c6 }

/* Планшет: подпись убираем, кнопка компактнее. */
@media (max-width: 900px) {
  .drafts-widget { right: min(190px, calc(100vw - 210px)) }
  .drafts-toggle-label { display: none }
  .drafts-toggle { padding: 10px; border-radius: 50% }
}

/* Мобильный: «Мои расшифровки» слева; очки + поддержка в ряд справа; поиск выше. */
@media (max-width: 600px) {
  .display-tools {
    bottom: max(12px, env(safe-area-inset-bottom)) !important;
    right: calc(max(12px, env(safe-area-inset-right)) + 118px) !important;
  }
  .support-widget {
    right: max(12px, env(safe-area-inset-right)) !important;
    bottom: max(12px, env(safe-area-inset-bottom)) !important;
  }
  .drafts-widget { right: auto; left: 12px; bottom: max(12px, env(safe-area-inset-bottom)) }
  .drafts-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: 72vh;
    border-radius: 18px 18px 0 0;
  }
}

/* Если снизу закреплена панель покупки или навигация по разделам карты —
   поднимаем кнопку, чтобы она не легла поверх них. */
@media (max-width: 900px) {
  body:has(.mobile-buy-bar) .drafts-widget {
    bottom: calc(82px + env(safe-area-inset-bottom, 0px)) !important;
  }
  body:has(.context-navigation) .drafts-widget {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }
  body:has(.mobile-buy-bar):has(.context-navigation) .drafts-widget {
    bottom: calc(140px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Кабинет: поиск и модалка профиля выше плавающих кнопок */
body.account-page:has(.acct-service-search.is-open) .display-tools,
body.account-page:has(.acct-service-search.is-open) .support-widget,
body.account-page:has(.acct-service-search.is-open) .drafts-widget,
body.account-page:has(.acct-service-search.is-open) .mv-search-fab,
body.rum-search-modal-open .display-tools,
body.rum-search-modal-open .support-widget,
body.rum-search-modal-open .drafts-widget,
body.rum-search-modal-open .mv-search-fab {
  z-index: 40 !important;
}
