:root {
  --color-bg:           #f0f2f5;
  --color-surface:      #ffffff;
  --color-header-bg:    #1c1c2e;
  --color-accent:       #e63c4b;
  --color-text:         #1a1a1a;
  --color-text-muted:   #5c5c5c;
  --color-border:       #e8e8e8;
  --color-row-sep:      #f4f4f4;
  --color-card-head:    #f7f7f9;
  --color-connect:      #2ecc71;
  --color-disconnect:   #e74c3c;
  --color-send:         #f39c12;
  --color-request:      #3498db;
  --color-save:         #e88093;
  --color-slider-track: #d8d8d8;
  --color-slider-thumb: #1c1c2e;
  --radius:    12px;
  --radius-sm:  8px;
  --shadow:    0 2px 12px rgba(0, 0, 0, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: 'Noto Sans JP', 'Yu Gothic', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-header-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 4px 28px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

/* ── タイトル (Plan B: 赤グロー) ─────────────────────── */
.site-header h1 {
  margin: 0;
  font-size: 1.55rem;
  color: var(--color-accent);
  letter-spacing: 0.1em;
  cursor: default;
  text-shadow: 0 0 6px rgba(230, 60, 75, 0.25);
  transition: text-shadow 0.35s ease, letter-spacing 0.35s ease;
}


/* ── i18n ────────────────────────────────────────────── */
.i18n-en { display: none; }
body.is-en .i18n-ja { display: none; }
body.is-en .i18n-en { display: revert; }

/* ── iOS-style toggle switch ─────────────────────────── */
.ios-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}
.ios-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.ios-track {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: rgba(255,255,255,0.18);
  transition: background 0.25s;
  flex-shrink: 0;
}
.ios-track::after {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 2px; left: 2px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: transform 0.22s cubic-bezier(.34,1.56,.64,1);
}
.ios-switch input:checked ~ .ios-track { background: #38bdf8; }
.ios-switch input:checked ~ .ios-track::after { transform: translateX(18px); }
#langToggle ~ .ios-track { background: var(--color-accent); }
#langToggle:checked ~ .ios-track { background: #38bdf8; }
.ios-sw-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.6);
}

