:root {
  --bg-color: #f0f2f5;
  --card-bg: #ffffff;
  --text-color: #1f2937;
  --text-mute: #6b7280;
  --header-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --primary-color: #1a73e8;
  --border-color: #e5e7eb;
  --overlay-color: rgba(0, 0, 0, 0.4);
  --transition-speed: 0.3s;
}

:root.dark-theme {
  --bg-color: #121212;
  --card-bg: #1e1e1e;
  --text-color: #e5e7eb;
  --text-mute: #9ca3af;
  --header-bg: #1e1e1e;
  --sidebar-bg: #1e1e1e;
  --border-color: #333333;
  --primary-color: #4285f4;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color var(--transition-speed);
}
input, button { font-family: inherit; }

/* サムネイル非表示設定 */
body.hide-thumbs .thumb {
  display: none;
}

.header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 15px;
  height: 60px;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-title { font-size: 1.5rem; font-weight: bold; margin: 0; color: var(--primary-color); text-align: center; }
.header-right { display: flex; justify-content: flex-end; }

.menu-trigger-btn {
  background: var(--primary-color);
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  color: white;
  cursor: pointer;
}

.sidebar {
  position: fixed;
  top: 0; right: 0;
  width: 280px; max-width: 80vw; height: 100vh;
  box-sizing: border-box;
  background-color: var(--sidebar-bg);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -5px 0 15px rgba(0,0,0,0.1);
  display: flex; flex-direction: column;
  overscroll-behavior: contain;
}

.sidebar.active { transform: translateX(0); }
.sidebar-header { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); }
.sidebar-title-group h2 { margin: 0; font-size: 18px; }
#resultCount { font-size: 13px; color: var(--primary-color); font-weight: bold; }
.sidebar-scroll-area {
  padding: 20px;
  padding-bottom: 40px;
  overflow-y: auto;
  overflow-x: hidden;
  flex-grow: 1;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  container-type: inline-size;
  box-sizing: border-box;
}
.sidebar-section { margin-bottom: 25px; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.section-label { display: block; font-size: 11px; font-weight: bold; color: var(--text-mute); }
.text-clear-btn { background: none; border: none; color: var(--primary-color); font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline; }

input[type="text"] {
  width: 100%; padding: 10px; border: 2px solid var(--border-color);
  border-radius: 8px; background: var(--card-bg); color: var(--text-color); outline: none; box-sizing: border-box;
  font-size: 16px;
}

#formatsList {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 12px;
  row-gap: 8px;
  width: 100%;
}
#formatsList .checkbox-item {
  margin-bottom: 0;
  width: 100%;
  box-sizing: border-box;
}
.checkbox-item { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; margin-bottom: 8px; }

.date-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.date-row-label {
  width: 40px;
  flex-shrink: 0;
}
.date-select-group { display: flex; gap: 6px; flex-wrap: nowrap; flex-grow: 1; }
.date-select {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  appearance: none;
}
.date-select.year { flex: 0 0 4.6em; }
.date-select.month,
.date-select.day { flex: 0 0 3.1em; }
.ios .date-select-group.is-updating .date-select.month,
.ios .date-select-group.is-updating .date-select.day {
  visibility: hidden;
  pointer-events: none;
}

.date-clear-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-mute);
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  box-sizing: border-box;
  transition: all 0.2s;
}
.date-clear-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }

@supports not (appearance: none) {
  .date-select { -webkit-appearance: none; -moz-appearance: none; appearance: none; }
}

.container {
  max-width: 1920px;
  margin: 0 auto;
  padding: 15px 15px 0 15px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#resultList {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  width: 100%;
}

@media (min-width: 600px) { #resultList { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { #resultList { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1400px) { #resultList { grid-template-columns: repeat(4, 1fr); } }

.song-card {
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
}

.thumb { width: 100%; aspect-ratio: 16/9; background: #000; position: relative; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb::after { content: '▶'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: white; font-size: 24px; opacity: 0.5; }
.thumb.playing::after { content: ""; }
.thumb iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; z-index: 1; }
.thumb-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.thumb-close-btn:hover { background: rgba(0, 0, 0, 0.85); }
.thumb-close-btn:active { transform: translateY(1px); }
.thumb[data-video-id=""]::after { content: ""; }
.thumb[data-video-id=""] { cursor: default; }

.content { padding: 6px; flex-grow: 1; }
.title { font-size: 14px; font-weight: bold; color: var(--primary-color); margin-bottom: 2px; line-height: 1.2; }
.title-link { text-decoration: none; }
.title-link:hover { text-decoration: underline; }
.artist { font-size: 12px; color: var(--text-mute); margin-bottom: 6px; }

.card-footer { display: flex; justify-content: space-between; align-items: center; font-size: 10px; border-top: 1px solid var(--border-color); padding-top: 4px; }

/* 日付は左、タグは右にまとめる */
.footer-left { display: flex; align-items: center; gap: 8px; }
.footer-right { display: flex; align-items: center; justify-content: flex-end; }
.footer-tags { display: flex; align-items: center; gap: 6px; }

.tag { padding: 1px 3px; border-radius: 2px; font-size: 9px; background: var(--border-color); color: var(--text-mute); font-weight: bold; }
.tag-relay { background: #fff3e0; color: #e65100; }
.tag-harmony { background: #f3e5f5; color: #7b1fa2; }

.load-more-container { margin: 10px 0 5px; text-align: center; }
.load-more-btn {
  background-color: var(--primary-color);
  color: white; border: none; padding: 10px 20px; font-size: 13px; border-radius: 20px; cursor: pointer;
}
.hidden { display: none !important; }

.site-footer {
  width: 100%;
  max-width: 1920px;
  margin: 5px auto 0;
  padding: 10px 15px 20px;
  border-top: 1px solid var(--border-color);
  color: var(--text-mute);
  font-size: 11px;
  line-height: 1.6;
  text-align: left;
  box-sizing: border-box;
}

.site-footer p { margin: 0; }

.close-btn { background: none; border: none; font-size: 28px; color: var(--text-color); cursor: pointer; }
.overlay { position: fixed; inset: 0; background: var(--overlay-color); z-index: 900; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.overlay.show { opacity: 1; pointer-events: auto; }

/* スイッチの位置合わせ */
.menu-item-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 8px;
  min-width: 0;
}
.menu-item-toggle span { flex: 1; min-width: 0; }

.switch { position: relative; width: 34px; height: 18px; display: inline-block; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 20px; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 12px; width: 12px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .4s; }
input:checked + .slider { background: var(--primary-color); }
input:checked + .slider:before { transform: translateX(16px); }
hr { border: 0; border-top: 1px solid var(--border-color); margin: 15px 0; }
