:root {
  --bg: #0d0c0a;
  --surface: #17140f;
  --surface-2: #1e1a14;
  --line: rgba(255,255,255,0.08);
  --ink: #f4efe6;
  --muted: #9a9184;
  --faint: #6f695f;
  --tan: #d9b98a;
  --tan-deep: #c9a26c;
  --danger: #c97a6d;

  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', -apple-system, sans-serif;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 90px;
  position: relative;
}

/* Header */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 20px 4px;
}

.wordmark {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.01em;
}

.wordmark .dot { color: var(--tan); }

.tagline {
  margin: 2px 0 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dot-badge {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tan);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--line);
  display: block;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

main { padding: 0 20px; }

/* Upload card */
.upload-card {
  position: relative;
  margin-top: 18px;
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(217,185,138,0.35);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.2s;
}

.upload-glow {
  position: absolute;
  width: 220px;
  height: 220px;
  right: -60px;
  top: -60px;
  background: radial-gradient(circle, rgba(217,185,138,0.16), transparent 70%);
  pointer-events: none;
}

.upload-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--tan);
  color: #1a1610;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.upload-copy h2 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  margin: 0 0 4px;
}

.upload-copy p {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 240px;
}

.format-tags { display: flex; gap: 6px; }

.format-tags span {
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--muted);
}

/* Pills */
.pill-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 18px;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.pill-row::-webkit-scrollbar { display: none; }

.pill {
  flex-shrink: 0;
  padding: 9px 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.pill.is-active {
  background: var(--tan);
  color: #1a1610;
  border-color: var(--tan);
}

/* Sections */
.section { margin-top: 28px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h3 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.head-icon { color: var(--tan); }

.view-all {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 3px;
}

.loading-row {
  font-size: 13px;
  color: var(--faint);
  padding: 20px 0;
}

/* Recommended scroll */
.rec-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -20px;
  padding: 0 20px;
}

.rec-scroll::-webkit-scrollbar { display: none; }

.rec-card {
  flex-shrink: 0;
  width: 150px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  padding: 0;
  color: inherit;
}

.rec-card img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: var(--surface-2);
  display: block;
}

.rec-empty {
  width: 100%;
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11px;
  color: var(--faint);
  padding: 12px;
  background: var(--surface-2);
}

.rec-body { padding: 10px 12px 12px; }

.rec-title { font-size: 13px; font-weight: 600; margin: 0 0 2px; }
.rec-sub { font-size: 11px; color: var(--muted); margin: 0; }

/* Wardrobe strip (home page mini preview) */
.wardrobe-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -20px;
  padding: 0 20px;
}

.wardrobe-strip::-webkit-scrollbar { display: none; }

.wardrobe-thumb {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
}

.wardrobe-thumb img { width: 100%; height: 100%; object-fit: cover; }

.wardrobe-more {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.wardrobe-empty { font-size: 13px; color: var(--faint); }

/* Info row */
.info-row { margin-top: 24px; }

.info-card {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
}

.info-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tan);
  margin: 0 0 6px;
}

.info-body { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  padding: 12px 8px 18px;
  background: rgba(13,12,10,0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--faint);
}

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

/* Error / empty states */
.error { text-align: center; color: var(--danger); padding: 20px 0; font-size: 13px; }

/* ===== Wardrobe grid page ===== */
.wardrobe-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.w-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.w-card img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}

.w-card-empty {
  width: 100%;
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-size: 11px;
  background: var(--surface-2);
}

.w-card-body { padding: 10px 12px 12px; }

.w-card-title { font-size: 12px; font-weight: 600; margin: 0 0 6px; }

.w-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }

.w-tag {
  font-size: 9px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 20px;
}

.w-actions { display: flex; gap: 6px; }

.w-btn {
  flex: 1;
  padding: 7px 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.w-btn.edit { color: var(--tan); border-color: rgba(217,185,138,0.35); }
.w-btn.remove { color: var(--danger); border-color: rgba(201,122,109,0.35); }

/* ===== Modal (outfit detail + edit item) ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.is-open { opacity: 1; pointer-events: auto; }

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 20px 20px 28px;
  transform: translateY(16px);
  transition: transform 0.2s;
}

.modal-overlay.is-open .modal-sheet { transform: translateY(0); }

.modal-handle {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  margin: 0 auto 16px;
}

.modal-img {
  width: 100%;
  border-radius: var(--radius-md);
  aspect-ratio: 3/4;
  object-fit: cover;
  background: var(--surface-2);
  margin-bottom: 16px;
}

.modal-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 4px;
}

.modal-sub { font-size: 12px; color: var(--muted); margin: 0 0 16px; }

.modal-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.modal-item-name { font-weight: 600; }
.modal-item-meta { color: var(--muted); font-size: 11px; margin-top: 2px; }

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Edit form inside modal */
.edit-field { margin-bottom: 12px; }

.edit-field label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  margin-bottom: 5px;
}

