/**
 * MagicDecor Design Discovery — CSS (Phase 18 + 19)
 * Pinterest-style masonry grid + inline detail view + enhanced search
 */

/* ── Reset & Page Container ─────────────────────── */

.mdss-discover-page {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 16px;
  color: #1a1a2e;
  -webkit-font-smoothing: antialiased;
}

.mdss-discover-page *,
.mdss-discover-page *::before,
.mdss-discover-page *::after {
  box-sizing: border-box;
}

/* ── Search Bar (Sticky) ────────────────────────── */

.mdss-discover-search-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 0;
  border-bottom: 1px solid #e5e7eb;
}

.mdss-discover-search-inner {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
}

.mdss-discover-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

#mdss-discover-search-input {
  width: 100%;
  padding: 14px 130px 14px 48px;
  border: 2px solid #e5e7eb;
  border-radius: 50px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}

#mdss-discover-search-input:focus {
  border-color: #9f1127;
  box-shadow: 0 0 0 3px rgba(159, 17, 39, 0.1);
}

#mdss-discover-search-input::placeholder {
  color: #9ca3af;
}

.mdss-discover-search-clear {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: #e5e7eb;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  color: #4b5563;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mdss-discover-search-clear:hover {
  background: #d1d5db;
}

/* ── Search Action Buttons (Voice + Camera) ─────── */

.mdss-search-action-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #9f1127;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: all 0.2s;
  padding: 0;
  box-shadow: 0 2px 8px rgba(159, 17, 39, 0.25);
}

.mdss-search-action-btn:hover {
  background: #7f0d1f;
  color: #fff;
  box-shadow: 0 3px 12px rgba(159, 17, 39, 0.35);
  transform: translateY(-50%) scale(1.08);
}

.mdss-voice-btn {
  right: 50px;
}

.mdss-camera-btn {
  right: 90px;
}

/* Voice listening state */
.mdss-voice-btn.listening {
  background: #9f1127;
  color: #fff;
  animation: mdss-pulse 1.5s ease-in-out infinite;
}

@keyframes mdss-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(159, 17, 39, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(159, 17, 39, 0); }
}

/* ── Popular Searches ────────────────────────────── */

.mdss-popular-searches {
  max-width: 640px;
  margin: 8px auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 4px;
}

.mdss-popular-label {
  font-size: 13px;
  color: #9ca3af;
  font-weight: 500;
  flex-shrink: 0;
}

.mdss-popular-searches-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mdss-popular-search-chip {
  padding: 4px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 50px;
  background: #fff;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.mdss-popular-search-chip:hover {
  border-color: #9f1127;
  color: #9f1127;
  background: #fdf2f4;
}

.mdss-popular-search-chip.pinned {
  border-color: #e8a0ab;
  background: #fdf2f4;
  color: #7f0d1f;
}

/* ── Toolbar: Sort + Filter Toggle ──────────────── */

.mdss-discover-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 12px;
  flex-wrap: wrap;
}

.mdss-discover-sort-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.mdss-sort-tab {
  padding: 8px 18px;
  border: 1px solid #e5e7eb;
  border-radius: 50px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.2s;
}

.mdss-sort-tab:hover {
  border-color: #9f1127;
  color: #9f1127;
}

.mdss-sort-tab.active {
  background: #9f1127;
  border-color: #9f1127;
  color: #fff;
}

.mdss-discover-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mdss-filter-toggle-btn,
.mdss-history-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 50px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.2s;
}

.mdss-filter-toggle-btn:hover,
.mdss-history-btn:hover {
  border-color: #9f1127;
  color: #9f1127;
}

.mdss-history-btn {
  padding: 8px 12px;
}

/* ── Main Content Layout ────────────────────────── */

