:root {
  --denim-blue: #4A7DB8;
  --deep-denim: #1F3A5F;
  --yellow: #F4C430;
  --yellow-hover: #e5b52a;

  --bg: #EFF2F6;
  --bg-card: #FFFFFF;
  --border: #E2E8F0;

  --text: #1F2933;
  --text-muted: #687280;

  --radius: 12px;
  --radius-lg: 20px;
  --radius-full: 100px;

  --shadow: 0 4px 20px rgba(31, 58, 95, 0.08);
  --shadow-lg: 0 8px 40px rgba(31, 58, 95, 0.12);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background: white;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding: 0;
}

.nowrap {
  white-space: nowrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--yellow);
  color: var(--deep-denim);
  /* Soft, glowing yellow shadow */
  box-shadow: 0 12px 24px -6px rgba(244, 196, 48, 0.6);
}

.btn-primary:hover {
  background: var(--yellow-hover);
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -6px rgba(244, 196, 48, 0.7);
}

.btn-outline {
  background: #FFFFFF;
  border: none;
  color: var(--deep-denim);
  /* Clean white button with soft shadow */
  box-shadow: 0 12px 24px -6px rgba(31, 58, 95, 0.08);
}

.btn-outline:hover {
  background: #FFFFFF;
  color: var(--denim-blue);
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -6px rgba(31, 58, 95, 0.12);
}

.btn-block {
  width: 100%;
}

.btn-cta {
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
  font-weight: 800;
}

/* Hero */
.hero {
  background-image: url('../images/background.png?v=2');
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
  padding: 4rem 2rem 8rem;
  position: relative;
  /* Remove old mask/gradients */
  background-color: transparent;
  /* Gentle S-curve wave mask */
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0,0 L100,0 L100,92 C70,100 30,85 0,95 Z' fill='black'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0,0 L100,0 L100,92 C70,100 30,85 0,95 Z' fill='black'/%3E%3C/svg%3E");
  mask-size: 100% 100%;
  -webkit-mask-size: 100% 100%;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
}

.hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  /* More space for text */
  grid-template-columns: 1.25fr 0.75fr;
  gap: 2rem;
  align-items: center;
  padding-left: 2rem;
}

.hero-content {
  max-width: 680px;
}

.hero h1 {
  font-size: 2.85rem;
  font-weight: 800;
  line-height: 1.08;
  color: var(--deep-denim);
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
  /* Enhanced text shadow */
  text-shadow: 0 2px 4px rgba(31, 58, 95, 0.05);
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
}

.hero-image {
  display: flex;
  justify-content: center;
  align-items: center;
}

.mascot {
  width: 580px;
  height: 400px;
  object-fit: cover;
  object-position: 50% 55%;
  /* Blend mascot better */
  filter: brightness(1.05) contrast(1.02) saturate(1.02) drop-shadow(0 20px 40px rgba(74, 125, 184, 0.18));
  animation: float 3s ease-in-out infinite;
  border-radius: 0;
  -webkit-mask-image: radial-gradient(circle at 50% 55%, #000 60%, transparent 85%);
  mask-image: radial-gradient(circle at 50% 55%, #000 60%, transparent 85%);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* App Card Layout */
.app-container {
  max-width: 1400px;
  margin: 2rem auto 4rem;
  padding: 0 2rem;
  position: relative;
  z-index: 10;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2rem;
  align-items: stretch;
}

.app-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(31, 58, 95, 0.1);
  border: 1px solid rgba(226, 232, 240, 0.8);
  overflow: hidden;
  height: 100%;
}

.measure-card {
  padding: 0;
}

.measure-form {
  padding: 3rem 2.5rem;
}

.measure-form h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--deep-denim);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.measure-form > p {
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-size: 1rem;
  line-height: 1.5;
}

/* Gender & Unit Toggle */
.gender-group,
.unit-group {
  background: #F8FAFC;
  padding: 0.4rem;
  border-radius: var(--radius-full);
  display: flex;
  border: 1px solid var(--border);
  width: 280px;
  max-width: 100%;
}

.gender-group {
  margin-bottom: 1rem;
}

.unit-group {
  margin-bottom: 2rem;
}

.toggle-pills {
  display: flex;
  gap: 0.25rem;
  width: 100%;
}

.toggle-pills label {
  flex: 1;
  text-align: center;
  padding: 0.6rem 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-pills input:checked + label {
  background: var(--denim-blue);
  color: white;
  box-shadow: 0 4px 12px rgba(74, 125, 184, 0.25);
  transform: translateY(-1px);
}

/* Measurement Guide Modal */
.measure-guide-trigger {
  text-align: center;
  margin-bottom: 1.5rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--denim-blue);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  transition: opacity 0.2s;
}

.btn-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(31, 58, 95, 0.6);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.show {
  display: flex;
  opacity: 1;
}

.modal-content {
  background-color: white;
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  text-align: center;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal.show .modal-content {
  transform: translateY(0);
}

.close-modal {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.close-modal:hover {
  color: var(--deep-denim);
}

.guide-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin-top: 1rem;
}

.modal h3 {
  color: var(--deep-denim);
  margin-bottom: 1rem;
}

/* Sliders */
.slider-group {
  margin-bottom: 1.5rem;
}

.slider-row {
  display: grid;
  grid-template-columns: 70px 1fr 60px;
  gap: 1.25rem;
  align-items: center;
}

.slider-label {
  font-weight: 700;
  color: var(--deep-denim);
  font-size: 1rem;
}

.slider-value {
  font-weight: 700;
  color: var(--denim-blue);
  background: #F0F7FF;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  text-align: center;
  border: 1px solid rgba(74, 125, 184, 0.2);
  font-size: 0.95rem;
  min-width: 50px;
}

.slider {
  width: 100%;
  height: 10px;
  border-radius: 10px;
  background: linear-gradient(to right, var(--denim-blue) 0%, var(--denim-blue) var(--value, 50%), #E2E8F0 var(--value, 50%), #E2E8F0 100%);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--yellow);
  cursor: pointer;
  border: 4px solid white;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.measure-form .btn {
  margin-top: 1.5rem;
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
}

.brands-card {
  padding: 2.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.brands-card h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--deep-denim);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.brands-card > p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 1rem;
}

.brand-search-wrap {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: center;
}

.brand-search {
  width: 100%;
  max-width: 200px;
  padding: 0.25rem 0.5rem;
  border: 1px solid #94A3B8;
  border-radius: 0;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  background: transparent;
  text-align: left;
}

.brand-search:focus {
  border-color: var(--denim-blue);
}

.brands-grid {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
  flex: 1;
  padding-right: 0.5rem;
  max-height: 500px;
}

/* Custom Scrollbar */
.brands-grid::-webkit-scrollbar {
  width: 5px;
}

.brands-grid::-webkit-scrollbar-track {
  background: transparent;
}

.brands-grid::-webkit-scrollbar-thumb {
  background-color: #CBD5E1;
  border-radius: 10px;
}

.brand-card {
  padding: 0.35rem;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.2s ease;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.brand-card:hover {
  color: var(--denim-blue);
}

.brand-card.selected {
  color: var(--denim-blue);
  font-weight: 800;
}

.result-card {
  display: flex;
  flex-direction: column;
  padding: 2.5rem;
}

#result-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Custom Scrollbar for Result */
#result-content::-webkit-scrollbar {
  width: 5px;
}

#result-content::-webkit-scrollbar-track {
  background: transparent;
}

#result-content::-webkit-scrollbar-thumb {
  background-color: #CBD5E1;
  border-radius: 10px;
}

.placeholder-result {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 1rem;
}

/* Responsive */
@media (max-width: 1100px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
}

.size-result {
  animation: fadeIn 0.3s ease;
}

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

.result-brand {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--deep-denim);
  margin-bottom: 0.25rem;
}

