.bg-key-detector {
  --key-ink: #22303a;
  --key-muted: #6d7980;
  --key-line: #e3ded3;
  --key-paper: #fff;
  --key-blue: #dceef7;
  --key-blue-deep: #3f7897;
  --key-yellow: #ffdc27;
  --key-tonic: #2f7d6e;
  --key-subdominant: #c08a2d;
  --key-dominant: #c0492f;
  width: min(calc(100% - 4px), 850px); /* .jlp-header(ナビ)の実寸に一致。diatonic-chords.cssと同じ計算式 */
  margin: 24px auto 0;
  color: var(--key-ink);
  font-size: 15px;
  line-height: 1.6;
}

.bg-key-detector *,
.bg-key-detector *::before,
.bg-key-detector *::after {
  box-sizing: border-box;
}

.bg-key-detector button {
  color: inherit;
  font: inherit;
}

.bg-key-detector-header {
  margin-bottom: 24px;
  padding: 28px 24px;
  border-radius: 28px;
  background: var(--key-blue);
}

.bg-key-detector-title {
  margin: 0;
  color: var(--key-ink);
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 900;
  line-height: 1.18;
  letter-spacing: 0;
}

.bg-key-detector-panel {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--key-line);
  border-radius: 24px;
  background: var(--key-paper);
}

.bg-key-detector-panel h3 {
  margin: 0;
  color: var(--key-ink);
  font-size: 16px;
  letter-spacing: 0;
}

.bg-key-detector-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.bg-key-detector-clear {
  padding: 5px 12px;
  border: 1px solid var(--key-line);
  border-radius: 999px;
  background: #fff;
  color: var(--key-muted);
  font-size: 12px;
  cursor: pointer;
}

.bg-key-detector-clear:hover {
  border-color: var(--key-ink);
  color: var(--key-ink);
}

.bg-key-detector-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  margin-top: 12px;
}

.bg-key-detector-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--key-tonic);
  border-radius: 10px;
  background: rgba(47, 125, 110, 0.06);
  color: var(--key-ink);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.bg-key-detector-chip i {
  color: var(--key-dominant);
  font-style: normal;
}

.bg-key-detector-placeholder,
.bg-key-detector-verdict {
  color: var(--key-muted);
  font-size: 13px;
}

.bg-key-detector-accidental {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--key-line);
  border-radius: 999px;
}

.bg-key-detector-accidental button {
  min-width: 48px;
  padding: 5px 14px;
  border: 0;
  background: #fff;
  color: var(--key-muted);
  cursor: pointer;
}

.bg-key-detector-accidental button + button {
  border-left: 1px solid var(--key-line);
}

.bg-key-detector-accidental button.is-active {
  background: var(--key-ink);
  color: #fff;
  font-weight: 800;
}

.bg-key-detector-palette {
  margin-top: 10px;
}

.bg-key-detector-note {
  margin: 14px 0 4px;
  padding: 12px 14px;
  border-left: 4px solid var(--key-blue-deep);
  border-radius: 0 10px 10px 0;
  background: var(--key-blue);
  color: var(--key-ink);
  font-size: 13px;
  line-height: 1.7;
}

.bg-key-detector-note p {
  margin: 0;
}

.bg-key-detector-note p + p {
  margin-top: 8px;
}

.bg-key-detector-root {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--key-line);
}

.bg-key-detector-root:last-child {
  border-bottom: 0;
}

.bg-key-detector-root-label {
  flex: 0 0 40px;
  font-size: 15px;
  font-weight: 800;
}

.bg-key-detector-quality-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bg-key-detector-quality {
  padding: 6px 9px;
  border: 1px solid var(--key-line);
  border-radius: 10px;
  background: #fff;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.bg-key-detector-quality:hover {
  border-color: var(--key-blue-deep);
  background: var(--key-blue);
}

.bg-key-detector-quality.is-selected,
.bg-key-detector-quality.is-selected:hover {
  border-color: #a8adb0;
  background: #d9dcde;
  color: #555d61;
  font-weight: 800;
}

.bg-key-detector-results[hidden] {
  display: none;
}

.bg-key-detector-verdict {
  margin: 8px 0 14px;
}

.bg-key-detector-key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 64px;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  padding: 11px 12px;
  border: 1px solid var(--key-line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}

.bg-key-detector-key-row.is-selected {
  border-color: var(--key-tonic);
  background: rgba(47, 125, 110, 0.05);
}

.bg-key-detector-key-name {
  font-size: 16px;
  font-weight: 800;
}

