/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #1c1917;
  --text-muted: #78716c;
  --text-faint: #a8a29e;
  --accent: #1c1917;
  --accent-soft: #292524;
  --danger: #b91c1c;
  --success: #15803d;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow: 0 4px 16px rgba(28, 25, 23, 0.06);
  --shadow-lg: 0 10px 40px rgba(28, 25, 23, 0.12);

  --sidebar-w: 240px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ===== Layout ===== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--accent); color: white;
  display: grid; place-items: center;
  font-weight: 600; font-size: 13px; letter-spacing: 0.5px;
}
.brand-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  transition: background 120ms, color 120ms;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent); color: white; }
.nav-icon { font-size: 14px; width: 18px; text-align: center; opacity: 0.9; }

.sidebar-footer { display: flex; flex-direction: column; gap: 6px; padding-top: 16px; border-top: 1px solid var(--border); }

.main {
  padding: 36px 48px 80px;
  max-width: 1400px;
}

/* ===== Typography ===== */
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; font-weight: 600; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; gap: 24px; flex-wrap: wrap; }
.page-title-group { display: flex; flex-direction: column; gap: 4px; }
.page-subtitle { color: var(--text-muted); font-size: 14px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px; font-weight: 500;
  transition: all 120ms;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); border-color: var(--border); background: var(--surface); }
.btn-danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 24px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 500; font-size: 13px; color: var(--text); }
.field-hint { font-size: 12px; color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color 120ms, box-shadow 120ms;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(28, 25, 23, 0.06);
}
.textarea { min-height: 80px; resize: vertical; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  transition: all 120ms;
}
.check input { display: none; }
.check.checked { background: var(--accent); color: white; border-color: var(--accent); }
.check:hover:not(.checked) { border-color: var(--border-strong); }

/* ===== Closet grid ===== */
.toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.toolbar .input, .toolbar .select { padding: 7px 10px; font-size: 13px; width: auto; }
.toolbar .select { min-width: 130px; }
.toolbar .search { flex: 1; min-width: 220px; }
.toolbar-divider { width: 1px; align-self: stretch; background: var(--border); }
.toolbar-spacer { flex: 1; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 120ms, box-shadow 120ms, border-color 120ms;
  display: flex; flex-direction: column;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}
.card-image {
  aspect-ratio: 1;
  background: var(--surface-2);
  background-size: cover;
  background-position: center;
}
.card-body { padding: 10px 12px 12px; }
.card-title { font-weight: 500; font-size: 13.5px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { font-size: 12px; color: var(--text-muted); }
.card-tags { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11px;
  padding: 2px 7px;
  background: var(--surface-2);
  border-radius: 999px;
  color: var(--text-muted);
}

/* ===== Empty state ===== */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-title { font-size: 18px; color: var(--text); margin-bottom: 8px; font-weight: 600; }
.empty p { margin: 0 0 18px; }

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
}
[hidden] { display: none !important; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(28, 25, 23, 0.5);
  backdrop-filter: blur(4px);
}
.modal-panel {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 880px;
  width: calc(100vw - 80px);
  max-height: calc(100vh - 80px);
  overflow: auto;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: var(--surface-2);
  font-size: 20px; line-height: 1;
  color: var(--text-muted);
  display: grid; place-items: center;
  z-index: 1;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-content { padding: 32px; }

/* Item detail layout */
.item-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.item-detail-image {
  aspect-ratio: 1;
  background: var(--surface-2);
  background-size: cover; background-position: center;
  border-radius: var(--radius);
}
.item-detail-info h2 { margin-bottom: 4px; }
.item-detail-brand { color: var(--text-muted); margin-bottom: 20px; }
.detail-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.detail-row:last-of-type { border-bottom: none; }
.detail-row dt { color: var(--text-muted); }
.detail-row dd { margin: 0; font-weight: 500; text-align: right; }
.item-detail-actions { display: flex; gap: 8px; margin-top: 20px; }

/* ===== Upload area ===== */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: all 120ms;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: var(--surface-2);
}
.upload-zone-text { color: var(--text-muted); font-size: 13.5px; }
.upload-zone-hint { color: var(--text-faint); font-size: 12px; margin-top: 4px; }
.upload-preview {
  display: grid; grid-template-columns: 200px 1fr; gap: 24px;
  align-items: start;
}
.upload-preview-image {
  aspect-ratio: 1;
  background-size: cover; background-position: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.batch-bar {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.upload-or {
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  letter-spacing: 0.08em;
  margin: 18px 0;
  text-transform: uppercase;
}

.upload-search {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.upload-search .input { flex: 1; min-width: 0; }
.upload-search .row { flex-wrap: nowrap; }
.upload-search-title {
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 12px;
}
.upload-search-tip {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
}
.upload-search-tip kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text);
}

/* ===== Outfit builder ===== */
.builder { display: grid; grid-template-columns: 320px 1fr; gap: 28px; align-items: start; }
.builder-canvas {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: sticky; top: 24px;
}
.builder-occasion { margin-bottom: 18px; }
.outfit-slots {
  display: grid; gap: 10px;
  margin-top: 16px; min-height: 200px;
}
.outfit-slot {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.outfit-slot-thumb {
  width: 48px; height: 48px;
  border-radius: 6px;
  background: var(--surface);
  background-size: cover; background-position: center;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.outfit-slot-info { flex: 1; min-width: 0; }
.outfit-slot-name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.outfit-slot-meta { font-size: 11.5px; color: var(--text-muted); }
.outfit-slot-remove {
  width: 24px; height: 24px; border-radius: 50%;
  border: none; background: transparent;
  color: var(--text-faint); font-size: 16px;
}
.outfit-slot-remove:hover { background: var(--border); color: var(--danger); }

.builder-picker .toolbar { margin-bottom: 18px; }
.builder-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.builder-grid .card-image { aspect-ratio: 1; }
.builder-grid .card-body { padding: 8px 10px 10px; }
.builder-grid .card-title { font-size: 12.5px; }
.builder-grid .card-meta { font-size: 11px; }
.builder-grid .card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* Outfits list */
.outfits-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.outfit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 120ms;
}
.outfit-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.outfit-card-thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 12px; }
.outfit-card-thumb {
  aspect-ratio: 1;
  background: var(--surface-2);
  background-size: cover; background-position: center;
  border-radius: 4px;
}
.outfit-card-title { font-weight: 600; font-size: 14px; }
.outfit-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: flex; gap: 8px; }
.occasion-badge {
  display: inline-block;
  padding: 2px 9px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text);
}

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

