* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f7f7f4;
  --card: rgba(255, 255, 255, 0.82);
  --card-solid: #ffffff;
  --surface: rgba(255, 255, 255, 0.74);
  --surface-raised: rgba(255, 255, 255, 0.92);
  --surface-subtle: rgba(248, 250, 252, 0.76);
  --text: #1f2937;
  --text-soft: #374151;
  --muted: #6b7280;
  --line: rgba(15, 23, 42, 0.09);
  --primary: #202123;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --success: #2563eb;
  --danger: #dc2626;
  --warning: #d97706;
  --input-bg: rgba(255, 255, 255, 0.9);
  --input-bg-focus: #ffffff;
  --overlay: rgba(15, 23, 42, 0.52);
  --focus-ring: rgba(37, 99, 235, 0.14);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  --shadow-strong: 0 18px 44px rgba(15, 23, 42, 0.08);
  --radius: 24px;
  --motion-fast: 0.16s ease;
  --motion-medium: 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  --motion-slow: 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

body.dark {
  color-scheme: dark;
  --bg: #07090d;
  --card: rgba(17, 22, 29, 0.86);
  --card-solid: #111827;
  --surface: rgba(14, 19, 26, 0.82);
  --surface-raised: rgba(21, 28, 38, 0.96);
  --surface-subtle: rgba(148, 163, 184, 0.08);
  --text: #f8fafc;
  --text-soft: #e2e8f0;
  --muted: #aeb9ca;
  --line: rgba(226, 232, 240, 0.12);
  --primary: #f8fafc;
  --accent: #8bb7ff;
  --accent-2: #5f8dff;
  --success: #7dd3fc;
  --danger: #fb7185;
  --warning: #fbbf24;
  --input-bg: rgba(15, 23, 42, 0.72);
  --input-bg-focus: rgba(17, 24, 39, 0.92);
  --overlay: rgba(2, 6, 23, 0.72);
  --focus-ring: rgba(139, 183, 255, 0.2);
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.34);
  --shadow-strong: 0 28px 80px rgba(0, 0, 0, 0.52);
}

html,
body {
  min-height: 100%;
}

body {
  font-family: 'Manrope', 'Inter', system-ui, -apple-system, Arial, sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.04), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.26), transparent 22%),
    var(--bg);
  color: var(--text);
}

body.dark {
  background:
    radial-gradient(circle at 14% -10%, rgba(96, 165, 250, 0.18), transparent 34%),
    radial-gradient(circle at 86% 2%, rgba(45, 212, 191, 0.09), transparent 28%),
    linear-gradient(180deg, rgba(10, 14, 20, 0.98), rgba(5, 7, 11, 0.99)),
    var(--bg);
}

body.dark ::selection {
  background: rgba(139, 183, 255, 0.34);
  color: #ffffff;
}

body.dark * {
  scrollbar-color: rgba(148, 163, 184, 0.36) rgba(15, 23, 42, 0.36);
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  display: block;
  width: 100%;
}

/* Blur-up lazy load: изображение плавно появляется */
.lazy-img {
  filter: blur(6px);
  transform: scale(1.02);
  transition: filter var(--motion-slow), transform var(--motion-slow);
  will-change: filter, transform;
}

.lazy-img.loaded {
  filter: blur(0);
  transform: scale(1);
}

button,
.btn {
  border: none;
  cursor: pointer;
  transition: 0.2s ease;
  font: inherit;
}

/* ─── Button loading state ───────────────────────────────── */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.82;
  color: transparent !important;
}

.btn-loading > * {
  opacity: 0;
}

.btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(37, 99, 235, 0.3);
  border-top-color: #2563eb;
  animation: loading-spin 0.7s linear infinite;
}

/* On dark/solid buttons use white spinner */
.btn-dark.btn-loading::after,
.btn-danger.btn-loading::after,
[class*="btn-primary"].btn-loading::after {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
}

body.dark .btn-light,
body.dark button.btn-light,
body.dark a.btn-light,
body.dark .card button:not(.btn-dark):not(.btn-danger):not(.btn-accent):not(.lang-btn):not(.theme-toggle):not(.menu-toggle):not(.favorite-btn):not(.chat-attach-btn),
body.dark .card .btn:not(.btn-dark):not(.btn-danger):not(.btn-accent) {
  color: #f8fafc !important;
  border-color: rgba(148, 163, 184, 0.28) !important;
  background:
    radial-gradient(circle at top right, rgba(96, 165, 250, 0.18), transparent 44%),
    linear-gradient(135deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.96)) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
}

