/* =============================================
   CSS Variables
   ============================================= */
:root {
  /* ── ライトモード（屋外デフォルト） ── */
  --bg-primary:   #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-card:      #ffffff;
  --bg-elevated:  #e8ecf1;
  --bg-hover:     #dde2ea;

  --accent-primary:   #1d4ed8;   /* 濃い青：晴天下でも視認性◎ */
  --accent-secondary: #1e40af;
  --accent-glow:      rgba(29, 78, 216, 0.25);
  --accent-gradient:  linear-gradient(135deg, #1d4ed8, #1e40af);

  --playing-color:    #dc2626;   /* 赤：再生中は一目でわかる */
  --playing-glow:     rgba(220, 38, 38, 0.3);
  --playing-gradient: linear-gradient(135deg, #dc2626, #b91c1c);
  --playing-bg:       #fef2f2;

  --success: #15803d;
  --danger:  #dc2626;
  --warning: #b45309;
  --info:    #0369a1;

  --text-primary:   #0f172a;   /* ほぼ黒 */
  --text-secondary: #334155;
  --text-muted:     #64748b;
  --text-on-accent: #ffffff;

  --border:        rgba(0,0,0,0.12);
  --border-strong: rgba(0,0,0,0.25);
  --border-accent: #1d4ed8;

  --sidebar-width:  230px;
  --header-height:  68px;
  --player-height:  96px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.10), 0 0 0 1px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);

  --transition: 0.15s cubic-bezier(0.4,0,0.2,1);
}

/* ── ダークモード ── */
[data-theme="dark"] {
  --bg-primary:   #0e0e16;
  --bg-secondary: #161622;
  --bg-card:      #1e1e2e;
  --bg-elevated:  #252538;
  --bg-hover:     #2e2e45;

  --accent-primary:   #7c6af7;
  --accent-secondary: #5b4fcf;
  --accent-glow:      rgba(124,106,247,0.35);
  --accent-gradient:  linear-gradient(135deg, #7c6af7, #5b4fcf);

  --playing-color:    #f97316;
  --playing-glow:     rgba(249,115,22,0.4);
  --playing-gradient: linear-gradient(135deg, #f97316, #ea580c);
  --playing-bg:       rgba(249,115,22,0.08);

  --success: #22c55e;
  --danger:  #ef4444;
  --warning: #f59e0b;
  --info:    #38bdf8;

  --text-primary:   #f1f0ff;
  --text-secondary: #a09ec0;
  --text-muted:     #5e5c7a;
  --text-on-accent: #ffffff;

  --border:        rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.15);
  --border-accent: rgba(124,106,247,0.5);

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
}

/* =============================================
   Reset
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }   /* 屋外は少し大きめ基準 */

body {
  font-family: 'Inter', 'Noto Sans JP', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--header-height) 1fr;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* =============================================
   Header
   ============================================= */
.app-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

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

.app-logo {
  width: 42px;
  height: 42px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.header-title h1 {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.title-event {
  display: inline-block;
  margin-left: 8px;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 10px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  vertical-align: middle;
}

.header-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 2px;
}

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

/* 時計：屋外で遠目からでも読める */
.clock-display {
  font-family: 'Inter', monospace;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
  background: var(--bg-elevated);
  padding: 6px 18px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  line-height: 1;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 700;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  transition: var(--transition);
}

.header-status.playing {
  background: var(--playing-bg);
  border-color: var(--playing-color);
  color: var(--playing-color);
}

.header-status.playing i { animation: pulse-dot 1s infinite; }

@keyframes pulse-dot {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* テーマ切り替えボタン */
.theme-toggle {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent-primary); color: var(--accent-primary); }

/* =============================================
   Main Layout
   ============================================= */
.app-main {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* =============================================
   Sidebar
   ============================================= */
.sidebar {
  background: var(--bg-secondary);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.setlist-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.setlist-nav::-webkit-scrollbar { width: 4px; }
.setlist-nav::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

/* セットリストタブ：屋外でタッチしやすいよう大きめ */
.setlist-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 12px;        /* タッチターゲット大きめ */
  min-height: 48px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  margin-bottom: 3px;
  position: relative;
}

.setlist-tab:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}

.setlist-tab.active {
  background: rgba(29, 78, 216, 0.08);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  font-weight: 700;
}

[data-theme="dark"] .setlist-tab.active {
  background: rgba(124, 106, 247, 0.15);
}

.setlist-tab .tab-num {
  width: 26px;
  height: 26px;
  background: var(--bg-elevated);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  color: var(--text-muted);
}

.setlist-tab.active .tab-num {
  background: var(--accent-primary);
  color: white;
}

.setlist-tab .tab-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setlist-tab .tab-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 100px;
  min-width: 26px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-actions {
  padding: 10px;
  border-top: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  min-height: 44px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  font-family: inherit;
}

.btn-action:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-strong); }

