
/* ==============================
   ベース設定（タイトルと同一フォントに統一）
============================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --home-fg: #1e292b;
  --home-fg-soft: rgba(30, 41, 43, 0.85);
  --home-surface: rgba(255, 255, 255, 0.42);
  --home-surface-hover: rgba(255, 255, 255, 0.62);
  --home-border: rgba(30, 41, 43, 0.28);
  --home-ripple: rgba(30, 41, 43, 0.36);
  --site-font: "Cormorant Garamond", "Shippori Mincho", "Yu Mincho", serif;
}

/* 暗い背景テーマ（Midnight Blue など） */
body.theme-midnight,
body.dark-theme,
body[data-theme="midnight"] {
  --home-fg: #ffffff;
  --home-fg-soft: rgba(255, 255, 255, 0.9);
  --home-surface: rgba(255, 255, 255, 0.16);
  --home-surface-hover: rgba(255, 255, 255, 0.28);
  --home-border: rgba(255, 255, 255, 0.4);
  --home-ripple: rgba(255, 255, 255, 0.48);
}

body {
  margin: 0;
  background: #99afb0;
  color: var(--home-fg);
  font-family: var(--site-font);
  overflow-x: hidden;
  position: relative;
  min-height: 100dvh;
  transition: color 0.25s ease;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

/* ==============================
   サイト上部：overtone タイトルロゴ ＆ 下部の細い区切り線
============================== */
.site-header {
  position: fixed;
  top: 24px;
  left: 0;
  right: 0;
  z-index: 110;
  pointer-events: none;
  display: flex;
  justify-content: center;
}

.site-header::after {
  content: "";
  position: fixed;
  top: 82px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--home-border);
  pointer-events: none;
  transition: background-color 0.25s ease;
}

.site-logo {
  margin: 0;
  font-size: clamp(1.45rem, 2.8vw, 2.1rem);
  font-weight: 400;
  font-family: var(--site-font);
  letter-spacing: 0.28em;
  text-transform: lowercase;
  color: var(--home-fg);
  user-select: none;
  transition: color 0.25s ease;
}


/* スマホ時（縦・横）：線を非表示 */
@media (max-width: 768px), (max-height: 500px) and (orientation: landscape) {
  .site-header::after {
    display: none;
  }
}

/* ==============================
   左上マスターコントロール（再生/一時停止 ＆ 音声SVG＋全体音量）
============================== */
.top-master-controls {
  position: fixed;
  top: 30px;
  left: 40px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 100;
}

.global-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--home-border);
  background: var(--home-surface);
  color: var(--home-fg);
  font-size: 15px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}

.global-play-btn:hover {
  transform: scale(1.06);
  background: var(--home-surface-hover);
}

.global-play-btn.is-playing {
  background: rgba(217, 72, 72, 0.92);
  border-color: rgba(255, 145, 145, 0.85);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(217, 72, 72, 0.45);
}

.global-play-btn.is-paused .global-btn-icon {
  margin-left: 2px;
}

.master-vol-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--home-surface);
  padding: 6px 14px;
  border-radius: 20px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--home-border);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.volume-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
}

.master-vol-wrapper .vol-slider {
  width: 90px;
}

/* ==============================
   右上 言語切替 ＆ About ボタン
============================== */
.top-about-action {
  position: fixed;
  top: 28px;
  right: 40px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
}