body.dark .btn-light:hover,
body.dark button.btn-light:hover,
body.dark a.btn-light:hover,
body.dark .card button:not(.btn-dark):not(.btn-danger):not(.btn-accent):not(.lang-btn):not(.theme-toggle):not(.menu-toggle):not(.favorite-btn):not(.chat-attach-btn):hover,
body.dark .card .btn:not(.btn-dark):not(.btn-danger):not(.btn-accent):hover {
  color: #ffffff !important;
  border-color: rgba(125, 174, 255, 0.42) !important;
  background:
    radial-gradient(circle at top right, rgba(96, 165, 250, 0.24), transparent 44%),
    linear-gradient(135deg, rgba(51, 65, 85, 0.98), rgba(15, 23, 42, 0.98)) !important;
}

body.dark .btn-light:disabled,
body.dark button.btn-light:disabled,
body.dark .btn-light[disabled],
body.dark button.btn-light[disabled],
body.dark .card button:disabled,
body.dark .card .btn:disabled,
body.dark .card button[disabled],
body.dark .card .btn[disabled] {
  color: rgba(226, 232, 240, 0.66) !important;
  border-color: rgba(148, 163, 184, 0.16) !important;
  background: rgba(30, 41, 59, 0.52) !important;
  box-shadow: none !important;
  opacity: 1 !important;
}

body.dark .btn-dark,
body.dark button.btn-dark,
body.dark a.btn-dark,
body.dark .btn-accent,
body.dark button.btn-accent,
body.dark a.btn-accent {
  color: #ffffff !important;
  border-color: rgba(125, 174, 255, 0.28) !important;
  background:
    radial-gradient(circle at top right, rgba(96, 165, 250, 0.3), transparent 44%),
    linear-gradient(135deg, #111827 0%, #1d4ed8 100%) !important;
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.24) !important;
}

body.dark .btn-dark:disabled,
body.dark button.btn-dark:disabled,
body.dark .btn-dark[disabled],
body.dark button.btn-dark[disabled],
body.dark .btn-accent:disabled,
body.dark button.btn-accent:disabled,
body.dark .btn-accent[disabled],
body.dark button.btn-accent[disabled] {
  color: rgba(226, 232, 240, 0.72) !important;
  border-color: rgba(148, 163, 184, 0.18) !important;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.78)) !important;
  box-shadow: none !important;
  opacity: 1 !important;
}

/* ─── Top page progress bar ─────────────────────────────── */
.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent, #2563eb), #60a5fa);
  z-index: 9999;
  border-radius: 0 2px 2px 0;
  opacity: 0;
  transition: width 0.28s ease, opacity 0.35s ease;
  pointer-events: none;
}

.page-progress.progress-running {
  opacity: 1;
}

.page-progress.progress-done {
  width: 100% !important;
  opacity: 0;
  transition: width 0.18s ease, opacity 0.4s ease 0.1s;
}

/* ─── Character counter ─────────────────────────────────── */
.char-counter {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  margin-top: 4px;
  transition: color 0.18s;
}

.char-counter.char-warn {
  color: #f59e0b;
}

.char-counter.char-over {
  color: var(--danger, #ef4444);
  font-weight: 600;
}

input,
textarea,
select {
  box-sizing: border-box;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  outline: none;
  font-size: 14px;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent, #2563eb);
  background: var(--input-bg-focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

body.dark input,
body.dark textarea,
body.dark select {
  background: var(--input-bg);
  border-color: rgba(226, 232, 240, 0.13);
  color: var(--text);
}

body.dark input:focus,
body.dark textarea:focus,
body.dark select:focus {
  background: var(--input-bg-focus);
  border-color: rgba(139, 183, 255, 0.62);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

body.dark input::placeholder,
body.dark textarea::placeholder {
  color: rgba(203, 213, 225, 0.58);
}

textarea {
  min-height: 130px;
  resize: vertical;
}

@media (max-width: 560px) {
  body {
    overflow-x: hidden;
  }

  :where(h1, h2, h3, p, li, label, small, strong, span, a) {
    overflow-wrap: break-word;
    word-break: normal;
  }

  :where(button, .btn) {
    overflow-wrap: normal;
    word-break: normal;
  }

  input,
  textarea,
  select,
  button {
    font-size: 16px;
  }
}

/* Page entrance animation */
@keyframes page-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.page {
  animation: page-in 0.18s ease-out both;
}

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

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.92);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.lightbox-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 16px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
  transform: scale(0.94);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  user-select: none;
}

.lightbox-overlay.open .lightbox-img {
  transform: scale(1);
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 20px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.14s;
  z-index: 1001;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* product detail image — show pointer so user knows it's clickable */
.product-detail-image {
  cursor: zoom-in;
}

/* Scroll-to-top button */
.scroll-top-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(16px);
  color: var(--text);
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.22s ease, transform 0.22s ease, background 0.16s ease;
  z-index: 900;
}

.scroll-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.scroll-top-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}


/* === Redesign pass: accessibility baseline === */
:where(a, button, .btn, input, textarea, select, [role="button"], [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:where(button, .btn, input, textarea, select):disabled {
  cursor: not-allowed;
}

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