/* Окно «Не хватает монет» с пакетами — общее для редактора (/create) и студии
   (/projects). Разметку в студии вставляет scripts/coins-modal.js, в редакторе
   она в create.html. Светлая тема — в theme.css. */

.coins-overlay[hidden] {
  display: none !important;
}

.coins-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 15, 0.78);
  backdrop-filter: blur(8px);
}

.coins-panel {
  position: relative;
  width: min(100%, 420px);
  border: 1px solid rgba(83, 144, 255, 0.26);
  border-radius: 24px;
  padding: 46px 32px 32px;
  color: #f7fbff;
  background: linear-gradient(180deg, rgba(21, 33, 60, 0.98), rgba(9, 15, 30, 0.98));
  box-shadow:
    0 34px 100px rgba(0, 0, 0, 0.62),
    0 0 72px rgba(25, 111, 237, 0.22);
  text-align: center;
}

.coins-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 12px;
  color: #aebbd1;
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease;
}

.coins-close:hover {
  color: #f7fbff;
}

.coins-close svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.coins-mark {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  margin: 0 auto 12px;
}

.coins-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.coins-panel h2 {
  margin: 0 0 10px;
  font-size: 24px;
  line-height: 1.2;
  text-wrap: balance;
}

.coins-panel p {
  margin: 0 0 22px;
  color: #aebbd1;
  font-size: 15px;
  line-height: 1.5;
  text-wrap: balance;
}

.coins-panel--plans {
  width: min(100%, 680px);
  padding: 46px 36px 28px;
}

.coins-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 6px 0 18px;
}

.coins-plan {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 12px 16px;
  border: 1px solid rgba(83, 144, 255, 0.22);
  border-radius: 18px;
  background: rgba(13, 22, 42, 0.7);
}

.coins-plan[hidden] {
  display: none;
}

.coins-plan--featured {
  border-color: rgba(28, 122, 230, 0.6);
  background: rgba(20, 40, 78, 0.8);
  box-shadow:
    0 0 0 1px rgba(28, 122, 230, 0.25),
    0 18px 40px rgba(14, 78, 171, 0.25);
}

.coins-plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #1c7ae6, #0f5fc7);
  white-space: nowrap;
}

