:root {
  --bg-primary: #0D0E11;
  --bg-surface: #15171C;
  --bg-elevated: #1D2027;
  --accent-gold: #C5A059;
  --accent-gold-glow: rgba(197, 160, 89, 0.25);
  --text-main: #F4F5F7;
  --text-muted: #8E929D;
  --border-light: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(197, 160, 89, 0.4);
  --safe-bottom: env(safe-area-inset-bottom, 20px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { background: var(--bg-primary); color: var(--text-main); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.app-wrapper { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; padding-bottom: calc(65px + var(--safe-bottom)); }
.header { padding: 14px 20px; background: var(--bg-surface); border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; }
.brand-name { font-weight: 800; letter-spacing: 2px; color: var(--accent-gold); font-size: 16px; }
.header-badge { font-size: 11px; color: var(--text-muted); background: rgba(255,255,255,0.05); padding: 4px 8px; border-radius: 6px; }

/* Сторис бар в разделе Мастерская */
.stories-bar {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  margin-bottom: 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.stories-bar::-webkit-scrollbar { display: none; }
.story-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex: 0 0 auto;
}
.story-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, #DFBA73 0%, #C5A059 50%, #8A6D3B 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(197, 160, 89, 0.25);
  transition: transform 0.2s ease;
}
.story-bar-item:active .story-ring { transform: scale(0.94); }
.story-ring.viewed { background: rgba(255, 255, 255, 0.15); box-shadow: none; }
.story-avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #14161C;
  border: 2px solid #0D0E11;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 24px;
}
.story-avatar-inner img { width: 100%; height: 100%; object-fit: cover; }
.story-label { font-size: 11px; color: var(--text-main); max-width: 68px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

.tab-content { display: none; padding: 12px 16px; flex: 1; }
.tab-content.active { display: block; }
.product-card { background: var(--bg-surface); border-radius: 16px; border: 1px solid var(--border-light); overflow: hidden; margin-bottom: 16px; }

/* Квадратный слайдер 1:1 */
.carousel-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
}
.carousel-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  cursor: grab;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-track.is-dragging { cursor: grabbing; scroll-snap-type: none !important; }
.carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.carousel-slide img, .carousel-slide video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(13, 14, 17, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--accent-gold);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
}
.carousel-arrow-prev { left: 10px; }
.carousel-arrow-next { right: 10px; }

.carousel-dots {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  z-index: 5;
}
.carousel-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.35); cursor: pointer; }
.carousel-dot.active { width: 20px; border-radius: 4px; background: var(--accent-gold); }

.badge-handmade {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(13, 14, 17, 0.85);
  border: 1px solid var(--border-gold);
  color: var(--accent-gold);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  z-index: 6;
}

.product-info { padding: 18px; }
.product-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.product-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 16px; min-height: 40px; }
.control-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; display: block; }

.chips-grid { display: flex; gap: 8px; margin-bottom: 16px; }
.chip { flex: 1; padding: 12px 6px; background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: 10px; color: var(--text-main); font-size: 13px; cursor: pointer; text-align: center; }
.chip.active { background: var(--accent-gold-glow); border-color: var(--accent-gold); color: var(--accent-gold); font-weight: 600; }
.btn-cta { width: 100%; padding: 14px; font-size: 14px; }

