:root {
  color-scheme: light;
  --bg-1: #0b1418;
  --bg-2: #13242b;
  --bg-3: #1d333b;
  --card: rgba(17, 30, 37, 0.9);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f2f6f7;
  --muted: #9db1ba;
  --accent: #f5b941;
  --accent-2: #5ad0ad;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  background-image:
    radial-gradient(circle at top left, rgba(90, 208, 173, 0.2), transparent 45%),
    radial-gradient(circle at 30% 80%, rgba(245, 185, 65, 0.18), transparent 50%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2) 50%, var(--bg-3));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

input,
textarea {
  -webkit-user-select: text;
  user-select: text;
}

.app {
  width: min(980px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 24px;
  animation: fadeIn 0.6s ease;
}

.hero {
  display: grid;
  gap: 10px;
}

.support {
  margin-top: 6px;
}

.support-group {
  display: grid;
  grid-template-columns: minmax(140px, 180px) 1fr;
  column-gap: 16px;
  row-gap: 4px;
  margin-top: 10px;
}

.support-group:first-of-type {
  margin-top: 0;
}

.support-group .label {
  font-weight: 700;
}

.support-group,
.support-group .label,
.support-group .sub {
  -webkit-user-select: text;
  user-select: text;
}

@media (max-width: 720px) {
  .support-group {
    grid-template-columns: 1fr;
  }
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.title-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

#bmc-btn,
#settings-btn,
#help-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

#bmc-btn svg,
#settings-btn svg,
#help-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-title {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: 0.02em;
}

.brand-name {
  font-size: 1em;
}

.brand-sub {
  font-size: 0.42em;
  letter-spacing: 0.08em;
  color: var(--accent-2);
}

.help-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 20px 0 10px;
}

.help-title:first-of-type {
  margin-top: 0;
}

.help-list {
  margin: 0;
  padding-left: 24px;
  display: grid;
  gap: 6px;
  color: var(--text);
}

.help-note {
  margin: 0 0 2px;
  color: var(--text);
}

.help-support {
  margin: 0 0 4px;
  color: var(--text);
}

.help-intro {
  color: var(--text);
  margin-bottom: 6px;
}

.help-subnote {
  margin: 2px 0 0;
  color: var(--text);
}

.help-content .support-group {
  margin-top: 10px;
}

.help-content .support-group .label,
.help-content .support-group .sub {
  color: var(--text);
}

.settings-group {
  display: grid;
  gap: 12px;
}

.settings-group-first {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-group + .settings-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-group-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.settings-subtitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.6);
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 2px 2px;
}

.footer-links {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(90, 208, 173, 0.14);
  border: 1px solid rgba(90, 208, 173, 0.35);
  border-radius: 999px;
  color: var(--accent-2);
  font-weight: 600;
  width: fit-content;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  display: grid;
  gap: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

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

.row.spaced {
  justify-content: space-between;
}

.audio-indicators {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.meter {
  width: 72px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.meter.on {
  opacity: 1;
}

.meter-fill {
  height: 100%;
  width: 100%;
  transform-origin: left;
  transform: scaleX(0.05);
  background: linear-gradient(90deg, #5ad0ad, #f5b941);
}

label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

label.check {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--text);
}

label.check.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--text);
}

label.check.block {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--text);
}

input[type="text"] {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 14, 18, 0.8);
  color: var(--text);
  font-size: 16px;
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 22px;
  margin: 0;
  padding: 0;
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(
    to right,
    #168bff 0%,
    #168bff var(--range-fill, 100%),
    rgba(255, 255, 255, 0.24) var(--range-fill, 100%),
    rgba(255, 255, 255, 0.24) 100%
  );
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border-radius: 50%;
  border: 0;
  background: #168bff;
  box-shadow: 0 0 0 2px rgba(22, 139, 255, 0.2);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.24);
}

input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  border: 0;
  background: #168bff;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: #168bff;
  box-shadow: 0 0 0 2px rgba(22, 139, 255, 0.2);
}

input[type="range"]::-moz-focus-outer {
  border: 0;
}

.check-row {
  display: flex;
  gap: 14px;
  align-items: center;
}

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

label.radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 14, 18, 0.7);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

label.radio input {
  accent-color: var(--accent-2);
}

button {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
}

button.primary {
  background: linear-gradient(130deg, var(--accent), #f2d68a);
  border: none;
  color: #1d1a12;
}

#audio-btn {
  min-width: 128px;
  text-align: center;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.status {
  display: grid;
  gap: 6px;
}

.status-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.status-pane,
.metronome-pane {
  gap: 12px;
}

.current-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.metronome {
  display: grid;
  gap: 12px;
}

.metronome-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.metronome-controls-row .tempo-controls {
  margin-left: auto;
}

.metronome-bpm {
  display: flex;
  align-items: baseline;
  min-height: 42px;
}

.tempo-readout {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.tempo-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tempo-controls button {
  min-width: 36px;
  padding: 8px 10px;
}

#tempo-input {
  width: 92px;
  flex: 0 0 92px;
  text-align: center;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
}

#metronome-btn {
  width: fit-content;
  min-width: 112px;
}

