:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1b1f24;
  --muted: #6b7280;
  --border: #e5e7eb;
  /* Softened 2026-07-14 - the original #2563eb ("Грязно синий") was
     flagged as too harsh/vivid. Same hue, lower saturation/higher
     lightness. This is now the ONE accent color for the whole public
     site - buttons, links, focus rings, corner-fold photo accent (see
     Update-ProductPhotoFile in serve.ps1, kept in sync with this value)
     all reuse it, nothing else introduces a new hue. */
  --accent: #4e7fd1;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 18px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* site header */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.brand {
  color: inherit;
  text-decoration: none;
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}
.brand .brand-logo {
  height: 56px;
  width: auto;
  display: block;
}
.brand .brand-sub {
  font-weight: 400;
  color: var(--muted);
  font-size: 15px;
  margin-left: 8px;
}
.header-search {
  display: flex;
  flex: 1 1 420px;
  max-width: 580px;
  min-width: 200px;
}
.header-search input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 13px 18px;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 6px 0 0 6px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}
.header-search input::placeholder {
  color: var(--muted);
}
.header-search input:focus {
  outline: none;
  border-color: var(--accent);
}
.header-search button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 20px;
  border: 1px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
.header-search button:hover {
  opacity: 0.88;
}
.main-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.main-nav a {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
  background: var(--bg);
}
.main-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* site footer */
.site-footer {
  margin-top: auto;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.footer-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 40px 20px 20px;
  color: var(--muted);
  font-size: 14px;
}
.footer-brand {
  display: inline-flex;
  margin-bottom: 28px;
}
.footer-brand img {
  height: 44px;
  width: auto;
  display: block;
  opacity: .85;
  transition: opacity .15s ease;
}
.footer-brand:hover img {
  opacity: 1;
}
.footer-cols {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  margin-bottom: 28px;
}
.footer-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
}
.footer-col:last-child {
  max-width: 320px;
}
.footer-col a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.5;
  transition: color .15s ease;
}
.footer-col a:hover {
  color: var(--accent);
}
.footer-bottom {
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
}
.footer-bottom a {
  color: var(--muted);
  text-decoration: underline;
}
.footer-bottom a:hover {
  color: var(--accent);
}
main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  width: 100%;
  flex: 1;
}
.breadcrumb {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
main > h1 { font-size: 24px; margin: 0 0 20px; }
.pager {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  color: var(--muted);
  margin-top: 8px;
}
.pager a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}
.pager a:hover { border-color: var(--accent); color: var(--accent); }
h2.section-title {
  font-size: 18px;
  margin: 0 0 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

/* category cards */
.cat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: inherit;
  text-decoration: none;
}
.cat-card:hover { border-color: var(--accent); }
.cat-card .cat-name { font-size: 17px; font-weight: 600; }
.cat-card .cat-count { font-size: 14px; color: var(--muted); }

/* product cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card .thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--border);
  position: relative;
  overflow: hidden;
}
.card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card .thumb.captioned img {
  /* The source image already has a title plate baked into its bottom
     ~16% (see Update-ProductPhotoFile) - the card shows its own title
     text right below anyway, so scale the image up just enough and pin
     it to the top (clipped by .thumb's overflow:hidden) to crop that
     strip out of view here. */
  transform: scale(1.2);
  transform-origin: top center;
}
.card .thumb .imgcount {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 10px;
}
/* "Избранное" heart toggle on a card thumb - fixed dark badge background
   (not a theme variable) for the same reason .imgcount above is fixed:
   contrast needs to hold over an arbitrary product photo, not the page
   background, regardless of light/dark theme. */
.card .thumb .favorite-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  color: #fff;
  cursor: pointer;
  z-index: 1;
}
.card .thumb .favorite-btn:hover { background: rgba(0,0,0,.65); }
.card .thumb .favorite-btn.active { color: #ff5a7a; }
.card .thumb .favorite-btn.active svg path { fill: #ff5a7a; }
.card .body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.card .title { font-size: 17px; line-height: 1.35; font-weight: 600; margin: 0; }
.card .id { font-size: 13px; color: var(--muted); }
.attrs {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 8px;
  font-size: 14px;
  margin-top: 4px;
}
.attrs dt { color: var(--muted); white-space: nowrap; }
.attrs dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .desc {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: auto;
}

/* product detail page */
.product {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 32px;
}
.similar-products,
.section-divider {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
@media (max-width: 800px) {
  .product { grid-template-columns: 1fr; }
}
.gallery .main-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.gallery .main-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.zoomable {
  cursor: zoom-in;
}
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox.open {
  display: flex;
}
.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  cursor: default;
}
.lightbox .lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
}
.lightbox .lightbox-prev,
.lightbox .lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 14px 16px;
  border-radius: 6px;
}
.lightbox .lightbox-prev:hover,
.lightbox .lightbox-next:hover {
  background: rgba(255, 255, 255, 0.25);
}
.lightbox .lightbox-prev {
  left: 16px;
}
.lightbox .lightbox-next {
  right: 16px;
}
.gallery .thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.gallery .thumbs img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--border);
}
/* Admin-only front-end tools on the product page (requested 2026-07-17) -
   only ever rendered server-side when Test-BasicAuth passes for the
   request, so this markup/CSS is never even sent to a regular visitor.
   Deliberately distinct from the public .cta-btn language (dashed border,
   muted colors, small caps-ish label) - these are internal admin actions,
   not something a customer should mistake for part of the product page. */