.lang-toggle-btn,
.about-top-btn {
  background: var(--home-surface);
  border: 1px solid var(--home-border);
  color: var(--home-fg);
  padding: 10px 20px;
  border-radius: 24px;
  cursor: pointer;
  font-size: 15.5px;
  line-height: 1.2;
  font-family: inherit;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.lang-toggle-btn {
  padding: 10px 18px;
  letter-spacing: 0.08em;
}

.lang-toggle-btn:hover,
.about-top-btn:hover {
  background: var(--home-surface-hover);
  transform: translateY(-1px);
}

/* ==============================
   メイン中央：波紋付きの円形 Sound List ボタン（常に画面中央）
============================== */
.main-center-action {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  margin: 0;
}

.ripple-circle-btn {
  position: relative;
  width: 104px;
  height: 104px;
  padding: 0;
  border-radius: 50%;
  background: var(--home-surface);
  border: 1px solid var(--home-border);
  color: var(--home-fg);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  transition: transform 0.25s ease, background-color 0.25s ease, border-color 0.25s ease;
}

.ripple-circle-btn:hover {
  background: var(--home-surface-hover);
  transform: scale(1.06);
}

.ripple-circle-btn .circle-icon {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0;
  line-height: 1;
}

.ripple-circle-btn .circle-svg-icon {
  width: 38px;
  height: 38px;
  display: block;
  object-fit: contain;
}

.ripple-circle-btn .ripple-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--home-ripple);
  pointer-events: none;
  animation: soundRipple 3.2s cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
  transition: border-color 0.25s ease;
}

.ripple-circle-btn .ripple-ring.delay {
  animation-delay: 1.6s;
}

@keyframes soundRipple {
  0% {
    transform: scale(1);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.85);
    opacity: 0;
  }
}

/* ==============================
   右下 背景コントロール
============================== */
.bg-controls {
  color: var(--home-fg);
  font-family: inherit;
  transition: color 0.25s ease;
}

.bg-controls .bg-label,
.bg-controls .bg-select {
  color: var(--home-fg);
  font-family: inherit;
}

/* ==============================
   モーダル（暗いボックス内で白文字を維持）
============================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: rgba(37, 50, 58, 0.92);
  width: 90%;
  max-width: 520px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  padding: 28px;
  color: #ffffff;
  font-family: inherit;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 27px;
  font-family: inherit;
  font-weight: normal;
  letter-spacing: 0.06em;
  color: #ffffff;
}

.back-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: 0.2s;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.about-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  font-size: 16px;
  line-height: 1.85;
  color: rgba(255, 255, 255, 0.92);
  font-family: inherit;
  letter-spacing: 0.3px;
}

.about-body::-webkit-scrollbar {
  width: 6px;
}

.about-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.about-body p {
  margin: 0 0 14px;
}

.about-body p:last-child {
  margin-bottom: 0;
}

.about-section-title {
  margin: 24px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: #ffffff;
}

.about-section-title:first-child {
  margin-top: 0;
}

.about-step-title {
  margin: 16px 0 4px !important;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.04em;
}

/* プリセットセクション */
.preset-section {
  flex-shrink: 0;
}

.preset-section h3 {
  font-size: 20px;
  opacity: 0.8;
  margin: 0 0 10px;
  font-weight: normal;
  font-family: inherit;
  color: #ffffff;
}

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

.preset-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: 0.2s;
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.preset-btn.active-preset {
  background: rgba(255, 255, 255, 0.4);
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin: 20px 0;
  flex-shrink: 0;
}

/* ==============================
   タグ（カテゴリ）切替セクション
============================== */
.tag-section {
  margin-top: 16px;
  flex-shrink: 0;
}

.tag-section h3 {
  font-size: 14px;
  opacity: 0.75;
  margin: 0 0 10px;
  font-weight: normal;
  font-family: inherit;
  color: #ffffff;
}

.tag-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.85);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tag-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.tag-btn.active-tag {
  background: #5b8c85;
  border-color: #79a8a3;
  color: #ffffff;
}

#activePresetTagBtn {
  border-style: dashed;
}

/* ==============================
   サウンドリスト一覧（スクロール対応）
============================== */
.sound-list-container {
  overflow-y: auto;
  max-height: 320px;
  padding-right: 4px;
}

.sound-list-container::-webkit-scrollbar {
  width: 6px;
}

.sound-list-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.sound-item {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: background 0.3s;
}

.sound-item.active {
  background: rgba(255, 255, 255, 0.12);
}

.sound-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sound-item.hidden {
  display: none !important;
}

