:root {
  color-scheme: light;
  --mamamoo: #08a66a;
  --mamamoo-dark: #057c51;
  --bg: #f6f8f4;
  --surface: #ffffff;
  --surface-2: #eef5ef;
  --text: #17211c;
  --muted: #647169;
  --border: #dbe6df;
  --shadow: 0 18px 45px rgba(24, 44, 34, 0.10);
  --rank-bg: #f9fbf8;
}

body.dark {
  color-scheme: dark;
  --bg: #101612;
  --surface: #18211c;
  --surface-2: #1f2d25;
  --text: #edf8f1;
  --muted: #9caf9f;
  --border: #2d4035;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.26);
  --rank-bg: #131b16;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 44px) 18px;
}

h1,
h2 {
  margin: 0;
  color: var(--mamamoo);
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.1rem);
  line-height: 0.95;
  font-weight: 850;
}

h2 {
  font-size: 1.05rem;
  font-weight: 800;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
}

.theme-toggle,
.primary-button,
.text-button,
.segment {
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--mamamoo);
  font-weight: 750;
  box-shadow: var(--shadow);
}

.theme-toggle:hover,
.primary-button:hover,
.text-button:hover,
.segment:hover {
  transform: translateY(-1px);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 18px;
  padding: 0 clamp(18px, 4vw, 44px) 34px;
}

.panel {
  min-height: calc(100vh - 140px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.text-button {
  min-height: 36px;
  padding: 0 12px;
  background: transparent;
  color: var(--mamamoo);
  font-size: 0.88rem;
  font-weight: 800;
}

.search-wrap {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
}

input[type="search"] {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: 0;
  background: var(--rank-bg);
  color: var(--text);
}

input[type="search"]:focus {
  border-color: var(--mamamoo);
  box-shadow: 0 0 0 3px rgba(8, 166, 106, 0.16);
}

.album-list {
  height: calc(100vh - 246px);
  min-height: 520px;
  overflow: auto;
  padding: 8px 12px 18px;
}

.album {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.album:last-child {
  border-bottom: 0;
}

.album-head {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 0 8px 10px;
}

.cover {
  width: 52px;
  aspect-ratio: 1;
  border-radius: 7px;
  object-fit: cover;
  background: linear-gradient(145deg, var(--mamamoo), #202620);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
}

.album-title {
  font-size: 0.95rem;
  font-weight: 850;
}

.album-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.song-total {
  color: var(--mamamoo);
  font-size: 0.78rem;
  font-weight: 800;
}

.song-list {
  display: grid;
  gap: 5px;
}

.song-button {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  padding: 7px 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.song-button:hover {
  background: var(--surface-2);
}

.check-dot {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1.6px solid var(--border);
  border-radius: 5px;
  color: white;
  font-size: 0.75rem;
  font-weight: 900;
}

.song-button.selected {
  background: rgba(8, 166, 106, 0.12);
  color: var(--mamamoo);
  font-weight: 800;
}

.song-button.selected .check-dot {
  border-color: var(--mamamoo);
  background: var(--mamamoo);
}

.rank-head {
  align-items: center;
}

.primary-button {
  min-height: 40px;
  padding: 0 15px;
  border-color: var(--mamamoo);
  background: var(--mamamoo);
  color: white;
  font-weight: 850;
}

.top-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.segment {
  min-height: 38px;
  background: var(--rank-bg);
  color: var(--mamamoo);
  font-size: 0.88rem;
  font-weight: 850;
}

.segment.active {
  border-color: var(--mamamoo);
  background: rgba(8, 166, 106, 0.14);
  color: var(--mamamoo);
}

.ranking-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 18px 20px 22px;
  list-style: none;
}

.rank-row {
  display: grid;
  grid-template-columns: 46px 58px 1fr 32px;
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--rank-bg);
}

.rank-num {
  color: var(--mamamoo);
  font-size: 1.35rem;
  font-weight: 900;
  text-align: center;
}

.rank-row .cover {
  width: 58px;
}

.rank-title {
  display: block;
  font-weight: 850;
}

.rank-album {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.remove-button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
}

.remove-button:hover {
  background: var(--surface-2);
  color: var(--mamamoo);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 280px;
  margin: 18px 20px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--mamamoo);
  font-size: 1.1rem;
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .album-list {
    height: auto;
    min-height: 0;
    max-height: 640px;
  }
}

@media (max-width: 520px) {
  .panel-head,
  .rank-head {
    flex-direction: column;
  }

  .primary-button,
  .text-button {
    width: 100%;
  }

  .album-head {
    grid-template-columns: 46px 1fr;
  }

  .song-total {
    grid-column: 2;
  }

  .rank-row {
    grid-template-columns: 38px 48px 1fr 30px;
    gap: 9px;
    padding: 8px;
  }

  .rank-row .cover {
    width: 48px;
  }
}
