:root {
  --color-primary: #4a4a4a;
  --color-primary-dark: #333333;
  --color-bg: #f5f3ef;
  --color-surface: #ffffff;
  --color-surface-light: #faf9f7;
  --color-text: #4a4a4a;
  --color-text-secondary: #999999;
  --color-accent: #7a6e5d;
  --color-accent-blue: #7a6e5d;
  --color-accent-gold: #b8a99a;
  --color-success: #8b9a7e;
  --color-danger: #b55a4a;
  --color-gradient-start: #b8afa5;
  --color-gradient-end: #7a6e5d;
  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 2px;
  --font-mono: 'SF Mono', 'Menlo', 'Monaco', monospace;
  --shadow-sm: none;
  --shadow-md: none;
  --border-color: #e8e5e0;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#page-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--nav-height);
}

#bottom-nav {
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-surface);
  border-top: 1px solid rgba(0,0,0,0.06);
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color 0.2s;
  font-size: 10px;
  gap: 2px;
}

.nav-item.active { color: var(--color-accent); }

.nav-icon { font-size: 22px; }
.nav-label { font-size: 10px; }

.nav-icon-wrapper {
  position: relative;
  display: inline-block;
}

.cart-badge {
  position: absolute;
  top: -6px;
  right: -10px;
  background: var(--color-danger);
  color: white;
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.page {
  padding: 16px;
  animation: fadeIn 0.25s ease;
}

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

.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--color-surface);
  color: var(--color-text);
  padding: 12px 24px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.2s forwards;
  text-align: center;
  font-size: 14px;
}

.toast.achievement {
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

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

/* ===== Shop Page ===== */
.net-worth-section {
  text-align: center;
  padding: 20px 0 12px;
}

.net-worth-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.net-worth-value {
  font-size: 28px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--color-accent);
  letter-spacing: 1px;
}

.title-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  color: #fff;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
}

.nickname-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.progress-section {
  margin: 8px 16px 16px;
}

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

.progress-bar {
  height: 10px;
  background: rgba(0,0,0,0.06);
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-gradient-start), var(--color-gradient-end));
  border-radius: 5px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

.search-bar {
  margin: 0 16px 12px;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: var(--color-accent);
}

.search-bar::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

.category-tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar { display: none; }

.category-tab {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 12px;
  border: 1px solid rgba(0,0,0,0.06);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.category-tab.active {
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
  border-color: var(--color-accent);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 16px 24px;
}

.product-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border: 1px solid rgba(0,0,0,0.04);
  transition: transform 0.15s, border-color 0.15s;
  cursor: pointer;
  position: relative;
}

.product-card:active {
  transform: scale(0.97);
  border-color: var(--color-accent);
}

.product-emoji {
  font-size: 36px;
  margin-bottom: 8px;
}

.product-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  line-height: 1.3;
}

.product-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-accent);
  font-family: var(--font-mono);
  margin-bottom: 10px;
}

.product-add-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  border: none;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.2s;
  line-height: 1;
}

.product-add-btn:active {
  transform: scale(0.85);
  background: var(--color-gradient-end);
}

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.detail-modal {
  background: var(--color-surface);
  border-radius: 16px;
  padding: 24px;
  margin: 16px;
  text-align: center;
  max-width: 320px;
  width: 100%;
}

.detail-modal .product-emoji { font-size: 64px; }
.detail-modal .product-name { font-size: 18px; }
.detail-modal .product-price { font-size: 16px; }
.detail-modal .product-desc { font-size: 13px; color: var(--color-text-secondary); margin: 8px 0 16px; }

.detail-buy-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* ===== Cart Page ===== */
.cart-page { padding-bottom: 100px; }

.cart-page h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

.cart-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-secondary);
}

.cart-empty p { font-size: 16px; margin-bottom: 16px; }
.cart-empty button {
  padding: 10px 24px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--color-surface);
  border-radius: var(--radius);
  margin-bottom: 8px;
  border: 1px solid rgba(0,0,0,0.04);
}

.cart-item-emoji { font-size: 28px; flex-shrink: 0; }

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