/* Light variant – on white card backgrounds */
.ios-switch--light .ios-track { background: #d1d1d6; }
.ios-switch--light input:checked ~ .ios-track { background: #34c759; }
.ios-switch--light .ios-sw-label {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* Mode toggle row between sensitivity and delay cards */
.mode-toggle-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 2px 4px;
}

/* Hide advanced cards by default */
.advanced-card { display: none; }
.advanced-card.is-visible { display: block; }

.beginner-explain { display: block; }
.advanced-explain { display: none; }

.delay-toggle-item { justify-content: space-between; }
.delay-toggle-lbl { font-size: 0.85rem; font-weight: 600; color: var(--color-text); }
.delay-toggle-sub { display: block; font-size: 0.72rem; color: var(--color-text-muted); margin-top: 1px; }

/* ── ヘッダー左 ──────────────────────────────────────── */
.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ── バージョンナビ ───────────────────────────────────── */
.version-nav {
  display: flex;
  gap: 4px;
}

.version-link {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.version-link:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

.version-link--active {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  border-color: transparent;
}

/* ── ヘッダーリンク ───────────────────────────────────── */
.header-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-link {
  color: rgba(255, 255, 255, 0.65);
  font-size: 1.25rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  transition: color 0.2s, transform 0.2s;
}

.header-link:hover {
  color: #ffffff;
  transform: scale(1.2);
}

.header-link--yt:hover { color: #ff4444; }
.header-link--x:hover { color: #ffffff; }
.header-link--zenn:hover { color: #3ea8ff; }

/* ── ステータスエリア ─────────────────────────────────── */
.header-status {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

/* ステータスドット（塗りつぶし丸） */
.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  background: #555;
  flex-shrink: 0;
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
}

.status-dot.is-connecting {
  background: #f39c12;
  animation: ring-blink 0.9s ease-in-out infinite;
}

.status-dot.is-connected {
  background: #2ecc71;
  animation: ring-don 2.2s ease-in-out infinite;
}

.status-dot.is-loading {
  background: #3498db;
  animation: ring-katsu 0.45s ease-in-out infinite;
}

.status-dot.is-error {
  background: #e74c3c;
}

@keyframes ring-don {
  0%,100% { box-shadow: 0 0 0 0 rgba(46,204,113,0.7); }
  55%      { box-shadow: 0 0 0 8px rgba(46,204,113,0); }
}

@keyframes ring-katsu {
  0%,100% { box-shadow: 0 0 0 0 rgba(52,152,219,0.7); transform: scale(1); }
  50%      { box-shadow: 0 0 0 5px rgba(52,152,219,0); transform: scale(0.75); }
}

@keyframes ring-blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* 太鼓アイコン */
.taiko-icon {
  font-size: 1rem;
  transition: transform 0.2s;
}

/* 状態連動アニメーション（CSS sibling） */
.status-dot.is-connected ~ .taiko-icon {
  animation: taiko-don-beat 2.2s ease-in-out infinite;
}

.status-dot.is-loading ~ .taiko-icon {
  animation: taiko-katsu-beat 0.45s ease-in-out infinite;
}

.status-dot.is-connecting ~ .taiko-icon {
  animation: taiko-katsu-beat 0.9s ease-in-out infinite;
}

@keyframes taiko-don-beat {
  0%,90%,100% { transform: scale(1) rotate(0deg); }
  50%          { transform: scale(1.3) rotate(-10deg); }
  55%          { transform: scale(0.9) rotate(5deg); }
  60%          { transform: scale(1.05) rotate(0deg); }
}

@keyframes taiko-katsu-beat {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.2) rotate(8deg); }
}

.situation {
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.85);
  flex: 0 1 280px;
  min-width: 0;
  max-width: 280px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

/* ── Main layout ─────────────────────────────────────── */
.app-layout {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 24px 20px;
  max-width: 1280px;
  margin: 0 auto;
}

/* ── Controls panel ──────────────────────────────────── */
.controls-panel {
  flex: 0 0 500px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Explanation panel ───────────────────────────────── */
.explanation-panel {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Card ────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.button-card {
  padding: 14px 16px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-text-muted);
  background: var(--color-card-head);
  border-bottom: 1px solid var(--color-border);
  padding: 9px 18px;
}

/* V1.3の主要設定は、右の説明カードと同じ見出しの密度・強調で揃える。 */
.v13-config-heading {
  justify-content: flex-start;
  gap: 8px;
  padding: 13px 18px;
  color: var(--color-text);
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
}
.v13-config-heading::before {
  content: '▶';
  color: var(--color-accent);
  flex-shrink: 0;
  font-size: 0.6rem;
  transition: transform 0.2s ease;
}
.v13-config-heading.keymap-title .keymap-chevron { display: none; }
.v13-config-heading.keymap-title:not(.is-collapsed)::before { transform: rotate(90deg); }

.keymap-title {
  cursor: pointer;
  user-select: none;
  transition: background 0.14s;
}
.keymap-title:hover {
  background: #efefef;
}
.keymap-chevron {
  font-size: 0.78rem;
  color: var(--color-accent);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.keymap-title.is-collapsed .keymap-chevron {
  transform: rotate(-180deg);
}

/* ── Button group ────────────────────────────────────── */
.button-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.button-group--five {
  grid-template-columns: repeat(5, 1fr);
}

button {
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  position: relative;
  overflow: hidden;
  width: 100%;
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1),
              box-shadow 0.18s ease,
              background-color 0.2s ease,
              color 0.2s ease,
              border-color 0.2s ease;
}

/* デフォルト状態：ボタンごとに色tint */
#connection,
#hidConnection { background: rgba(46, 204, 113, 0.12); border-color: rgba(46, 204, 113, 0.4); }
#disconnection { background: rgba(231,  76,  60, 0.10); border-color: rgba(231, 76,  60, 0.35); }
#sendButton    { background: rgba(243, 156,  18, 0.12); border-color: rgba(243,156,  18, 0.4); }
#requestButton { background: rgba(52,  152, 219, 0.12); border-color: rgba(52, 152, 219, 0.4); }
#saveButton    { background: rgba(232, 128, 147, 0.12); border-color: rgba(232, 128, 147, 0.4); }
#bootButton    { background: rgba(192,  42, 192, 0.12); border-color: rgba(192,  42, 192, 0.4); }

/* ホバー：フルカラー */
button:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}
button:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  transition-duration: 0.08s;
}

/* ホバーは白文字になるので、通常より濃い側の色を使う（元の色は白文字で2.1〜3.8:1しかない） */
#connection:hover,
#hidConnection:hover { background: #1e874b; color: #fff; border-color: transparent; }
#disconnection:hover { background: #d24537; color: #fff; border-color: transparent; }
#sendButton:hover    { background: #a3690c; color: #fff; border-color: transparent; }
#requestButton:hover { background: #2a7bb1; color: #fff; border-color: transparent; }
#saveButton:hover    { background: #ac5f6d; color: #fff; border-color: transparent; }
#bootButton:hover    { background: #c02ac0;                 color: #fff; border-color: transparent; }

/* ── ボタンアイコン ───────────────────────────────────── */
.btn-icon {
  font-size: 0.95em;
  flex-shrink: 0;
}

/* ── アイコン個別アニメーション ─────────────────────── */
#connection:hover .btn-icon,
#hidConnection:hover .btn-icon { animation: icon-wiggle 0.5s ease; }
#disconnection:hover .btn-icon { animation: icon-shake  0.45s ease; }
#sendButton:hover    .btn-icon { animation: icon-fly    0.55s ease forwards; }
#requestButton:hover .btn-icon { animation: icon-spin   0.6s ease; }

@keyframes icon-wiggle {
  0%,100% { transform: rotate(0deg); }
  20%     { transform: rotate(-20deg); }
  40%     { transform: rotate(20deg); }
  60%     { transform: rotate(-12deg); }
  80%     { transform: rotate(12deg); }
}

@keyframes icon-shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-5px); }
  40%     { transform: translateX(5px); }
  60%     { transform: translateX(-3px); }
  80%     { transform: translateX(3px); }
}

