* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

:root {
  --bg: #0a0a0c;
  --bg-elevated: #141417;
  --bg-card: #18181c;
  --border: #232327;
  --text: #f2f2f4;
  --text-dim: #9a9aa2;
  --text-faint: #5c5c64;
  --accent: #e8e8ec;
  --danger: #ff6b6b;
  --warn: #ffb547;
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-top: calc(env(safe-area-inset-top, 0px) + 56px + var(--tg-safe-top, 0px));
  --safe-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--tg-safe-bottom, 0px));
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* --- top bar with the Гарантия / Каталог switch --- */

#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  z-index: 20;
  padding: var(--safe-top) 16px 12px;
}

.segment {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}

.segment-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  background: var(--accent);
  border-radius: 999px;
  transition: transform 0.4s var(--ease-out);
}

.segment[data-active="1"] .segment-thumb {
  transform: translateX(100%);
}

.segment-btn {
  position: relative;
  z-index: 1;
  appearance: none;
  border: none;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 0;
  cursor: pointer;
  transition: color 0.3s var(--ease);
}

.segment-btn.active {
  color: #0a0a0c;
}

/* --- two pages side by side, slid horizontally; each keeps its own scroll --- */

#track {
  display: flex;
  width: 200%;
  height: 100%;
  height: 100dvh;
  transition: transform 0.45s var(--ease-out), filter 0.25s var(--ease);
  will-change: transform;
}

#track[data-active="1"] {
  transform: translateX(-50%);
}

.page {
  width: 50%;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 16px;
  padding-top: calc(var(--top-bar-height, 0px) + 12px);
  padding-bottom: calc(48px + var(--safe-bottom));
}

.page-head {
  padding: 4px 2px 16px;
}

.page-head h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.4;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- warranty --- */

.w-hero {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px 20px 20px;
  animation: rise 0.5s var(--ease) backwards;
}

.w-hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 232, 236, 0.14), transparent 70%);
  pointer-events: none;
}

.w-hero-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.w-hero-days {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-top: 10px;
}

.w-hero-days span {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-dim);
  margin-left: 6px;
}

.w-hero-text {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-top: 12px;
}

.w-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 26px 2px 10px;
}

.w-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.w-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  animation: rise 0.5s var(--ease) backwards;
}

.w-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
}

.w-item-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.w-item-text {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-top: 3px;
  white-space: pre-wrap;
}

.w-outro {
  margin-top: 22px;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
  animation: rise 0.5s var(--ease) backwards;
}

.w-outro .btn {
  margin-top: 14px;
}

/* --- catalog --- */

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.35s var(--ease);
  animation: rise 0.5s var(--ease) backwards;
}

.card:active {
  transform: scale(0.97);
}

.card-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 12px;
  overflow: hidden;
}

.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.card-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.empty {
  text-align: center;
  color: var(--text-faint);
  padding: 64px 16px;
  font-size: 14px;
}

/* --- device sheet --- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: calc(100dvh - var(--safe-top) + 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-elevated);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--border);
  padding-bottom: calc(28px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.35s var(--ease-out);
}

.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: translateY(0); }

.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(10, 10, 12, 0.7);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.gallery {
  position: relative;
  border-radius: 22px 22px 0 0;
  overflow: hidden;
  background: var(--bg-card);
}

.gallery-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.gallery-track::-webkit-scrollbar { display: none; }

.gallery-slide {
  flex: 0 0 100%;
  aspect-ratio: 1 / 1;
  max-height: 46dvh;
  scroll-snap-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 13px;
}

.gallery-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}

.gallery-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  transition: width 0.3s var(--ease-out), background 0.3s var(--ease);
}

.gallery-dot.active {
  width: 18px;
  background: #fff;
}

.sheet-body {
  padding: 18px 18px 0;
}

.sheet-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.block {
  margin-top: 18px;
}

.block-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.block-text {
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.block-text.placeholder {
  color: var(--text-faint);
}

.warning {
  display: flex;
  gap: 12px;
  background: rgba(255, 181, 71, 0.08);
  border: 1px solid rgba(255, 181, 71, 0.28);
  border-radius: var(--radius);
  padding: 14px;
}

.warning-icon {
  font-size: 18px;
  line-height: 1.3;
}

.warning-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--warn);
}

.warning-text {
  font-size: 14px;
  line-height: 1.55;
  margin-top: 3px;
  white-space: pre-wrap;
}

.consumables {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -18px;
  padding: 0 18px 4px;
  scroll-snap-type: x proximity;
}

.consumables::-webkit-scrollbar { display: none; }

.cons {
  flex: 0 0 116px;
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s var(--ease);
}

.cons:active { transform: scale(0.96); }

.cons-photo {
  aspect-ratio: 1 / 1;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-faint);
}

.cons-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cons-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  padding: 8px 10px 10px;
}

/* --- fullscreen photo --- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}

.lightbox.open { opacity: 1; }

.lightbox img {
  max-width: 100%;
  max-height: 78dvh;
  border-radius: 14px;
  transform: scale(0.94);
  transition: transform 0.3s var(--ease-out);
}

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

.lightbox-caption {
  margin-top: 14px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

/* --- buttons & admin (shared) --- */

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.25s var(--ease), transform 0.15s var(--ease);
  background: var(--accent);
  color: #0a0a0c;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn-block {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(24px + var(--safe-bottom));
  z-index: 95;
  background: #2a2a30;
  color: var(--text);
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.toast.show { opacity: 1; transform: translateY(0); }

/* --- instruction steps: numbered timeline --- */

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.step {
  position: relative;
  display: flex;
  gap: 14px;
  padding-bottom: 18px;
}

/* connector line between step numbers */
.step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 32px;
  bottom: 2px;
  width: 1px;
  background: var(--border);
}

.step:last-child { padding-bottom: 0; }

.step-num {
  flex-shrink: 0;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: var(--accent);
  color: #0a0a0c;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-body {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}

.step-text {
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.step-photo {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  margin-top: 10px;
  cursor: pointer;
}