.btn-add    { color: var(--success); border-color: rgba(21,128,61,0.3); }
.btn-rename { color: var(--accent-primary); border-color: var(--border-accent); }
.btn-clear  { color: var(--danger); border-color: rgba(220,38,38,0.3); }

.btn-add:hover    { background: rgba(21,128,61,0.07);   border-color: var(--success);         color: var(--success); }
.btn-rename:hover { background: rgba(29,78,216,0.07);   border-color: var(--accent-primary);   color: var(--accent-primary); }
.btn-clear:hover  { background: rgba(220,38,38,0.07);  border-color: var(--danger);            color: var(--danger); }

/* =============================================
   Content Area
   ============================================= */
.content-area { display: flex; flex-direction: column; overflow: hidden; }

.buttons-section {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.buttons-section::-webkit-scrollbar { width: 6px; }
.buttons-section::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

/* セクションタイトル：遠くから見てもわかる */
.section-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.section-meta { display: flex; align-items: center; gap: 10px; }

.count-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid var(--border);
}

.drag-hint {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* =============================================
   Empty State
   ============================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--text-muted);
  margin-bottom: 20px;
  border: 2px dashed var(--border-strong);
}

.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 24px; }

.btn-empty-add {
  padding: 14px 32px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}
.btn-empty-add:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* =============================================
   Button Grid — 屋外向け大型ボタン
   ============================================= */
.button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.button-wrapper { position: relative; }

.button-wrapper.drag-over .sound-button {
  border-color: var(--accent-primary);
  background: rgba(29,78,216,0.06);
}

.sound-button {
  width: 100%;
  min-height: 90px;          /* 大きめで押しやすい */
  background: var(--bg-card);
  color: var(--text-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  font-size: 14px;
  font-weight: 700;          /* 太字で読みやすい */
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  word-break: break-word;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  /* タップのしやすさ */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.sound-button:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  background: var(--bg-elevated);
}

.sound-button:active {
  transform: translateY(0) scale(0.97);
  box-shadow: var(--shadow-sm);
}

/* 再生中：赤で強調 — 遠くから一目でわかる */
.sound-button.playing {
  background: var(--playing-bg);
  border-color: var(--playing-color);
  border-width: 3px;
  color: var(--playing-color);
  box-shadow: 0 0 0 4px rgba(220,38,38,0.15), var(--shadow-md);
  animation: playing-pulse 2s ease-in-out infinite;
}

[data-theme="dark"] .sound-button.playing {
  box-shadow: 0 0 0 4px rgba(249,115,22,0.2), var(--shadow-md);
}

@keyframes playing-pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(220,38,38,0.2), var(--shadow-md); }
  50%      { box-shadow: 0 0 0 7px rgba(220,38,38,0.08), var(--shadow-md); }
}

[data-theme="dark"] .sound-button.playing {
  animation: playing-pulse-dark 2s ease-in-out infinite;
}
@keyframes playing-pulse-dark {
  0%,100% { box-shadow: 0 0 0 3px rgba(249,115,22,0.25), var(--shadow-md); }
  50%      { box-shadow: 0 0 0 7px rgba(249,115,22,0.08), var(--shadow-md); }
}

.sound-button:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 3px;
}

.sound-button .btn-icon {
  font-size: 22px;
  color: var(--text-muted);
  transition: var(--transition);
}

.sound-button:hover .btn-icon { color: var(--accent-primary); }

/* 再生中アイコン */
.sound-button.playing .btn-icon {
  color: var(--playing-color);
  animation: icon-bounce 0.6s ease-in-out infinite alternate;
}

@keyframes icon-bounce {
  from { transform: scale(1); }
  to   { transform: scale(1.2); }
}

.sound-button .btn-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.sound-button.playing .btn-name { color: var(--playing-color); font-weight: 800; }
.sound-button.dragging { opacity: 0.4; cursor: grabbing; }

/* =============================================
   Player Bar — 屋外向け大型コントロール
   ============================================= */
