:root {
  --primary: #c59b6d;
  --primary-hover: #b08759;
  --primary-light: #fbf6ef;
  --accent: #d9777f;
  --accent-light: #fef2f2;
  --bg-page: #fcfaf7;
  --bg-card: #ffffff;
  --text-main: #2d2a26;
  --text-muted: #736b63;
  --text-light: #9c948b;
  --border-color: #ede7de;
  --border-focus: #c59b6d;
  --success: #3e885b;
  --success-bg: #edf7f0;
  --shadow-sm: 0 2px 8px rgba(45, 42, 38, 0.04);
  --shadow-md: 0 8px 24px rgba(45, 42, 38, 0.08);
  --shadow-lg: 0 16px 40px rgba(45, 42, 38, 0.12);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* --- Auth Wrapper --- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top, #fffdfa 0%, #f7f2ea 100%);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px 36px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  animation: fadeIn 0.5s ease-out;
}

.wedding-rings-icon {
  font-size: 42px;
  margin-bottom: 12px;
}

.wedding-title {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 6px;
}

.input-group input,
.form-group input,
.form-group textarea,
.custom-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  transition: all 0.2s ease;
}

.input-group input:focus,
.form-group input:focus,
.form-group textarea:focus,
.custom-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(197, 155, 109, 0.15);
}

.error-msg {
  color: #c53030;
  font-size: 13px;
  background: #fff5f5;
  border: 1px solid #fed7d7;
  padding: 10px;
  border-radius: var(--radius-sm);
  text-align: center;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #f0ebe4;
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #e4ddd3;
}

.btn-outline-sm {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 13px;
}

.btn-outline-sm:hover {
  border-color: var(--text-main);
  color: var(--text-main);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* --- Main App Container --- */
.app-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* Header */
.app-header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.header-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 14px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
}

.header-title {
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin-bottom: 16px;
}

.header-intro {
  max-width: 680px;
  margin: 0 auto 20px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.7;
}

.header-actions {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

/* Controls & Filters */
.controls-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  width: 18px;
  height: 18px;
  color: var(--text-light);
}

.search-box input {
  width: 100%;
  padding: 14px 44px 14px 44px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--text-main);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(197, 155, 109, 0.15);
}

.clear-btn {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}

.clear-btn:hover {
  color: var(--text-main);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.availability-select-wrapper select {
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  background-color: #ffffff;
}

/* States */
.state-container {
  text-align: center;
  padding: 60px 20px;
  background: #ffffff;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  margin-top: 20px;
}

.state-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

/* --- Gift Grid & Cards --- */
.gifts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.gift-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
}

.gift-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.gift-card.completed {
  opacity: 0.85;
  background: #faf8f5;
}

.gift-image-wrapper {
  position: relative;
  width: 100%;
  height: 200px;
  background: #f4efe9;
  overflow: hidden;
}

.gift-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.gift-card:hover .gift-image {
  transform: scale(1.04);
}

.gift-image-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--text-light);
  background: linear-gradient(135deg, #f7f2eb 0%, #ebe2d5 100%);
}

.category-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.completed-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--success);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

.gift-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.gift-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
  line-height: 1.3;
}

.gift-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex-grow: 1;
}

.gift-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.gift-price {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
}

.gift-external-link {
  font-size: 12.5px;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.gift-external-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* Progress bar */
.gift-progress-section {
  margin-bottom: 18px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: #ede6dc;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-fill.full {
  background: var(--success);
}

.gift-card-actions {
  margin-top: auto;
}

.gift-card-actions .btn {
  width: 100%;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 42, 38, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  padding: 32px;
  position: relative;
  animation: slideUp 0.25s ease-out;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-header {
  margin-bottom: 20px;
}

.modal-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 6px;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.25;
}

.modal-info-box {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
}

.info-row {
  display: flex;
  justify-content: space-between;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.field-help {
  display: block;
  font-size: 11.5px;
  color: var(--text-light);
  margin-top: 4px;
}

.quantity-picker {
  display: flex;
  align-items: center;
  max-width: 140px;
}

.qty-btn {
  width: 38px;
  height: 38px;
  background: #f0ebe4;
  border: 1px solid var(--border-color);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.qty-btn:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.qty-btn:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.qty-btn:hover {
  background: #e4ddd3;
}

.quantity-picker input {
  width: 50px;
  height: 38px;
  text-align: center;
  border-left: none;
  border-right: none;
  border-radius: 0;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-main);
  color: #ffffff;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  animation: slideInRight 0.3s ease-out;
}

/* Footer */
.app-footer {
  text-align: center;
  margin-top: 60px;
  padding-top: 30px;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 14px;
}

.footer-sync {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Responsive */
@media (max-width: 640px) {
  .header-title {
    font-size: 34px;
  }
  .app-container {
    padding: 20px 14px 60px;
  }
  .gifts-grid {
    grid-template-columns: 1fr;
  }
  .filters-row {
    flex-direction: column;
    align-items: stretch;
  }
  .category-pills {
    overflow-x: auto;
    padding-bottom: 4px;
    flex-wrap: nowrap;
  }
  .pill {
    white-space: nowrap;
  }
  .modal-dialog {
    padding: 24px 18px;
  }
}
