/* 3D print shop — мягкая светлая тема (без «кислотной» яркости) */
:root {
  --bg: #d8dee8;
  --bg-subtle: #cfd6e2;
  --surface: #eef1f6;
  --surface-muted: #e8ecf3;
  --surface-solid: #e2e7ef;
  --text: #2a3544;
  --text-secondary: #5a6575;
  --muted: #7a8494;
  --accent: #4a6d9a;
  --accent-hover: #3d5d84;
  --accent-soft: rgba(74, 109, 154, 0.12);
  --accent-ring: rgba(74, 109, 154, 0.28);
  --sale: #2d6a4f;
  --sale-bg: rgba(45, 106, 79, 0.1);
  --border: rgba(42, 53, 68, 0.09);
  --border-strong: rgba(42, 53, 68, 0.14);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(42, 53, 68, 0.05), 0 3px 10px rgba(42, 53, 68, 0.05);
  --shadow-md: 0 2px 8px rgba(42, 53, 68, 0.06), 0 8px 20px rgba(42, 53, 68, 0.06);
  --shadow-card-hover: 0 6px 16px rgba(42, 53, 68, 0.08), 0 12px 28px rgba(42, 53, 68, 0.07);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --font-display: "Outfit", var(--font);
  --header-h: 4rem;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 70% at 50% -25%, rgba(74, 109, 154, 0.06), transparent 52%),
    linear-gradient(175deg, var(--bg-subtle) 0%, var(--bg) 42%, #d4dae5 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s var(--ease-out), opacity 0.15s;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Skip link — доступность */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 9999;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  transition: top 0.2s var(--ease-out);
}
.skip-link:focus {
  top: max(1rem, env(safe-area-inset-top, 0px));
  text-decoration: none;
}

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  /* safe-area: iPhone и др. с вырезом / индикатором домой */
  padding-left: calc(env(safe-area-inset-left, 0px) + clamp(1rem, 4.5vw, 1.75rem));
  padding-right: calc(env(safe-area-inset-right, 0px) + clamp(1rem, 4.5vw, 1.75rem));
}
.wide {
  max-width: 1040px;
}

/* Шапка */
.top {
  position: sticky;
  top: 0;
  z-index: 100;
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 1px solid var(--border);
  background: rgba(238, 241, 246, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset;
}
.top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  gap: 0.75rem;
}
.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}
.logo-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logo:hover {
  color: var(--accent-hover);
  text-decoration: none;
}
.logo::before {
  content: "";
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #5a7aa3, #6b7c99);
  opacity: 1;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(42, 53, 68, 0.15);
}
.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.nav a:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
  text-decoration: none;
  border-color: rgba(74, 109, 154, 0.22);
}

.main {
  padding: clamp(1.5rem, 4vw, 2.75rem) 0 calc(clamp(3rem, 6vw, 4.5rem) + env(safe-area-inset-bottom, 0px));
  min-height: calc(100vh - var(--header-h) - 120px);
}

/* Герой каталога */
.page-hero {
  margin-bottom: clamp(1.75rem, 4vw, 2.5rem);
  padding: clamp(1.25rem, 3vw, 2rem) 0;
}
.page-hero .eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}
.h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 0.65rem;
  color: var(--text);
}
.lead {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.125rem);
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 52ch;
}

/* Сетка карточек */
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: clamp(1rem, 2.5vw, 1.35rem);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}

.card {
  position: relative;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s, border-color 0.2s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(74, 109, 154, 0.18);
}
.card a {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  color: inherit;
  text-decoration: none;
}
.card a:hover {
  text-decoration: none;
}
.card a:focus-visible {
  outline: none;
}
.card a:focus-visible::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: calc(var(--radius-md) - 3px);
  border: 2px solid var(--accent);
  pointer-events: none;
  z-index: 2;
}

/* Превью в каталоге */
.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-solid);
  border-bottom: 1px solid var(--border);
}
.card-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.35s var(--ease-out);
}
.card:hover .card-img {
  transform: scale(1.04);
}
.card-media-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 8rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  background: linear-gradient(145deg, var(--surface-muted), var(--surface-solid));
}
.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.2rem 0.35rem;
}
.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  line-height: 1.3;
  color: var(--text);
}
.card-desc {
  flex: 1;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding: 0.85rem 1.2rem 1.05rem;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}
