/* 色は個人サイト（moyashidaisuke.com）の暗い帯と琥珀色に合わせる */
:root {
  --bg: #16181c;
  --panel: #1f2227;
  --line: #33363d;
  --text: #f2f2f0;
  --muted: #b9bcc2;
  --accent: #e8a33d;
  --on-accent: #1a1206;
  /* 時間を過ぎたときの色 */
  --over: #ff7a6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  /* ダブルタップズームによるタップ反応の遅延を防ぐ */
  touch-action: manipulation;
}

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

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 24px;
}

/* ---------- 見出し ---------- */

.header {
  margin-bottom: 16px;
}

.title {
  margin: 0;
  font-size: 20px;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- 枠 ---------- */

.main {
  display: grid;
  /* 中身の最小幅で列が広がり、狭い画面ではみ出さないようにする */
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.panel {
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--muted);
}

/* ---------- タイマー ---------- */

.time {
  margin: 0;
  font-size: clamp(72px, 26vw, 150px);
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.time[data-over='true'] {
  color: var(--over);
}

.time-setting {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 12px 0 20px;
}

.number-field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.number-field input {
  width: 4.5em;
  min-height: 44px;
  padding: 6px 10px;
  text-align: right;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- ボタン ---------- */

.button {
  min-height: 52px;
  padding: 10px 16px;
  font-size: 17px;
  font-weight: 700;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.button.primary {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.button.round {
  width: 52px;
  padding: 0;
  font-size: 24px;
  border-radius: 50%;
}

.button:active {
  transform: translateY(1px);
}

.button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- メトロノーム ---------- */

.beat-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  min-height: 20px;
  margin-bottom: 12px;
}

.dot {
  width: 16px;
  height: 16px;
  border: 2px solid var(--muted);
  border-radius: 50%;
}

.dot.accent {
  border-color: var(--accent);
}

.dot.on {
  background: var(--text);
  border-color: var(--text);
}

.dot.accent.on {
  background: var(--accent);
  border-color: var(--accent);
}

.bpm-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 4vw, 20px);
}

.bpm {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 5.5em;
  margin: 0;
  justify-content: center;
}

.bpm output {
  font-size: 48px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bpm-unit {
  color: var(--muted);
  font-size: 14px;
}

.slider {
  width: 100%;
  margin: 16px 0 0;
  accent-color: var(--accent);
}

.bpm-steps {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.button.small {
  min-height: 44px;
  padding: 6px 0;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* 狭い画面では3つずつ2段にする */
@media (max-width: 400px) {
  .bpm-steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.metronome-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.select-field {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
}

.select-field select {
  min-height: 52px;
  padding: 6px 12px;
  font-size: 18px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.mixer {
  margin-top: 16px;
  padding: 14px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.mixer-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.mixer-sliders {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  justify-items: center;
}

/* 1拍目のつまみは、16分音符の4本と線で分ける */
.mixer-slider.accent {
  justify-self: stretch;
  border-right: 1px solid var(--line);
  color: var(--accent);
}

.mixer-slider.accent span {
  font-size: 12px;
  white-space: nowrap;
}

.mixer-slider input:disabled {
  opacity: 0.35;
}

.mixer-slider {
  display: grid;
  justify-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--muted);
}

/* 縦向きのつまみ（上が大きい） */
.mixer-slider input {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 32px;
  height: 120px;
  margin: 0;
  accent-color: var(--accent);
}

.presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.preset {
  min-height: 44px;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.preset[aria-pressed='true'] {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.volume {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
}

.volume span {
  flex-shrink: 0;
}

.volume .slider {
  margin: 0;
}

.metronome-toggle {
  width: 100%;
  margin-top: 16px;
}

.metronome-toggle[hidden] {
  display: none;
}

/* ---------- 設定 ---------- */

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}

.switch input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

/* ---------- 著作者表示 ---------- */

.site-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: center;
}

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

.credit-sep {
  margin: 0 8px;
  opacity: 0.5;
}

.credit-link {
  color: var(--muted);
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 2px;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .credit-link:hover {
    color: var(--accent);
  }
}

/* ---------- ユーティリティ ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