.coins-plan-icon {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.coins-plan-label {
  font-size: 13px;
  font-weight: 600;
  color: #aebbd1;
}

.coins-plan-price {
  font-size: 22px;
  font-weight: 800;
  color: #f7fbff;
}

.coins-plan-coins {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #ffc759;
}

/* Бесплатные перерисовки пакета — как строка «+3 перерисовки бесплатно» на
   /pricing. У «Новичка» её нет, поэтому кнопка прижата к низу карточки
   (`margin-top: auto`), а отступ над ней даёт последняя строка перед ней. */
.coins-plan-extra {
  margin: -8px 0 8px;
  color: #cddcf0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.coins-plan-extra b {
  color: #82c1ff;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.coins-plan-button {
  width: 100%;
  margin-top: auto;
  min-height: 42px;
  border: none;
  border-radius: 12px;
  color: #ffffff;
  background: linear-gradient(135deg, #1c7ae6, #0f5fc7);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.coins-plan-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(14, 78, 171, 0.35);
}

/* «Легенда» — персональный тариф, открыт не всем. На ПК это широкая строка
   под тремя пакетами, как карточка на /pricing, в золоте окна «Вы открыли
   тариф». Слева иконка с названием и ценой, под ними монеты
   и перерисовки; справа ползунок и кнопка оплаты. */
.coins-plan--legend {
  border-color: rgba(235, 184, 58, 0.62);
  background:
    radial-gradient(circle at 88% 0%, rgba(255, 211, 99, 0.16), transparent 42%),
    linear-gradient(155deg, rgba(28, 35, 53, 0.96), rgba(8, 15, 28, 0.96));
  box-shadow: 0 0 22px rgba(229, 174, 41, 0.14);
}

.coins-plan--legend .coins-plan-badge {
  color: #2d2104;
  background: linear-gradient(180deg, #ffe291 0%, #e9b83f 100%);
}

.coins-plan--legend .coins-plan-label {
  color: #f6c95d;
}

.coins-plan--legend .coins-plan-extra b {
  color: #f6c95d;
}

.coins-plan-legend-summary,
.coins-plan-legend-controls {
  min-width: 0;
}

.coins-plan-legend-summary {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.coins-plan-legend-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.coins-plan-legend-title {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.coins-plan--legend .coins-plan-icon {
  flex: 0 0 auto;
}

.coins-plan-legend-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
}

.coins-plan-legend-meta {
  display: flex;
  min-width: 0;
  flex-flow: row wrap;
  align-items: baseline;
  column-gap: 10px;
  row-gap: 1px;
  font-variant-numeric: tabular-nums;
}

.coins-plan--legend .coins-plan-legend-meta .coins-plan-coins,
.coins-plan--legend .coins-plan-legend-meta .coins-plan-extra {
  margin: 0;
}

.coins-plan--legend .coins-plan-price,
.coins-plan--legend .coins-plan-coins,
.coins-plan--legend [data-coins-legend-redraws] {
  font-variant-numeric: tabular-nums;
}

.coins-legend-volume-picker {
  --coins-legend-progress: 0%;
  --coins-legend-focus: rgba(255, 226, 145, 0.86);
  position: relative;
  top: -6px;
  width: min(100%, 260px);
  height: 44px;
  margin-top: 2px;
  color: #fff7de;
}

.coins-legend-volume-picker[hidden] {
  display: none;
}

.coins-legend-range {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background: transparent;
  touch-action: pan-y;
}

.coins-plan--legend .coins-legend-volume-picker .coins-legend-range,
.coins-plan--legend .coins-legend-volume-picker .coins-legend-range:focus {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
}

.coins-legend-range:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--coins-legend-focus);
  outline-offset: 3px;
}

.coins-legend-range:focus-visible::-moz-range-thumb {
  outline: 2px solid var(--coins-legend-focus);
  outline-offset: 3px;
}

.coins-legend-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    #f5c84f 0%,
    #f5c84f var(--coins-legend-progress),
    rgba(255, 255, 255, 0.24) var(--coins-legend-progress),
    rgba(255, 255, 255, 0.24) 100%
  );
}

.coins-legend-range::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    #f5c84f 0%,
    #f5c84f var(--coins-legend-progress),
    rgba(255, 255, 255, 0.24) var(--coins-legend-progress),
    rgba(255, 255, 255, 0.24) 100%
  );
}

.coins-legend-range::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #fff6d8;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe899, #e9b83f);
  box-shadow: 0 0 0 3px rgba(242, 193, 70, 0.16), 0 2px 7px rgba(0, 0, 0, 0.38);
  transition-property: box-shadow, transform;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.coins-legend-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid #fff6d8;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe899, #e9b83f);
  box-shadow: 0 0 0 3px rgba(242, 193, 70, 0.16), 0 2px 7px rgba(0, 0, 0, 0.38);
  transition-property: box-shadow, transform;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

@media (hover: hover) and (pointer: fine) {
  .coins-legend-range:hover::-webkit-slider-thumb,
  .coins-legend-range:active::-webkit-slider-thumb {
    box-shadow: 0 0 0 5px rgba(242, 193, 70, 0.2), 0 2px 9px rgba(0, 0, 0, 0.42);
    transform: scale(1.05);
  }

  .coins-legend-range:hover::-moz-range-thumb,
  .coins-legend-range:active::-moz-range-thumb {
    box-shadow: 0 0 0 5px rgba(242, 193, 70, 0.2), 0 2px 9px rgba(0, 0, 0, 0.42);
    transform: scale(1.05);
  }
}

.coins-legend-volume-marks {
  position: absolute;
  z-index: 3;
  right: 8px;
  bottom: 0;
  left: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  color: rgba(255, 255, 255, 0.56);
  font-size: 10px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  pointer-events: none;
}

.coins-legend-volume-marks span {
  text-align: center;
  transition-property: color;
  transition-duration: 150ms;
  transition-timing-function: ease;
}