.bg-key-detector-key-name small,
.bg-key-detector-key-name .is-missing {
  margin-left: 6px;
  color: var(--key-muted);
  font-size: 12px;
  font-weight: 400;
}

.bg-key-detector-key-name .is-missing {
  color: var(--key-dominant);
}

.bg-key-detector-bar {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #ece7dc;
}

.bg-key-detector-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--key-tonic);
}

.bg-key-detector-fit {
  color: var(--key-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.bg-key-detector-hint {
  margin-top: 8px;
  padding: 10px 13px;
  border: 1px solid #f0e2c0;
  border-radius: 10px;
  background: #fbf3e0;
  color: #8f6722;
  font-size: 13px;
}

.bg-key-detector-diatonic-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin-top: 24px;
}

.bg-key-detector-diatonic-title {
  margin: 0;
}

.bg-key-detector-diatonic-for-key {
  color: var(--key-muted);
  font-size: 14px;
  font-weight: 400;
}

.bg-key-detector-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 8px;
  margin: 12px 0;
}

.bg-key-detector-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.bg-key-detector-toggle button {
  padding: 6px 12px;
  border: 1px solid var(--key-line);
  border-radius: 999px;
  background: #fff;
  color: var(--key-muted);
  font-size: 12px;
  cursor: pointer;
}

.bg-key-detector-toggle button.is-active {
  border-color: var(--key-ink);
  color: var(--key-ink);
  font-weight: 700;
}

.bg-key-detector-voice {
  display: inline-flex;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--key-line);
  border-radius: 999px;
}

.bg-key-detector-voice button {
  padding: 6px 10px;
  border: 0;
  background: #fff;
  color: var(--key-muted);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.bg-key-detector-voice button + button {
  border-left: 1px solid var(--key-line);
}

.bg-key-detector-voice button.is-active {
  background: var(--key-ink);
  color: #fff;
  font-weight: 700;
}

.bg-key-detector-diatonic {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.bg-key-detector-degree {
  min-width: 0;
  padding: 7px 6px;
  border: 1px solid var(--key-line);
  border-radius: 10px;
  background: #fff;
  text-align: center;
}

.bg-key-detector-degree-name {
  font-size: 11px;
  font-weight: 800;
}

.bg-key-detector-chord-name {
  margin-top: 3px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 14px;
  font-weight: 800;
}

.bg-key-detector-degree.is-tonic {
  border-color: rgba(47, 125, 110, 0.4);
  background: rgba(47, 125, 110, 0.06);
}

.bg-key-detector-degree.is-subdominant {
  border-color: rgba(192, 138, 45, 0.4);
  background: rgba(192, 138, 45, 0.06);
}

.bg-key-detector-degree.is-dominant {
  border-color: rgba(192, 73, 47, 0.4);
  background: rgba(192, 73, 47, 0.06);
}

.bg-key-detector-degree.is-tonic .bg-key-detector-degree-name {
  color: var(--key-tonic);
}

.bg-key-detector-degree.is-subdominant .bg-key-detector-degree-name {
  color: var(--key-subdominant);
}

.bg-key-detector-degree.is-dominant .bg-key-detector-degree-name {
  color: var(--key-dominant);
}

.bg-key-detector-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  color: var(--key-muted);
  font-size: 12px;
}

.bg-key-detector-legend span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.bg-key-detector-legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.bg-key-detector-legend .is-tonic {
  background: var(--key-tonic);
}

.bg-key-detector-legend .is-subdominant {
  background: var(--key-subdominant);
}

.bg-key-detector-legend .is-dominant {
  background: var(--key-dominant);
}

.bg-key-detector-dock {
  position: fixed;
  z-index: 999;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 10px;
  display: none;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--key-blue-deep);
  border-radius: 16px;
  background: var(--key-blue-deep);
  box-shadow: 0 10px 28px rgba(34, 48, 58, 0.24);
}

.bg-key-detector-dock.is-visible {
  display: grid;
}