.deadline-box { background: rgba(197, 160, 89, 0.06); border: 1px dashed var(--border-gold); border-radius: 12px; padding: 14px; margin-bottom: 18px; }
.deadline-title { font-size: 13px; font-weight: 600; color: var(--accent-gold); margin-bottom: 8px; }
.date-input { width: 100%; background: var(--bg-primary); border: 1px solid var(--border-light); padding: 10px 12px; border-radius: 8px; color: var(--text-main); font-size: 13px; margin-bottom: 8px; }
.deadline-status { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.trust-block { background: var(--bg-surface); border-radius: 16px; border: 1px solid var(--border-light); padding: 20px; margin-bottom: 16px; }
.master-profile { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.master-avatar { width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--accent-gold); background: #252830; }
.guarantee-banner { background: var(--bg-elevated); border-left: 3px solid var(--accent-gold); padding: 12px 14px; border-radius: 0 8px 8px 0; font-size: 12px; line-height: 1.4; color: #E2E4E9; }

/* Чат */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 160px); }
.chat-header-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg-surface); border-radius: 12px 12px 0 0; border: 1px solid var(--border-light); border-bottom: none; }
.chat-status-dot { width: 8px; height: 8px; background: #30D158; border-radius: 50%; }
.chat-history { flex: 1; background: #090A0C; border: 1px solid var(--border-light); overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg-bubble { max-width: 82%; padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.4; }
.msg-client { align-self: flex-end; background: var(--bg-elevated); border: 1px solid var(--border-light); color: #F4F5F7; }
.msg-manager { align-self: flex-start; background: rgba(197, 160, 89, 0.12); border: 1px solid var(--border-gold); color: #FFF; }
.msg-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; text-align: right; }
.msg-img { max-width: 100%; border-radius: 8px; margin-top: 4px; }
.quick-chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; }
.quick-chip { white-space: nowrap; background: var(--bg-elevated); border: 1px solid var(--border-light); padding: 6px 12px; border-radius: 16px; font-size: 11px; color: var(--text-main); cursor: pointer; }
.chat-input-bar { display: flex; align-items: center; gap: 8px; padding: 10px; background: var(--bg-surface); border-radius: 0 0 12px 12px; border: 1px solid var(--border-light); }
.btn-media { background: transparent; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.chat-input-field { flex: 1; background: var(--bg-primary); border: 1px solid var(--border-light); padding: 10px 14px; border-radius: 20px; color: #FFF; font-size: 13px; outline: none; }
.btn-send { background: var(--accent-gold); border: none; width: 36px; height: 36px; border-radius: 50%; color: #000; font-weight: bold; cursor: pointer; }

/* Навигация */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto; height: calc(60px + var(--safe-bottom)); background: rgba(21, 23, 28, 0.95); backdrop-filter: blur(12px); border-top: 1px solid var(--border-light); display: flex; justify-content: space-around; align-items: center; padding-bottom: var(--safe-bottom); z-index: 100; }
.nav-btn { background: none; border: none; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px; cursor: pointer; }
.nav-btn.active { color: var(--accent-gold); font-weight: 600; }
.nav-icon { font-size: 18px; }

/* Сторис модалка */
.story-modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: #000; z-index: 9999; justify-content: center; align-items: center; }
.story-modal.active { display: flex; }
.story-container { position: relative; width: 100%; max-width: 480px; height: 100%; background: #000; overflow: hidden; display: flex; flex-direction: column; }
.story-progress-bar { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 4px; z-index: 30; }
.story-prog-segment { flex: 1; height: 3px; background: rgba(255, 255, 255, 0.25); border-radius: 2px; overflow: hidden; }
.story-prog-fill { width: 0%; height: 100%; background: #FFF; transition: width 0.1s linear; }
.story-header { position: absolute; top: 24px; left: 14px; right: 14px; display: flex; align-items: center; justify-content: space-between; z-index: 30; }
.story-header-info { display: flex; align-items: center; gap: 10px; }
.story-header-icon { font-size: 22px; }
.story-header-title { font-size: 14px; font-weight: 700; color: #FFF; }
.story-header-subtitle { font-size: 11px; color: rgba(255,255,255,0.7); }
.story-close-btn { background: rgba(0,0,0,0.4); border: none; color: #FFF; font-size: 18px; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.story-touch-area { position: absolute; top: 60px; bottom: 80px; width: 35%; z-index: 20; }
.story-touch-left { left: 0; }
.story-touch-right { right: 0; width: 65%; }
.story-content { width: 100%; height: 100%; position: relative; display: flex; align-items: center; justify-content: center; }
.story-content img, .story-content video { width: 100%; height: 100%; object-fit: cover; }
.story-caption { position: absolute; bottom: 85px; left: 16px; right: 16px; background: rgba(13, 14, 17, 0.75); backdrop-filter: blur(10px); border: 1px solid rgba(197, 160, 89, 0.3); padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.4; color: #FFF; z-index: 25; }
.story-footer { position: absolute; bottom: calc(16px + var(--safe-bottom)); left: 16px; right: 16px; z-index: 30; }
.story-cta-btn { width: 100%; padding: 14px; background: var(--accent-gold); border: none; border-radius: 12px; color: #000; font-weight: 700; font-size: 14px; cursor: pointer; }