.mdss-discover-content {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.mdss-discover-grid-wrapper {
  flex: 1;
  min-width: 0;
}

/* ── Filter Sidebar ─────────────────────────────── */

.mdss-discover-filters {
  width: 260px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  position: sticky;
  top: 80px;
  transition: all 0.3s;
  overflow: hidden;
}

.mdss-discover-filters.collapsed {
  width: 0;
  border: none;
  padding: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.mdss-filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
}

.mdss-filters-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.mdss-filters-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.mdss-filters-body {
  padding: 16px 20px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.mdss-filter-group {
  margin-bottom: 20px;
}

.mdss-filter-group h4 {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px 0;
}

.mdss-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mdss-filter-chip {
  padding: 6px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 50px;
  background: #fff;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.mdss-filter-chip:hover {
  border-color: #e8a0ab;
  background: #fdf2f4;
}

.mdss-filter-chip.active {
  background: #9f1127;
  border-color: #9f1127;
  color: #fff;
}

.mdss-filter-chip .count {
  font-size: 11px;
  opacity: 0.7;
}

.mdss-color-chip {
  min-width: 70px;
  text-align: center;
}

/* ── Image Mode Toggle ─────────────────────────── */

.mdss-image-mode-toggle {
  display: flex;
  border: 1px solid #1a1a2e;
  border-radius: 50px;
  overflow: hidden;
  background: #fff;
}

.mdss-img-mode-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.mdss-img-mode-btn.active {
  background: #1a1a2e;
  color: #fff;
}

.mdss-img-mode-btn:hover:not(.active) {
  background: #f3f4f6;
  color: #1a1a2e;
}

/* ── Detail Nav Bar ────────────────────────────── */

.mdss-detail-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.mdss-detail-nav-arrows {
  display: flex;
  gap: 8px;
}

.mdss-detail-nav-btn {
  padding: 8px 18px;
  border: 1px solid #e5e7eb;
  border-radius: 50px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.2s;
}

.mdss-detail-nav-btn:hover:not(:disabled) {
  border-color: #9f1127;
  color: #9f1127;
  background: #fdf2f4;
}

.mdss-detail-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mdss-filter-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
}

.mdss-apply-filters-btn {
  flex: 1;
  padding: 10px 16px;
  background: #9f1127;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.mdss-apply-filters-btn:hover {
  background: #7f0d1f;
}

.mdss-clear-filters-btn {
  padding: 10px 16px;
  background: #fff;
  color: #6b7280;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.mdss-clear-filters-btn:hover {
  border-color: #d1d5db;
  color: #374151;
}

/* ── Active Filters Display ─────────────────────── */

.mdss-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.mdss-active-filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: #fdf2f4;
  border: 1px solid #e8a0ab;
  border-radius: 50px;
  font-size: 13px;
  color: #7f0d1f;
}

.mdss-active-filter-badge .remove {
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  opacity: 0.7;
}

.mdss-active-filter-badge .remove:hover {
  opacity: 1;
}

/* ── Results Info ────────────────────────────────── */

.mdss-discover-results-info {
  font-size: 14px;
  color: #9ca3af;
  margin-bottom: 12px;
  min-height: 20px;
}

/* ── Masonry Grid ────────────────────────────────── */

.mdss-discover-grid {
  columns: 4 240px;
  column-gap: 16px;
}

/* ── Design Card ─────────────────────────────────── */

.mdss-design-card {
  break-inside: avoid;
  margin-bottom: 16px;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid #d1d5db;
}

.mdss-design-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  border-color: #9ca3af;
}

.mdss-card-image-wrapper {
  position: relative;
  overflow: hidden;
}

.mdss-card-image {
  width: 100%;
  display: block;
  object-fit: cover;
  transition: transform 0.3s;
}

.mdss-design-card:hover .mdss-card-image {
  transform: scale(1.03);
}

.mdss-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 50%, rgba(0,0,0,0.15) 100%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 12px;
}

.mdss-design-card:hover .mdss-card-overlay {
  opacity: 1;
}

.mdss-card-wishlist {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a2e;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.mdss-card-wishlist:hover {
  background: #fff;
  transform: scale(1.1);
}

.mdss-card-wishlist.wishlisted {
  color: #ef4444;
  background: #fff;
}

/* ── Loading ─────────────────────────────────────── */

.mdss-discover-loading {
  text-align: center;
  padding: 40px 0;
}

.mdss-discover-loading p {
  color: #9ca3af;
  font-size: 14px;
  margin-top: 12px;
}

.mdss-discover-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: #9f1127;
  border-radius: 50%;
  animation: mdss-spin 0.8s linear infinite;
  margin: 0 auto;
}

.mdss-discover-spinner.small {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

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

/* ── Empty State ─────────────────────────────────── */

.mdss-discover-empty {
  text-align: center;
  padding: 80px 20px;
  color: #9ca3af;
}

.mdss-discover-empty h3 {
  margin: 16px 0 8px;
  font-size: 20px;
  color: #4b5563;
}

.mdss-discover-empty p {
  font-size: 15px;
}

/* ── Inline Detail View (Phase 19) ────────────────── */

.mdss-discover-detail-view {
  background: #fff;
  border-radius: 20px;
  padding: 0;
  animation: mdss-detail-fade-in 0.3s ease;
}

@keyframes mdss-detail-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.mdss-detail-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 0;
}

.mdss-detail-back-btn:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #1a1a2e;
}

.mdss-detail-content {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 32px;
  margin-bottom: 40px;
}

.mdss-detail-image-section {
  position: sticky;
  top: 100px;
  align-self: start;
}

#mdss-detail-main-image {
  width: 100%;
  border-radius: 16px;
  display: block;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* ── Explore / Visual Search Button (Pinterest-style) ── */

.mdss-detail-explore-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 24px;
  border: none;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s, transform 0.15s;
  z-index: 5;
}

