:root {
  /* Colors - Clean, Editorial, Earthy Premium */
  --bg-color: #ffffff;
  --bg-surface: #f9fafb;
  --bg-surface-elevated: #ffffff;
  --primary: #2b4535; /* Deep, grounded forest/olive green */
  --primary-hover: #1e3325;
  --secondary: #e8edea; /* Soft sage background */
  --accent: #d4a373;
  --text-main: #111827;
  --text-muted: #4b5563;
  --border: #e5e7eb;
  
  /* Typography */
  --font-sans: 'Outfit', system-ui, -apple-system, sans-serif;
  
  /* Layout */
  --app-max-width: 440px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --transition-fast: 0.15s ease-out;
  --transition-smooth: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: #f0f0eb; /* Linen/Oatmeal desktop background */
  color: var(--text-main);
  /* Use block and margin auto instead of flex to prevent top cut-off on short screens */
  display: block;
  min-height: 100vh;
  padding: 20px 10px;
}

#app {
  width: 100%;
  max-width: var(--app-max-width);
  height: 100dvh;
  margin: 0 auto;
  background-color: var(--bg-color);
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

@media (min-width: 481px) {
  #app {
    height: 850px;
    max-height: calc(100vh - 40px); /* Leaves 20px padding top and bottom */
    border-radius: 24px;
    border: 1px solid rgba(0,0,0,0.05);
  }
}

/* ========== SCREEN MANAGEMENT ========== */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity var(--transition-smooth), transform var(--transition-smooth);
  background: var(--bg-color);
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  z-index: 10;
}

.screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  padding-bottom: 120px;
}

/* ========== TYPOGRAPHY & BUTTONS ========== */
h1, h2, h3 { font-family: var(--font-sans); font-weight: 600; letter-spacing: -0.01em; color: var(--text-main); }
p { line-height: 1.6; color: var(--text-muted); }

button {
  font-family: var(--font-sans);
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  outline: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 16px 24px;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-full { width: 100%; margin-top: 16px; }

.btn-secondary {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 16px 24px;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
  font-size: 16px;
  margin-top: 12px;
}

.btn-secondary:hover { background: var(--bg-surface); }

.btn-ghost {
  color: var(--text-muted);
  font-weight: 500;
  padding: 16px;
  margin-top: 8px;
}
.btn-ghost:hover { color: var(--text-main); }

.btn-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-back:hover { background: #e5e7eb; }

/* ========== SPLASH SCREEN ========== */
#splash-screen {
  justify-content: center;
  padding: 32px;
  background: var(--bg-color);
}

.splash-bg-orbs { display: none; /* Removed AI glowing orbs */ }

.splash-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* Left-aligned editorial look */
  text-align: left;
}

.splash-logo-wrap {
  width: 64px; height: 64px;
  background: var(--secondary);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 32px;
}

.splash-logo { width: 100%; height: 100%; object-fit: contain; }

.splash-title {
  font-family: var(--font-sans);
  font-size: 40px;
  margin-bottom: 16px;
  color: var(--text-main);
  line-height: 1.1;
  font-weight: 700;
}
.splash-title span { color: var(--primary); }

.splash-tagline { font-size: 18px; color: var(--text-muted); margin-bottom: 40px; }

.splash-features {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 48px;
  width: 100%;
}

.feature-pill {
  padding: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 500;
  font-size: 15px;
  color: var(--text-main);
}

.feature-icon { font-size: 24px; }

.splash-note { margin-top: 24px; font-size: 13px; color: var(--text-muted); align-self: center; }

/* ========== COMMON HEADERS ========== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-color);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}
.header-title { font-size: 16px; font-weight: 600; }
.header-spacer { width: 40px; }
.section-subtitle { margin-bottom: 24px; font-size: 15px; color: var(--text-muted); }

/* ========== STORE SELECTION ========== */
.store-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.store-card {
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
}
.store-card:hover { border-color: var(--text-muted); box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
.store-card:active { background: var(--bg-surface); }

.store-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}
.store-name { font-weight: 600; font-size: 15px; color: var(--text-main); }
.store-meta { font-size: 12px; color: var(--text-muted); }

.powered-by {
  margin-top: 40px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-surface);
  padding: 12px;
  border-radius: var(--border-radius-sm);
}
.powered-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
}

