/* Herz: Apple のサイトのような薄いグレーの地に、白いパネル。色は上の線・点・背景だけに使う */

:root {
  --a: #5b7ea4;
  --b: #2f4a6b;
  --bg: #f5f5f7;
  --panel: rgb(255 255 255 / 0.86);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #86868b;
  --line: #e8e8ed;
  --surface: #f5f5f7;
  --accent: #0071e3;
  --link: #0066cc;
  --danger: #d70015;
  /* Apple の端末では San Francisco とヒラギノ角ゴになる */
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  color-scheme: light;
}

@property --a {
  syntax: "<color>";
  inherits: true;
  initial-value: #5b7ea4;
}
@property --b {
  syntax: "<color>";
  inherits: true;
  initial-value: #2f4a6b;
}
:root {
  transition:
    --a 0.8s ease,
    --b 0.8s ease;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

/* 背景は探し方ごとにがらっと変える。
   雰囲気で探すときは気分の色で全面を塗り、曲から探すときはジャケット写真を大きく敷く */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: #1d1d1f;
}

.backdrop-wash,
.backdrop-art,
.backdrop-cover {
  position: absolute;
  transition: opacity 0.9s ease;
}

.backdrop-wash {
  inset: 0;
  background:
    radial-gradient(70% 70% at 0% 0%, var(--a), transparent 75%),
    radial-gradient(70% 80% at 100% 100%, var(--b), transparent 75%),
    color-mix(in srgb, var(--a) 50%, var(--b));
}

/* ジャケット写真をぼかして全面に */
.backdrop-art {
  inset: -60px;
  background-position: center;
  background-size: cover;
  filter: blur(40px) saturate(1.2) brightness(0.75);
  opacity: 0;
}

/* その上に、くっきりしたジャケット写真を左に大きく */
.backdrop-cover {
  top: 0;
  bottom: 0;
  left: 0;
  width: min(68vw, 100vh);
  background-position: center;
  background-size: cover;
  opacity: 0;
  -webkit-mask-image: linear-gradient(to right, #000 55%, transparent);
  mask-image: linear-gradient(to right, #000 55%, transparent);
}

.backdrop.art .backdrop-wash {
  opacity: 0;
}

.backdrop.art .backdrop-art,
.backdrop.art .backdrop-cover {
  opacity: 1;
}

/* 白い文字が読めるよう、左（文字がのる側）を中心にうすく暗くする */
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgb(0 0 0 / 0.25), transparent 60%);
  transition: background 0.9s ease;
}

.backdrop.art::after {
  background:
    linear-gradient(to right, rgb(0 0 0 / 0.55), rgb(0 0 0 / 0.15) 55%, transparent),
    linear-gradient(to bottom, rgb(0 0 0 / 0.3), transparent 30%);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

/* display を指定した要素でも hidden 属性で隠れるようにする */
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* 上の細い線。色は JS が --a/--b を書き換えて変える */
.line {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 6px;
  background: linear-gradient(90deg, var(--a), var(--b));
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 40px 48px;
}

/* ---- header ---- */

.masthead {
  display: flex;
  align-items: baseline;
  gap: 32px;
}

.tabs {
  display: flex;
  gap: 20px;
}

.tab {
  padding: 0 0 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--faint);
  font-size: 14px;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  border-bottom-color: var(--text);
  color: var(--text);
  font-weight: 700;
}

.tab-count:not(:empty) {
  margin-left: 2px;
  color: var(--muted);
  font-size: 12px;
}

.stats {
  margin: 0 0 0 auto;
  color: var(--faint);
  font-size: 13px;
}

/* ---- search ---- */

.search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 64px;
  align-items: start;
  padding-top: 72px;
}

.mood-column {
  position: sticky;
  top: 36px;
}

/* 検索のページの見出しは、サービス名を大きく出す */
.logo {
  margin: 0;
  font-size: clamp(72px, 10vw, 128px);
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.tagline {
  margin: 14px 0 0;
  font-size: 19px;
  font-weight: 500;
  opacity: 0.9;
}

.headline {
  margin: 0;
  font-size: clamp(36px, 4.6vw, 52px);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.lead {
  max-width: 32em;
  margin: 20px 0 0;
  color: var(--muted);
  line-height: 2;
}

.moods {
  display: grid;
  gap: 2px;
  margin: 36px 0 0;
  padding: 0;
  list-style: none;
}

.mood-item {
  display: flex;
  align-items: center;
  gap: 2px;
}

.mood {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease;
}

.mood-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mood:hover {
  color: var(--text);
}

.mood[aria-pressed="true"] {
  color: var(--dot);
  font-weight: 600;
}

.dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dot);
}

.dot.art {
  width: 18px;
  height: 18px;
  margin: 0 -4px 0 -5px;
  border-radius: 4px;
  object-fit: cover;
}