.edit-field input, .edit-field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
}

.edit-save {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--tan);
  color: #1a1610;
  font-weight: 700;
  font-size: 13px;
  margin-top: 6px;
}

/* ===== Auth pages ===== */
.auth-page { max-width: 360px; margin: 0 auto; padding: 40px 20px; }

.auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }

.auth-form input {
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}

.auth-form input::placeholder { color: var(--faint); }

.auth-form button {
  padding: 13px;
  border-radius: 10px;
  border: none;
  background: var(--tan);
  color: #1a1610;
  font-weight: 700;
  font-size: 14px;
}

.switch-link { text-align: center; font-size: 13px; margin-top: 18px; color: var(--muted); }
.switch-link a { color: var(--tan); font-weight: 600; }

/* ===== Chat page ===== */
.chat-box {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 0;
}

.msg { max-width: 78%; padding: 11px 14px; border-radius: 16px; font-size: 13px; line-height: 1.45; }
.msg-user { align-self: flex-end; background: var(--tan); color: #1a1610; }
.msg-bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }

.chat-input-row { display: flex; gap: 8px; padding: 10px 0 18px; }

#chat-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

#send-btn {
  padding: 12px 18px;
  border-radius: 20px;
  border: none;
  background: var(--tan);
  color: #1a1610;
  font-weight: 700;
}

/* ===== Responsive: desktop / tablet ===== */
body {
  background: var(--bg);
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  width: 100%;
}

@media (min-width: 900px) {
  body {
    background: #050505;
    display: flex;
    justify-content: center;
  }

  .app {
    background: var(--bg);
    min-height: 100vh;
    box-shadow: 0 0 60px rgba(0,0,0,0.6);
  }

  .bottom-nav {
    position: sticky;
  }
}

@media (min-width: 900px) {
  .wardrobe-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1200px) {
  .wardrobe-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== Toasts ===== */
.toast-stack {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 420px;
  padding: 0 16px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }

.toast-success { border-color: rgba(150,200,150,0.3); }
.toast-error { border-color: rgba(201,122,109,0.4); color: #eecbc5; }
.toast-loading { border-color: rgba(217,185,138,0.35); }

.toast-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(217,185,138,0.25);
  border-top-color: var(--tan);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ===== Chat page polish ===== */
.app-chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding-bottom: 0;
}

.app-chat .topbar { flex: 0 0 auto; }

.app-chat .bottom-nav {
  position: static;
  flex: 0 0 auto;
  max-width: none;
  margin: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stylist-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tan);
  color: #1a1610;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msg p { margin: 0 0 6px; }
.msg p:last-child { margin-bottom: 0; }
.msg h4, .msg h5, .msg h6 {
  margin: 10px 0 4px;
  font-family: var(--serif);
  font-weight: 600;
}
.msg h4 { font-size: 15px; }
.msg h5 { font-size: 14px; }
.msg h6 { font-size: 13px; }
.msg ul { margin: 4px 0 8px; padding-left: 18px; }
.msg li { margin-bottom: 3px; }
.msg strong { font-weight: 700; }
.msg em { font-style: italic; }

.msg-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
}

.msg-typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  animation: bounce 1.2s infinite ease-in-out;
}

.msg-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.msg-typing .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-page {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 16px 12px;
}

#send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
}

#send-btn:disabled { opacity: 0.5; }

/* ===== Rec card media + favourite heart ===== */
.rec-media { position: relative; }

.fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(13,12,10,0.55);
  backdrop-filter: blur(4px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fav-btn.is-active { color: var(--danger); }

.rec-body {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 10px 12px 12px;
  color: inherit;
}

/* ===== Empty state (favourites) ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 20px 20px;
  color: var(--muted);
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tan);
  margin-bottom: 14px;
}

.empty-state p { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--ink); }
.empty-sub { font-size: 12px; font-weight: 400 !important; color: var(--muted) !important; max-width: 220px; }

.empty-cta {
  margin-top: 16px;
  padding: 10px 20px;
  border-radius: 20px;
  background: var(--tan);
  color: #1a1610;
  font-size: 13px;
  font-weight: 700;
}

.w-btn.view { color: var(--ink); }

/* ===== Profile page ===== */
.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 20px 8px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--tan);
  color: #1a1610;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.profile-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  margin: 0 0 2px;
}

.profile-sub { font-size: 12px; color: var(--muted); margin: 0; }

.profile-stats {
  display: flex;
  gap: 12px;
  padding: 20px;
}

.stat {
  flex: 1;
  text-align: center;
  padding: 16px 0;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
}

.stat-num {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 2px;
  color: var(--tan);
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.profile-actions { padding: 0 20px; }

.profile-btn {
  width: 100%;
  padding: 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.profile-btn.danger { color: var(--danger); border-color: rgba(201,122,109,0.35); }
