:root {
  /* Color Palette */
  --color-bg: #f6f7f9;
  --color-surface: #ffffff;
  --color-surface-muted: #f0f2f5;
  --color-border-subtle: #e0e3e8;
  --color-border-strong: #c2c7d0;

  --color-text: #1f2933;
  --color-text-muted: #6b7280;
  --color-text-soft: #9ca3af;

  /* Brand & State Colors (subtle reds + trust neutrals) */
  --color-primary: #c62828; /* deep, confident red */
  --color-primary-soft: #fbecec;
  --color-primary-hover: #ab2020;
  --color-primary-ghost: rgba(198, 40, 40, 0.08);

  --color-success: #15803d;
  --color-success-soft: #e6f4ea;

  --color-warning: #b45309;
  --color-warning-soft: #fff4e5;

  --color-danger: #b91c1c;
  --color-danger-soft: #fde7e7;

  --color-info: #2563eb;
  --color-info-soft: #e3edff;

  /* Neutral Grays */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2933;
  --gray-900: #111827;

  /* Typography */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Font Sizes (rem-based for scalability) */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;

  /* Line Heights */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.7;

  /* Spacing Scale (0–96px) */
  --space-0: 0;
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */
  --space-20: 5rem;    /* 80px */
  --space-24: 6rem;    /* 96px */

  /* Radius */
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 999px;

  /* Shadows (subtle for trustworthy feel) */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 45px rgba(15, 23, 42, 0.12);

  /* Transitions */
  --transition-fast: 120ms ease-out;
  --transition-normal: 180ms ease-out;
  --transition-slow: 250ms ease-out;

  /* Layout */
  --layout-max-width: 1120px;
  --layout-max-width-wide: 1280px;
  --layout-gutter: var(--space-4);
}

/* =========================
   Reset / Normalize
   ========================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

body {
  margin: 0;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: none;
  background: none;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html:focus-within {
  scroll-behavior: smooth;
}

/* Remove default link underlines; handled in base styles */

/* =========================
   Base Styles
   ========================= */

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

main {
  min-height: 60vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: var(--line-height-tight);
  color: var(--color-text);
}

h1 {
  font-size: clamp(2rem, 2.4vw + 1.4rem, 2.5rem);
  margin-bottom: var(--space-4);
}

h2 {
  font-size: clamp(1.6rem, 1.8vw + 1.1rem, 2rem);
  margin-bottom: var(--space-3);
}

h3 {
  font-size: 1.25rem;
  margin-bottom: var(--space-2);
}

h4 {
  font-size: 1.125rem;
  margin-bottom: var(--space-2);
}

h5 {
  font-size: 1rem;
  margin-bottom: var(--space-1);
}

h6 {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
  color: var(--color-text-muted);
}

p {
  margin-bottom: var(--space-3);
  }

small {
  font-size: var(--font-size-sm);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-normal);
}

a:hover {
  color: var(--color-primary-hover);
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border-subtle);
  margin: var(--space-6) 0;
}

code,
pre {
  font-family: var(--font-mono);
}

/* =========================
   Accessibility & Motion
   ========================= */

:focus-visible {
  outline: 2px solid var(--color-info);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

@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;
  }
}

/* =========================
   Utilities
   ========================= */

/* Layout Containers */

.container {
  width: 100%;
  max-width: var(--layout-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--layout-gutter);
  padding-right: var(--layout-gutter);
}

.container--wide {
  max-width: var(--layout-max-width-wide);
}

.section {
  padding-top: var(--space-8);
  padding-bottom: var(--space-8);
}

.section--muted {
  background-color: var(--color-surface-muted);
}

/* Flex Helpers */

.flex {
  display: flex;
}

.inline-flex {
  display: inline-flex;
}

.flex-row {
  flex-direction: row;
}

.flex-column {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.gap-4 {
  gap: var(--space-4);
}

/* Grid Helpers */

.grid {
  display: grid;
}

.grid-auto {
  grid-auto-flow: row;
}

.grid-gap-4 {
  gap: var(--space-4);
}

.grid-gap-6 {
  gap: var(--space-6);
}

.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 960px) {
  .grid-cols-4 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
}

/* Spacing Utilities (vertical rhythm helpers) */

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.pt-4 { padding-top: var(--space-4); }
.pb-4 { padding-bottom: var(--space-4); }
.pt-6 { padding-top: var(--space-6); }
.pb-6 { padding-bottom: var(--space-6); }

/* Text Utilities */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.text-soft { color: var(--color-text-soft); }

/* Screen Reader Only */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =========================
   Components
   ========================= */

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font-size: var(--font-size-sm);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  background-color: var(--color-primary);
  color: #ffffff;
  box-shadow: var(--shadow-xs);
  transition:
    background-color var(--transition-normal),
    color var(--transition-normal),
    box-shadow var(--transition-normal),
    border-color var(--transition-normal),
    transform var(--transition-fast);
}