.kind {
  flex-shrink: 0;
  padding: 0 7px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.05);
  color: var(--faint);
  font-size: 11px;
  font-weight: 400;
}

.mood-action {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
}

.mood-item:hover .mood-action,
.mood-action:focus-visible {
  opacity: 1;
}

/* マウスのない端末では、名前の変更・削除のボタンを常に見せる */
@media (hover: none) {
  .mood-action {
    opacity: 0.7;
  }
}

.mood-action:hover {
  background: rgb(0 0 0 / 0.06);
  color: var(--text);
}

.rename {
  flex: 1;
  min-width: 0;
  padding: 3px 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  outline: none;
  background: #fff;
  font-size: 16px;
}

.moods-empty {
  color: var(--faint);
  font-size: 13px;
}

.reset-searches {
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--link);
  font-size: 12px;
  cursor: pointer;
}

.reset-searches:hover {
  text-decoration: underline;
}

.kind-switch {
  display: inline-flex;
  gap: 2px;
  margin-bottom: 14px;
  padding: 2px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.06);
}

.kind-switch input {
  position: absolute;
  opacity: 0;
}

.kind-switch span {
  display: inline-block;
  padding: 3px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.kind-switch input:checked + span {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

.kind-switch input:focus-visible + span {
  outline: 2px solid var(--accent);
}

.search-form {
  margin-top: 32px;
}

.underline {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--text);
}

.underline input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
}

.underline input::placeholder {
  color: #c4c4c4;
}

.underline input:disabled {
  opacity: 0.5;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--link);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.text-button:disabled {
  color: var(--faint);
  cursor: default;
}

.hint {
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 12px;
}

.hint.warning {
  color: var(--danger);
}

.seed {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin-top: 14px;
  padding: 4px 6px 4px 14px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
}