.mdss-detail-explore-btn:hover {
  background: rgba(0,0,0,0.85);
  transform: scale(1.05);
}

.mdss-detail-explore-btn svg {
  flex-shrink: 0;
}

.mdss-detail-info-section {
  padding: 8px 0;
}

#mdss-detail-title {
  margin: 0 0 12px 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
  color: #1a1a2e;
}

.mdss-detail-short-desc {
  font-size: 15px;
  line-height: 1.6;
  color: #6b7280;
  margin: 0 0 4px 0;
}

.mdss-detail-expand-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 14px;
  font-weight: 500;
  color: #9f1127;
  cursor: pointer;
  transition: color 0.2s;
  margin-bottom: 16px;
  display: inline-block;
}

.mdss-detail-expand-btn:hover {
  color: #7f0d1f;
  text-decoration: underline;
}

.mdss-detail-full-desc {
  font-size: 14px;
  line-height: 1.7;
  color: #4b5563;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #f9fafb;
  border-radius: 12px;
}

.mdss-detail-full-desc p {
  margin: 0 0 8px;
}

.mdss-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.mdss-detail-tag {
  padding: 5px 14px;
  background: #f3f4f6;
  border-radius: 50px;
  font-size: 13px;
  color: #6b7280;
  transition: all 0.15s;
}

.mdss-detail-tag:hover {
  background: #e5e7eb;
  color: #4b5563;
}

/* Detail Wishlist */

.mdss-detail-wishlist-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: 2px solid #e5e7eb;
  border-radius: 50px;
  background: #fff;
  font-size: 15px;
  font-weight: 500;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 24px;
}

.mdss-detail-wishlist-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.mdss-detail-wishlist-btn.wishlisted {
  border-color: #ef4444;
  color: #ef4444;
  background: #fef2f2;
}

/* Detail Order Section */

.mdss-detail-order-section {
  border-top: 1px solid #f3f4f6;
  padding-top: 20px;
}

.mdss-detail-order-section h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mdss-order-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.mdss-order-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
  border: 2px solid transparent;
  flex: 1;
  min-width: 0;
  justify-content: center;
}

.mdss-order-btn svg {
  flex-shrink: 0;
}

.mdss-order-wallpaper {
  background: #9f1127;
  color: #fff;
  border-color: #9f1127;
}

.mdss-order-wallpaper:hover {
  background: #7f0d1f;
  border-color: #7f0d1f;
}

.mdss-order-blinds {
  background: #0891b2;
  color: #fff;
  border-color: #0891b2;
}

.mdss-order-blinds:hover {
  background: #0e7490;
  border-color: #0e7490;
}

.mdss-order-canvas {
  background: #d97706;
  color: #fff;
  border-color: #d97706;
}

.mdss-order-canvas:hover {
  background: #b45309;
  border-color: #b45309;
}

.mdss-order-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  color: #6b7280;
  font-size: 14px;
}

/* ── Detail Mockup Gallery Carousel ─────────────── */

.mdss-detail-mockups-section {
  margin-bottom: 40px;
  border-top: 1px solid #f3f4f6;
  padding-top: 28px;
}

.mdss-detail-mockups-section h3 {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 600;
  color: #1a1a2e;
}

.mdss-detail-mockups-carousel {
  display: flex;
  overflow-x: auto;
  gap: 16px;
  padding-bottom: 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.mdss-detail-mockups-carousel::-webkit-scrollbar {
  height: 6px;
}

.mdss-detail-mockups-carousel::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 3px;
}

.mdss-detail-mockups-carousel::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.mdss-detail-mockups-carousel::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.mdss-mockup-item {
  flex: 0 0 75px;
  scroll-snap-align: start;
}

.mdss-mockup-item img {
  width: 100%;
  border-radius: 8px;
  display: block;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.mdss-mockup-item img:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

/* ── Detail Similar / More Like This ────────────── */

.mdss-detail-similar-section {
  border-top: 1px solid #f3f4f6;
  padding-top: 28px;
  margin-bottom: 20px;
}

.mdss-detail-similar-section h3 {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 600;
  color: #1a1a2e;
}

.mdss-detail-similar-grid {
  column-count: 4;
  column-gap: 14px;
}

.mdss-detail-similar-grid .mdss-design-card {
  break-inside: avoid;
  margin-bottom: 14px;
}

/* ── Pinterest-style Similar Card ──────────────── */

.mdss-similar-card {
  border: none;
  border-radius: 16px;
  box-shadow: none;
  background: #fff;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.mdss-similar-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.10);
  border-color: transparent;
}

.mdss-similar-card .mdss-card-image {
  width: 100%;
  display: block;
  border-radius: 16px 16px 0 0;
}

.mdss-similar-card-footer {
  padding: 8px 10px 10px;
}

.mdss-similar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.mdss-similar-tag {
  font-size: 11px;
  color: #6b7280;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.mdss-similar-actions {
  display: flex;
  gap: 4px;
}

.mdss-similar-order-btn {
  flex: 1;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 4px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: center;
}

.mdss-similar-order-btn:hover {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.mdss-detail-similar-loading {
  text-align: center;
  padding: 24px;
}

.mdss-no-similar {
  color: #9ca3af;
  font-size: 14px;
  text-align: center;
  padding: 16px;
}

/* ── History Drawer ──────────────────────────────── */

.mdss-history-drawer {
  position: fixed;
  inset: 0;
  z-index: 10001;
}

.mdss-history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
}

.mdss-history-content {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 360px;
  max-width: 90vw;
  background: #fff;
  box-shadow: -10px 0 40px rgba(0,0,0,0.2);
  animation: mdss-drawer-slide-in 0.25s ease;
  display: flex;
  flex-direction: column;
}

@keyframes mdss-drawer-slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.mdss-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #f3f4f6;
}

