/* === Variables === */
:root {
  --bg-color: #ffffff;
  --inactive-blue: #c9dfff;
  --active-blue: #91bdff;
  --line-color: #333333;
  --card-bg: #e1f5fe;
  --special-pink: #ffdbdb;
  --special-pink-text: #ffa3a3;
  --hover-pink: #ffa3a3;
  --font-family: 'Noto Sans KR', sans-serif;
}

/* === Reset === */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  font-family: var(--font-family);
  background-color: var(--bg-color);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.1px;
}

button {
  font-family: var(--font-family);
  letter-spacing: 0.1px;
}

a {
  text-decoration: none;
  color: inherit;
}

/* === Main Page === */
.main-container {
  flex: 1;
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.main-header {
  text-align: center;
  padding: 30px 0 20px;
}

.main-title {
  font-size: 1.8rem;
  margin: 0 0 8px;
  color: var(--line-color);
}

.main-subtitle {
  font-size: 0.95rem;
  color: #888;
  margin: 0;
}

/* Group Card List */
.group-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 20px 0;
}

.group-card {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
  background: white;
}

.group-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.group-card-img {
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--inactive-blue), var(--active-blue));
  display: flex;
  align-items: center;
  justify-content: center;
}

.group-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.group-card-img-fallback {
  font-size: 1.5rem;
  font-weight: bold;
  color: white;
}

.group-card-info {
  padding: 16px;
}

.group-card-name {
  font-size: 1.2rem;
  margin: 0 0 4px;
}

.group-card-short {
  font-size: 0.85rem;
  color: #888;
  margin: 0 0 6px;
}

.group-card-desc {
  font-size: 0.85rem;
  color: #666;
  margin: 0 0 10px;
}

.group-card-members {
  font-size: 1.2rem;
  letter-spacing: 4px;
}

/* === Group Page === */
.group-container {
  flex: 1;
  padding: 15px 20px;
  padding-bottom: 50px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
}

.back-link {
  font-size: 0.9rem;
  color: var(--active-blue);
  white-space: nowrap;
}

.back-link:hover {
  text-decoration: underline;
}

.group-title {
  font-size: 1.3rem;
  margin: 0;
}

/* Song Select */
.song-select {
  padding: 6px 10px;
  border: 2px solid var(--active-blue);
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: bold;
  background: white;
  color: var(--line-color);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.song-select:focus, .source-select:focus {
  outline: none;
  border-color: var(--hover-pink);
}

.source-select {
  padding: 6px 10px;
  border: 2px solid var(--special-pink-text);
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: bold;
  background: white;
  color: var(--line-color);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.reset-btn {
  padding: 6px 10px;
  border: 2px solid var(--inactive-blue);
  border-radius: 8px;
  font-size: 1rem;
  background: white;
  color: var(--line-color);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.reset-btn:hover {
  border-color: var(--active-blue);
  background: var(--inactive-blue);
}

/* Member Bar */
.member-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 10px;
  justify-content: space-between;
}

.mem-btn {
  flex: 1;
  min-width: 0;
  padding: 8px 0;
  background-color: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 12px;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
}

.mem-btn:hover {
  background-color: var(--hover-pink);
  color: white;
}

.mem-btn.active {
  background-color: var(--hover-pink);
  color: white;
}

.variety-fixed {
  font-size: 0.6rem;
  font-weight: bold;
  line-height: 1;
  white-space: nowrap;
  background-color: var(--inactive-blue);
  border-color: lightgray;
}

.variety-fixed.active {
  background-color: var(--active-blue);
  color: white;
}

/* Date Bar */
.date-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 15px 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.date-bar::-webkit-scrollbar {
  display: none;
}

.date-btn {
  flex: 0 0 auto;
  padding: 12px 25px;
  background-color: var(--inactive-blue);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.95rem;
}

.date-btn-special {
  background-color: var(--special-pink);
  color: var(--special-pink-text);
}

.date-btn.active {
  background-color: var(--active-blue);
  color: white;
}

.date-btn-special.active {
  background-color: var(--hover-pink);
  color: white;
}

/* Content Area */
.content-area {
  padding-bottom: 30px;
}

.category-title {
  margin-top: 30px;
  font-size: 1.2rem;
  border-bottom: 2px solid var(--line-color);
  padding-bottom: 5px;
}

.content-item {
  display: flex;
  align-items: center;
  background-color: var(--card-bg);
  margin: 15px 0;
  padding: 10px;
  border-radius: 8px;
  text-decoration: none;
  color: black;
}

.content-item:hover {
  background-color: #b3e5fc;
}

.thumb-wrap {
  position: relative;
  flex-shrink: 0;
  margin-right: 15px;
}

.thumbnail {
  width: 120px;
  height: 67px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.date-badge {
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 3px;
}

.content-title {
  font-size: 0.9rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Date Divider */
.date-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 5px;
  font-size: 0.8rem;
  color: #999;
  font-weight: bold;
}

.date-divider::before,
.date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #ddd;
}

/* Loading Spinner */
.loading-spinner {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 0.9rem;
}

.loading-spinner::before {
  content: '';
  display: block;
  width: 24px;
  height: 24px;
  margin: 0 auto 10px;
  border: 3px solid #ddd;
  border-top-color: var(--active-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Retry Button */
.retry-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 20px;
  background: var(--active-blue);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.retry-btn:hover {
  background: var(--hover-pink);
}

/* Messages */
.empty-msg, .error-msg {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 0.95rem;
}

.error-msg {
  color: #e57373;
}

/* === Footer === */
footer {
  width: 100%;
  padding: 30px 0;
  margin-top: auto;
  display: flex;
  justify-content: center;
  border-top: 1px solid #eeeeee;
}

.footer-content {
  text-align: center;
  font-size: 0.75rem;
  color: #ccc;
}

/* === Responsive === */
@media (max-width: 600px) {
  .main-container {
    padding: 15px;
  }

  .main-title {
    font-size: 1.4rem;
  }

  .group-list {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .group-card-img {
    height: 150px;
  }

  .group-container {
    padding: 10px 15px;
  }

  .group-header {
    gap: 8px;
  }

  .group-title {
    font-size: 1.1rem;
  }

  .date-btn {
    padding: 10px 18px;
    font-size: 0.85rem;
  }

  .thumb-wrap {
    margin-right: 10px;
  }

  .thumbnail {
    width: 100px;
    height: 56px;
  }

  .content-title {
    font-size: 0.8rem;
  }

  .category-title {
    font-size: 1rem;
  }
}