.label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.current {
  font-size: 34px;
  font-weight: 700;
}

.position {
  color: var(--muted);
}

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

.controls-right {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.hint {
  font-size: 13px;
  color: var(--muted);
}

.voicing-block {
  display: grid;
  gap: 10px;
}

.voicing {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: #e6f3f1;
}

.voicing-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.voicing-row .label {
  flex: 0 0 auto;
}

.voicing-row .voicing {
  text-align: right;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 12, 15, 0.6);
  backdrop-filter: blur(6px);
  z-index: 50;
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(560px, 92vw);
  background: rgba(12, 20, 24, 0.96);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.settings-card {
  width: min(760px, 94vw);
  max-height: 86vh;
  grid-template-rows: auto minmax(0, 1fr);
}

.settings-body {
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  padding-bottom: 10px;
}

.info-card {
  width: min(560px, 92vw);
  max-height: 80vh;
  grid-template-rows: auto minmax(0, 1fr);
}

.info-body {
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  padding-bottom: 8px;
}

.info-text {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.info-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.selectable-text {
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}

.help-card {
  width: min(760px, 94vw);
  max-height: 86vh;
  grid-template-rows: auto minmax(0, 1fr);
}

.help-body {
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  padding-bottom: 10px;
}

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

.modal-body {
  display: grid;
  gap: 12px;
}

.library-list {
  display: grid;
  gap: 10px;
}

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

.library-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 14, 18, 0.85);
  color: var(--text);
  font-size: 16px;
}

.library-item {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.library-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.library-actions-left,
.library-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-actions-right {
  margin-left: auto;
}

.library-actions .primary {
  min-width: 72px;
}

button.danger {
  background: rgba(227, 78, 94, 0.18);
  border: 1px solid rgba(227, 78, 94, 0.5);
  color: #ffd8dd;
}

button.danger:hover {
  background: rgba(227, 78, 94, 0.28);
  border-color: rgba(227, 78, 94, 0.7);
}

details.toggle {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(9, 15, 19, 0.5);
}

details.toggle[open] {
  background: rgba(9, 15, 19, 0.7);
}

details.toggle summary {
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

details.toggle summary::-webkit-details-marker {
  display: none;
}

details.toggle summary::after {
  content: "＋";
  float: right;
}

details.toggle[open] summary::after {
  content: "－";
}

details.toggle > *:not(summary) {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

details.toggle.spacious > *:not(summary) {
  margin-top: 28px;
}

.sub {
  font-size: 13px;
  color: var(--muted);
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  color: var(--muted);
}

.list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chord-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border 0.12s ease;
}

.chord-pill.active {
  background: rgba(90, 208, 173, 0.25);
  border-color: rgba(90, 208, 173, 0.6);
  color: var(--accent-2);
}

.chord-pill:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
}

.warn {
  color: #f6c56b;
  font-size: 12px;
}

@media (max-width: 780px) {
  body {
    display: block;
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-right: 12px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    padding-left: 12px;
  }

  .app {
    width: 100%;
    gap: 16px;
  }

  .card {
    padding: 16px;
  }

  .row {
    flex-wrap: wrap;
  }

  .row > input[type="text"] {
    min-width: 0;
    flex-basis: 100%;
  }

  .progression-row {
    justify-content: flex-end;
  }

  #settings-modal,
  #help-modal,
  #privacy-modal,
  #support-modal,
  #legal-modal {
    align-items: flex-start;
    overflow: auto;
    padding-top: calc(40px + env(safe-area-inset-top));
    padding-right: 12px;
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
    padding-left: 12px;
  }

  #settings-modal .settings-card,
  #help-modal .help-card,
  #privacy-modal .info-card,
  #support-modal .info-card,
  #legal-modal .info-card {
    margin-top: 0;
    margin-bottom: 0;
    max-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 80px);
  }

  #settings-modal .settings-body,
  #help-modal .help-body,
  #privacy-modal .info-body,
  #support-modal .info-body,
  #legal-modal .info-body {
    padding-bottom: 12px;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .footer-links {
    flex-wrap: wrap;
    gap: 10px;
  }

  .status-split {
    grid-template-columns: 1fr;
  }

  .metronome-controls-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .metronome-controls-row .tempo-controls {
    margin-left: auto;
  }

  .voicing-row {
    flex-wrap: nowrap;
    align-items: center;
  }

  .voicing-row .voicing {
    text-align: right;
  }
}

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