.card-cta {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.card a:hover .card-cta {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.price,
.price-row {
  margin: 0;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
}
.price-row.big {
  font-size: clamp(1.2rem, 3vw, 1.45rem);
}
.price-old {
  text-decoration: line-through;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.88em;
}
.price-sale {
  color: var(--sale);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.badge-sale {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--sale-bg);
  color: var(--sale);
  border: 1px solid rgba(45, 106, 79, 0.22);
}
.price-row .price {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Пустой каталог */
.empty-state {
  text-align: center;
  padding: clamp(2rem, 5vw, 3.5rem) 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  max-width: 36rem;
  margin: 0 auto;
}

/* Хлебные крошки */
.breadcrumb {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}
.breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.breadcrumb li:not(:last-child)::after {
  content: "/";
  opacity: 0.35;
  font-weight: 400;
  margin-left: 0.5rem;
  pointer-events: none;
}
.breadcrumb a {
  padding: 0.25rem 0.5rem;
  margin: -0.25rem -0.5rem;
  border-radius: 6px;
}
.breadcrumb a:hover {
  background: var(--accent-soft);
  text-decoration: none;
}
.breadcrumb [aria-current="page"] {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.25rem 0;
}

/* Страница товара */
.product-layout {
  display: grid;
  gap: clamp(1.5rem, 4vw, 2.5rem);
}
@media (min-width: 900px) {
  .product-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    align-items: start;
  }
}

.product-media {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + 0.75rem);
}
@media (max-width: 899px) {
  .product-media {
    position: static;
  }
}

.gallery {
  display: grid;
  gap: 0.85rem;
  margin: 0;
}
.gallery figure {
  margin: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.gallery img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(72vh, 560px);
  object-fit: contain;
  object-position: center;
  background: linear-gradient(180deg, var(--surface-muted) 0%, var(--surface-solid) 100%);
  transition: transform 0.35s var(--ease-out);
}
.gallery figure:hover img {
  transform: scale(1.015);
}

/* Галерея на странице товара: маркетплейс (миниатюры сбоку) + lightbox */
.mp-gallery.pg {
  display: block;
  gap: 0;
}
.mp-gallery-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: #fff;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.05),
    0 6px 20px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}
