:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --border: #d7dbe4;
  --text: #1c1f2a;
  --text-sub: #5a5f70;
  --primary: #4c6ef5;
  --primary-ink: #ffffff;
  --accent: #f59f00;
  --success: #37b24d;
  --danger: #e03131;
  --pad-bg: #ffffff;
  --pad-border: #d7dbe4;
  --pad-text: #1c1f2a;
  --pad-active-bg: #4c6ef5;
  --pad-active-text: #ffffff;
  --pad-next-border: #f59f00;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #1a1d25;
    --surface-2: #242833;
    --border: #363b48;
    --text: #f5f6fa;
    --text-sub: #9aa0b0;
    --primary: #748ffc;
    --primary-ink: #0f1115;
    --accent: #ffd43b;
    --success: #51cf66;
    --danger: #ff6b6b;
    --pad-bg: #1f232d;
    --pad-border: #363b48;
    --pad-text: #f5f6fa;
    --pad-active-bg: #748ffc;
    --pad-active-text: #0f1115;
    --pad-next-border: #ffd43b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100svh;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 14px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.title-sub {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 500;
  margin-left: 6px;
}

.header-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.field-label {
  font-size: 11px;
  color: var(--text-sub);
  font-weight: 500;
}

.select {
  height: var(--tap);
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-sub) 50%),
    linear-gradient(135deg, var(--text-sub) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  box-shadow: var(--shadow-sm);
}

.toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: var(--tap);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.toggle-btn {
  border: 0;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  min-height: var(--tap);
  transition: background 120ms ease, color 120ms ease;
}

.toggle-btn.is-active {
  background: var(--primary);
  color: var(--primary-ink);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

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

.metronome-btn[aria-pressed="true"] {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary);
}

.metronome-icon {
  font-size: 18px;
  line-height: 1;
}

.beat-dots {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.beat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 60ms ease, transform 60ms ease;
}

.beat-dot.is-on {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.3);
}

.beat-dot.is-strong.is-on {
  background: var(--danger);
  border-color: var(--danger);
}

.bpm-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bpm-label {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 500;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  background: transparent;
  cursor: pointer;
}

.slider::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  border: 1px solid var(--border);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  margin-top: -10px;
  box-shadow: var(--shadow-sm);
}

.slider::-moz-range-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  border: 1px solid var(--border);
}

.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
}

.segmented {
  display: flex;
  align-items: center;
  gap: 6px;
}

.segmented-label {
  font-size: 11px;
  color: var(--text-sub);
  font-weight: 500;
  margin-right: 2px;
}

.seg-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-sub);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

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

.pads {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 10px;
  aspect-ratio: 3 / 2.2;
}

.pad {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: var(--radius);
  border: 2px solid var(--pad-border);
  background: var(--pad-bg);
  color: var(--pad-text);
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  padding: 10px 6px;
  min-height: calc(var(--tap) * 2);
  box-shadow: var(--shadow-sm);
  transition: transform 80ms ease, background 80ms ease, color 80ms ease, border-color 80ms ease, box-shadow 80ms ease;
}

.pad-name {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.pad-role {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sub);
  letter-spacing: 0.08em;
  line-height: 1;
}

.pad.is-pressed,
.pad.is-playing {
  background: var(--pad-active-bg);
  color: var(--pad-active-text);
  border-color: var(--pad-active-bg);
  transform: scale(0.97);
  box-shadow: var(--shadow-md);
}

.pad.is-pressed .pad-role,
.pad.is-playing .pad-role {
  color: var(--pad-active-text);
  opacity: 0.85;
}

.pad.is-next {
  border-color: var(--pad-next-border);
  border-style: dashed;
  box-shadow: 0 0 0 2px rgba(245, 159, 0, 0.15);
}

.progressions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  letter-spacing: 0.04em;
}

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

@media (min-width: 420px) {
  .progression-list {
    grid-template-columns: 1fr 1fr;
  }
}

.prog-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 120ms ease, border-color 120ms ease;
}

.prog-btn.is-playing {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary);
}

.prog-icon {
  font-size: 16px;
  line-height: 1;
}

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

.prog-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.prog-roles {
  font-size: 11px;
  color: var(--text-sub);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.prog-btn.is-playing .prog-roles {
  color: var(--pad-active-text);
  opacity: 0.85;
}

.footer {
  margin-top: 4px;
  padding-top: 8px;
  text-align: center;
}

.footer-note {
  margin: 0;
  font-size: 11px;
  color: var(--text-sub);
}