/* ========== LOGIN SCREEN ========== */
.login-body { display: flex; flex-direction: column; justify-content: center; }
.login-card {
  background: var(--bg-color);
  padding: 24px 0;
}
.login-store-badge {
  width: 64px; height: 64px; border-radius: 50%; background: var(--bg-surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  margin: 0 auto 16px;
}
.login-info { text-align: center; margin-bottom: 24px; color: var(--text-muted); }
.login-info strong { color: var(--text-main); }

.ecoswap-shield {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 13px; color: var(--primary);
  background: var(--secondary); padding: 8px; border-radius: var(--border-radius-sm); margin-bottom: 32px;
}
.input-group { margin-bottom: 20px; }
.input-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 8px; color: var(--text-main); }
.input-group input {
  width: 100%; padding: 14px 16px; border-radius: var(--border-radius-sm);
  background: var(--bg-color); border: 1px solid var(--border);
  color: var(--text-main); font-family: inherit; font-size: 15px;
  transition: border-color 0.2s;
}
.input-group input:focus { outline: none; border-color: var(--primary); }

.hide { display: none !important; }

/* ========== SHOPPING SCREEN ========== */
#shop-screen { background: var(--bg-surface); }
.shop-header { background: var(--bg-color); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.shop-header-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }

.url-bar {
  flex: 1; margin: 0 16px; background: var(--bg-surface); border-radius: var(--border-radius-sm);
  padding: 10px 16px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted);
}