.mp-gallery-body--strip {
  display: grid;
  grid-template-columns: 4.75rem minmax(0, 1fr);
  align-items: stretch;
  min-height: 0;
}
.mp-thumbs-aside {
  background: linear-gradient(180deg, #eef1f6 0%, #e8ecf3 100%);
  border-right: 1px solid var(--border);
  padding: 0.45rem 0.35rem;
}
.mp-thumbs-strip {
  flex-direction: column;
  flex-wrap: nowrap;
  max-height: min(520px, 68vh);
  overflow-y: auto;
  overflow-x: hidden;
  gap: 0.45rem;
  scrollbar-width: thin;
}
.mp-thumb-btn {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  min-height: 0;
  max-height: 4.5rem;
}
.mp-thumb-btn img {
  object-fit: cover;
}
.mp-main-aside {
  padding: 0.65rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.mp-gallery-body--single {
  padding: 0.65rem 0.75rem 0.75rem;
}
.mp-gallery-body--single .pg-main {
  margin: 0;
}
.mp-gallery-hint {
  margin: 0;
  font-size: 0.8125rem;
}
@media (max-width: 899px) {
  .mp-gallery-body--strip {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  .mp-thumbs-aside {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--border);
    padding: 0.5rem 0.35rem;
  }
  .mp-thumbs-strip {
    flex-direction: row;
    flex-wrap: nowrap;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0.45rem;
    padding-bottom: 0.15rem;
  }
  .mp-thumb-btn {
    flex: 0 0 auto;
    width: 3.75rem;
    height: 3.75rem;
    max-height: none;
    aspect-ratio: 1;
  }
  .mp-main-aside {
    order: 1;
    padding-bottom: 0.35rem;
  }
}

/* Старый вертикальный блок галереи (если где-то останется без .mp-gallery) */
.pg:not(.mp-gallery) {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.pg-main-btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: zoom-in;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.pg-main-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.pg-main-btn img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(72vh, 560px);
  object-fit: contain;
  object-position: center;
  background: linear-gradient(180deg, var(--surface-muted) 0%, var(--surface-solid) 100%);
  vertical-align: middle;
}
.pg-hint {
  margin: 0.35rem 0 0;
  line-height: 1.45;
}
.pg-thumbs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.pg-thumbs > li {
  list-style: none;
  margin: 0;
  padding: 0;
}
.pg-thumb {
  display: block;
  margin: 0;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--surface);
  width: 4.25rem;
  height: 4.25rem;
  flex: 0 0 auto;
}
.pg-thumb:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.pg-thumb.is-active {
  border-color: var(--accent);
}
.pg-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pg-lightbox {
  border: 0;
  padding: 0;
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  background: transparent;
}
.pg-lightbox::backdrop {
  background: rgba(15, 18, 24, 0.82);
}
.pg-lb-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  box-sizing: border-box;
}
.pg-lb-close {
  position: absolute;
  top: calc(0.5rem + env(safe-area-inset-top, 0px));
  right: calc(0.5rem + env(safe-area-inset-right, 0px));
  z-index: 5;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(20, 24, 30, 0.65);
  color: #f1f5f9;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.pg-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 2.5rem;
  height: 3.25rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(20, 24, 30, 0.55);
  color: #f8fafc;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.pg-lb-prev {
  left: calc(0.35rem + env(safe-area-inset-left, 0px));
}
.pg-lb-next {
  right: calc(0.35rem + env(safe-area-inset-right, 0px));
}
.pg-lb-prompt {
  position: absolute;
  bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  margin: 0;
  padding: 0.35rem 0.75rem;
  max-width: min(36rem, 92vw);
  text-align: center;
  color: rgba(248, 250, 252, 0.88);
  background: rgba(12, 14, 18, 0.55);
  border-radius: 999px;
  pointer-events: none;
}
.pg-lb-stage {
  flex: 1;
  width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.pg-lb-stage:active {
  cursor: grabbing;
}
.pg-lb-img {
  max-width: 100%;
  max-height: min(88vh, 100%);
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
}

.product-info {
  padding: 0.25rem 0;
}
.product-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.stock-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.stock-badge.in {
  background: var(--sale-bg);
  color: var(--sale);
  border: 1px solid rgba(45, 106, 79, 0.22);
}
.stock-badge.out {
  background: rgba(120, 113, 108, 0.12);
  color: #6b5d52;
  border: 1px solid rgba(120, 113, 108, 0.22);
}

.bodytext {
  margin-top: 1.25rem;
  max-width: 58ch;
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--text-secondary);
}
.muted {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Подвал */
.foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1.75rem 0 calc(2rem + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-size: 0.875rem;
}
.foot-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.foot a {
  font-weight: 500;
}

/* ——— Админка ——— */
.admin-body {
  background: var(--bg);
  background-image: linear-gradient(180deg, var(--surface) 0%, var(--bg) 40%, var(--bg) 100%);
  min-height: 100vh;
}
.admin-wrap {
  max-width: 520px;
  margin: 2rem auto;
  padding-left: calc(env(safe-area-inset-left, 0px) + clamp(1rem, 4vw, 1.25rem));
  padding-right: calc(env(safe-area-inset-right, 0px) + clamp(1rem, 4vw, 1.25rem));
}
.admin-wrap.wide {
  max-width: 920px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 3vw, 2rem);
  box-shadow: var(--shadow-md);
}
.admin-panel + .admin-panel {
  margin-top: 1.25rem;
}
.admin-panel--flush {
  padding: 0 !important;
  overflow: hidden;
}
.admin-panel--flush .tbl {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.admin-head h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0;
}
.admin-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.admin-nav a {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.admin-nav a:hover {
  border-color: rgba(74, 109, 154, 0.3);
  color: var(--accent-hover);
  text-decoration: none;
}
.stack label {
  display: block;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.stack .field-hint {
  display: block;
  margin: 0.15rem 0 0.45rem;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.45;
  color: var(--muted);
  max-width: 52ch;
}
.stack .field-label-strong {
  font-weight: 600;
  color: var(--text-secondary);
}
.stack .field-block {
  margin-bottom: 0.85rem;
}
.stack .field-block label.chk {
  margin-bottom: 0;
}
.stack .field-block .field-hint {
  margin-top: 0.2rem;
  margin-bottom: 0;
}
.admin-callout {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(120, 113, 108, 0.1);
  border: 1px solid var(--border-strong);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.admin-callout strong {
  color: var(--text);
}

.admin-panel--photos-first {
  margin-bottom: 1.25rem;
}
.admin-photo-block {
  margin-bottom: 0.25rem;
}
.admin-photo-block__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.admin-photo-block__hr {
  margin: 1rem 0 0.25rem;
  border: 0;
  border-top: 1px solid var(--border);
}
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.admin-media-picker {
  margin-bottom: 0.25rem;
}
label.admin-media-zone {
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: 7.5rem;
  padding: 1rem 1.25rem;
  margin: 0.5rem 0 0.75rem !important;
  border: 2px dashed rgba(74, 109, 154, 0.35);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s,
    box-shadow 0.2s;
  text-align: center;
  font-weight: 400 !important;
  color: var(--text-secondary) !important;
}
label.admin-media-zone:hover {
  border-color: rgba(74, 109, 154, 0.55);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}
label.admin-media-zone:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
label.admin-media-zone.is-dragover {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
}
.admin-media-zone__inner {
  pointer-events: none;
  max-width: 22rem;
}
.admin-media-zone__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.4rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}
.admin-media-zone__title {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}
.admin-media-zone__hint {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

.admin-photo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 0.65rem;
  margin: 0.75rem 0 0;
  min-height: 0;
}
.admin-photo-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.admin-photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.admin-photo-tile__badge {
  position: absolute;
  top: 0.35rem;
  left: 0.35rem;
  z-index: 1;
  max-width: calc(100% - 2.5rem);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  line-height: 1.25;
}
.admin-photo-tile__badge--main {
  background: rgba(22, 101, 52, 0.88);
}
.admin-photo-tile__remove {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  z-index: 2;
  width: 1.65rem !important;
  height: 1.65rem !important;
  min-height: 1.65rem !important;
  margin: 0 !important;
  margin-top: 0 !important;
  padding: 0 !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.65) !important;
  background: rgba(15, 23, 42, 0.48) !important;
  background-image: none !important;
  color: #fff !important;
  font-size: 1rem !important;
  font-weight: 600;
  line-height: 1 !important;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  transition:
    background 0.15s,
    transform 0.12s;
}
.admin-photo-tile__remove:hover {
  filter: none !important;
  background: rgba(185, 28, 38, 0.92) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
  transform: scale(1.05);
}
.admin-photo-tile__remove:active {
  transform: scale(0.96);
}
.admin-photo-tile__name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.5rem 0.35rem 0.3rem;
  font-size: 0.65rem;
  line-height: 1.2;
  color: #f1f5f9;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(transparent, rgba(15, 23, 42, 0.75));
  pointer-events: none;
}
.admin-photo-count {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  min-height: 1.25em;
}