.player-bar {
  height: auto;
  min-height: var(--player-height);
  background: var(--bg-secondary);
  border-top: 2px solid var(--border);
  display: grid;
  grid-template-columns: 220px 1fr auto auto;
  align-items: center;
  padding: 10px 18px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

/* Now Playing */
.now-playing { display: flex; align-items: center; gap: 12px; min-width: 0; }

.now-playing-icon {
  width: 46px;
  height: 46px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
  border: 2px solid var(--border);
  transition: var(--transition);
}

.now-playing-icon.active {
  background: var(--playing-bg);
  color: var(--playing-color);
  border-color: var(--playing-color);
}

.now-playing-icon.active i { animation: wave 1s ease-in-out infinite; }

@keyframes wave {
  0%,100% { transform: scaleY(1); }
  50%      { transform: scaleY(1.4); }
}

.now-playing-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* 現在再生中のタイトル：大きく太く */
.now-playing-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

/* Seekbar + Analyzer コンテナ */
.seekbar-area { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* アナライザー＋シークバーを縦に並べる列 */
.analyzer-seekbar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

/* シークバー行（時刻＋バー） */
.seekbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* =============================================
   Spectrum Analyzer
   ============================================= */
.analyzer-wrap {
  position: relative;
  width: 100%;
  height: 52px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: var(--transition);
}

/* 再生中は枠に色つける */
.analyzer-wrap.active {
  border-color: var(--accent-primary);
}

[data-theme="dark"] .analyzer-wrap.active {
  box-shadow: 0 0 0 1px var(--accent-primary);
}

#analyzer-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
}

/* アナライザー再生中はラインドラッグのヒントカーソル */
.analyzer-wrap.active #analyzer-canvas {
  cursor: crosshair;
}

/* 待機中のオーバーレイ */
.analyzer-idle {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.analyzer-idle i { font-size: 16px; }

.analyzer-idle.hidden { opacity: 0; }

/* ターゲットレベル表示行 */
.target-level-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
}

.target-level-icon {
  color: #f59e0b;   /* 琥珀色 - ラインと同色 */
  font-size: 11px;
  opacity: 0.9;
}

.target-level-hint {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
}

.target-level-label {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #d97706;   /* 濃い琥珀色 */
  font-size: 12px;
  min-width: 80px;
  letter-spacing: 0.02em;
}

[data-theme="dark"] .target-level-label {
  color: #fbbf24;
}

.target-level-tip {
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.75;
  margin-left: 2px;
}

.time-display {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: center;
}

.seekbar-wrapper {
  flex: 1;
  position: relative;
  height: 8px;       /* 少し太め */
  cursor: pointer;
}

.seekbar {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  z-index: 2;
  /* タッチ操作しやすくするため当たり判定拡大 */
  padding: 10px 0;
  margin: -10px 0;
  box-sizing: content-box;
}

.seekbar-progress {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  width: 0%;
  background: var(--accent-primary);
  border-radius: 4px;
  pointer-events: none;
  z-index: 1;
  transition: width 0.1s linear;
}

.seekbar-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 4px;
  z-index: 0;
  border: 1px solid var(--border);
}

.seekbar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  border: 2px solid white;
  margin-top: -5px;
}

.seekbar::-webkit-slider-track { height: 8px; background: transparent; }

.seekbar::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid white;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.seekbar::-moz-range-track { height: 8px; background: var(--bg-elevated); border-radius: 4px; }

/* Transport Controls — 屋外向け大きいボタン */
.transport-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 64px;
  height: 64px;
  padding: 0 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: 20px;      /* アイコン大きめ */
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.ctrl-btn:active { transform: scale(0.94); box-shadow: none; }

.ctrl-btn .ctrl-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.3px;
  font-family: inherit;
  color: inherit;
}

.ctrl-btn kbd {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: inherit;
  border: 1px solid var(--border);
}

/* 各ボタンカラー */
.ctrl-play  { color: var(--success);         border-color: rgba(21,128,61,0.4);   background: rgba(21,128,61,0.04); }
.ctrl-stop  { color: var(--danger);          border-color: rgba(220,38,38,0.4);   background: rgba(220,38,38,0.04); }
.ctrl-pause { color: var(--info);            border-color: rgba(3,105,161,0.4);   background: rgba(3,105,161,0.04); }
.ctrl-fade  { color: var(--warning);         border-color: rgba(180,83,9,0.4);    background: rgba(180,83,9,0.04); }

.ctrl-play:hover  { background: rgba(21,128,61,0.12);   border-color: var(--success);  transform: translateY(-2px); }
.ctrl-stop:hover  { background: rgba(220,38,38,0.12);   border-color: var(--danger);   transform: translateY(-2px); }
.ctrl-pause:hover { background: rgba(3,105,161,0.12);   border-color: var(--info);     transform: translateY(-2px); }
.ctrl-fade:hover  { background: rgba(180,83,9,0.12);    border-color: var(--warning);  transform: translateY(-2px); }