.result-fit {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--denim-blue);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.primary-size {
  padding: 2rem;
  background: linear-gradient(135deg, #FEF9E7 0%, #FDF3CD 100%);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.size-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.size-value {
  font-size: 3rem;
  font-weight: 800;
  color: var(--deep-denim);
  line-height: 1.1;
  white-space: nowrap;
}

.confidence {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.confidence-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.confidence-dot.high { background: #22c55e; }
.confidence-dot.medium { background: #f59e0b; }
.confidence-dot.low { background: #ef4444; }

.confidence-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.size-note {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.fit-selector {
  margin-bottom: 1.5rem;
  text-align: left;
}

.fit-selector > label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.fit-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.fit-option {
  padding: 0.4rem 0.75rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}

.fit-option:hover {
  border-color: var(--denim-blue);
  color: var(--denim-blue);
}

.fit-option.selected {
  border-color: var(--denim-blue);
  background: var(--denim-blue);
  color: white;
}

.inseam-result {
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.inseam-result .label {
  color: var(--text-muted);
  font-weight: 600;
}

.inseam-result .value {
  font-weight: 800;
  color: var(--deep-denim);
}

.alternatives {
  text-align: left;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.alternatives-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.alt-size {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.alt-size:last-child {
  border-bottom: none;
}

.alt-size .size {
  font-weight: 800;
  color: var(--denim-blue);
  font-size: 1.1rem;
  min-width: 2.5rem;
}

.alt-size .note {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.4;
}

.result-actions {
  margin-top: 1.5rem;
}

/* How Section */
.how-section {
  max-width: 1000px;
  margin: 0 auto;
  padding: 4rem 2rem;
  text-align: center;
}

.how-section h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--deep-denim);
  margin-bottom: 2.5rem;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.step {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.step-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.step h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--deep-denim);
  margin-bottom: 0.5rem;
}

.step p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem;
  background: var(--deep-denim);
  color: white;
  width: 100%;
}

.footer p:first-child {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.footer .disclaimer {
  font-size: 0.8rem;
  opacity: 0.7;
}

/* Loading */
.loading {
  display: flex;
  justify-content: center;
  padding: 3rem;
}

.loading::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--denim-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
  font-weight: 600;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: #22c55e;
  background: #ecfdf5;
  color: #166534;
}

/* Responsive */
@media (max-width: 1100px) {
  .app-grid {
    grid-template-columns: 1fr;
    margin-top: -4rem;
  }

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

@media (max-width: 900px) {
  .hero {
    padding: 3rem 1.5rem 5rem;
  }

  .hero-inner {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .hero-content {
    order: 1;
  }

  .hero-image {
    order: 0;
    margin-bottom: 1rem;
  }

  .mascot {
    max-width: 220px;
  }

  .hero h1 {
    font-size: 2rem;
  }

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

  .measure-section {
    margin-top: -2rem;
  }

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

  .measure-form {
    padding: 2rem;
  }

  .steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 1rem;
  }

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

  .measure-form {
    padding: 1.5rem;
  }

  .brands-section {
    padding: 2rem 1rem;
  }
}