@keyframes icon-fly {
  0%   { transform: translate(0,0) rotate(0deg); opacity: 1; }
  55%  { transform: translate(8px,-8px) rotate(20deg); opacity: 0; }
  56%  { transform: translate(-4px,4px) rotate(0deg); opacity: 0; }
  100% { transform: translate(0,0) rotate(0deg); opacity: 1; }
}

@keyframes icon-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes icon-bounce {
  0%,100% { transform: translateY(0) scale(1); }
  30%     { transform: translateY(-7px) scale(1.25); }
  60%     { transform: translateY(2px) scale(0.9); }
  80%     { transform: translateY(-3px) scale(1.05); }
}

/* ── Slider rows ─────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--color-row-sep);
}

.slider-row:last-child {
  border-bottom: none;
}

.pad-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  width: 52px;
}

.pad-label img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  display: block;
  transform: scaleX(-1);
}

.pad-name {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.label {
  display: inline-block;
  width: 52px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
  flex-shrink: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: var(--color-slider-track);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-slider-thumb);
  border: 2.5px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.28);
  cursor: grab;
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.25); }
input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-slider-thumb);
  border: 2.5px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.28);
  cursor: grab;
}

.slider-value {
  width: 38px;
  text-align: right;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-text);
  flex-shrink: 0;
}

.unit {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  width: 18px;
  flex-shrink: 0;
}

/* ── Explanation accordion ───────────────────────────── */
details {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

details summary {
  font-weight: 700;
  font-size: 0.88rem;
  padding: 13px 18px;
  cursor: pointer;
  background: var(--color-card-head);
  border-bottom: 1px solid var(--color-border);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: background 0.14s;
  color: var(--color-text);
}

details summary h2 { margin: 0; font: inherit; }
details summary::-webkit-details-marker { display: none; }

details summary::before {
  content: '▶';
  font-size: 0.6rem;
  color: var(--color-accent);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

details[open] summary::before { transform: rotate(90deg); }
details summary:hover { background: #efefef; }

/* Detail body padding */
.detail-body {
  padding: 14px 20px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--color-text-muted);
}

.detail-body ol {
  margin: 8px 0 0;
  padding-left: 1.4em;
}

.detail-body li {
  margin: 8px 0;
}

.detail-body li small {
  display: block;
  color: #5c5c5c;
  font-size: 0.92em;
  margin-top: 2px;
}

.detail-body p {
  margin: 0 0 10px;
}

.detail-body ul {
  margin: 6px 0 4px;
  padding-left: 1.4em;
}

.detail-body ul li {
  margin: 4px 0;
}

.detail-body strong { color: var(--color-text); }

/* Explanation sections (inside details) */
.explanation-section {
  padding: 12px 18px;
  border-bottom: 1px solid var(--color-row-sep);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--color-text-muted);
}

.explanation-section:last-child { border-bottom: none; }

.explanation-section h3 {
  margin: 0 0 6px;
  font-size: 0.88rem;
  color: var(--color-text);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.std {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.explanation-section p { margin: 0; }
.explanation-section strong { color: var(--color-text); }

/* Drum pad icons in explanation */
.drum-icons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 6px 0 10px;
}

.drum-icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.drum-icon-item img {
  width: 34px;
  height: 34px;
  border-radius: 5px;
  border: 1px solid var(--color-border);
  display: block;
  transform: scaleX(-1);
}

.drum-icon-item span {
  font-size: 0.65rem;
  color: var(--color-text-muted);
}

details a {
  color: var(--color-accent);
  text-decoration: none;
}

details a:hover { text-decoration: underline; }

.no-style-img {
  display: block;
  width: 160px;
  height: auto;
  border: none;
  border-radius: 0;
  margin: 10px 0 4px;
  box-shadow: none;
}

/* ── Firmware steps ──────────────────────────────────── */
.fw-step {
  padding: 14px 0;
  border-bottom: 1px solid var(--color-row-sep);
}

.fw-step:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.fw-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--color-text);
  margin-bottom: 8px;
}

