/* Inscription editor — модальный canvas-редактор надписей и крестов поверх ретуши */

.inscribe-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 200ms ease;
}

.inscribe-overlay.is-open {
  display: flex;
  opacity: 1;
}

.inscribe-shell {
  position: relative;
  margin: auto;
  display: flex;
  flex-direction: column;
  background: #fafaf9;
  color: #18181b;
  width: min(100%, 1280px);
  height: min(100%, 92vh);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.08);
  transform: translateY(8px);
  transition: transform 220ms ease;
}

html.dark .inscribe-shell {
  background: #121212;
  color: #f4f4f5;
  border-color: rgba(255, 255, 255, 0.06);
}

.inscribe-overlay.is-open .inscribe-shell {
  transform: translateY(0);
}

.inscribe-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

html.dark .inscribe-header {
  background: #18181b;
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.inscribe-title {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.inscribe-title-icon {
  color: #c9a227;
  font-size: 18px;
  line-height: 1;
}

.inscribe-close {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: inherit;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  font-size: 20px;
  line-height: 1;
}

.inscribe-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

html.dark .inscribe-close {
  border-color: rgba(255, 255, 255, 0.12);
}

html.dark .inscribe-close:hover {
  background: rgba(255, 255, 255, 0.06);
}

.inscribe-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
}

@media (max-width: 1024px) {
  .inscribe-body { grid-template-columns: minmax(0, 1fr); }
  .inscribe-side { border-left: 0; border-top: 1px solid rgba(0,0,0,0.08); max-height: 50vh; }
  html.dark .inscribe-side { border-top-color: rgba(255,255,255,0.06); }
  .inscribe-shell { height: 100vh; max-height: 100vh; border-radius: 0; }
  .inscribe-stage { min-height: 40vh; }
}

.inscribe-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, rgba(0,0,0,0.04) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(-45deg, rgba(0,0,0,0.04) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.04) 75%) 0 0/16px 16px,
    linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.04) 75%) 0 0/16px 16px,
    #e7e5e4;
  padding: 18px;
  min-height: 0;
  overflow: hidden;
}

html.dark .inscribe-stage {
  background:
    linear-gradient(45deg, rgba(255,255,255,0.025) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(-45deg, rgba(255,255,255,0.025) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.025) 75%) 0 0/16px 16px,
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.025) 75%) 0 0/16px 16px,
    #1a1a1a;
}

.inscribe-canvas-wrap {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
}

.inscribe-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  box-shadow: 0 8px 32px -8px rgba(0,0,0,0.35);
  touch-action: none;
  user-select: none;
}

.inscribe-canvas.is-grabbable { cursor: grab; }
.inscribe-canvas.is-grabbing { cursor: grabbing; }
.inscribe-canvas.is-resizing { cursor: nwse-resize; }

.inscribe-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: #71717a;
  font-size: 14px;
  background: inherit;
}

.inscribe-loading.is-hidden { display: none; }

.inscribe-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #c9a227;
  border-radius: 50%;
  animation: inscribe-spin 0.8s linear infinite;
}

html.dark .inscribe-spinner {
  border-color: rgba(255, 255, 255, 0.12);
  border-top-color: #c9a227;
}

@keyframes inscribe-spin { to { transform: rotate(360deg); } }

.inscribe-side {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  min-height: 0;
}

html.dark .inscribe-side {
  background: #18181b;
  border-left-color: rgba(255, 255, 255, 0.06);
}

.inscribe-side-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 8px;
}

.inscribe-section {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.inscribe-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }

html.dark .inscribe-section { border-bottom-color: rgba(255, 255, 255, 0.05); }

.inscribe-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #92400e;
  margin-bottom: 10px;
}

