/* ===== components.css: Buttons, cards, modals, playlist, filter ===== */

/* Buttons */
.btn {
  background: var(--glass); border: 1px solid var(--glass-border); color: var(--txt);
  padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: var(--t-caption);
  transition: all var(--transition);
}
.btn:hover { background: var(--tint-weak); transform: translateY(-1px); }
.small { font-size: var(--t-micro); padding: 6px 8px; }
.btn-icon { padding: 8px 10px; min-width: 42px; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon .star { font-size: var(--t-body); line-height: 1; opacity: .55; }
.btn-icon.active .star { opacity: 1; }

/* Cards / Thumbs */
.strip { display: flex; gap: 12px; overflow-x: auto; padding: 6px 2px; scroll-snap-type: x mandatory; }
.card {
  flex: 0 0 132px; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--glass-border); border-radius: var(--r-lg);
  overflow: hidden; cursor: pointer; scroll-snap-align: start; position: relative;
  transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px var(--scrim-weak); }
.thumb { width: 100%; height: 132px; background: var(--thumb); background-size: cover; background-position: center; }
.card .star {
  position: absolute; right: 8px; bottom: 8px; width: 28px; height: 28px;
  border-radius: var(--r-sm); background: var(--scrim); border: 1px solid var(--wash);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  backdrop-filter: blur(4px); transition: all var(--transition);
}
.card .star svg { width: 18px; height: 18px; stroke: var(--blue); fill: none; filter: drop-shadow(0 0 3px var(--primary)); }
.card.fav .star svg { fill: var(--blue); stroke: var(--blue); }

/* Favorites strip */
#favoritesWrap { margin: 10px 0 2px 0; display: none; }
#favoritesTitle { color: var(--text-primary); font-weight: 800; margin: 4px 0 8px 2px; font-size: var(--t-body); }
#favoritesStrip { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; }
#favoritesStrip .card { flex: 0 0 132px; scroll-snap-align: start; }

/* Vertical list */
#libBrowseView { display: block; }
#libPlayerView { display: block; }
#libPlayerView.hidden { display: none !important; }
/* A list of rows, not a stack of cards.
   Every row used to be its own bordered, tinted, rounded card with a 1px cyan
   edge, and a column of them reads as clutter: fourteen borders competing for
   the same attention. A hairline divider does the same separating work and
   lets the artwork and the title carry the row. */
.strip.vstrip { display: flex; flex-direction: column; gap: 0; overflow: visible; padding: 6px 0; }
.v-item {
  display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4) 0;
  border-bottom: 1px solid var(--border);
  background: transparent; border-radius: 0;
  cursor: pointer; transition: background var(--transition);
}
.v-item:last-child { border-bottom: 0; }
.v-item:hover { background: var(--tint-weak); }
.v-thumb {
  width: 96px; height: 96px; border-radius: var(--r-sm);
  background: var(--thumb); background-size: cover; background-position: center;
  flex: 0 0 auto; border: 1px solid var(--glass-border);
}
.v-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: var(--s-1); }
.v-item.track .v-meta { padding-right: var(--tap); }
.v-title { font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--t-body); }
.v-sub {
  color: var(--muted); font-size: var(--t-caption); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.v-item.track .v-thumb { width: 64px; height: 64px; border-radius: var(--r-sm); }
/* A track row carries a title and one line of metadata. The two-line clamp
   above is for category rows, whose descriptions are the point. */
.v-item.track .v-sub { display: block; white-space: nowrap; text-overflow: ellipsis; }
.v-item.track { position: relative; }
.v-item.track .star {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: var(--tap); height: var(--tap); border-radius: var(--r-sm);
  background: transparent; border: 0;
}

/* Filter bar */
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 10px; }
.filterbar input, .filterbar select {
  background: var(--glass); border: 1px solid var(--glass-border); color: var(--txt);
  border-radius: var(--r-sm); padding: 0 10px;
  /* These carried no height and computed to ~21px — under half the minimum. */
  min-height: var(--tap); font-size: var(--t-body);
}
#favOnlyBtn.active { background: var(--tint); color: var(--blue); }

/* Modal (legacy text) */
.backdrop { position: fixed; inset: 0; background: var(--scrim); display: none; z-index: 90; }
.legacy-modal {
  position: fixed; inset: auto 10px 10px 10px; top: 8%; max-width: 760px; max-height: 80vh;
  background: var(--panel); border: 1px solid var(--tint-weak); border-radius: var(--r-lg);
  box-shadow: 0 24px 64px var(--scrim); display: none; z-index: 101; padding: 18px;
}
.mhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#modalBody { white-space: pre-wrap; line-height: 1.6; color: var(--text-primary); max-height: 60vh; overflow: auto; font-size: var(--t-body); }