.seed-clear {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.seed-clear:hover {
  background: #e6e6e3;
}

/* ---- buttons ---- */

.button {
  padding: 7px 16px;
  border: 1px solid #d4d4d4;
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.button:hover {
  border-color: var(--text);
}

.button.solid {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ---- filters ---- */

.filters {
  margin-top: 24px;
  font-size: 14px;
}

.filters summary,
.admin summary {
  color: var(--muted);
  cursor: pointer;
}

.filter-count:not(:empty) {
  margin-left: 4px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  margin: 14px 0;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend,
.stacked > span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.range {
  display: flex;
  align-items: center;
  gap: 6px;
}

.range legend {
  float: left;
  width: 100%;
}

.filters input[type="number"],
.filters input[type="text"],
.filters select,
.ingest-form input {
  width: 100%;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid #dcdcdc;
  border-radius: 8px;
  background: #fff;
}

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

.segmented legend {
  width: 100%;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid #dcdcdc;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.segmented input:checked + span {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--a);
}

.stacked {
  display: flex;
  flex-direction: column;
}

/* ---- status ---- */

.status {
  min-height: 1.6em;
  margin: 0 0 8px;
  color: var(--faint);
  font-size: 12px;
}

.status.error {
  color: var(--danger);
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  vertical-align: -1px;
  border: 2px solid #e0e0e0;
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---- results ---- */

/* 曲の一覧は白いパネルに載せ、背景の写真や色の上でも読みやすくする */
.results-column {
  padding: 24px 28px 12px;
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.now {
  padding-bottom: 4px;
}

.now-title {
  margin: 0;
  /* 白いパネルの上でも読めるよう、気分の色を少し暗くする */
  color: color-mix(in srgb, var(--a) 70%, #000);
  font-size: 22px;
  font-weight: 700;
  overflow-wrap: anywhere;
  transition: color 0.8s ease;
}

.now-desc {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.results {
  margin: 0;
  padding: 0;
  list-style: none;
}

.track {
  display: grid;
  grid-template-columns: 4px 36px minmax(0, 1fr) auto;
  gap: 2px 14px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  animation: fade 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 20ms);
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* 左の縦の線は、曲の特徴（キー・エネルギー・アコースティック度）から決まる色 */
.track::before {
  content: "";
  grid-row: span 2;
  align-self: stretch;
  border-radius: 999px;
  background: var(--dot);
}

.play {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #e2e2e2;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.play svg {
  width: 12px;
  height: 12px;
  fill: var(--text);
}

.play:hover,
.track.playing .play {
  border-color: var(--dot);
  background: var(--dot);
}

.play:hover svg,
.track.playing .play svg {
  fill: #fff;
}

.play:disabled {
  opacity: 0.4;
  cursor: default;
}

.meta {
  min-width: 0;
}

.track-title {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-artist {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score {
  color: var(--faint);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

.score strong {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.facts {
  grid-column: 3 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 2px;
  color: var(--faint);
  font-size: 12px;
}

.tag {
  white-space: nowrap;
}

.icon-button,
.link-button,
.external {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}

.link-button:hover,
.external:hover {
  color: var(--link);
  text-decoration: underline;
}

.icon-button {
  display: grid;
  place-items: center;
}

.icon-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}

.icon-button:hover {
  color: #e0457b;
}

.favorite-button[aria-pressed="true"] {
  color: #e0457b;
}

.favorite-button[aria-pressed="true"] svg {
  fill: currentColor;
}

.external {
  margin-left: auto;
}

.empty {
  padding: 28px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

/* ---- taste ---- */

.taste {
  padding-top: 72px;
}

.taste-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 40px 0 20px;
}

.card {
  padding: 24px 28px;
  border-radius: 22px;
  background: var(--panel);
}

.card-title {
  display: block;
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
}

.muted {
  color: var(--faint);
  font-size: 13px;
  font-weight: 400;
}

.favorites-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.song-list {
  display: grid;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.song-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.song-row .meta,
.song-row .empty {
  flex: 1;
}

.song-row .empty {
  padding: 8px 0;
  border: 0;
}

.artwork {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--surface);
  object-fit: cover;
}

.words {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.word {
  --weight: 1;
  font-size: calc(14px + 16px * var(--weight));
  font-weight: 700;
  line-height: 1.3;
  opacity: calc(0.4 + 0.6 * var(--weight));
}

.note {
  color: var(--muted);
  font-size: 13px;
}

.insights {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.insight {
  display: grid;
  grid-template-columns: 8em minmax(0, 1fr);
  gap: 2px 12px;
  align-items: center;
  font-size: 13px;
}

.insight-value {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.insight-label + .insight-value {
  grid-column: 2;
  grid-row: 1;
}

.meter-bar {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.meter-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--a), var(--b));
}

.section-title {
  margin: 48px 0 12px;
  font-size: 18px;
}

/* ---- footer ---- */

.footer {
  margin-top: 96px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.admin {
  font-size: 13px;
}

.ingest-form {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 12px 0;
}

.ingest-summary {
  margin: 0;
  padding-left: 1.2em;
}

.backfill {
  display: flex;
  align-items: center;
  gap: 12px;
}

.credit {
  margin: 16px 0 0;
  color: var(--faint);
  font-size: 12px;
}

.footer-links {
  display: flex;
  gap: 20px;
  margin-top: 8px;
  font-size: 12px;
}

.footer-links a {
  color: var(--faint);
}

/* ---- small screens ---- */

@media (max-width: 860px) {
  .page {
    padding: 20px 16px 40px;
  }

  .masthead {
    flex-wrap: wrap;
    gap: 8px 24px;
  }

  .stats {
    width: 100%;
    margin: 0;
  }

  .search {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
    padding-top: 40px;
  }

  .mood-column {
    position: static;
  }

  .taste {
    padding-top: 40px;
  }

  .taste-grid,
  .filter-grid,
  .ingest-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 480px) {
  .mood {
    font-size: 16px;
  }

  .results-column {
    margin: 0 -8px;
    padding: 18px 16px 8px;
  }

  .score {
    display: none;
  }

  .track {
    grid-template-columns: 4px 36px minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root,
  .now-title {
    transition: none;
  }

  .track {
    animation: none;
  }
}

/* ---- 色や写真の背景の上に直接のる部分は白い文字にする ---- */

.masthead,
.mood-column,
.taste-intro,
.footer {
  --text: #fff;
  --muted: rgb(255 255 255 / 0.78);
  --faint: rgb(255 255 255 / 0.62);
  --link: #fff;
  color: var(--text);
  text-shadow: 0 1px 12px rgb(0 0 0 / 0.25);
}

.tab[aria-selected="true"] {
  border-bottom-color: #fff;
}

.mood[aria-pressed="true"] {
  color: #fff;
}

.mood[aria-pressed="true"] .dot {
  box-shadow: 0 0 0 2px #fff;
}

.kind {
  background: rgb(255 255 255 / 0.18);
}

.mood-action:hover {
  background: rgb(255 255 255 / 0.18);
}

.mood-column .underline {
  border-bottom-color: #fff;
}

.mood-column .underline input::placeholder {
  color: rgb(255 255 255 / 0.55);
}

.mood-column .text-button,
.reset-searches {
  color: #fff;
}

.kind-switch {
  background: rgb(255 255 255 / 0.18);
}

.kind-switch input:checked + span {
  color: #1d1d1f;
  text-shadow: none;
}

.seed {
  background: rgb(255 255 255 / 0.9);
  color: #1d1d1f;
  text-shadow: none;
}

.filters input[type="number"],
.filters input[type="text"],
.filters select,
.ingest-form input,
.rename {
  color: #1d1d1f;
  text-shadow: none;
}

.segmented span {
  border-color: rgb(255 255 255 / 0.5);
}

.segmented input:checked + span {
  border-color: #fff;
  background: #fff;
  color: #1d1d1f;
  text-shadow: none;
}

.footer {
  border-top-color: rgb(255 255 255 / 0.25);
}

.footer .button {
  text-shadow: none;
}
