:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e3e1dc;
  --accent: #2d2d30;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 6px 16px rgba(0,0,0,0.05);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 18px; margin: 0; letter-spacing: 0.5px; }
.tabs { display: flex; gap: 4px; }
.tab {
  border: 0; background: transparent; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted);
}
.tab:hover { background: var(--bg); }
.tab.is-active { background: var(--accent); color: #fff; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.progress-pill {
  font-size: 12px; color: var(--muted); padding: 4px 10px;
  background: var(--bg); border-radius: 20px;
}
.btn-ghost {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.btn-ghost:hover { background: var(--bg); }
.btn-primary {
  border: 0; background: var(--accent); color: #fff;
  padding: 10px 18px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn-primary:hover { opacity: 0.9; }

/* Views */
.view { display: none; padding: 20px 24px 60px; }
.view.is-active { display: block; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.chip {
  border: 1px solid var(--line); background: var(--card);
  padding: 5px 12px; border-radius: 20px; cursor: pointer; font-size: 13px; color: var(--muted);
}
.chip.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer; position: relative;
  transition: transform 0.12s ease;
}
.card:hover { transform: translateY(-2px); }
.card img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; background: #eee; }
.card .meta { padding: 8px 10px; font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.card .tagdot {
  position: absolute; top: 8px; right: 8px; width: 10px; height: 10px;
  border-radius: 50%; background: #d9534f; box-shadow: 0 0 0 2px #fff;
}
.card.tagged .tagdot { background: #4c9a5d; }
.pill { background: var(--bg); padding: 2px 7px; border-radius: 10px; }

/* Outfit view */
.outfit-controls { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 24px; }
.outfit-controls label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.outfit-controls select { padding: 8px; border-radius: 8px; border: 1px solid var(--line); font-size: 14px; }
.outfit-stage { display: flex; gap: 18px; flex-wrap: wrap; }
.outfit-slot { text-align: center; }
.outfit-slot img {
  width: 180px; aspect-ratio: 3/4; object-fit: cover; border-radius: var(--radius);
  box-shadow: var(--shadow); background: #eee;
}
.outfit-slot .label { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Gaps view */
.gaps-content { max-width: 720px; }
.gap-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.gap-card h3 { margin: 0 0 10px; font-size: 15px; }
.count-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.count-row:last-child { border-bottom: 0; }
.count-row .n { font-variant-numeric: tabular-nums; color: var(--muted); }
.warn { color: #b9533f; }

/* Tag panel */
.tag-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 340px; max-width: 90vw;
  background: var(--card); box-shadow: -4px 0 24px rgba(0,0,0,0.12); z-index: 40;
  padding: 20px; overflow-y: auto;
}
.tag-close { position: absolute; top: 12px; right: 14px; border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }
.tag-img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: var(--radius); margin-bottom: 18px; background: #eee; }
.tag-fields label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 5px; margin-bottom: 14px; }
.tag-fields select { padding: 9px; border-radius: 8px; border: 1px solid var(--line); font-size: 14px; }
.seasons { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.seasons legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.chk { flex-direction: row !important; align-items: center; gap: 8px !important; font-size: 14px !important; color: var(--ink) !important; margin-bottom: 6px !important; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.25); z-index: 30; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Rating system */
.rating-bar {
  display: flex; justify-content: center; gap: 16px;
  margin: 12px 0 4px;
}
.rating-btn {
  font-size: 28px; border: 2px solid var(--line); background: var(--card);
  border-radius: 50%; width: 56px; height: 56px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
  line-height: 1;
}
.rating-btn:hover { transform: scale(1.1); }
.rating-btn.is-active { border-color: var(--accent); background: var(--accent); }
#btn-like.is-active  { border-color: #2e7d32; background: #e8f5e9; }
#btn-dislike.is-active { border-color: #c62828; background: #fdecea; }

.outfit-stage.is-liked  { outline: 3px solid #4caf50; border-radius: var(--radius); }
.outfit-stage.is-disliked { outline: 3px solid #ef9a9a; border-radius: var(--radius); }

.liked-toggle {
  display: flex !important; flex-direction: row !important;
  align-items: center; gap: 6px; font-size: 14px;
  color: var(--ink) !important; cursor: pointer;
}
.rating-stats {
  font-size: 12px; color: var(--muted);
  padding: 4px 10px; background: var(--bg); border-radius: 20px;
}
