/* ===========================================
   ヒトトキ-RadioFitter - スタイルシート
   =========================================== */

/* リセットと基本設定 */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #6366f1;
  --color-primary-dark: #4f46e5;
  --color-secondary: #64748b;
  --color-success: #22c55e;
  --color-error: #ef4444;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-text: #1e293b;
  --color-text-light: #64748b;
  --color-border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* コンテナ */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ヘッダー */
.header {
  text-align: center;
  margin-bottom: 32px;
}

.header__title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.header__subtitle {
  font-size: 0.875rem;
  color: var(--color-text-light);
}

.header__nav {
  margin-top: 12px;
}

.header__link {
  font-size: 0.875rem;
  color: var(--color-secondary);
  text-decoration: none;
}

.header__link:hover {
  text-decoration: underline;
}

/* スクリーン */
.screen {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 選択グループ */
.selection-group {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.selection-group__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--color-text);
}

/* ラジオボタングループ */
.radio-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.radio-option {
  position: relative;
  cursor: pointer;
}

.radio-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-option__label {
  display: block;
  padding: 12px 16px;
  text-align: center;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.radio-option input:checked + .radio-option__label {
  border-color: var(--color-primary);
  background-color: var(--color-primary);
  color: white;
}

.radio-option:hover .radio-option__label {
  border-color: var(--color-primary);
}

/* スライダー */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#time-slider {
  width: 100%;
}

.slider-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--color-text-light);
}

.slider-value {
  font-weight: 600;
  color: var(--color-text);
}

.slider-hint {
  color: var(--color-text-light);
}

.preset-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}

.preset-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.preset-btn.is-active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: white;
}

/* ボタン */
.btn {
  display: block;
  width: 100%;
  padding: 16px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn--primary {
  background-color: var(--color-primary);
  color: white;
}

.btn--primary:hover {
  background-color: var(--color-primary-dark);
}

.btn--primary:disabled {
  background-color: var(--color-border);
  cursor: not-allowed;
}

.btn--secondary {
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 2px solid var(--color-border);
  padding: 12px 20px;
  width: auto;
}

.btn--secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn--outline {
  background-color: transparent;
  color: var(--color-secondary);
  border: 2px solid var(--color-border);
  margin-top: 24px;
}

.btn--outline:hover {
  border-color: var(--color-secondary);
}

.btn--favorite {
  background-color: #fef3c7;
  color: #92400e;
  border: 2px solid #fcd34d;
  width: auto;
  padding: 8px 16px;
  margin-top: 12px;
}

.btn--favorite.is-active {
  background-color: #fde68a;
  border-color: #f59e0b;
}

/* エラーメッセージ */
.error-message {
  color: var(--color-error);
  font-size: 0.875rem;
  text-align: center;
  margin-bottom: 16px;
  padding: 12px;
  background-color: #fef2f2;
  border-radius: 8px;
}

/* キュー情報 */
.queue-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.queue-info__item {
  background: var(--color-surface);
  padding: 16px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
}

.queue-info__label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-bottom: 4px;
}

.queue-info__value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
}

/* プレイヤー */
.player {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.player__now-playing {
  text-align: center;
  margin-bottom: 16px;
}

.player__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player__source {
  font-size: 0.875rem;
  color: var(--color-text-light);
}

.player__audio {
  width: 100%;
  margin-bottom: 16px;
}

.player__controls {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* キュー一覧 */
.queue-list {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.queue-list__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.queue-list__items {
  list-style: none;
}

.queue-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--color-bg);
  transition: background 0.2s ease;
}

.queue-item--active {
  background: #eef2ff;
  border: 2px solid var(--color-primary);
}

.queue-item__number {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-border);
  border-radius: 50%;
  font-size: 0.875rem;
  font-weight: 600;
  margin-right: 12px;
  flex-shrink: 0;
}

.queue-item--active .queue-item__number {
  background: var(--color-primary);
  color: white;
}

.queue-item__info {
  flex: 1;
  min-width: 0;
}

.queue-item__title {
  font-size: 0.875rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-item__duration {
  font-size: 0.75rem;
  color: var(--color-text-light);
}

/* 候補一覧 */
.candidate-list {
  list-style: none;
}

.candidate-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--color-bg);
  position: relative;
}

.candidate-item__info {
  min-width: 0;
  padding-right: 140px;
}

.candidate-item__title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-item__meta {
  font-size: 0.75rem;
  color: var(--color-text-light);
}

.candidate-note {
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-bottom: 8px;
}

.candidate-item__action {
  flex-shrink: 0;
  position: absolute;
  top: 12px;
  right: 12px;
}

.candidate-empty {
  font-size: 0.875rem;
  color: var(--color-text-light);
}

.candidate-details {
  margin-top: 10px;
  padding: 10px;
  background: var(--color-surface);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.candidate-details__title {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.candidate-details__list {
  list-style: none;
  font-size: 0.75rem;
  color: var(--color-text-light);
}

.candidate-details__item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--color-border);
}

.candidate-details__item:last-child {
  border-bottom: none;
}

.candidate-details__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-details__time {
  flex-shrink: 0;
}

/* お気に入り */
.favorite-list {
  list-style: none;
}

.favorite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--color-bg);
  margin-bottom: 8px;
}

.favorite-item__info {
  min-width: 0;
}

.favorite-item__title {
  font-size: 0.875rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-item__url {
  font-size: 0.75rem;
  color: var(--color-text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-item__remove {
  flex-shrink: 0;
}

.favorite-empty {
  font-size: 0.875rem;
  color: var(--color-text-light);
}

/* 広告バナー */
.ad-banner {
  margin: 16px 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px dashed var(--color-border);
  background: #f8fafc;
}

.ad-banner__label {
  font-size: 0.7rem;
  color: var(--color-text-light);
  margin-bottom: 6px;
}

.ad-banner__link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.ad-banner__title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.ad-banner__desc {
  font-size: 0.75rem;
  color: var(--color-text-light);
}

/* ローディング */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading[hidden] {
  display: none;
}

.loading__spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading__text {
  margin-top: 16px;
  color: var(--color-text-light);
}

/* レスポンシブ */
@media (max-width: 360px) {
  .radio-group {
    grid-template-columns: 1fr;
  }

  .queue-info {
    grid-template-columns: 1fr;
  }
}