/* Backdrop modal (glass) */
.bd-modal {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--scrim); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center; padding: 18px;
}
.bd-modal.show { display: flex; }
.modal-card {
  width: min(920px, 96vw); max-height: min(86vh, 860px); overflow: auto;
  border-radius: var(--r-lg); border: 1px solid var(--tint-weak);
  background: var(--panel-blur); box-shadow: 0 24px 64px var(--scrim);
}
.modal-head {
  position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 16px 16px 12px; border-bottom: 1px solid var(--glass-border);
  background: var(--panel-blur); backdrop-filter: blur(8px); z-index: 2;
}
.modal-title { font-weight: 700; font-size: var(--t-body); letter-spacing: .2px; }
.bd-controls { padding: 14px 16px 0; }
.bd-row { display: grid; grid-template-columns: 140px 1fr 56px; gap: 10px; align-items: center; padding: 8px 0; }
.bd-label { opacity: .9; font-size: var(--t-caption); }
.bd-row input[type="range"] { width: 100%; }
.bd-val { text-align: right; opacity: .85; font-variant-numeric: tabular-nums; }
.bd-grid-title { padding: 12px 16px 8px; opacity: .9; font-size: var(--t-caption); }
.bd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; padding: 0 16px 16px; }
.bd-tile {
  border: 1px solid var(--tint-weak); border-radius: var(--r-lg); overflow: hidden;
  background: var(--tint-weak); cursor: pointer; min-height: 108px;
  display: flex; flex-direction: column; justify-content: flex-end; position: relative; padding: 0;
  transition: border-color var(--transition);
}
.bd-tile:hover { border-color: var(--tint-strong); }
.bd-thumb { position: absolute; inset: 0; background-size: cover; background-position: center; filter: saturate(1.05); }
.bd-caption { position: relative; padding: 8px 12px; font-size: var(--t-micro); text-align: left; background: linear-gradient(to top, var(--scrim-deep), transparent); }
.bd-selected { outline: 2px solid var(--primary); box-shadow: 0 0 0 3px var(--tint); }

/* Playlist Panel */
#plPanel {
  display: none; position: fixed; inset: auto 10px 10px 10px; top: 12%; max-width: 760px; margin: auto;
  background: var(--panel); border: 1px solid var(--tint-weak); border-radius: var(--r-lg);
  box-shadow: 0 24px 64px var(--scrim); z-index: 120;
}
#plHead { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--glass-border); }
#plBody { padding: 12px 16px; display: grid; gap: 10px; max-height: 56vh; overflow: auto; }
.pl-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--r-sm); padding: 10px 12px;
}
#plFoot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--glass-border); }
.pl-controls {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--glass-border);
}
.pl-spacer { flex: 1; }
.pl-icbtn {
  position: relative; width: 38px; height: 38px; border-radius: var(--r-sm);
  border: 1px solid var(--glass-border); background: var(--tint-weak);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all var(--transition);
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.pl-icbtn:hover { background: var(--tint-weak); border-color: var(--tint); }
.pl-icbtn:active { transform: scale(.96); }
.pl-icbtn[disabled] { opacity: .35; cursor: not-allowed; }
.pl-ic { width: 20px; height: 20px; fill: var(--text-primary); }
.pl-icbtn.is-on { background: var(--tint); border-color: var(--tint-strong); }
.pl-icbtn.is-on .pl-ic { fill: var(--blue); }
.pl-badge {
  position: absolute; right: 6px; top: 6px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: var(--r-pill); font-size: var(--t-micro); line-height: 16px; text-align: center;
  background: var(--text-primary); color: var(--bg); display: none;
}
.pl-icbtn.is-loop-all .pl-badge { display: inline-block; }
.pl-toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  padding: 10px 14px; border-radius: var(--r-sm); background: var(--glass);
  border: 1px solid var(--glass-border); color: var(--text-primary); font-size: var(--t-caption);
  backdrop-filter: blur(12px);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 99999;
}
.pl-toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.pl-item.is-playing { outline: 1px solid var(--tint-strong); background: var(--tint-weak); }