[data-theme="dark"] .ctrl-play  { background: rgba(34,197,94,0.06);  border-color: rgba(34,197,94,0.3); }
[data-theme="dark"] .ctrl-stop  { background: rgba(239,68,68,0.06);  border-color: rgba(239,68,68,0.3); }
[data-theme="dark"] .ctrl-pause { background: rgba(56,189,248,0.06); border-color: rgba(56,189,248,0.3); }
[data-theme="dark"] .ctrl-fade  { background: rgba(245,158,11,0.06); border-color: rgba(245,158,11,0.3); }

/* Volume */
.volume-area { display: flex; align-items: center; gap: 10px; flex-shrink: 0; min-width: 170px; }

.volume-icon-btn {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.volume-icon-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }

.volume-slider-wrapper { flex: 1; position: relative; height: 8px; cursor: pointer; }

.volume-slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  z-index: 2;
  padding: 10px 0;
  margin: -10px 0;
  box-sizing: content-box;
}

.volume-fill {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  width: 100%;
  background: var(--accent-primary);
  border-radius: 4px;
  pointer-events: none;
  z-index: 1;
  transition: width 0.05s linear;
}

.volume-slider-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 4px;
  z-index: 0;
  border: 1px solid var(--border);
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid white;
  cursor: pointer;
  margin-top: -5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.volume-slider::-webkit-slider-track { height: 8px; background: transparent; }

.volume-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid white;
  cursor: pointer;
}

.volume-slider::-moz-range-track { height: 8px; background: var(--bg-elevated); border-radius: 4px; }

/* 音量表示：大きめフォント */
.volume-value {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-secondary);
  min-width: 42px;
  text-align: right;
}

/* =============================================
   Toast
   ============================================= */
#toast-container {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: auto;
  max-width: 320px;
}

.toast.show { transform: translateX(0); opacity: 1; }

.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--info); }
.toast.warning { border-left: 4px solid var(--warning); }

.toast i { font-size: 16px; flex-shrink: 0; }
.toast.success i { color: var(--success); }
.toast.error   i { color: var(--danger); }
.toast.info    i { color: var(--info); }
.toast.warning i { color: var(--warning); }

/* =============================================
   Help FAB
   ============================================= */
.help-fab {
  position: fixed;
  bottom: calc(var(--player-height) + 12px);
  right: 16px;
  width: 48px; height: 48px;
  background: var(--bg-elevated);
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  box-shadow: var(--shadow-md);
}

.help-fab:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  transform: scale(1.1);
}

/* =============================================
   Modal
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.modal {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-primary);
}

.modal-close {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.modal-body { padding: 20px 24px 24px; }

.shortcut-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.shortcut-item kbd {
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  background: var(--bg-secondary);
  color: var(--accent-primary);
  border: 2px solid var(--border-accent);
  border-radius: 6px;
  padding: 3px 8px;
  min-width: 38px;
  text-align: center;
  flex-shrink: 0;
}

.shortcut-item span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* =============================================
   Loading
   ============================================= */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(14,14,22,0.85);
}

.loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--bg-elevated);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 900px) {
  :root { --sidebar-width: 190px; }
  .clock-display { font-size: 22px; padding: 5px 14px; }
}

@media (max-width: 700px) {
  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 2px solid var(--border);
    flex-direction: row;
    height: auto;
  }

  .sidebar-header { display: none; }

  .setlist-nav {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
    gap: 4px;
    scrollbar-width: none;
  }

  .setlist-nav::-webkit-scrollbar { display: none; }

  .setlist-tab {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 10px 14px;
    margin-bottom: 0;
    min-height: 44px;
  }

  .setlist-tab .tab-count { display: none; }

  .sidebar-actions {
    flex-direction: row;
    border-top: none;
    border-left: 2px solid var(--border);
    padding: 8px;
    gap: 6px;
  }

  .btn-action span { display: none; }
  .btn-action { min-width: 44px; justify-content: center; min-height: 44px; }

  .player-bar {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    padding: 12px 14px;
    gap: 8px;
    --player-height: auto;
  }

  .volume-area { display: none; }
  .button-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .analyzer-wrap { height: 38px; }
}

