:root {
  --bg-deep: #0b1116;
  --bg-panel: rgba(18, 28, 36, 0.78);
  --bg-card: rgba(25, 38, 48, 0.65);
  --bg-card-active: rgba(22, 56, 52, 0.82);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(52, 211, 153, 0.55);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.35);
  --accent-sky: #38bdf8;
  --accent-amber: #fbbf24;
  --radius-lg: 16px;
  --radius-md: 12px;
}

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

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at 15% 15%, #132a2e 0%, #0b1116 55%, #070b0e 100%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: 90px;
}

/* 상단 헤더 & 마스터 콘솔 */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(18px);
  background: rgba(11, 17, 22, 0.88);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 24px;
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 16px var(--accent-emerald-glow);
}

.brand-title h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.store-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.35);
  font-weight: 600;
}

.brand-title p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 마스터 컨트롤 바 */
.master-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.visualizer-box {
  width: 150px;
  height: 38px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
}

#spectrumCanvas {
  width: 100%;
  height: 100%;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.control-group label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.control-group span.val-badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: #34d399;
  min-width: 34px;
  text-align: right;
}

.btn {
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.83rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #34d399;
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 0 14px var(--accent-emerald-glow);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* 메인 컨테이너 */
.main-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px;
}

/* 매장 추천 프리셋 & 커스텀 저장 바 */
.presets-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.presets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.presets-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.presets-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.preset-chip {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  max-width: 270px;
}

.preset-chip:hover {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(52, 211, 153, 0.45);
  transform: translateY(-1px);
}

.preset-chip.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: #34d399;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}

.preset-chip .p-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.preset-chip .p-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 현재 재생 중인 사운드 요약 바 (Active Mix Deck) */
.active-mix-bar {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.12), rgba(14, 165, 233, 0.1));
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.active-mix-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1;
}

.active-sound-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(52, 211, 153, 0.45);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: #ecfdf5;
}

.active-sound-pill .pill-vol {
  color: #34d399;
  font-weight: 700;
  font-size: 0.75rem;
}

.active-sound-pill button {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.active-sound-pill button:hover {
  color: #f87171;
}

/* 카테고리 필터 탭 & 검색 */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-tab {
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cat-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.09);
}

.cat-tab.active {
  background: #10b981;
  color: #06281e;
  border-color: #34d399;
  font-weight: 700;
}

.search-box {
  position: relative;
  min-width: 240px;
}

.search-box input {
  width: 100%;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 14px 8px 34px;
  border-radius: 999px;
  font-size: 0.84rem;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent-emerald);
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 카테고리 블록 */
.category-section {
  margin-bottom: 32px;
  background: rgba(15, 23, 30, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.cat-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cat-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.cat-title-wrap h3 {
  font-size: 1.08rem;
  font-weight: 700;
}

.cat-title-wrap p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* 사운드 그리드 */
.sounds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.sound-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 15px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 11px;
  position: relative;
}

.sound-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.sound-card.playing {
  background: var(--bg-card-active);
  border-color: var(--border-active);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.14);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.sound-info {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.sound-emoji {
  font-size: 1.45rem;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sound-card.playing .sound-emoji {
  background: rgba(16, 185, 129, 0.22);
  animation: gentlePulse 3s infinite ease-in-out;
}

@keyframes gentlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.sound-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f8fafc;
}

.sound-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.power-toggle {
  width: 32px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.15s;
}

.sound-card.playing .power-toggle {
  background: #10b981;
  color: #052e16;
  border-color: #34d399;
  font-weight: bold;
}

.card-remove-btn {
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.28);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s;
}

.card-remove-btn:hover {
  background: rgba(239, 68, 68, 0.28);
  border-color: rgba(239, 68, 68, 0.6);
  color: #fff;
}

/* 슬라이더 영역 */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-label {
  font-size: 0.73rem;
  color: var(--text-muted);
  width: 48px;
  flex-shrink: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f8fafc;
  border: 2px solid #10b981;
  cursor: pointer;
  transition: transform 0.12s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.18);
}

.sound-card.playing .vol-slider {
  background: linear-gradient(90deg, #10b981 0%, rgba(255,255,255,0.15) 100%);
}

.vol-percent {
  font-size: 0.76rem;
  font-weight: 700;
  color: #cbd5e1;
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

.sound-card.playing .vol-percent {
  color: #34d399;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.06);
}

.sound-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-badge {
  font-size: 0.67rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
}

.mode-switch-btn {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #7dd3fc;
  cursor: pointer;
}

.mode-switch-btn:hover {
  background: rgba(56, 189, 248, 0.22);
}

/* 카테고리 내 "+ 소리 추가" 카드 버튼 */
.add-sound-card {
  border: 1px dashed rgba(52, 211, 153, 0.35);
  background: rgba(16, 185, 129, 0.04);
  border-radius: var(--radius-md);
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  color: #6ee7b7;
  transition: all 0.2s ease;
  padding: 16px;
  text-align: center;
}

.add-sound-card:hover {
  background: rgba(16, 185, 129, 0.11);
  border-color: #34d399;
  transform: translateY(-2px);
}

.add-sound-card .plus-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: bold;
}

/* 모달 (소리 추가 & 프리셋 저장) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 12, 0.78);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: #111b24;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-lg);
  max-width: 780px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
}

.modal-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.exp-item.is-added {
  background: rgba(16, 185, 129, 0.09);
  border-color: rgba(52, 211, 153, 0.4);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-size: 1.12rem;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.modal-tab {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.84rem;
  text-align: center;
}

.modal-tab.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: #34d399;
  color: #ecfdf5;
}

.expansion-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.exp-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: #cbd5e1;
  margin-bottom: 6px;
  font-weight: 600;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 0.88rem;
}

@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
  }
  .master-controls {
    justify-content: space-between;
  }
}