.admin-front-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px dashed var(--muted);
  border-radius: 6px;
  background: var(--bg);
}
.admin-front-tools form { margin: 0; display: inline; }
.admin-flag-btn {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--muted);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.admin-flag-btn:hover { border-color: var(--accent); color: var(--accent); }
.admin-flag-btn.danger:hover { border-color: #dc2626; color: #dc2626; }
.admin-flag-done {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
  font-size: 13px;
}
.product-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.product-badges .badge {
  display: inline-block;
  font-size: 14px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}
.info h1 { font-size: 24px; line-height: 1.35; margin: 0 0 10px; }
.info .id { font-size: 15px; color: var(--muted); margin-bottom: 18px; }
.cta-btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 17px;
  font-weight: 600;
  margin: 24px 0 10px;
  vertical-align: middle;
}
.cta-btn.buy { background: var(--accent); color: #fff; }
.cta-btn.ask { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
/* "Избранное" toggle on the product page - button, not <a>, needs its own
   reset (border/background don't inherit .cta-btn's <a> defaults).
   Styled in the same language as .buy/.ask (requested 2026-07-17: "в стиле
   других кнопок") instead of the earlier one-off muted/red treatment:
   not-yet-favorited looks like .ask (accent outline), favorited looks like
   .buy (solid accent fill) - same two visual states the other CTAs
   already use, just toggled by click instead of being fixed per button.
   ⚠️ Bug found 2026-07-17 ("кнопка выше в строке, чем остальные") - this
   used to reset `font: inherit`, which (being the font SHORTHAND) wipes
   out font-size/line-height too, not just font-family - a <button> has no
   reason to inherit those from its container instead of getting .cta-btn's
   own 17px/600 like the <a> buttons next to it, and the resulting size
   mismatch is exactly what threw off the vertical alignment. Fixed by
   resetting only font-family (the one thing a <button> actually needs
   fixed - browsers give it a UI font, not the page's font-family) and
   letting font-size/font-weight/line-height fall through from .cta-btn
   normally, same as .buy/.ask do. */
.cta-btn.favorite-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: inherit;
  cursor: pointer;
}
.cta-btn.favorite-btn.active { background: var(--accent); color: #fff; }
.cta-btn.favorite-btn.active svg path { fill: #fff; }
.info h2 {
  font-size: 17px;
  margin: 24px 0 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.product-attrs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 16px;
}
.attr-row {
  display: flex;
  align-items: baseline;
  min-width: 0;
}
.attr-row .attr-name { color: var(--muted); white-space: nowrap; }
.attr-row .attr-dots {
  flex: 1 1 auto;
  border-bottom: 1px dotted var(--border);
  margin: 0 6px;
  min-width: 12px;
  transform: translateY(-4px);
}
.attr-row .attr-value {
  font-weight: 600;
  white-space: normal;
  overflow-wrap: break-word;
  min-width: 0;
  text-align: right;
}
.description {
  font-size: 17px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text);
  max-width: 760px;
}
.description p {
  margin: 0 0 16px;
}
.description p:last-child {
  margin-bottom: 0;
}
.description h2,
.description h3 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  white-space: normal;
}
.description h2 {
  font-size: 21px;
  margin: 32px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}
.description h2:first-child {
  margin-top: 0;
}
.description h3 {
  font-size: 18px;
  margin: 24px 0 10px;
  color: var(--accent);
}
.description strong {
  color: var(--accent);
  font-weight: 700;
}
.description ul,
.description ol {
  margin: 0 0 16px;
  padding-left: 26px;
  white-space: normal;
}
.description li {
  margin-bottom: 8px;
}
.description a {
  color: var(--accent);
}

/* /manufacturers - trilingual (RU/EN/ZH) three-column layout. Markup is
   admin-authored (site_pages, slug "manufacturers"), the classes below
   just style what's already there. This page's content needs full main
   width, not the 760px reading column .description enforces everywhere
   else - scoped override via :has() so About/Contacts/Legal/Ask keep
   their narrower, more readable column untouched. */
.description:has(.languages-grid) {
  max-width: none;
  /* .description defaults to white-space:pre-wrap so plain-text bodies
     (About/Contacts/Ask, no HTML tags) keep their manual line breaks.
     This page's body is actual indented HTML instead, so pre-wrap was
     rendering the source's own indentation as literal leading spaces on
     every line (bug found 2026-07-15) - HTML's own <p>/<br> already
     handle line breaks here, this page never needed pre-wrap. */
  white-space: normal;
}
.page-title {
  font-size: 24px;
  margin: 0 0 28px;
}
.languages-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
}
@media (max-width: 900px) {
  .languages-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}
.language-column {
  min-width: 0;
}
.content-block {
  margin-bottom: 28px;
}
.content-block:last-child {
  margin-bottom: 0;
}
.content-block h2 {
  font-size: 16px;
  margin: 0 0 10px;
  padding-bottom: 0;
  border-bottom: none;
}
.content-block p {
  font-size: 15px;
  margin: 0 0 10px;
}
.content-block ul {
  font-size: 15px;
  margin: 0 0 10px;
  padding-left: 22px;
}
.content-block li {
  margin-bottom: 6px;
}
.content-block .email {
  display: inline-block;
  margin: 2px 0 10px;
  font-weight: 600;
}
.language-column.chinese,
.language-column[lang="zh-CN"] {
  line-height: 1.9;
}
.pinyin-note {
  display: block;
  margin-top: 16px;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  color: var(--muted);
  white-space: normal;
}
.empty {
  color: var(--muted);
  font-size: 15px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --card-bg: #1e2226;
    --text: #e7e9ea;
    --muted: #9aa1a8;
    --border: #2c3136;
    --accent: #6ea8fe;
  }
  .card .thumb,
  .gallery .main-image,
  .gallery .thumbs img { background-color: #2a2e33; }
}