html.dark .inscribe-section-title { color: #fcd34d; }

.inscribe-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.inscribe-row:last-child { margin-bottom: 0; }
.inscribe-row-label {
  flex: 0 0 84px;
  font-size: 12px;
  color: #6b7280;
}
html.dark .inscribe-row-label { color: #a1a1aa; }

.inscribe-input,
.inscribe-textarea,
.inscribe-select {
  width: 100%;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  color: inherit;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

html.dark .inscribe-input,
html.dark .inscribe-textarea,
html.dark .inscribe-select {
  background: #1f1f23;
  border-color: rgba(255, 255, 255, 0.1);
}

.inscribe-input:focus,
.inscribe-textarea:focus,
.inscribe-select:focus {
  border-color: #c9a227;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}

.inscribe-textarea { resize: vertical; min-height: 60px; line-height: 1.4; }

.inscribe-range {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(0,0,0,0.12);
  outline: none;
}

html.dark .inscribe-range { background: rgba(255,255,255,0.12); }

.inscribe-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #c9a227;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  cursor: pointer;
}

.inscribe-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #c9a227;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  cursor: pointer;
}

.inscribe-layer-slider {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.inscribe-layer-slider-label {
  font-size: 12px;
  color: #525252;
  font-weight: 500;
}
html.dark .inscribe-layer-slider-label { color: #d4d4d8; }

.inscribe-layer-range {
  width: 100%;
  height: 6px;
  touch-action: pan-y;
}
.inscribe-layer-range::-webkit-slider-thumb { width: 20px; height: 20px; }
.inscribe-layer-range::-moz-range-thumb { width: 20px; height: 20px; }

.inscribe-layer-number {
  width: 100%;
  height: 36px;
  padding: 4px 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #ffffff;
  color: #18181b;
  appearance: textfield;
  -moz-appearance: textfield;
  font-weight: 600;
}
.inscribe-layer-number::-webkit-outer-spin-button,
.inscribe-layer-number::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.inscribe-layer-number:focus {
  outline: none;
  border-color: #c9a227;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}
html.dark .inscribe-layer-number {
  background: #1c1c20;
  color: #fafafa;
  border-color: rgba(255, 255, 255, 0.14);
}

.inscribe-side.is-keyboard-open {
  max-height: calc(56vh - var(--keyboard-inset, 0px)) !important;
}
.inscribe-side.is-keyboard-open .inscribe-side-scroll {
  scroll-padding-bottom: calc(16px + var(--keyboard-inset, 0px));
}

.inscribe-range-value {
  flex: 0 0 36px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: #71717a;
}

.inscribe-adjust {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(0, 0, 0, 0.02);
}
html.dark .inscribe-adjust {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}
.inscribe-adjust-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 10px;
}
.inscribe-adjust-label {
  font-size: 12px;
  color: #525252;
  font-weight: 500;
}
html.dark .inscribe-adjust-label { color: #d4d4d8; }

.inscribe-adjust-range {
  width: 100%;
  height: 6px;
  touch-action: pan-y;
}

.inscribe-adjust-range::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
}
.inscribe-adjust-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
}

.inscribe-adjust-number {
  width: 100%;
  height: 36px;
  padding: 4px 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #ffffff;
  color: #18181b;
  appearance: textfield;
  -moz-appearance: textfield;
  font-weight: 600;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.inscribe-adjust-number::-webkit-outer-spin-button,
.inscribe-adjust-number::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.inscribe-adjust-number:focus {
  outline: none;
  border-color: #c9a227;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}
html.dark .inscribe-adjust-number {
  background: #1c1c20;
  color: #fafafa;
  border-color: rgba(255, 255, 255, 0.14);
}

.inscribe-adjust-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}
.inscribe-adjust-reset {
  font-size: 12px;
  color: #6b7280;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  padding: 6px 12px;
  min-height: 36px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.inscribe-adjust-reset:hover {
  color: #b08d2f;
  border-color: rgba(176, 141, 47, 0.55);
  background: rgba(201, 162, 39, 0.06);
}
html.dark .inscribe-adjust-reset {
  color: #a1a1aa;
  border-color: rgba(255, 255, 255, 0.14);
}
html.dark .inscribe-adjust-reset:hover {
  color: #fcd34d;
  border-color: rgba(252, 211, 77, 0.45);
  background: rgba(252, 211, 77, 0.08);
}

/* Touch-устройства: больший thumb, удобнее для пальца */
@media (hover: none) and (pointer: coarse) {
  .inscribe-range,
  .inscribe-adjust-range,
  .inscribe-layer-range {
    height: 8px;
  }
  .inscribe-range::-webkit-slider-thumb,
  .inscribe-adjust-range::-webkit-slider-thumb,
  .inscribe-layer-range::-webkit-slider-thumb {
    width: 26px;
    height: 26px;
  }
  .inscribe-range::-moz-range-thumb,
  .inscribe-adjust-range::-moz-range-thumb,
  .inscribe-layer-range::-moz-range-thumb {
    width: 26px;
    height: 26px;
  }
  .inscribe-layer-number,
  .inscribe-adjust-number {
    height: 40px;
    font-size: 16px;
  }
  .inscribe-btn-group button {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
  }
  .inscribe-quick-clear {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  .inscribe-trigger { min-height: 44px; padding: 10px 8px; font-size: 13px; }
}

/* Узкий экран: ставим лейбл сверху, чтобы ползунок занял всю ширину */
@media (max-width: 520px) {
  .inscribe-adjust-row,
  .inscribe-layer-slider {
    grid-template-columns: 1fr 70px;
    grid-template-rows: auto auto;
    column-gap: 10px;
    row-gap: 4px;
  }
  .inscribe-adjust-label,
  .inscribe-layer-slider-label {
    grid-column: 1 / -1;
  }
  .inscribe-adjust-range,
  .inscribe-layer-range { grid-column: 1; grid-row: 2; }
  .inscribe-adjust-number,
  .inscribe-layer-number { grid-column: 2; grid-row: 2; }
}

/* iOS: чтобы не было автоматического зума при фокусе нужен шрифт >= 16px */
@supports (-webkit-touch-callout: none) {
  .inscribe-adjust-number { font-size: 16px; }
}


.inscribe-row--col { align-items: flex-start; }
.inscribe-row--col .inscribe-row-label { padding-top: 6px; }

.inscribe-color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.inscribe-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-width: 0;
  border-radius: 7px;
  border: 1.5px solid rgba(0,0,0,0.12);
  cursor: pointer;
  padding: 0;
  transition: transform 80ms ease, border-color 100ms ease, box-shadow 120ms ease;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

html.dark .inscribe-swatch { border-color: rgba(255,255,255,0.15); }

.inscribe-swatch:hover { transform: scale(1.07); }

.inscribe-swatch.is-active {
  border-color: #c9a227;
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.35);
}

.inscribe-color-custom {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  border: 1.5px dashed rgba(0,0,0,0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #71717a;
  font-size: 17px;
  font-weight: 700;
  overflow: hidden;
  background:
    conic-gradient(from 180deg, #ff5a5a, #ffd166, #6dd47e, #5ec1ff, #c47fff, #ff5a5a);
}

html.dark .inscribe-color-custom { border-color: rgba(255,255,255,0.18); }

.inscribe-color-custom span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0,0,0,0.55);
  text-shadow: 0 1px 1px rgba(255,255,255,0.4);
  pointer-events: none;
}

.inscribe-color {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0;
}

.inscribe-color::-webkit-color-swatch-wrapper { padding: 0; }
.inscribe-color::-webkit-color-swatch { border: 0; border-radius: 6px; }
.inscribe-color::-moz-color-swatch { border: 0; border-radius: 6px; }

.inscribe-epitaphs-wrap {
  margin: 0 0 10px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  background: rgba(0,0,0,0.02);
  overflow: hidden;
}

html.dark .inscribe-epitaphs-wrap {
  background: rgba(255,255,255,0.025);
  border-color: rgba(255,255,255,0.06);
}

.inscribe-epitaphs-summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 6px;
}

.inscribe-epitaphs-summary::before {
  content: '▸';
  font-size: 10px;
  transition: transform 150ms ease;
  color: #c9a227;
}

.inscribe-epitaphs-wrap[open] .inscribe-epitaphs-summary::before {
  transform: rotate(90deg);
}

.inscribe-epitaphs-summary:hover { color: #18181b; }
html.dark .inscribe-epitaphs-summary { color: #a1a1aa; }
html.dark .inscribe-epitaphs-summary:hover { color: #f4f4f5; }

.inscribe-epitaphs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 8px 10px;
}

.inscribe-epitaph {
  background: transparent;
  border: 1px solid rgba(0,0,0,0.08);
  color: inherit;
  border-radius: 7px;
  padding: 6px 10px;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.35;
  transition: background 120ms ease, border-color 120ms ease;
}

.inscribe-epitaph:hover {
  background: rgba(201, 162, 39, 0.1);
  border-color: rgba(201, 162, 39, 0.45);
}

html.dark .inscribe-epitaph { border-color: rgba(255,255,255,0.08); }
html.dark .inscribe-epitaph:hover { background: rgba(252, 211, 77, 0.1); border-color: rgba(252, 211, 77, 0.35); }

.inscribe-btn-group { display: inline-flex; gap: 2px; background: rgba(0,0,0,0.05); padding: 2px; border-radius: 8px; }
html.dark .inscribe-btn-group { background: rgba(255,255,255,0.06); }

.inscribe-btn-group button {
  background: transparent;
  border: 0;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: inherit;
  cursor: pointer;
  transition: background 120ms ease;
  min-width: 32px;
  font-weight: 500;
}

.inscribe-btn-group button.is-active {
  background: #fff;
  color: #18181b;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

html.dark .inscribe-btn-group button.is-active {
  background: #2c2c30;
  color: #fff;
}

.inscribe-tone-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.inscribe-tone-chip {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  color: inherit;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 80ms ease;
}

.inscribe-tone-chip:hover {
  border-color: #c9a227;
  background: rgba(201,162,39,0.08);
}

.inscribe-tone-chip.is-active {
  border-color: #c9a227;
  background: rgba(201,162,39,0.14);
  box-shadow: 0 0 0 2px rgba(201,162,39,0.2);
}

html.dark .inscribe-tone-chip {
  background: #1f1f23;
  border-color: rgba(255,255,255,0.12);
}

html.dark .inscribe-tone-chip:hover {
  background: rgba(252,211,77,0.10);
  border-color: rgba(252,211,77,0.38);
}

html.dark .inscribe-tone-chip.is-active {
  background: rgba(252,211,77,0.14);
  border-color: rgba(252,211,77,0.48);
}

.inscribe-quick {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inscribe-quick-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inscribe-quick-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inscribe-quick-input-row .inscribe-input {
  flex: 1;
}

.inscribe-quick-clear {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.12);
  background: transparent;
  color: #71717a;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.inscribe-quick-clear:hover {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.5);
  color: #b91c1c;
}

html.dark .inscribe-quick-clear {
  border-color: rgba(255,255,255,0.12);
  color: #a1a1aa;
}

html.dark .inscribe-quick-clear:hover {
  background: rgba(239,68,68,0.15);
  border-color: rgba(248,113,113,0.45);
  color: #fca5a5;
}

.inscribe-quick-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #6b7280;
  text-transform: uppercase;
}

html.dark .inscribe-quick-label { color: #a1a1aa; }

.inscribe-quick-epitaphs { margin-top: 6px; }

.inscribe-add-btn {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(201, 162, 39, 0.5);
  background: rgba(201, 162, 39, 0.06);
  color: #92400e;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.inscribe-add-btn:hover {
  background: rgba(201, 162, 39, 0.12);
  border-color: rgba(201, 162, 39, 0.7);
}

html.dark .inscribe-add-btn { color: #fcd34d; }

.inscribe-crosses-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.inscribe-cross-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.1);
  background: #f4f4f5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transition: border-color 120ms ease, transform 120ms ease;
}

html.dark .inscribe-cross-thumb {
  background: #232326;
  border-color: rgba(255,255,255,0.08);
}

.inscribe-cross-thumb:hover {
  border-color: #c9a227;
  transform: translateY(-1px);
}

.inscribe-cross-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
}

.inscribe-layers-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inscribe-layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid rgba(0,0,0,0.08);
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

html.dark .inscribe-layer-row {
  background: #1f1f23;
  border-color: rgba(255,255,255,0.06);
}

.inscribe-layer-row.is-active {
  border-color: #c9a227;
  background: rgba(201, 162, 39, 0.08);
}

.inscribe-layer-icon {
  flex: 0 0 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #c9a227;
}

.inscribe-layer-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inscribe-layer-actions {
  display: inline-flex;
  gap: 2px;
}

.inscribe-layer-actions button {
  background: transparent;
  border: 0;
  color: #71717a;
  cursor: pointer;
  padding: 5px 7px;
  min-width: 28px;
  min-height: 28px;
  font-size: 14px;
  border-radius: 4px;
  line-height: 1;
}

.inscribe-layer-actions button:hover { background: rgba(0,0,0,0.06); color: #18181b; }
html.dark .inscribe-layer-actions button:hover { background: rgba(255,255,255,0.08); color: #fff; }

.inscribe-layer-actions .inscribe-layer-delete {
  color: #dc2626;
}

html.dark .inscribe-layer-actions .inscribe-layer-delete {
  color: #f87171;
}

.inscribe-empty-hint {
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  padding: 10px 4px;
  font-style: italic;
}

.inscribe-footer {
  flex-shrink: 0;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(0,0,0,0.08);
  background: #fff;
}

html.dark .inscribe-footer {
  background: #18181b;
  border-top-color: rgba(255,255,255,0.06);
}

.inscribe-footer-info {
  flex: 1;
  font-size: 12px;
  color: #71717a;
  line-height: 1.4;
}

.inscribe-btn {
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms ease, transform 80ms ease, box-shadow 120ms ease;
  white-space: nowrap;
}

.inscribe-btn:active { transform: translateY(1px); }

.inscribe-btn--ghost {
  background: transparent;
  border-color: rgba(0,0,0,0.12);
  color: inherit;
}

.inscribe-btn--ghost:hover { background: rgba(0,0,0,0.05); }
html.dark .inscribe-btn--ghost { border-color: rgba(255,255,255,0.1); }
html.dark .inscribe-btn--ghost:hover { background: rgba(255,255,255,0.05); }

.inscribe-btn--danger {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.45);
  color: #b91c1c;
}

.inscribe-btn--danger:hover {
  background: rgba(239,68,68,0.2);
}

html.dark .inscribe-btn--danger {
  background: rgba(239,68,68,0.16);
  border-color: rgba(248,113,113,0.5);
  color: #fecaca;
}

.is-hidden {
  display: none !important;
}

.inscribe-btn--primary {
  background: linear-gradient(180deg, #d4af37 0%, #c9a227 60%, #a8841f 100%);
  color: #18181b;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.35);
}

.inscribe-btn--primary:hover {
  background: linear-gradient(180deg, #e0bb44 0%, #ceaa30 60%, #ad8920 100%);
}

.inscribe-text-preview {
  font-size: 16px;
  line-height: 1.2;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0,0,0,0.03);
  border: 1px dashed rgba(0,0,0,0.08);
  color: #18181b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  margin-bottom: 8px;
}

html.dark .inscribe-text-preview {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
  color: #f4f4f5;
}

/* Кнопка-триггер на карточках */
.inscribe-trigger {
  margin-top: 0.375rem;
  width: 100%;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  padding: 0.5rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px dashed rgba(201, 162, 39, 0.55);
  background: rgba(201, 162, 39, 0.06);
  color: #92400e;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.inscribe-trigger:hover {
  background: rgba(201, 162, 39, 0.14);
  border-color: rgba(201, 162, 39, 0.75);
}

html.dark .inscribe-trigger {
  color: #fcd34d;
  background: rgba(252, 211, 77, 0.06);
  border-color: rgba(252, 211, 77, 0.35);
}

html.dark .inscribe-trigger:hover {
  background: rgba(252, 211, 77, 0.14);
}

.inscribe-trigger-icon { margin-right: 6px; }

/* Кнопка-триггер в карточке истории (компактная) */
.inscribe-history-trigger {
  background: transparent;
  border: 0;
  color: #92400e;
  cursor: pointer;
  font-size: 10px;
  padding: 0;
}

html.dark .inscribe-history-trigger { color: #fcd34d; }
.inscribe-history-trigger:hover { color: #c9a227; }

/* Десктоп: мобильные элементы скрыты */
.inscribe-mobile-tabs,
.inscribe-sheet-handle,
.inscribe-mobile-toolbar { display: none; }
.inscribe-mobile-hint { margin: 0 0 10px; text-align: left; }
[data-mobile-tab].is-mobile-hidden { display: none !important; }

/* Мобильная оптимизация редактора надписей — bottom sheet + вкладки */
@media (max-width: 768px) {
  .inscribe-overlay {
    align-items: stretch;
    padding: 0;
  }

  .inscribe-shell {
    margin: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
  }

  .inscribe-header {
    padding: max(10px, env(safe-area-inset-top, 10px)) 12px 10px;
    gap: 8px;
  }
  .inscribe-title { font-size: 14px; }
  .inscribe-close { width: 44px; height: 44px; font-size: 22px; margin-left: auto; }

  .inscribe-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    grid-template-columns: unset;
  }

  .inscribe-stage {
    flex: 1 1 auto;
    min-height: 0;
    padding: 8px;
    order: 1;
  }

  .inscribe-mobile-toolbar {
    display: none;
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 5;
    gap: 6px;
    padding: 6px;
    border-radius: 14px;
    background: rgba(15, 17, 24, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
  .inscribe-mobile-toolbar.is-visible {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
  }
  .inscribe-mtb-btn {
    appearance: none;
    border: 0;
    border-radius: 10px;
    min-height: 44px;
    font-size: 18px;
    font-weight: 700;
    color: #fafafa;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
  }
  .inscribe-mtb-btn:active { transform: scale(0.96); background: rgba(255, 255, 255, 0.18); }
  .inscribe-mtb-btn--danger { color: #fecaca; background: rgba(239, 68, 68, 0.25); }

  .inscribe-side {
    order: 2;
    flex: 0 0 auto;
    border-left: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
    max-height: none;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
  }
  html.dark .inscribe-side {
    border-top-color: rgba(255, 255, 255, 0.08);
    background: #18181b;
  }

  .inscribe-sheet-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 8px 12px 4px;
    border: 0;
    background: transparent;
    color: #71717a;
    cursor: pointer;
    flex-shrink: 0;
  }
  .inscribe-sheet-handle-bar {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.18);
  }
  html.dark .inscribe-sheet-handle-bar { background: rgba(255, 255, 255, 0.22); }
  .inscribe-sheet-handle-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  .inscribe-mobile-tabs {
    display: flex;
    gap: 4px;
    padding: 0 10px 8px;
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .inscribe-mobile-tabs::-webkit-scrollbar { display: none; }
  .inscribe-mobile-tabs button {
    flex: 1 0 auto;
    min-width: 72px;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.03);
    color: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }
  html.dark .inscribe-mobile-tabs button {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
  }
  .inscribe-mobile-tabs button.is-active {
    border-color: #c9a227;
    background: rgba(201, 162, 39, 0.16);
    color: #92400e;
  }
  html.dark .inscribe-mobile-tabs button.is-active {
    color: #fcd34d;
    background: rgba(252, 211, 77, 0.14);
  }

  .inscribe-side--collapsed .inscribe-side-scroll {
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    pointer-events: none;
  }
  .inscribe-side--expanded .inscribe-side-scroll {
    max-height: min(48dvh, 400px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 1;
    pointer-events: auto;
    padding: 8px 12px 12px;
  }
  .inscribe-side.is-keyboard-open.inscribe-side--expanded .inscribe-side-scroll {
    max-height: min(38dvh, 320px);
  }

  .inscribe-section { margin-bottom: 12px; padding-bottom: 12px; }
  .inscribe-row { flex-wrap: wrap; row-gap: 4px; }
  .inscribe-row-label { flex: 0 0 100%; font-size: 12px; }
  .inscribe-color-grid { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .inscribe-crosses-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .inscribe-cross-thumb { min-height: 72px; padding: 10px; }
  .inscribe-epitaph { min-height: 44px; padding: 10px 12px; font-size: 13px; }
  .inscribe-add-btn { min-height: 48px; font-size: 14px; }
  .inscribe-tone-chip { min-height: 44px; font-size: 13px; }

  .inscribe-footer {
    order: 3;
    flex-shrink: 0;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom, 8px));
    flex-wrap: nowrap;
    gap: 8px;
    box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.06);
  }
  .inscribe-footer-info { display: none; }
  .inscribe-btn {
    flex: 1 1 0;
    min-height: 48px;
    padding: 12px 10px;
    font-size: 14px;
  }
  .inscribe-btn--primary { flex: 1.4 1 0; }

  .inscribe-input,
  .inscribe-textarea,
  .inscribe-select { font-size: 16px; padding: 10px 12px; }
  .inscribe-textarea { min-height: 72px; }

  .inscribe-layer-row { min-height: 48px; padding: 10px 12px; font-size: 13px; }
  .inscribe-layer-actions button { min-width: 44px; min-height: 44px; }
}

@media (max-width: 380px) {
  .inscribe-color-grid { grid-template-columns: repeat(5, 1fr); }
  .inscribe-mobile-tabs button { min-width: 64px; font-size: 12px; }
}