.coins-legend-volume-marks span:first-child { text-align: left; }
.coins-legend-volume-marks span:last-child { text-align: right; }
.coins-legend-volume-marks .is-current { color: #ffe291; }

.coins-plan--legend .coins-plan-button {
  color: #2d2104;
  background: linear-gradient(180deg, #ffe291 0%, #e9b83f 100%);
  margin-top: 0;
}

.coins-plan--legend .coins-plan-button:hover {
  box-shadow: 0 14px 30px rgba(222, 163, 28, 0.3);
}

@media (min-width: 721px) {
  .coins-plan--legend {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(180px, 0.95fr) minmax(220px, 1.05fr);
    grid-template-rows: auto;
    align-items: center;
    column-gap: 16px;
    margin-top: 6px;
    padding: 16px 18px;
    text-align: left;
  }

  .coins-plan--legend .coins-plan-badge {
    left: 18px;
    transform: none;
  }

  .coins-plan--legend .coins-plan-legend-summary {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 12px;
    row-gap: 6px;
  }

  .coins-plan--legend .coins-plan-legend-heading {
    display: contents;
  }

  .coins-plan--legend .coins-plan-icon {
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: center;
  }

  .coins-plan--legend .coins-plan-legend-title {
    grid-column: 2;
    grid-row: 1;
  }

  .coins-plan--legend .coins-plan-legend-controls {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    width: 100%;
    max-width: 260px;
    gap: 8px;
  }

  .coins-plan--legend .coins-legend-volume-picker {
    width: 100%;
  }

  .coins-plan--legend .coins-plan-legend-meta {
    grid-column: 2;
    grid-row: 2;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin-left: 0;
  }

  .coins-plan--legend .coins-plan-button {
    width: 100%;
    min-width: 0;
    padding: 0 20px;
  }
}

.coins-plan-button:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
  box-shadow: none;
}

.coins-panel .coins-error {
  margin: -8px 0 14px;
  color: #ffb3b3;
  font-size: 13px;
}

.coins-panel .coins-consent {
  margin: 0 0 14px;
  color: #8595ad;
  font-size: 12px;
  line-height: 1.45;
}

.coins-panel .coins-consent a {
  color: #aebbd1;
}

.coins-shop-link {
  display: inline-block;
  color: #6fa8ff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.coins-shop-link:hover {
  text-decoration: underline;
}

@media (max-width: 720px) {
  .coins-overlay {
    padding: 16px;
    align-items: center;
    overflow-y: auto;
  }

  .coins-panel {
    max-width: 360px;
    border-radius: 20px;
    padding: 50px 20px 22px;
  }

  .coins-panel--plans {
    padding: 48px 14px 22px;
  }

  .coins-plans {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 4px 0 14px;
  }

  .coins-plan {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 10px;
    row-gap: 0;
    padding: 12px 12px 12px 14px;
    text-align: left;
  }

  .coins-plan-icon {
    display: none;
  }

  .coins-plan-label {
    grid-column: 1;
    grid-row: 1;
  }

  .coins-plan-price {
    grid-column: 1;
    grid-row: 2;
    font-size: 19px;
  }

  .coins-plan-coins {
    grid-column: 1;
    grid-row: 3;
    margin-bottom: 0;
  }

  .coins-plan-extra {
    grid-column: 1;
    grid-row: 4;
    margin: 3px 0 0;
  }

  .coins-plan--legend .coins-plan-legend-meta .coins-plan-coins,
  .coins-plan--legend .coins-plan-legend-meta .coins-plan-extra {
    grid-column: auto;
    grid-row: auto;
  }

  .coins-plan--legend .coins-legend-volume-picker {
    width: 100%;
    max-width: none;
    margin-top: 0;
  }

  .coins-plan--legend .coins-legend-volume-marks {
    right: 0;
    left: 0;
  }

  .coins-plan--legend {
    grid-template-columns: minmax(0, 1.2fr) minmax(104px, 1fr);
    align-items: center;
    column-gap: 10px;
  }

  .coins-plan--legend .coins-plan-legend-summary {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    gap: 6px;
  }

  .coins-plan--legend .coins-plan-legend-heading {
    gap: 6px;
  }

  .coins-plan--legend .coins-plan-icon {
    display: block;
    width: clamp(32px, 9.5vw, 38px);
    height: 40px;
  }

  .coins-plan--legend .coins-plan-legend-controls {
    grid-column: 2;
    grid-row: 1;
    gap: 8px;
  }

  .coins-plan--legend .coins-plan-label {
    grid-column: auto;
    grid-row: auto;
  }

  .coins-plan--legend .coins-plan-price {
    grid-column: auto;
    grid-row: auto;
    display: flex;
    flex-direction: column;
    font-size: 19px;
    white-space: nowrap;
  }

  .coins-plan--legend .coins-plan-price-old {
    margin-right: 0;
  }

  .coins-plan--legend .coins-plan-legend-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    line-height: 1.25;
  }

  .coins-plan--legend .coins-plan-legend-meta .coins-plan-extra {
    font-size: 11px;
  }

  .coins-plan-button {
    grid-column: 2;
    grid-row: 1 / 5;
    align-self: center;
    width: auto;
    min-width: 96px;
    margin-top: 0;
    padding: 0 14px;
  }

  .coins-plan--legend .coins-plan-button {
    grid-column: auto;
    grid-row: auto;
    width: 100%;
    min-width: 0;
    align-self: stretch;
    min-height: 42px;
    padding-inline: 10px;
  }

  .coins-plan-badge {
    top: -9px;
    left: 16px;
    transform: none;
  }

  .coins-close {
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
  }

  .coins-mark {
    width: 96px;
    height: 96px;
    margin-bottom: 10px;
  }

  .coins-panel h2 {
    font-size: 20px;
  }

  .coins-panel p {
    margin-bottom: 18px;
    font-size: 14px;
  }
}