@media (max-width: 480px) {
  .analyzer-wrap { height: 32px; }
  .analyzer-idle { font-size: 11px; }
  :root { --header-height: 60px; }
  .app-header { padding: 0 12px; }
  .header-sub { display: none; }
  .title-event { display: none; }
  .clock-display { font-size: 20px; padding: 4px 12px; }
  .button-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .sound-button { min-height: 80px; font-size: 13px; }
  .ctrl-btn .ctrl-label, .ctrl-btn kbd { display: none; }
  .ctrl-btn { min-width: 52px; height: 52px; padding: 0; }
}

/* =============================================
   アクセシビリティ
   ============================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* =============================================
   PWA インストール / 更新バナー
   ============================================= */
#pwa-install-banner,
#pwa-update-banner {
  position: fixed;
  bottom: -120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  min-width: 320px;
  max-width: calc(100vw - 32px);
  transition: bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#pwa-install-banner.show,
#pwa-update-banner.show {
  bottom: 24px;
}

.pwa-banner-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.pwa-banner-icon img {
  width: 100%;
  height: 100%;
  display: block;
}

.pwa-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pwa-banner-text strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.pwa-banner-text span {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.3;
}

.pwa-btn-install {
  flex-shrink: 0;
  padding: 8px 16px;
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.12s;
}

.pwa-btn-install:hover { opacity: 0.9; }

.pwa-btn-dismiss {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s;
}

.pwa-btn-dismiss:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* =============================================
   高コントラストモード */
@media (forced-colors: active) {
  .sound-button, .ctrl-btn, .btn-action, .setlist-tab {
    border: 2px solid ButtonText;
  }
}

/* =============================================
   トラック コンテキストメニュー
   ============================================= */
.context-menu {
  display: none;
  position: fixed;
  z-index: 9999;
  min-width: 200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
  font-size: 14px;
  overflow: hidden;
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  white-space: nowrap;
}

.ctx-item:hover {
  background: var(--bg-hover);
  color: var(--accent-primary);
}

.ctx-item.ctx-danger { color: var(--danger); }
.ctx-item.ctx-danger:hover { background: #fef2f2; color: #b91c1c; }
[data-theme="dark"] .ctx-item.ctx-danger:hover { background: rgba(220,38,38,0.12); color: #f87171; }

.ctx-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.ctx-move-label {
  padding: 4px 16px 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctx-move-list {
  max-height: 200px;
  overflow-y: auto;
}

.ctx-move-item {
  padding-left: 24px;
  font-weight: 500;
  font-size: 13px;
}

/* セットリストタブ ドロップターゲット */
.setlist-tab.drop-target {
  background: var(--accent-primary) !important;
  color: #fff !important;
  border-color: var(--accent-primary) !important;
  box-shadow: 0 0 0 3px var(--accent-glow);
  transform: scale(1.02);
  transition: all 0.15s;
}

/* =============================================
   トラックボタン ⋮ メニュートリガー
   ============================================= */
.btn-ctx-trigger {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.12s;
  z-index: 2;
}

.sound-button:hover .btn-ctx-trigger,
.sound-button:focus-within .btn-ctx-trigger {
  opacity: 1;
}

.btn-ctx-trigger:hover {
  background: var(--bg-elevated);
  color: var(--accent-primary);
  opacity: 1;
}

/* 再生中はトリガーボタンの色を合わせる */
.sound-button.playing .btn-ctx-trigger {
  color: var(--playing-color);
}

/* =============================================
   トラック名変更モーダル
   ============================================= */
.modal-sm {
  max-width: 420px;
}

.rename-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.rename-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.rename-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: flex-end;
}

.btn-modal-cancel {
  padding: 10px 20px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-modal-cancel:hover { background: var(--bg-hover); }

.btn-modal-ok {
  padding: 10px 22px;
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.12s;
}
.btn-modal-ok:hover { opacity: 0.9; }

/* =============================================
   ログイン画面
   ============================================= */

/* ログインページ専用ボディ */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 24px;
}

/* カード */
.login-container {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* ロゴ */
.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
  margin-bottom: 20px;
}

.login-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 6px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 36px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* フォーム */
.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
}

.login-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-input--error {
  border-color: var(--danger);
}

.login-input--error:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

/* エラーメッセージ */
.login-error {
  font-size: 13px;
  color: var(--danger);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ログインボタン */
.login-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity var(--transition), transform var(--transition);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.login-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.login-btn:active {
  transform: translateY(0);
  opacity: 1;
}

/* =============================================
   ログアウトボタン（ヘッダー右端）
   ============================================= */
.logout-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.logout-btn:hover {
  background: rgba(220, 38, 38, 0.08);
  color: var(--danger);
  border-color: var(--danger);
}
