:root {
  --bg: #faf6f1;
  --bg-2: #f3eee5;
  --surface: #ffffff;
  --surface-2: #faf6ed;
  --surface-3: #eee7d8;
  --border: #e8dfcc;
  --border-soft: #f0e9da;
  --accent: #e85f4d;
  --accent-2: #d44a39;
  --accent-soft: rgba(232, 95, 77, 0.10);
  --accent-glow: rgba(232, 95, 77, 0.30);

  --wood-light: #6a3f1e;
  --wood-mid: #4a2812;
  --wood-dark: #25130a;
  --bone: #f4ecd2;
  --bone-dim: #d6cca9;
  --metal-1: #f4f4f4;
  --metal-2: #b8b8b8;
  --metal-3: #6a6a6a;
  --metal-4: #2a2a2a;
  --string-bright: #e8e8e8;
  --string-mid: #9a9a9a;
  --string-wound-1: #d9b977;
  --string-wound-2: #8a6a3a;
  --gold: #f1c75a;
  --gold-ink: #9a6f12;

  --text: #1f1a14;
  --text-2: #5c5547;
  --text-3: #6e6557;
  --text-dim: #6e6557;

  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "PingFang TC", "PingFang SC", "Hiragino Sans", "Noto Sans CJK", sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 24px 48px rgba(0,0,0,0.12);
  --text-faint: #b5ac9b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
html, body {
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 235, 220, 0.55) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  line-height: 1.55;
  touch-action: manipulation;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
ul, ol { list-style: none; }
[hidden] { display: none !important; }

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 40px) 60px;
}

/* ===================== Skip link ===================== */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  text-decoration: none;
  z-index: 1000;
  border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===================== Top bar ===================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 28px;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-2);
  text-decoration: none;
  transition: color var(--transition);
}
.brand:hover { color: var(--accent); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover {
  color: var(--accent);
  background: var(--surface-2);
}

.lang-switcher {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%237a7973' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  transition: border-color var(--transition);
}
.lang-switcher:hover { border-color: var(--text-3); }
.lang-switcher:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }

/* ===================== Page title ===================== */
.page-title {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 6px;
}
.page-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 28px;
}

/* ===================== Controls panel ===================== */
.controls-panel {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.select-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.select-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-dim);
  text-transform: uppercase;
  text-align: center;
}

.chord-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 36px 12px 16px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%237a7973' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 9px;
  min-width: 160px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chord-select:hover { border-color: var(--accent); }
.chord-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}
.chord-select option { background: #ffffff; color: var(--text); }

/* ===================== Guitar stage ===================== */
.guitar-stage {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.fretboard-container {
  width: 100%;
  max-width: 1100px;
  position: relative;
}

.fretboard-svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  filter: drop-shadow(0 12px 28px rgba(60, 40, 20, 0.22));
}

/* ===================== Scale info panel ===================== */
.chord-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 28px;
  max-width: 520px;
  margin: 0 auto 32px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.chord-name {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.chord-details {
  display: flex;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
}

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

.detail-label {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.detail-value {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 1px;
}

/* ===================== SVG fretboard styling ===================== */
.fb-wood {
  fill: #4a2812;
}

.fb-nut {
  fill: var(--bone);
}

.fb-fret {
  stroke: #d0d0d0;
  stroke-width: 2.5;
}

.fb-inlay {
  fill: #f0e8c8;
  stroke: #a09078;
  stroke-width: 0.5;
}

.fb-inlay-double {
  fill: #f0e8c8;
  stroke: #a09078;
  stroke-width: 0.6;
}

.fb-string {
  fill: none;
  stroke-linecap: round;
}

.fb-string-plain {
  stroke: #c8c8c8;
}

.fb-string-wound {
  stroke: var(--string-wound-1);
}

/* Position markers */
.fb-position {
  cursor: pointer;
  transition: opacity 0.15s;
}
.fb-position:hover {
  opacity: 0.85;
}

.fb-marker-root {
  fill: var(--accent);
  stroke: var(--accent-2);
  stroke-width: 1.5;
}

.fb-marker-tone {
  fill: var(--gold);
  stroke: #b88a20;
  stroke-width: 1.2;
}

.fb-marker-label {
  font-family: "Georgia", serif;
  font-weight: 700;
  font-size: 12px;
  fill: #ffffff;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.fb-marker-label-tone {
  fill: #3a2a06;
}

/* Fretboard note label hover */
.fb-position:hover .fb-marker-root {
  filter: brightness(1.15);
}
.fb-position:hover .fb-marker-tone {
  filter: brightness(1.1);
}

.fb-marker-flash {
  animation: markerPulse 0.3s ease-out;
}
@keyframes markerPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* Nut string labels */
.fb-string-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  fill: var(--text-dim);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* Fret number labels */
.fb-fret-num {
  font-family: var(--font-ui);
  font-size: 10px;
  fill: var(--text-dim);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* ===================== Info ===================== */
.info {
  max-width: 720px;
  margin: 40px auto 0;
  padding: 0 4px;
}
.info h2 {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 26px 0 10px;
  color: var(--text);
}
.info p {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 10px;
  line-height: 1.7;
}
.info ol {
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  opacity: 0.92;
  list-style: decimal inside;
  padding-left: 4px;
}
.info ol li { margin-bottom: 8px; }

/* FAQ */
.faq-item {
  border-top: 1px solid var(--border-soft);
  padding: 14px 0;
}
.faq-item:last-child { border-bottom: 1px solid var(--border-soft); }
.faq-item summary {
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.5px;
  list-style: none;
  padding-right: 24px;
  position: relative;
  transition: color 0.15s;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 20px;
  font-weight: 300;
  transition: transform 0.2s;
}
.faq-item[open] summary::after { content: '\2212'; }
.faq-item summary:hover { color: var(--accent); }
.faq-item p {
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.7;
}

/* ===================== Site footer ===================== */
.site-footer {
  max-width: 720px;
  margin: 56px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
}
.site-footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-3);
}
.site-footer a { color: var(--text-2); }
.site-footer a:hover { color: var(--accent); }
.site-footer .sub {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}

/* ===================== Accessibility ===================== */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===================== Responsive ===================== */
@media (max-width: 700px) {
  .app { padding: 14px 10px 40px; }
  .page-title { font-size: 22px; }
  .page-sub { font-size: 13px; }
  .controls-panel { gap: 12px; flex-direction: column; align-items: center; }
  .chord-select { min-width: 200px; font-size: 14px; padding: 10px 32px 10px 14px; }
  .chord-info { padding: 16px 20px; }
  .chord-name { font-size: 26px; }
  .chord-details { gap: 24px; }
  .detail-value { font-size: 15px; }
  .info { margin-top: 28px; }
  .info h2 { font-size: 18px; }
  .site-footer { margin-top: 40px; }
  .site-footer-row { gap: 14px; font-size: 12px; }
}

@media (min-width: 701px) and (max-width: 900px) {
  .app { padding: 18px 20px 50px; }
}

@media (max-width: 420px) {
  .topbar-right .nav-link { display: none; }
  .topbar-right { gap: 6px; }
  .lang-switcher { max-width: 130px; font-size: 12px; padding: 4px 22px 4px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}