.button:hover {
  background-color: var(--color-primary-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

.button:focus-visible {
  outline: 2px solid var(--color-info);
  outline-offset: 2px;
}

.button--ghost {
  background-color: var(--color-primary-ghost);
  color: var(--color-primary);
  border-color: transparent;
  box-shadow: none;
}

.button--ghost:hover {
  background-color: var(--color-primary-soft);
}

.button--outline {
  background-color: transparent;
  color: var(--color-primary);
  border-color: var(--color-border-strong);
  box-shadow: none;
}

.button--outline:hover {
  border-color: var(--color-primary);
  background-color: var(--color-primary-soft);
}

.button--subtle {
  background-color: var(--gray-100);
  color: var(--color-text);
  border-color: var(--gray-200);
  box-shadow: none;
}

.button--subtle:hover {
  background-color: var(--gray-200);
}

.button--danger {
  background-color: var(--color-danger);
}

.button--danger:hover {
  background-color: #9f1414;
}

.button--sm {
  padding: 0.4rem 0.9rem;
  font-size: var(--font-size-xs);
}

.button--lg {
  padding: 0.8rem 1.6rem;
  font-size: var(--font-size-base);
}

.button[disabled],
.button--disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
  transform: none;
}

/* Inputs & Form Elements */

.input,
.select,
.textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-subtle);
  background-color: #ffffff;
  color: var(--color-text);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  transition:
    border-color var(--transition-normal),
    box-shadow var(--transition-normal),
    background-color var(--transition-normal);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--color-text-soft);
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--color-info);
  box-shadow: 0 0 0 1px var(--color-info-soft);
}

.input[aria-invalid='true'],
.textarea[aria-invalid='true'],
.select[aria-invalid='true'] {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 1px var(--color-danger-soft);
}

.input[disabled],
.textarea[disabled],
.select[disabled] {
  background-color: var(--gray-100);
  color: var(--color-text-soft);
  cursor: not-allowed;
}

label {
  display: inline-block;
  margin-bottom: var(--space-1);
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.form-help-text {
  margin-top: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-text-soft);
}

.form-error-text {
  margin-top: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-danger);
}

/* Card Component (for products, sellers, assurances) */

.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-subtle);
  box-shadow: var(--shadow-xs);
  padding: var(--space-4);
  transition:
    box-shadow var(--transition-normal),
    transform var(--transition-fast),
    border-color var(--transition-normal);
}

.card--interactive {
  cursor: pointer;
}

.card--interactive:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-border-strong);
}

.card-header {
  margin-bottom: var(--space-3);
}

.card-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.card-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.card-body {
  font-size: var(--font-size-sm);
}

.card-footer {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-subtle);
}

/* Pill / Badge (useful for buyer protection, verified seller, etc.) */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 500;
  border: 1px solid transparent;
}

.badge--success {
  background-color: var(--color-success-soft);
  color: var(--color-success);
  border-color: rgba(21, 128, 61, 0.14);
}

.badge--info {
  background-color: var(--color-info-soft);
  color: var(--color-info);
  border-color: rgba(37, 99, 235, 0.14);
}

.badge--neutral {
  background-color: var(--gray-100);
  color: var(--color-text-muted);
  border-color: var(--gray-200);
}

/* Image Wrapper for Product Thumbnails */

.media-cover {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  background-color: var(--gray-100);
}

.media-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.media-cover--hover-zoom:hover img {
  transform: scale(1.02);
}

/* Toast-like inline status message (e.g., for security / trust notices) */

.notice {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  border: 1px solid transparent;
  background-color: var(--gray-100);
  color: var(--color-text);
}

.notice--info {
  background-color: var(--color-info-soft);
  border-color: rgba(37, 99, 235, 0.18);
}

.notice--success {
  background-color: var(--color-success-soft);
  border-color: rgba(21, 128, 61, 0.18);
}

.notice--danger {
  background-color: var(--color-danger-soft);
  border-color: rgba(185, 28, 28, 0.18);
}

/* Header bar baseline (for consistent marketplace nav styling) */

.app-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border-subtle);
}

.app-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  height: 64px;
}

/* Footer baseline */

.site-footer {
  border-top: 1px solid var(--color-border-subtle);
  background-color: #ffffff;
  padding-top: var(--space-6);
  padding-bottom: var(--space-6);
  font-size: var(--font-size-sm);
  color: var(--color-text-soft);
}

/* Responsive helpers */

.hide-on-mobile {
  display: block;
}

@media (max-width: 640px) {
  .hide-on-mobile {
    display: none !important;
  }
}

.hide-on-desktop {
  display: none;
}

@media (max-width: 640px) {
  .hide-on-desktop {
    display: block;
  }
}