.cart-item-name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.cart-item-unit-price {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.12);
  background: transparent;
  color: var(--color-text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:active { background: var(--color-accent); color: #fff; }

.qty-value {
  font-size: 15px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

.cart-item-total {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-accent);
  font-family: var(--font-mono);
  min-width: 60px;
  text-align: right;
}

.cart-footer {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom));
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-top: 1px solid rgba(0,0,0,0.06);
  padding: 12px 16px calc(12px + var(--safe-bottom));
  z-index: 99;
}

.cart-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
}

.cart-total-amount {
  font-size: 18px;
  font-weight: 800;
  color: var(--color-accent);
  font-family: var(--font-mono);
}

.cart-footer-btns {
  display: flex;
  gap: 8px;
}

.cart-footer-btns button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-clear {
  background: rgba(0,0,0,0.06);
  color: var(--color-text-secondary);
}

.btn-checkout {
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  color: #fff;
}

/* ===== Achievements Page ===== */
.achievements-page { padding-bottom: 24px; }

.title-section {
  background: linear-gradient(135deg, rgba(241,196,15,0.1), rgba(231,76,60,0.1));
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
  border: 1px solid rgba(122,110,93,0.1);
}

.current-title {
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.title-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  justify-content: center;
}

.title-chip {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid rgba(0,0,0,0.06);
  cursor: pointer;
}

.title-chip.worn {
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  color: #fff;
  border-color: transparent;
}

.spending-stats {
  text-align: center;
  margin-bottom: 20px;
}

.spending-big-num {
  font-size: 36px;
  font-weight: 900;
  color: var(--color-accent);
  font-family: var(--font-mono);
  letter-spacing: 2px;
}

.spending-sub {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.achievement-badge {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  border: 1px solid rgba(0,0,0,0.04);
  transition: opacity 0.2s;
}

.achievement-badge.locked { opacity: 0.4; }

.achievement-badge .badge-icon { font-size: 28px; }
.achievement-badge .badge-name { font-size: 11px; margin-top: 4px; font-weight: 500; }
.achievement-badge .badge-desc { font-size: 9px; color: var(--color-text-secondary); margin-top: 2px; line-height: 1.3; }

.category-breakdown {
  margin-bottom: 20px;
}

.category-breakdown h3 {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--color-text-secondary);
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.bar-label { width: 48px; text-align: right; flex-shrink: 0; }

.bar-track {
  flex: 1;
  height: 8px;
  background: rgba(0,0,0,0.06);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--color-gradient-start), var(--color-gradient-end));
}

.bar-pct { width: 40px; text-align: right; color: var(--color-text-secondary); flex-shrink: 0; }

.btn-share {
  display: block;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

/* ===== Share Page ===== */
.settlement-card {
  background: var(--color-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.settlement-header {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.settlement-amount {
  font-size: 24px;
  font-weight: 800;
  color: var(--color-accent);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}

.settlement-title {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.settlement-achievements {
  font-size: 12px;
  color: var(--color-success);
  margin-top: 4px;
}

.share-preview {
  background: #faf9f7;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
  border: 2px solid rgba(122,110,93,0.1);
}

.share-nickname {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 2px;
}

.share-title {
  font-size: 14px;
  color: var(--color-accent);
  margin-bottom: 16px;
}

.share-big-money {
  font-size: 42px;
  font-weight: 900;
  color: var(--color-accent);
  font-family: var(--font-mono);
}

.share-label {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.share-actions {
  display: flex;
  gap: 8px;
}

.share-actions button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-share-img {
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  color: #fff;
}

.btn-copy-link {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid rgba(0,0,0,0.1);
}

/* ===== Share Overlay ===== */
.share-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.share-overlay.active {
  display: flex;
}

.share-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
}

.share-card-img {
  max-width: 90vw;
  max-height: 70vh;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  object-fit: contain;
}

.share-hint {
  color: #ccc;
  font-size: 14px;
  margin-top: 16px;
  text-align: center;
}

.share-close {
  color: #ccc;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 10px 32px;
  border-radius: 24px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 16px;
}