.bg-key-detector-dock button {
  display: grid;
  min-width: 0;
  min-height: 68px;
  gap: 2px;
  align-content: center;
  padding: 9px 12px;
  border: 0;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.bg-key-detector-dock span {
  color: var(--key-blue-deep);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.bg-key-detector-dock strong {
  display: block;
  overflow: hidden;
  color: var(--key-ink);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 681px) {
  .bg-key-detector-dock {
    right: auto;
    left: 50%;
    bottom: 20px;
    width: min(calc(100% - 32px), 420px);
    transform: translateX(-50%);
  }

  .bg-key-detector {
    padding-bottom: 0;
  }

  .bg-key-detector.has-dock {
    padding-bottom: 10px;
  }
}

@media (max-width: 680px) {
  .bg-key-detector {
    margin: 24px auto;
  }

  .bg-key-detector.has-dock {
    padding-bottom: 10px;
  }

  .bg-key-detector-panel {
    padding: 16px;
  }

  .bg-key-detector-root {
    align-items: flex-start;
  }

  .bg-key-detector-quality-buttons {
    flex: 1;
  }

  .bg-key-detector-quality {
    min-width: 54px;
  }

  .bg-key-detector-key-row {
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .bg-key-detector-key-name {
    font-size: 14px;
  }

  .bg-key-detector-bar {
    display: none;
  }

  .bg-key-detector-diatonic {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bg-key-detector-toggle-row {
    gap: 6px;
  }

  .bg-key-detector-toggle {
    overflow-x: auto;
  }

  .bg-key-detector-toggle button {
    padding: 6px 10px;
    white-space: nowrap;
  }
}

/* ================================================================
   SEO静的コンテンツセクション
   ================================================================ */

.kd-seo-outer {
  --kd-bg: #fbf8ef;
  --kd-white: #ffffff;
  --kd-blue-soft: #edf7fb;
  --kd-blue-deep: #3f7897;
  --kd-ink: #26323a;
  --kd-muted: #6f7a80;
  --kd-line: #e7dfd2;
  min-height: 100vh;
  background: var(--kd-bg);
  /* 上部の余白はjlp-tool-share-top(SNSシェアボタン)側で固定ナビ分を確保済みのため、
     ここは通常の余白(10px)のみでよい */
  padding: 10px 14px 48px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  color: var(--kd-ink);
  box-sizing: border-box;
}

.kd-seo-outer *,
.kd-seo-outer *::before,
.kd-seo-outer *::after {
  box-sizing: inherit;
}

.kd-seo-wrap {
  display: grid;
  gap: 18px;
  width: min(calc(100% - 4px), 850px); /* .jlp-header(ナビ)の実寸に一致。diatonic-chords.cssと同じ計算式 */
  margin: 32px auto 0;
}

.kd-seo-card {
  padding: 28px 32px;
  border: 1px solid var(--kd-line);
  border-radius: 24px;
  background: var(--kd-white);
  color: var(--kd-ink);
  font-size: 15px;
  line-height: 1.85;
}

.kd-seo-card-title {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.3;
  color: var(--kd-ink);
  border: none;
  padding: 0;
}

.kd-seo-card h3 {
  margin: 1.8em 0 0.5em;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.4;
  color: var(--kd-ink);
}

.kd-seo-card p {
  margin: 0.85em 0;
}

.kd-seo-card > p:first-of-type,
.kd-seo-card > h3:first-child + p {
  margin-top: 0;
}

/* 内部リンクカード */
.kd-seo-link-card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  align-items: center;
  gap: 2px 14px;
  padding: 22px 28px;
  border: 1px solid var(--kd-line);
  border-radius: 18px;
  background: var(--kd-blue-soft);
  color: var(--kd-ink);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.kd-seo-link-card:hover {
  background: var(--key-blue, #dceef7);
  border-color: rgba(63, 120, 151, 0.3);
}

.kd-seo-link-label {
  grid-column: 1;
  grid-row: 1;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--kd-blue-deep);
  text-transform: uppercase;
}

.kd-seo-link-title {
  grid-column: 1;
  grid-row: 2;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.3;
}

.kd-seo-link-desc {
  grid-column: 1;
  grid-row: 3;
  margin-top: 6px;
  font-size: 13px;
  color: var(--kd-muted);
  line-height: 1.6;
}

.kd-seo-link-arrow {
  grid-column: 2;
  grid-row: 1 / 3;
  justify-self: end;
  font-size: 22px;
  color: var(--kd-blue-deep);
  line-height: 1;
}

/* FAQ */
.kd-seo-faq-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--kd-line);
}

.kd-seo-faq-item:first-child {
  padding-top: 0;
}

.kd-seo-faq-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.kd-seo-faq-item h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.45;
  color: var(--kd-ink);
}

.kd-seo-faq-item p {
  margin: 0;
  font-size: 14px;
  color: var(--kd-muted);
  line-height: 1.85;
}

/* モバイル */
@media (max-width: 560px) {
  .kd-seo-outer {
    padding: 10px 10px 34px;
  }

  .bg-key-detector-header {
    padding: 24px 20px;
  }

  .kd-seo-card {
    padding: 20px 18px;
  }

  .kd-seo-link-card {
    padding: 18px 20px;
  }

  .kd-seo-link-arrow {
    display: none;
  }
}