.fw-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 99px;
  background: #da3947; /* --color-accent だと白文字で4.11:1。AAに届かせるため少し濃くする */
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.fw-step p {
  margin: 6px 0 10px;
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.65;
}

.fw-step strong {
  color: var(--color-text);
}

.fw-img {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  margin: 8px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.fw-release-link {
  display: inline-block;
  padding: 10px 20px;
  background: #238636;
  color: #fff !important;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 8px;
  text-decoration: none;
  margin: 4px 0 8px;
  transition: background 0.15s;
}
.fw-release-link:hover {
  background: #278638; /* 白文字で4.5:1を満たす濃さ */
}

.fw-path {
  display: inline-block;
  font-size: 12px;
  font-family: 'Consolas', 'Courier New', monospace;
  background: #f0f0f0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 6px 12px;
  margin: 6px 0 10px;
  color: var(--color-text);
  white-space: nowrap;
  overflow-x: auto;
  max-width: 100%;
}

.fw-step code {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  background: #f0f0f0;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--color-text);
}

/* ── Notification ────────────────────────────────────── */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #28a745;
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 100;
}

.notification.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Key layout ─────────────────────────────────────── */
.keymap-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--color-row-sep);
}

.keymap-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--color-row-sep);
}

.keymap-row:last-child {
  border-bottom: none;
}