/* ===== Sections ===== */
.section { margin-bottom: 28px; }
.section-title {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* Stats row */
.stats-row { display: flex; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; min-width: 140px; }
.stat-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* utility */
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.row { display: flex; gap: 8px; align-items: center; }
.right { margin-left: auto; }
0px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

/* ===== Sections ===== */
.section { margin-bottom: 28px; }
.section-title {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* Stats row */
.stats-row { display: flex; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; min-width: 140px; }
.stat-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* utility */
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.row { display: flex; gap: 8px; align-items: center; }
.right { margin-left: auto; }

/* ===== Progress overlay ===== */
.progress-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(28, 25, 23, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
}
.progress-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 32px;
  min-width: 360px;
  max-width: 480px;
}
.progress-title { font-weight: 600; font-size: 16px; margin-bottom: 14px; }
.progress-bar-track {
  height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden;
  margin-bottom: 10px;
}
.progress-bar-fill {
  height: 100%; background: var(--accent);
  width: 0%; transition: width 200ms;
}
.progress-detail { font-size: 13px; color: var(--text-muted); }

/* ===== Review banner ===== */
.review-banner {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.review-banner-text { flex: 1; }
.review-banner-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.review-banner-sub { font-size: 12.5px; color: var(--text-muted); }

/* ===== Photo gallery in detail/edit modals ===== */
.gallery {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gallery-main {
  aspect-ratio: 1;
  background: var(--surface-2);
  background-size: cover;
  background-position: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: zoom-in;
  position: relative;
  transition: transform 120ms;
}
.gallery-main:hover { transform: scale(1.005); }
.gallery-thumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.gallery-thumb {
  width: 56px; height: 56px;
  border-radius: 6px;
  background-size: cover; background-position: center;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 120ms;
  position: relative;
}
.gallery-thumb.active { border-color: var(--accent); }
.gallery-thumb:hover { border-color: var(--border-strong); }
.gallery-thumb-cover-badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 10px;
  display: grid; place-items: center;
  border: 2px solid var(--surface);
}
.gallery-thumb-actions {
  position: absolute;
  bottom: 2px; left: 2px; right: 2px;
  display: flex; gap: 2px;
  opacity: 0;
  transition: opacity 120ms;
}
.gallery-thumb:hover .gallery-thumb-actions { opacity: 1; }
.gallery-thumb-action {
  flex: 1;
  height: 18px;
  border: none;
  border-radius: 3px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 10px;
  cursor: pointer;
}
.gallery-thumb-action:hover { background: rgba(0,0,0,0.9); }
.gallery-thumb-action.remove:hover { background: var(--danger); }

.gallery-add-btn {
  width: 56px; height: 56px;
  border-radius: 6px;
  border: 2px dashed var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  flex-shrink: 0;
  display: grid; place-items: center;
  transition: all 120ms;
}
.gallery-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface-2);
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(10, 10, 10, 0.92);
  display: flex; align-items: center; justify-content: center;
}
.lightbox-image {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  user-select: none;
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255,255,255,0.12);
  border: none;
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 120ms;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255,255,255,0.22); }
.lightbox-close {
  top: 20px; right: 20px;
  width: 40px; height: 40px;
  font-size: 24px;
}
.lightbox-prev,
.lightbox-next {
  top: 50%; transform: translateY(-50%);
  width: 50px; height: 50px;
  font-size: 22px;
}
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }
.lightbox-counter {
  position: absolute;
  bottom: 24px;
  left: 50%; transform: translateX(-50%);
  color: white;
  font-size: 13px;
  background: rgba(0,0,0,0.5);
  padding: 6px 14px;
  border-radius: 999px;
}