.btn-cart { position: relative; color: var(--text-main); padding: 8px; }
.cart-badge {
  position: absolute; top: 0; right: 0; background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 600; width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.ecoswap-bar {
  background: var(--secondary); color: var(--primary); padding: 8px 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.ecoswap-bar-logo { width: 16px; height: 16px; }
.ecoswap-bar-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.ecoswap-bar-status { font-weight: 600; }

.shop-body { padding: 16px; overflow-y: auto; flex: 1; padding-bottom: 120px; }

.shop-categories { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 16px; scrollbar-width: none; }
.shop-categories::-webkit-scrollbar { display: none; }
.category-chip {
  padding: 8px 16px; background: var(--bg-color); border-radius: 100px; white-space: nowrap;
  font-size: 13px; font-weight: 500; border: 1px solid var(--border); cursor: pointer; color: var(--text-muted);
}
.category-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.shop-products { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.product-card {
  border: 1px solid var(--border); border-radius: var(--border-radius); overflow: hidden; background: var(--bg-color);
  display: flex; flex-direction: column;
}
.product-img { height: 120px; background: var(--bg-surface); display: flex; align-items: center; justify-content: center; font-size: 40px; }
.product-info { padding: 16px; display: flex; flex-direction: column; flex: 1; }
.product-brand { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.product-name { font-size: 14px; font-weight: 500; margin: 4px 0 12px; color: var(--text-main); line-height: 1.4; }
.product-price { font-size: 16px; font-weight: 600; color: var(--text-main); margin-top: auto; }
.btn-add {
  margin-top: 16px; background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-main);
  padding: 10px; border-radius: var(--border-radius-sm);
  font-weight: 500; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 0.2s, color 0.2s;
}
.btn-add.added { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ========== CART SCREEN ========== */
.cart-body { background: var(--bg-surface); }
.cart-item {
  display: flex; gap: 16px; padding: 16px; background: var(--bg-color);
  border-radius: var(--border-radius); border: 1px solid var(--border); margin-bottom: 12px;
}
.cart-item-img { width: 64px; height: 64px; background: var(--bg-surface); border-radius: var(--border-radius-sm); display: flex; align-items: center; justify-content: center; font-size: 28px; }
.cart-item-details { flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.cart-item-name { font-weight: 500; font-size: 14px; color: var(--text-main); line-height: 1.3; }
.cart-item-price { color: var(--text-main); font-weight: 600; font-size: 15px; margin-top: 8px;}
.cart-item-qty { display: flex; align-items: center; gap: 16px; margin-top: auto; align-self: flex-end; }
.qty-btn { width: 32px; height: 32px; background: var(--bg-surface); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-main); font-size: 16px; }

.cart-summary {
  margin-top: 32px; padding: 24px; background: var(--bg-color); border-radius: var(--border-radius); border: 1px solid var(--border);
}
.summary-row { display: flex; justify-content: space-between; margin-bottom: 12px; color: var(--text-muted); font-size: 14px; }
.summary-total { display: flex; justify-content: space-between; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 18px; font-weight: 600; color: var(--text-main); }

.btn-checkout { margin-top: 24px; }

/* ========== BOTTOM SHEET (ECOSWAP LOGIC) ========== */
.bottom-sheet-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(17, 24, 39, 0.4); backdrop-filter: blur(2px);
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity var(--transition-smooth);
}
.bottom-sheet-overlay.active { opacity: 1; pointer-events: auto; }

.bottom-sheet {
  position: absolute; bottom: 0; left: 0; width: 100%;
  background: var(--bg-color); border-top-left-radius: 24px; border-top-right-radius: 24px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.06); border-top: 1px solid var(--border);
  z-index: 101; transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; flex-direction: column; max-height: 90vh;
}
.bottom-sheet.active { transform: translateY(0); }

.bottom-sheet-handle { width: 36px; height: 4px; background: var(--border); border-radius: 4px; margin: 12px auto; }

.bottom-sheet-header { padding: 16px 24px 24px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--border); }
.bottom-sheet-brand { display: flex; gap: 16px; align-items: center; }
.sheet-logo { width: 48px; height: 48px; background: var(--secondary); border-radius: 12px; padding: 10px; }
.sheet-title { font-size: 18px; color: var(--text-main); font-weight: 600; }
.sheet-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.btn-close-sheet { background: var(--bg-surface); width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }

.bottom-sheet-body { padding: 24px; overflow-y: auto; flex: 1; background: var(--bg-surface); }

.swap-card {
  background: var(--bg-color); border: 1px solid var(--border); border-radius: var(--border-radius);
  padding: 20px; margin-bottom: 16px; position: relative;
}
.swap-card::before {
  content: ''; position: absolute; top: -1px; left: -1px; width: 4px; height: calc(100% + 2px); background: var(--primary); border-top-left-radius: var(--border-radius); border-bottom-left-radius: var(--border-radius);
}

.swap-comparison { display: flex; align-items: center; gap: 16px; }
.swap-item { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.swap-item-img { font-size: 32px; width: 64px; height: 64px; background: var(--bg-surface); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.swap-item-name { font-size: 13px; font-weight: 500; line-height: 1.3; color: var(--text-main); }
.swap-item-price { font-size: 14px; color: var(--text-muted); }
.swap-arrow { color: var(--primary); width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }

.swap-reason {
  margin-top: 20px; padding: 12px 16px; background: var(--secondary); border-radius: var(--border-radius-sm);
  font-size: 13px; display: flex; align-items: center; gap: 8px; color: var(--primary); font-weight: 500;
}

.bottom-sheet-footer { padding: 24px; border-top: 1px solid var(--border); background: var(--bg-color); }

.impact-summary { display: flex; gap: 16px; margin-bottom: 24px; }
.impact-stat { flex: 1; background: var(--bg-surface); padding: 16px; border-radius: var(--border-radius-sm); text-align: center; border: 1px solid var(--border); }
.impact-value { font-size: 20px; font-weight: 600; color: var(--primary); margin-bottom: 4px; }
.impact-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ========== CONFIRMATION SCREEN ========== */
.confirm-body { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-top: 40px; }
.confirm-animation { position: relative; margin-bottom: 32px; }
.confirm-circle {
  width: 80px; height: 80px; border-radius: 50%; background: var(--secondary);
  display: flex; align-items: center; justify-content: center; color: var(--primary);
}
.confirm-particles { display: none; /* removed noisy particles */ }

.confirm-title { font-size: 24px; margin-bottom: 8px; color: var(--text-main); font-weight: 600; }
.confirm-subtitle { font-size: 15px; margin-bottom: 24px; color: var(--text-muted); }

.confirm-points {
  background: rgba(43, 69, 53, 0.05);
  border: 1px solid rgba(43, 69, 53, 0.1);
  padding: 16px 24px;
  border-radius: var(--border-radius-sm);
  margin-bottom: 32px;
  display: inline-block;
}
.points-badge { font-size: 18px; font-weight: 700; color: var(--primary); margin-bottom: 4px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.points-desc { font-size: 13px; color: var(--text-muted); margin: 0; }

.confirm-receipt {
  width: 100%; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--border-radius);
  padding: 24px; margin-bottom: 32px; text-align: left;
}
.receipt-row { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 14px; color: var(--text-muted); }
.receipt-row:last-child { margin-bottom: 0; border-top: 1px solid var(--border); padding-top: 16px; font-weight: 600; color: var(--text-main); margin-top: 4px;}
