/* --- card editor --- */
/* --- редактор с форматированием (жирный, ссылки) ------------ */
.rich-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex-shrink: 0;
  align-items: center;
}
.rich-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--bg-raised); color: var(--ink-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; flex: none;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.rich-btn:hover { border-color: var(--accent); color: var(--accent); }
.rich-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.rich-btn svg { width: 15px; height: 15px; }
.rich-highlight-wrap { position: relative; }
.rich-hl-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  display: flex;
  gap: 5px;
  padding: 5px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 20;
}
.rich-hl-menu[hidden] { display: none !important; }
.rich-hl-swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid color-mix(in srgb, var(--ink) 14%, transparent);
  cursor: pointer;
  padding: 0;
  flex: none;
  transition: transform .14s var(--ease), border-color .14s;
}
.rich-hl-swatch:hover { transform: scale(1.08); border-color: var(--accent); }
.rich-hl-terra { background: var(--accent-soft); }
.rich-hl-green { background: var(--ok-soft); }
.rich-hl-rose { background: var(--danger-soft); }
.rich-hl-sand { background: color-mix(in srgb, var(--paper-deep) 55%, #F5E6C8); }
.rich-hl-sky { background: #E3EEF8; }
.rich-input.input {
  min-height: 72px; max-height: 220px; overflow-y: auto; text-align: left;
  white-space: pre-wrap; word-break: break-word; cursor: text;
}
.rich-input.input:empty::before { content: attr(data-placeholder); color: var(--ink-faint); }
.rich-input b, .rich-input strong { font-weight: 800; }
.rich-input u { text-decoration: underline; text-underline-offset: 2px; }
.rich-input mark { border-radius: 3px; padding: 0 2px; color: inherit; }
.rich-input a { color: var(--accent); text-decoration: underline; }
/* --- редактор карточки ------------------------------------- */
.editor-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .editor-sides { grid-template-columns: 1fr; } }
.side-box {
  border: 1.5px solid var(--line); border-radius: 16px; padding: 14px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}
.side-box .side-title {
  font-family: var(--font-display);
  font-style: normal; font-synthesis: none;
  font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 10px;
}
.img-drop {
  margin-top: 10px; border: 1.5px dashed color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 14px;
  min-height: 74px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer;
  color: var(--ink-faint); font-size: 13.5px; font-weight: 600; text-align: center;
  transition: border-color var(--dur), color var(--dur), background var(--dur);
  position: relative; overflow: hidden; padding: 8px;
  background: color-mix(in srgb, var(--accent-soft) 35%, var(--bg-raised));
}
.img-drop:hover, .img-drop.drag, .img-drop:focus-visible { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.img-drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.img-drop-hint { font-size: 11px; font-weight: 500; opacity: .7; }
.img-drop img { max-width: 100%; max-height: 140px; border-radius: 8px; display: block; }
.img-drop .img-x {
  position: absolute; top: 6px; right: 6px; border: 0; cursor: pointer;
  background: rgba(0,0,0,.55); color: #fff; border-radius: 999px;
  width: 32px; height: 32px; display: grid; place-items: center; font-size: 14px;
  transition: transform .16s var(--ease);
}
.img-drop .img-x:hover { transform: scale(1.1); }
.img-drop-actions { margin-top: 6px; }
.img-drop-actions .stock-find-btn {
  padding: 5px 12px;
  font-size: 12px;
  min-height: 36px;
}
.stock-picker { display: flex; flex-direction: column; gap: 10px; }
.stock-picker-lead {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.45;
}
.stock-search-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: stretch;
}
.stock-search-input { flex: 1 1 180px; min-width: 0; }
.stock-tabs { display: flex; gap: 6px; flex: none; flex-wrap: wrap; max-width: 100%; }
.stock-tab {
  padding: 8px 10px;
  min-height: 40px;
  font-size: 12px;
  background: var(--bg-sunken);
}
.stock-tab.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.stock-provider-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}
.stock-translate-hint {
  margin: 0;
  font-size: 12px;
  color: var(--accent);
  text-align: center;
  line-height: 1.4;
}
.stock-status {
  margin: 0;
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
}
.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  min-height: 120px;
  max-height: min(52vh, 360px);
  overflow: auto;
  padding: 2px;
}
.stock-thumb {
  position: relative;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-sunken);
  aspect-ratio: 1;
  transition: border-color var(--dur), transform .16s var(--ease), box-shadow var(--dur);
}
.stock-thumb:hover, .stock-thumb:focus-visible {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.stock-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.stock-thumb-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .62);
  color: #fff;
}
.stock-attribution {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-faint);
}
.stock-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.stock-page-btn { min-width: 44px; padding-inline: 10px; }
.stock-page-info { font-size: 13px; color: var(--ink-soft); min-width: 4.5em; text-align: center; }
.stock-picker-note {
  margin: 0;
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.4;
}
.bulk-textarea {
  width: 100%; min-height: 200px; resize: vertical; font-family: var(--font-body);
  line-height: 1.45; margin-bottom: 12px;
}
.bulk-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.bulk-option-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.bulk-option-lab { color: var(--ink-soft); font-weight: 600; }
.bulk-preview { margin: 0 0 8px; font-size: 13.5px; }

.translate-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 8px;
}
.translate-dir-toggle {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 650;
  min-width: 88px;
  min-height: 44px;
  text-align: center;
  background: var(--bg-sunken);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  perspective: 320px;
}
.translate-dir-toggle-label {
  display: inline-block;
  transform-origin: center center;
  backface-visibility: hidden;
}
.translate-dir-toggle.is-flipping .translate-dir-toggle-label {
  animation: translateDirFlip 0.32s ease-in-out;
}
.translate-dir-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.translate-btn { padding: 6px 12px; font-size: 13px; min-height: 44px; }

@keyframes translateDirFlip {
  0% { transform: rotateY(0deg); opacity: 1; }
  49% { transform: rotateY(90deg); opacity: 0.25; }
  50% { transform: rotateY(-90deg); opacity: 0.25; }
  100% { transform: rotateY(0deg); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .translate-dir-toggle.is-flipping .translate-dir-toggle-label {
    animation: none;
  }
}
.card-preview-wrap {
  max-width: 520px;
  margin: 0 auto 8px;
}
.card-preview-wrap .flip-card {
  max-height: min(42vh, 340px);
}
.card-preview-wrap .flip-face {
  padding: 20px 18px;
}
.card-preview-wrap .flip-face img {
  max-height: min(22vh, 160px);
}
.card-preview-wrap .grade-row {
  display: none !important;
}
.card-preview-lead {
  text-align: center;
  margin-bottom: 12px !important;
}
.card-editor-actions .card-preview-btn {
  min-width: 0;
}
@media (max-width: 540px) {
  .card-editor-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .card-editor-actions .modal-actions-end {
    margin-left: 0;
    width: 100%;
    justify-content: stretch;
  }
  .card-editor-actions .card-preview-btn {
    width: 100%;
    justify-content: center;
  }
}
.modal-actions .btn-save-more { min-width: 0; }
.btn-save-more-short { display: none; }
.btn-save-more-full { display: inline; }
@media (max-width: 540px) {
  .modal-actions:not(.modal-actions-center) {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .modal-actions-center {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }
  .modal-actions:not(.modal-actions-center) .btn {
    min-width: 0;
    width: 100%;
    justify-content: center;
  }
  .modal-actions-center .btn {
    min-width: 0;
    flex: 1 1 0;
    max-width: 160px;
    justify-content: center;
  }
  .btn-save-more-short { display: inline; }
  .btn-save-more-full { display: none; }
}