@media (max-width: 360px) {
  .coins-plan--legend {
    grid-template-columns: minmax(0, 1.15fr) minmax(96px, 1fr);
  }

  .coins-plan--legend .coins-plan-legend-heading {
    gap: 4px;
  }

  .coins-plan--legend .coins-plan-icon {
    width: 28px;
    height: 34px;
  }

  .coins-plan--legend .coins-plan-price {
    font-size: 18px;
  }
}

/* Низкий экран телефона: окно тарифов не влезало целиком (374×650 — на 75 px),
   и «Оплатить» у «Сэнсэя» уезжал под сгиб. Ужимаем шапку: меньше отступ
   сверху и Коми поменьше, сами карточки не трогаем. */
@media (max-width: 720px) and (max-height: 760px) {
  .coins-overlay {
    padding-block: 12px;
  }

  .coins-panel--plans {
    padding-top: 18px;
  }

  .coins-panel--plans .coins-mark {
    width: 60px;
    height: 60px;
    margin-bottom: 6px;
  }

  .coins-panel--plans h2 {
    margin-bottom: 6px;
  }

  .coins-panel--plans > p {
    margin-bottom: 12px;
  }
}

/* Строка «+3 перерисовки бесплатно» на 360 px не влезала в одну строку на 3 px. */
@media (max-width: 370px) {
  .coins-plan-extra {
    font-size: 11.5px;
  }
}

/* С «Легендой» строк четыре: на низком экране убираем подзаголовок и ещё
   ужимаем Коми, на совсем низком — Коми прячем. */
@media (max-width: 720px) and (max-height: 760px) {
  .coins-overlay.has-legend .coins-mark {
    width: 44px;
    height: 44px;
    margin-bottom: 4px;
  }

  .coins-overlay.has-legend .coins-panel--plans > p:first-of-type {
    display: none;
  }

  .coins-overlay.has-legend .coins-panel--plans h2 {
    margin-bottom: 14px;
  }
}

@media (max-width: 720px) and (max-height: 660px) {
  .coins-overlay.has-legend .coins-mark {
    display: none;
  }

  .coins-overlay.has-legend .coins-panel--plans h2 {
    padding-right: 30px;
    padding-left: 30px;
  }
}

@media (max-width: 720px) and (max-height: 600px) {
  .coins-panel--plans .coins-mark {
    width: 44px;
    height: 44px;
    margin-bottom: 4px;
  }

  .coins-panel--plans .coins-plan {
    padding-block: 9px;
  }

  .coins-panel--plans h2 {
    font-size: 18px;
  }

  .coins-panel--plans > p {
    margin-bottom: 10px;
    font-size: 13px;
  }

  .coins-panel--plans .coins-consent {
    margin-bottom: 10px;
  }
}

.coins-plan-price-old {
  margin-right: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