select {
  flex: 1;
  padding: 6px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

select:focus {
  border-color: var(--color-accent);
}

#keyMapSendButton    { background: rgba(243, 156,  18, 0.12); border-color: rgba(243,156,  18, 0.4); }
#keyMapRequestButton { background: rgba(52,  152, 219, 0.12); border-color: rgba(52, 152, 219, 0.4); }
#keyMapSendButton:hover    { background: var(--color-send);    color: #fff; border-color: transparent; }
#keyMapRequestButton:hover { background: var(--color-request); color: #fff; border-color: transparent; }

/* ── V1.2 update banner ──────────────────────────────── */
.promo-banner {
  background: linear-gradient(135deg, rgba(230, 60, 75, 0.10) 0%, rgba(230, 60, 75, 0.04) 100%);
  border-top: 3px solid var(--color-accent);
  border-bottom: 1px solid rgba(230, 60, 75, 0.2);
  padding: 18px 20px;
}

.promo-banner-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
}

.promo-banner-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-accent);
  flex-shrink: 0;
}

.promo-banner-title i {
  font-size: 1.05rem;
}

.promo-banner-list {
  flex: 1;
  min-width: 240px;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

.promo-banner-list li {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  padding-left: 1em;
  position: relative;
}

.promo-banner-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--color-accent);
  font-size: 0.75rem;
}

.promo-banner-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.promo-banner-btn:hover {
  opacity: 0.85;
  transform: translateX(3px);
}

/* ── Wiring table ────────────────────────────────────── */
.wiring-warning {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  background: #fffbe6;
  border-left: 3px solid #f0ad00;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.82rem;
  color: #5a4800;
  margin-bottom: 10px;
}
.wiring-warning-icon { flex-shrink: 0; }

.wiring-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.wiring-table th,
.wiring-table td {
  border: 1px solid var(--color-border);
  padding: 5px 10px;
  text-align: center;
}
.wiring-table thead th {
  background: var(--color-card-head);
  font-weight: 600;
  color: var(--color-text);
}
.wiring-table tbody tr:nth-child(even) td {
  background: var(--color-row-sep);
}
.wiring-table td:first-child {
  font-weight: 700;
  color: var(--color-text-muted);
  /* 見出し列は短い語しか入らない。折り返すと1文字ずつ縦に割れて読みにくい */
  white-space: nowrap;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 960px) {
  .app-layout {
    flex-direction: column;
    align-items: center;      /* 中央揃え */
  }

  .controls-panel {
    flex: none;
    width: 100%;
    max-width: 560px;         /* 中央に収束 */
  }

  .explanation-panel {
    width: 100%;
    max-width: 560px;
  }

  .button-group {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }
}

@media (max-width: 560px) {
  .site-header {
    padding: 6px 12px;
    height: auto;
    flex-wrap: wrap;
    gap: 6px 10px;
  }
  .header-left { gap: 10px; flex-wrap: wrap; }
  .header-links { gap: 14px; margin-left: auto; }
  .header-link { font-size: 1.05rem; }

  .site-header h1 { font-size: 1.2rem; }

  .situation { max-width: 120px; font-size: 12px; }

  .app-layout { padding: 14px 10px; gap: 12px; }

  button { font-size: 0.8rem; padding: 8px 10px; }

  .button-group {
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  }
}

/* ── 計測カード（v13のみ。v12は使わない） ── */
.stat-hint {
  margin: 0 16px 12px;
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--color-text-muted);
}

/* カード内の補足文。指定が無いとbodyの本文サイズのまま出て説明が主役に見えてしまう */
.note {
  margin: 0 16px 12px;
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--color-text-muted);
}

/* カード幅いっぱいのボタン1つ（button-groupの4列グリッドに乗せると細く潰れる） */
.card-action {
  margin: 0 16px 12px;
}
.card-action button {
  width: 100%;
}

/* ファーム更新の近道ボタン。手順本文(.detail-body)の上に置くので同じ左右余白に揃える */
.fw-shortcut {
  padding: 14px 4px 0;
  border-bottom: 1px solid var(--color-border);
}

/* ファーム更新の近道説明。操作の本体なので本文色でやや大きくし、下のLEDガイドより主役に見せる */
.fw-lead {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}