/* Numeric popup */
.num-popup-backdrop {
  position: fixed; inset: 0; background: var(--scrim);
  display: none; align-items: center; justify-content: center; z-index: 999;
}
.num-popup-backdrop.show { display: flex; }
.num-popup-panel {
  width: min(360px, 90vw); padding: 16px 18px 14px; border-radius: var(--r-lg);
  background: var(--panel); border: 1px solid var(--tint-weak); box-shadow: 0 20px 48px var(--scrim);
}
.num-popup-title { font-weight: 700; margin-bottom: 10px; color: var(--text-primary); text-shadow: 0 0 8px var(--primary); }
.num-popup-body { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
#numPopupValue, #numPopupRange { width: 100%; }
.num-popup-footer { display: flex; justify-content: flex-end; }
.num-popup-footer .btn.small { padding: 6px 12px; font-size: var(--t-caption); }

/* Ad banner */
#adBanner { margin-top: 8px; padding-top: 4px; border-top: 1px solid var(--tint-weak); }
.ad-banner-wrap { position: relative; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--glass-border); background: var(--thumb); }
.ad-banner-img { display: block; width: 100%; height: auto; }
.ad-banner-dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.ad-dot { width: 6px; height: 6px; border-radius: var(--r-pill); background: var(--tint); cursor: pointer; transition: all var(--transition); }
.ad-dot.active { background: var(--blue); width: 18px; border-radius: var(--r-pill); }

/* ===== Search bar ===== */
.searchbar { padding: 10px 16px 8px; display: flex; flex-direction: column; gap: 8px; background: var(--panel-blur); border-bottom: 1px solid var(--glass-border); }
.search-input-wrap {
  position: relative; display: flex; align-items: center;
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: var(--r-sm); overflow: hidden; transition: border-color var(--transition);
}
.search-input-wrap:focus-within { border-color: var(--tint-strong); box-shadow: 0 0 0 3px var(--tint-weak); }
.search-icon { width: 16px; height: 16px; margin-left: 12px; flex-shrink: 0; opacity: .35; stroke: var(--blue); }
.search-input-wrap input {
  flex: 1; border: none; background: transparent; color: var(--txt);
  /* min-height, not padding: the field has to clear 44px (Apple HIG) on its
     own, and the old 14px font made iOS Safari zoom the page on every tap. */
  min-height: var(--tap); padding: 0 10px; font-size: var(--t-body); outline: none;
}
.search-input-wrap input::placeholder { color: var(--text-tertiary); }
.search-clear-btn {
  width: 32px; height: 32px; margin-right: 4px; padding: 0; border: none; background: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: .35; color: var(--blue);
  transition: opacity var(--transition);
}
.search-clear-btn:hover { opacity: .7; }
.search-clear-btn svg { width: 14px; height: 14px; }

.search-actions { display: flex; align-items: center; gap: 8px; }
.search-mode-select {
  flex: 1; padding: 8px 12px; border-radius: var(--r-sm);
  background: var(--glass); border: 1px solid var(--glass-border);
  color: var(--txt); font-size: var(--t-caption);
}
.search-go-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm); padding: 0;
  background: var(--tint); border: 1px solid var(--tint-strong);
  color: var(--blue); display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all var(--transition);
}
.search-go-btn:hover { background: var(--tint-strong); border-color: var(--tint-strong); }
.search-go-btn svg { width: 16px; height: 16px; }
/* 38px drawn, 44px tappable. The pseudo-element is hit area only — it has no
   paint — so the row keeps its proportions and the target still clears HIG. */
.search-go-btn, .fav-filter-btn, .search-clear-btn { position: relative; }
.search-go-btn::after, .fav-filter-btn::after, .search-clear-btn::after {
  content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: var(--tap); height: var(--tap);
}
.fav-filter-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm); padding: 0; flex-shrink: 0;
  background: var(--tint-weak); border: 1px solid var(--glass-border);
  color: var(--text-secondary); display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all var(--transition);
}
.fav-filter-btn:hover { background: var(--glass-border); }
.fav-filter-btn.active { background: var(--tint); border-color: var(--tint-strong); color: var(--blue); }
.fav-filter-btn svg { width: 18px; height: 18px; }

/* ── Sub-tabs inside a tab ──────────────────────────────────────────────
   Used by the 분석 tab to hold Soul Code and Biofeedback. They are two
   features with two different entitlements, so they are two sub-tabs rather
   than one merged screen — the Pro gate stays on Soul Code alone. */
.inner-tabs {
  display: flex; gap: var(--s-2);
  height: var(--h-subtabs); align-items: center;
  padding: 0 var(--s-4);
  border-bottom: 1px solid var(--border);
}
.inner-tab {
  flex: 1; min-height: 32px; padding: 0 var(--s-3);
  border: 1px solid transparent; border-radius: var(--r-pill);
  background: transparent; color: var(--text-secondary);
  font-size: var(--t-caption); font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all var(--transition);
}
.inner-tab:hover { color: var(--text-primary); }
.inner-tab.active {
  background: var(--tint); border-color: var(--tint-strong); color: var(--primary);
}