.sound-name {
  font-size: 16px;
  font-family: inherit;
  color: #ffffff;
}

.play-toggle-btn {
  background: #5b8c85;
  border: none;
  color: #ffffff;
  padding: 6px 16px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: 0.2s;
}

.play-toggle-btn.playing {
  background: #d96b6b;
}

.volume-control-wrapper {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

.vol-slider {
  flex: 1;
  accent-color: #79a8a3;
  cursor: pointer;
}

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

/* ==============================
   スマホ・タブレット共通：スライダー非表示 ＆ 中央ボタン維持
============================== */
@media (max-width: 768px) {
  #masterVolumeSlider,
  .master-vol-wrapper,
  .vol-slider,
  .volume-control-wrapper {
    display: none !important;
  }
}

@media (max-width: 1024px) {
  html,
  body {
    min-height: 100dvh;
    overflow-x: hidden;
  }

  .site-header {
    top: max(16px, env(safe-area-inset-top));
  }

  .main-center-action {
    position: fixed;
    top: 50%;
    left: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    z-index: 40;
    margin: 0;
  }

  .ripple-circle-btn {
    width: 88px;
    height: 88px;
  }

  .ripple-circle-btn .circle-svg-icon {
    width: 32px;
    height: 32px;
  }

  .ripple-circle-btn:hover {
    transform: scale(1.04);
  }
}

/* ==============================
   スマホ縦：左右余白の確保 ＆ 背景選択のはみ出し防止
============================== */
@media (max-width: 768px) and (orientation: portrait) {
  .top-master-controls {
    top: max(16px, env(safe-area-inset-top));
    left: 16px;
  }

  .top-about-action {
    top: max(16px, env(safe-area-inset-top));
    right: 16px;
    gap: 6px;
  }

  .lang-toggle-btn,
  .about-top-btn {
    padding: 6px 12px;
    font-size: 13px;
  }

  .modal-content {
    width: calc(100% - 32px);
    max-width: calc(100vw - 32px);
    margin-left: auto;
    margin-right: auto;
    padding: 20px 18px;
  }

  .bg-controls {
    right: 12px;
    bottom: max(20px, env(safe-area-inset-bottom));
    max-width: calc(100vw - 24px);
    transform: scale(0.88);
    transform-origin: right bottom;
  }

  #speedSlider,
  #toneSelect {
    max-width: 100%;
  }
}

/* ==============================
   スマホ横：ヘッダー＋左列上下（プリセット/カテゴリー）＋ 右列（サウンド一覧）
============================== */
@media (max-height: 500px) and (orientation: landscape) {
  .site-header {
    top: 10px;
  }

  .site-logo {
    font-size: 1.2rem;
    letter-spacing: 0.22em;
  }

  .ripple-circle-btn {
    width: 76px;
    height: 76px;
  }

  .ripple-circle-btn .circle-svg-icon {
    width: 28px;
    height: 28px;
  }

  #soundModal .modal-content {
    display: grid;
    grid-template-columns: 42% 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "header header"
      "preset main"
      "category main";
    column-gap: 16px;
    row-gap: 8px;
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
    height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px);
    padding: 12px 16px;
    overflow: hidden;
  }

  #soundModal .modal-header {
    grid-area: header;
    margin-bottom: 4px;
  }

  #soundModal .preset-section {
    grid-area: preset;
    margin: 0;
  }

  #soundModal .preset-section h3 {
    font-size: 15px;
    margin-bottom: 6px;
  }

  #soundModal .tag-section {
    grid-area: category;
    margin: 0;
    overflow-y: auto;
    min-height: 0;
  }

  #soundModal .tag-section h3 {
    font-size: 13px;
    margin-bottom: 6px;
  }

  #soundModal .divider {
    display: none;
  }

  #soundModal .sound-list-container {
    grid-area: main;
    max-height: none;
    height: 100%;
    overflow-y: auto;
    min-height: 0;
    padding-right: 4px;
  }
}