.img-cell .admin-saved-photo-del {
  width: 100%;
  margin-top: 0.45rem;
  padding: 0.42rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff !important;
  background-image: none !important;
  color: #64748b !important;
}
.img-cell .admin-saved-photo-del:hover {
  filter: none !important;
  background: #fef2f2 !important;
  color: #b91c1c !important;
  border-color: rgba(220, 38, 38, 0.35) !important;
}

.stack input,
.stack textarea,
.stack button {
  width: 100%;
  font: inherit;
}
.stack input,
.stack textarea {
  margin-top: 0.35rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.stack input:focus-visible,
.stack textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.stack button {
  margin-top: 0.65rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  border: 0;
  background: linear-gradient(135deg, var(--accent), #5a7aa3);
  color: #f8fafc;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.2s, transform 0.15s;
}
.stack button:hover {
  filter: brightness(1.05);
}
.stack button:active {
  transform: scale(0.99);
}

/* Кнопка удаления на превью — не наследовать ширину/градиент .stack button */
.stack .admin-photo-tile .admin-photo-tile__remove {
  width: 1.65rem !important;
  height: 1.65rem !important;
  min-height: 1.65rem !important;
  margin: 0 !important;
  margin-top: 0 !important;
  padding: 0 !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.65) !important;
  background: rgba(15, 23, 42, 0.48) !important;
  background-image: none !important;
  color: #fff !important;
  font-weight: 600 !important;
  font-size: 1rem !important;
}
.stack .admin-photo-tile .admin-photo-tile__remove:hover {
  filter: none !important;
  background: rgba(185, 28, 38, 0.92) !important;
}
.stack input.admin-media-input.visually-hidden {
  margin-top: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  box-shadow: none !important;
}

label.chk {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.chk input {
  width: auto;
  margin-right: 0;
}
.err {
  color: #dc2626;
  font-weight: 500;
}
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}
.tbl th,
.tbl td {
  padding: 0.75rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.tbl th {
  background: var(--surface-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.tbl tr:last-child td {
  border-bottom: 0;
}
.tbl code {
  font-size: 0.82rem;
  color: var(--accent-hover);
}
.tbl-muted {
  color: var(--muted);
  text-decoration: line-through;
  font-size: 0.88em;
  margin-right: 0.25rem;
}
.td-actions {
  white-space: nowrap;
}
.td-actions .inline-del {
  display: inline;
  margin: 0 0 0 0.65rem;
}
.danger-inline {
  color: #dc2626 !important;
}
.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.img-cell {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  padding: 0.5rem;
}
.img-cell img {
  width: 100%;
  height: auto;
  max-height: 180px;
  object-fit: contain;
  border-radius: 6px;
}
.linkbtn {
  background: transparent;
  color: var(--accent);
  border: 0;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  width: auto;
  font: inherit;
}
.danger {
  background: linear-gradient(135deg, #be123c, #9f1239);
  color: #fff;
}
hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}
.small {
  font-size: 0.85rem;
  max-width: 44rem;
  line-height: 1.55;
}
.turnstile-wrap {
  margin: 0.5rem 0;
}

/* ——— Мобильные телефоны и планшеты ——— */
@media (hover: none) {
  .card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
    border-color: var(--border);
  }
  .card:hover .card-img {
    transform: none;
  }
  .gallery figure:hover img {
    transform: none;
  }
}

@media (max-width: 640px) {
  :root {
    --header-h: 3.35rem;
  }

  .wrap {
    padding-left: calc(env(safe-area-inset-left, 0px) + max(1.35rem, 6.5vw));
    padding-right: calc(env(safe-area-inset-right, 0px) + max(1.35rem, 6.5vw));
  }

  .admin-wrap,
  .admin-wrap.wide {
    padding-left: calc(env(safe-area-inset-left, 0px) + max(1.35rem, 6.5vw));
    padding-right: calc(env(safe-area-inset-right, 0px) + max(1.35rem, 6.5vw));
    margin-top: 1.25rem;
    margin-bottom: 2rem;
  }

  .admin-panel {
    padding-inline: clamp(1rem, 4vw, 1.35rem);
  }

  .page-hero {
    margin-bottom: 1.25rem;
    padding-top: 0.25rem;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .card-body {
    padding: 0.85rem 1rem 0.25rem;
  }

  .card-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.75rem 1rem 0.9rem;
  }

  .card-cta {
    text-align: center;
    padding: 0.55rem 0.75rem;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .breadcrumb {
    font-size: 0.8125rem;
    margin-bottom: 1.1rem;
  }

  .breadcrumb a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.65rem;
  }

  .breadcrumb [aria-current="page"] {
    line-height: 1.35;
    word-break: break-word;
    white-space: normal;
    max-width: 100%;
  }

  .gallery img,
  .pg-main-btn img {
    max-height: min(52vh, 420px);
  }

  .bodytext {
    font-size: 1rem;
  }

  .foot-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .admin-head {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-nav {
    justify-content: flex-start;
  }

  .admin-nav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .td-actions {
    white-space: normal;
  }

  .td-actions .inline-del {
    display: block;
    margin: 0.5rem 0 0;
  }

  .stack button,
  .danger {
    min-height: 48px;
  }

  .linkbtn {
    min-height: 44px;
    padding: 0.35rem 0;
    display: inline-flex;
    align-items: center;
  }
}

@media (max-width: 380px) {
  .logo {
    font-size: 0.92rem;
  }

  .logo::before {
    width: 1.65rem;
    height: 1.65rem;
  }

  .h1 {
    font-size: 1.45rem;
  }
}

body {
  -webkit-tap-highlight-color: rgba(74, 109, 154, 0.12);
}