/* Multi-photo badge on grid card */
.card-photo-count {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  display: flex; align-items: center; gap: 4px;
}
.card-image { position: relative; }
ointer;
  display: grid; place-items: center;
  transition: background 120ms;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255,255,255,0.22); }
.lightbox-close {
  top: 20px; right: 20px;
  width: 40px; height: 40px;
  font-size: 24px;
}
.lightbox-prev,
.lightbox-next {
  top: 50%; transform: translateY(-50%);
  width: 50px; height: 50px;
  font-size: 22px;
}
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }
.lightbox-counter {
  position: absolute;
  bottom: 24px;
  left: 50%; transform: translateX(-50%);
  color: white;
  font-size: 13px;
  background: rgba(0,0,0,0.5);
  padding: 6px 14px;
  border-radius: 999px;
}

.card-photo-count {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
}
.card-image { position: relative; }
}
.card-image { position: relative; }
ap: 4px;
}
.card-image { position: relative; }

/* ===== Login overlay ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: linear-gradient(135deg, #1c1917 0%, #292524 60%, #44403c 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}
.login-brand {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 28px;
}
.login-brand .brand-mark {
  width: 44px; height: 44px;
}
.login-brand-title {
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.login-brand-tag {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.login-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 999px;
  margin-bottom: 24px;
}
.login-tab {
  flex: 1;
  padding: 8px 14px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 120ms;
}
.login-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: var(--radius);
}
.login-footnote {
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
  margin: 8px 0 0;
  line-height: 1.5;
}

/* Sidebar user block */
.sidebar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 4px 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-user-name {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.login-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.login-tab:not(.active):hover {
  color: var(--text);
}

/* ==================================================================
   Browse view — tabs + photo-overlay tiles
   ================================================================== */

.serif {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.browse-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
  margin: 12px 0 20px;
}

.tab-bar {
  display: flex;
  justify-content: center;
  gap: 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.tab-bar .tab {
  padding: 12px 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s ease;
  cursor: pointer;
}
.tab-bar .tab:hover {
  color: var(--text);
}
.tab-bar .tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.browse-search {
  margin: 0 auto 24px;
  max-width: 560px;
  position: relative;
}
.browse-search .input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 14px;
}
.browse-search::before {
  content: "⌕";
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--surface-2);
  transition: transform 0.15s ease;
  display: block;
}
.tile:hover {
  transform: translateY(-2px);
}
.tile-photo {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: var(--surface-2);
}
.tile-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,0.55) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  color: #fff;
}
.tile-label {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.tile-count {
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
  opacity: 0.92;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.tile-empty .tile-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--text-faint);
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--border) 100%);
}

/* Active filter chip on the closet view */
.filter-chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--text);
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.filter-chip button {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0.8;
}
.filter-chip button:hover { opacity: 1; }

/* Sidebar toggle button — hidden on desktop, shown on mobile */
.sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  margin-left: auto;
}