/* The test flasher reports progress here without disturbing the global connection status. */
.fw-test-status,
.fw-flash-status {
  min-height: 1.5em;
  margin: 0 16px 14px;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* Keep the manual UF2 fallback available when WebUSB or WinUSB is unavailable. */
.fw-test-download {
  margin: 0 16px 10px;
  font-size: 0.78rem;
}

/* DFUモードのLEDガイド。補足なので地味に。色ドットだけで状態を判別できるようにする */
.led-guide {
  font-size: 0.78rem;
}
.led-guide > .i18n-ja { display: block; }
body.is-en .led-guide > .i18n-en { display: block; }

.led-guide-line { display: block; }

/* LEDの色ドット（小さく淡く。装飾ではなく判別のため） */
.led-dot {
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  margin-right: 4px;
  opacity: 0.8;
}
.led-dot--magenta { background: #c02ac0; }
.led-dot--ok      { background: var(--color-connect); }
.led-dot--warn    { background: var(--color-send); }
.led-dot--error   { background: var(--color-disconnect); }

/* 各ケース1行。キーワードは色を付けず普通の太字 */
.led-case { display: block; margin-top: 2px; }
.led-case b { font-weight: 600; }

/* ※の注記 */
.led-note-mark {
  font-size: 0.7em;
  vertical-align: super;
  margin-left: 2px;
}
.led-footnotes {
  display: block;
  margin-top: 6px;
  line-height: 1.6;
}

.stat-scroll {
  overflow-x: auto;
  margin: 0 16px 12px;
}

.stat-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.stat-table th,
.stat-table td {
  padding: 7px 10px;
  text-align: right;
  border-bottom: 1px solid var(--color-row-sep);
  white-space: nowrap;
}

.stat-table thead th {
  background: var(--color-card-head);
  color: var(--color-text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.stat-table tbody th {
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
}

.stat-table tbody tr:last-child th,
.stat-table tbody tr:last-child td { border-bottom: none; }

/* 感度に迫っているデルタを目立たせる。誤検出の一歩手前が一目で分かる */
/* 白背景の上の文字色なので、パレットそのままだと2.2〜4.1:1にしかならない */
.stat-table td.is-near { color: #a3690c; font-weight: 700; }
.stat-table td.is-over { color: #da3947; font-weight: 700; }

/* Switch機能カードのラベルは5文字あるので、52pxだと折り返す。ここだけ広げる */
#switchContent .label {
  width: 68px;
}


/* ── ui.js / 初心者向け導線の追加分 ───────────────────── */

/* 未対応ブラウザの警告。使い方の小さな注記では気づかれないのでページ先頭に出す */
.browser-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 1280px;
  margin: 14px auto 0;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: #fff4e0;
  border: 2px solid #e6a23c;
  color: #6b4708;
  font-size: 15px;
  line-height: 1.7;
}
.browser-warning i { margin-top: 3px; }

/* 接続状態を操作ボタンのすぐ上に大きく出す（ヘッダー右端では操作と結び付かない） */
.conn-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 1rem;
  font-weight: 700;
}
.conn-bar .situation { color: var(--color-text); font-size: 1rem; max-width: none; }
.conn-bar .status-dot { width: 16px; height: 16px; }
.dirty-badge {
  display: none;
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 700;
  color: #8a5a00;
  background: #ffe9b8;
  border: 1px solid #e6b451;
  border-radius: 99px;
  padding: 3px 10px;
}
body.is-dirty .dirty-badge { display: inline-block; }

/* 送信・読込・保存の結果を必ず文字で残す */
.result-msg {
  margin: 10px 0 0;
  min-height: 1.4em;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}
.result-msg.is-ok  { color: #1b7f4b; }
.result-msg.is-err { color: #c0392b; font-weight: 700; }

/* 未接続のうちは押せてはいけない */
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
}
button:disabled:hover { transform: none; box-shadow: none; }

/* やり直し用の副ボタン。主要操作と見分けが付くよう色を持たせない */
.undo-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.btn-sub {
  background: #f2f2f4;
  border-color: #dcdce2;
  font-size: 0.82rem;
  padding: 7px 12px;
  color: var(--color-text-muted);
}
.btn-sub:hover { background: #e4e4ea; color: var(--color-text); }

/* スライダーだけでは値を決めにくいので数値入力を併設する */
.slider-num {
  width: 62px;
  flex-shrink: 0;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: right;
  padding: 4px 4px 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fafafa;
  color: var(--color-text);
}
.slider-num:focus { outline: 2px solid var(--color-request); background: #fff; }

/* 推奨範囲を色（黄色）だけで示すと色覚特性によっては判別できない */
.range-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: -4px 0 8px 60px;
}

/* 打鍵テスト */
.hit-test {
  margin: 0 16px 12px;
  min-height: 54px;
  max-height: 54px;
  overflow-x: auto;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-sm);
  background: #fafafa;
  cursor: text;
}
.hit-test:focus { outline: none; border-color: var(--color-request); background: #fff; }
.hit-placeholder { color: var(--color-text-muted); font-size: 0.85rem; }
.hit-key {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--color-header-bg);
  color: #fff;
}

/* 用語集 */
.glossary { margin: 0; }
.glossary dt { font-weight: 700; color: var(--color-text); margin-top: 10px; }
.glossary dd { margin: 2px 0 0; padding-left: 0; }

/* 最初に読む案内。スマホでは設定欄より前に出す */
.quickstart {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 5px solid var(--color-request);
  padding: 14px 18px;
  font-size: 15px;
  line-height: 1.8;
}
.quickstart h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}
.quickstart ol { margin: 0; padding-left: 1.3em; }
.quickstart .qs-note { margin: 8px 0 0; font-size: 0.88rem; color: var(--color-text-muted); }

/* バージョンの選び分け */
.version-picker {
  max-width: 1280px;
  margin: 14px auto 0;
  padding: 0 20px;
}
.version-picker-inner {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  font-size: 15px;
  line-height: 1.8;
}
.version-picker h2 { margin: 0 0 6px; font-size: 1rem; }
.version-picker ul { margin: 6px 0 0; padding-left: 1.3em; }

/* キー配置の重複警告 */
.dup-warning {
  display: none;
  margin: 0 16px 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: #fff4e0;
  border: 1px solid #e6a23c;
  color: #6b4708;
  font-size: 0.85rem;
}
.dup-warning.is-on { display: block; }

@media (max-width: 560px) {
  .detail-body { font-size: 15px; }
  .undo-row { flex-wrap: wrap; }
  .range-hint { margin-left: 0; }
  .slider-num { width: 56px; }
}

/* コネクタのピン位置図。色名の表だけでは表裏・左右を間違える */
.wiring-fig {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 10px 0 4px;
}

/* ── Accessibility baseline ──────────────────────────── */

/* 開閉見出しをbutton化したので、ブラウザ既定の枠と字体だけ打ち消す */
button.keymap-title {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  font-family: inherit;
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
}

/* トラックやスライダーは outline:none にしてあるので、代わりのフォーカス表示を出す */
input[type="range"]:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--color-request);
  outline-offset: 2px;
}
.ios-switch input:focus-visible ~ .ios-track {
  outline: 3px solid var(--color-request);
  outline-offset: 2px;
}

/* 主要ナビと言語トグルのタッチ領域を確保する */
.version-link { display: inline-flex; align-items: center; min-height: 32px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.fw-picker {
  margin: 12px 0;
  padding: 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.fw-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.fw-picker-row label {
  min-width: 8.5em;
  font-size: 0.88rem;
}

.fw-picker-out {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.fw-picker-note {
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ダウンロードリンクと並ぶので、同じ高さで色だけ変えて主従を出す */
.fw-flash-button {
  display: inline-block;
  padding: 10px 20px;
  margin: 4px 0 8px 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #1f6feb;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
}
.fw-flash-button:hover:not(:disabled) {
  background: #1a5fd0;
}
.fw-flash-button:disabled {
  background: #6e7681;
  cursor: default;
}

.usb-mode-row {
  gap: 12px;
}

.usb-mode-row .label {
  min-width: 4em;
}

.usb-mode-row #usbModeName {
  min-width: 3.5em;
}

.usb-mode-row .ios-switch {
  flex: 0 0 auto;
}