.mdss-history-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.mdss-history-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #9ca3af;
  cursor: pointer;
}

.mdss-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.mdss-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.mdss-history-item:hover {
  background: #f9fafb;
}

.mdss-history-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.mdss-history-item-info {
  flex: 1;
  min-width: 0;
}

.mdss-history-item-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #1a1a2e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mdss-history-item-time {
  display: block;
  font-size: 12px;
  color: #9ca3af;
  margin-top: 2px;
}

.mdss-history-empty {
  text-align: center;
  color: #9ca3af;
  padding: 40px 20px;
  font-size: 15px;
}

/* ── Back to Top ─────────────────────────────────── */

.mdss-back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #9f1127;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(159, 17, 39, 0.3);
  transition: all 0.2s;
}

.mdss-back-to-top:hover {
  background: #7f0d1f;
  transform: translateY(-2px);
}

/* ── Responsive ──────────────────────────────────── */

@media (max-width: 1280px) {
  .mdss-discover-grid {
    columns: 3 220px;
  }
}

@media (max-width: 1024px) {
  .mdss-discover-filters {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    z-index: 10002;
    border-radius: 0;
    border: none;
    box-shadow: 10px 0 40px rgba(0,0,0,0.2);
    transition: transform 0.3s, opacity 0.3s;
  }

  .mdss-discover-filters.collapsed {
    width: 300px;
    transform: translateX(-100%);
    opacity: 1;
    pointer-events: none;
  }

  .mdss-discover-grid {
    columns: 3 200px;
  }

  .mdss-detail-content {
    gap: 24px;
  }
}

@media (max-width: 768px) {
  .mdss-discover-page {
    padding: 0 8px;
  }

  .mdss-discover-grid {
    columns: 2 160px;
    column-gap: 10px;
  }

  .mdss-design-card {
    margin-bottom: 10px;
    border-radius: 12px;
  }

  /* Inline detail responsive */
  .mdss-detail-content {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .mdss-detail-image-section {
    position: relative;
  }

  #mdss-detail-title {
    font-size: 22px;
  }

  .mdss-order-buttons {
    flex-direction: column;
  }

  .mdss-order-btn {
    width: 100%;
  }

  .mdss-mockup-item {
    flex: 0 0 65px;
  }

  .mdss-detail-similar-grid {
    column-count: 3;
    column-gap: 10px;
  }

  /* Sort tabs */
  .mdss-discover-toolbar {
    padding: 8px 0;
  }

  .mdss-sort-tab {
    padding: 6px 14px;
    font-size: 13px;
  }

  /* History drawer */
  .mdss-history-content {
    width: 100%;
    max-width: 100%;
  }

  /* Search action buttons */
  .mdss-voice-btn {
    right: 48px;
  }

  .mdss-camera-btn {
    right: 88px;
  }

  #mdss-discover-search-input {
    padding: 12px 120px 12px 44px;
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .mdss-discover-grid {
    columns: 2 140px;
    column-gap: 8px;
  }

  .mdss-design-card {
    margin-bottom: 8px;
    border-radius: 10px;
  }

  .mdss-card-wishlist {
    width: 34px;
    height: 34px;
  }

  .mdss-card-wishlist svg {
    width: 18px;
    height: 18px;
  }

  #mdss-discover-search-input {
    padding: 12px 100px 12px 44px;
    font-size: 14px;
  }

  .mdss-search-action-btn {
    width: 28px;
    height: 28px;
  }

  .mdss-search-action-btn svg {
    width: 15px;
    height: 15px;
  }

  .mdss-mockup-item {
    flex: 0 0 55px;
  }

  .mdss-detail-similar-grid {
    column-count: 2;
    column-gap: 8px;
  }
}

/* ── Sentinel (invisible) ────────────────────────── */

.mdss-discover-sentinel {
  height: 1px;
  width: 100%;
}