/* ==================================================================
   Responsive — mobile / narrow viewports
   ================================================================== */

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .brand {
    margin-bottom: 0;
    align-items: center;
  }
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .sidebar-user, .nav, .sidebar-footer {
    display: none;
  }
  .sidebar.open .sidebar-user,
  .sidebar.open .nav,
  .sidebar.open .sidebar-footer {
    display: flex;
  }
  .sidebar.open .nav {
    flex-direction: column;
    margin-top: 16px;
  }
  .sidebar.open .sidebar-footer {
    flex-direction: column;
    margin-top: 8px;
  }
  .main {
    padding: 18px 16px 80px;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .toolbar .input,
  .toolbar .select {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
  .toolbar .input.search {
    flex-basis: 100%;
  }
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .tile-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .tile-label {
    font-size: 18px;
  }
  .browse-title {
    font-size: 28px;
  }
  .tab-bar {
    gap: 24px;
  }
  .item-detail {
    grid-template-columns: 1fr;
  }
  .item-detail-image {
    min-height: 320px;
  }
  .upload-preview {
    grid-template-columns: 1fr;
  }
  .modal-panel {
    max-width: 100vw;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }
  .login-card {
    margin: 16px;
    padding: 24px;
  }
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .tile-grid {
    grid-template-columns: 1fr;
  }
  .tile {
    aspect-ratio: 16 / 9;
  }
  .tile-label {
    font-size: 24px;
  }
}
    flex-wrap: wrap;
    gap: 8px;
  }
  .toolbar .input,
  .toolbar .select {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
  .toolbar .input.search {
    flex-basis: 100%;
  }
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .tile-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .tile-label {
    font-size: 18px;
  }
  .browse-title {
    font-size: 28px;
  }
  .tab-bar {
    gap: 24px;
  }
  .item-detail {
    grid-template-columns: 1fr;
  }
  .item-detail-image {
    min-height: 320px;
  }
  .upload-preview {
    grid-template-columns: 1fr;
  }
  .modal-panel {
    max-width: 100vw;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }
  .login-card {
    margin: 16px;
    padding: 24px;
  }
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .tile-grid {
    grid-template-columns: 1fr;
  }
  .tile {
    aspect-ratio: 16 / 9;
  }
  .tile-label {
    font-size: 24px;
  }
}

/* ==================================================================
   Modern gradient tiles — replaces photo-overlay tiles in Browse view
   ================================================================== */

.tile.tile-modern {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  isolation: isolate;
}
.tile.tile-modern .tile-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at top left, rgba(255,255,255,0.18) 0%, transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(0,0,0,0.22) 0%, transparent 60%);
  pointer-events: none;
}
.tile.tile-modern .tile-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  text-align: center;
  color: #fff;
  z-index: 1;
}
.tile.tile-modern .tile-label {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 14px rgba(0,0,0,0.28);
  word-break: break-word;
  max-width: 100%;
}
.tile.tile-modern .tile-count {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.92;
  margin-top: 10px;
  text-shadow: 0 1px 6px rgba(0,0,0,0.3);
}
.tile.tile-modern__after {
  display: none;
}
.tile.tile-modern:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.16);
}

@media (max-width: 480px) {
  .tile.tile-modern .tile-label {
    font-size: 28px;
  }
  .tile.tile-modern .tile-count {
    font-size: 10px;
    margin-top: 8px;
  }
}

/* ==================================================================
   Subtype chip row — shown above closet items when a category is active
   ================================================================== */
.subtype-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 20px;
}
.subtype-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}
.subtype-chip:hover {
  border-color: var(--text);
}
.subtype-chip.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.subtype-chip .chip-count {
  font-size: 11px;
  opacity: 0.7;
  font-weight: 400;
  padding-left: 4px;
  border-left: 1px solid currentColor;
  margin-left: 2px;
  padding-left: 8px;
}
@media (max-width: 480px) {
  .subtype-chip { padding: 6px 10px; font-size: 12px; }
}

/* ==================================================================
   Outfit suggestion cards (Build Outfit page)
   ================================================================== */
.suggest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.suggest-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.suggest-card-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.suggest-pieces {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.suggest-piece {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  background: var(--surface-2);
  border-radius: var(--radius);
}
.suggest-piece-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  background-color: var(--border);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}
.suggest-piece-name {
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================================================================
   Outfit suggestion — missing-piece placeholder + shop link
   ================================================================== */
.suggest-piece-missing {
  border: 1px dashed var(--border-strong);
  background: transparent;
}
.suggest-piece-thumb.missing {
  background-color: var(--surface-2);
  border: 1px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text-faint);
}
.suggest-shop-link {
  font-size: 11.5px;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
  display: inline-block;
  margin-top: 2px;
}
.suggest-shop-link:hover { color: var(--accent); }
