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

:root {
  --bg: #f9f7f4;
  --surface: #ffffff;
  --border: #e8e4df;
  --text: #1a1814;
  --muted: #8a8480;
  --accent: #00dfeb;
  --accent-soft: #e8feff;
  --heart: #e05a6a;
  --radius: 14px;
  --font: 'Helvetica Neue', Arial, sans-serif;
}

body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; }

/* Nav */
.nav { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px;
       background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.nav-logo { display: flex; align-items: center; text-decoration: none; padding: 0; }
.nav-logo img { height: calc(100% - 0px); max-height: 44px; padding: 10px 0 10px 10px; box-sizing: content-box; }
.nav-links { display: flex; gap: 16px; align-items: center; }
.nav-link { color: var(--muted); text-decoration: none; font-size: 14px; }
.nav-logout { background: none; border: none; cursor: pointer; font-size: 14px; color: var(--muted); padding: 0; }

/* Filters */
.filters { padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.search-input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
                font-size: 15px; margin-bottom: 12px; background: var(--bg); }
.search-input:focus { outline: none; border-color: var(--accent); }
.filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.filter-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted);
                margin-right: 4px; min-width: 60px; }
.pill { background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 5px 14px;
        font-size: 13px; cursor: pointer; transition: all 0.15s; color: var(--text); }
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; padding: 20px; }

/* Card */
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; cursor: pointer;
        border: 1px solid var(--border); transition: transform 0.15s, box-shadow 0.15s; position: relative; }
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.card-img-wrap { aspect-ratio: 1; overflow: hidden; background: var(--bg); }
.card-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-title { font-size: 12px; color: var(--muted); padding: 8px 10px 6px; white-space: nowrap;
              overflow: hidden;
  margin-top: 0; text-overflow: ellipsis; }
.card-heart { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,0.9);
              border: none; border-radius: 50%; width: 30px; height: 30px; cursor: pointer;
              font-size: 15px; display: flex; align-items: center; justify-content: center; }
.card-heart.faved { color: var(--heart); }

/* Item detail */
.item-detail { max-width: 560px; margin: 0 auto; padding: 24px 20px; }
.back-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px;
            padding: 0; margin-bottom: 20px; }
.item-preview { border-radius: var(--radius); overflow: hidden; background: var(--bg);
                border: 1px solid var(--border); margin-bottom: 16px; }
.item-preview img { width: 100%; display: block; }
.item-title { font-size: 20px; font-weight: 600; margin-bottom: 10px; }
.item-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.tag { background: var(--accent-soft); color: var(--accent); border-radius: 12px;
       padding: 3px 10px; font-size: 12px; }
.item-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-action { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
              padding: 10px 20px; font-size: 14px; cursor: pointer; transition: all 0.15s; }
.btn-action:hover { border-color: var(--accent); color: var(--accent); }
.btn-action.faved { color: var(--heart); border-color: var(--heart); }

/* Auth */
.auth-wrap { max-width: 400px; margin: 80px auto; padding: 0 20px; }
.auth-wrap h2 { font-size: 24px; margin-bottom: 8px; }
.auth-wrap p { color: var(--muted); margin-bottom: 20px; font-size: 15px; }
.auth-wrap input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
                   font-size: 16px; margin-bottom: 12px; }
.btn-primary { width: 100%; padding: 13px; background: var(--accent); color: #fff; border: none;
               border-radius: var(--radius); font-size: 16px; cursor: pointer; font-weight: 600; }
.auth-msg { font-size: 14px; color: var(--muted); margin-top: 12px; }

/* Page title */
.page-title { font-size: 22px; font-weight: 700; padding: 24px 20px 8px; }

/* Toast */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
         background: #1a1814; color: #fff; padding: 10px 20px; border-radius: 20px; font-size: 14px;
         opacity: 0; transition: all 0.25s; pointer-events: none; z-index: 999; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Empty state */
.empty { text-align: center; padding: 80px 20px; color: var(--muted); font-size: 15px; }

@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; padding: 14px; }
  .filters { padding: 12px 14px; }
  .item-detail { padding: 16px 14px; }
}
/* Filter group — border label layout */
.filter-group {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 10px 10px;
  margin-bottom: 10px;
}
.filter-label {
  position: absolute;
  top: -9px;
  left: 12px;
  background: var(--surface);
  padding: 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  line-height: 1;
}
/* Pill scroll row */
.pill-scroll {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.pill-scroll::-webkit-scrollbar { display: none; }

/* ── Filters ──────────────────────────────────────── */

.filters {
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* Search + toggle row */
.filter-top {
  display: flex;
  gap: 10px;
  align-items: center;
}
.filter-top .search-input {
  flex: 1;
  margin-bottom: 0;
}
.filter-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.filter-toggle-btn:hover,
.filter-toggle-btn.open { border-color: var(--accent); color: var(--accent); }
.filter-toggle-btn.has-active { color: var(--accent); border-color: var(--accent); }
.filter-icon { display: flex; align-items: center; font-size: 18px; line-height: 1; }

/* Slide container */
.filter-groups {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}
.filter-groups.open {
  grid-template-rows: 1fr;
}
.filter-groups-inner {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 0;
  transition: padding-top 0.3s ease;
}
.filter-groups.open .filter-groups-inner {
  padding-top: 14px;
}

/* Individual group */
.filter-group {
  display: block;
  width: 100%;
}
.filter-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Scrolling pill row */
.pill-scroll {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  width: 100%;
  box-sizing: border-box;
}
.pill-scroll::-webkit-scrollbar { display: none; }
.pill-scroll .pill { flex-shrink: 0; }

/* Filter group padding adjustments */
.filter-groups.open .filter-groups-inner { padding-top: 24px !important; }
.filter-group { padding: 0 !important; }
.pill-scroll { padding: 8px 0 !important; }

.pill-scroll { padding: 10px !important; }

.card-play { color: var(--accent); font-size: 10px; }
