:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #555;
  --border: #e0e0e0;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --section-bg: #fafafa;
  --drawer-width: min(320px, 88vw);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "PingFang TC", "Heiti TC", "Noto Sans TC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 17px;
}

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

a:hover {
  text-decoration: underline;
}

.lesson-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 22;
}

.chapter-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.55rem 1rem 0.65rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 3.05rem;
  z-index: 21;
}

.chapter-tabs::-webkit-scrollbar {
  display: none;
}

.chapter-tab {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--section-bg);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
}

.chapter-tab:hover {
  border-color: #c7d2fe;
  color: var(--accent);
}

.chapter-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chapter-tab-num {
  opacity: 0.85;
  margin-right: 0.2rem;
}

.lesson-nav .back-link {
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--accent);
}

.lesson-nav .back-link:hover {
  text-decoration: underline;
}

.current-section {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  flex: 1;
  text-align: center;
  padding: 0 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s;
}

.current-section.is-active {
  color: var(--accent);
  font-weight: 700;
}

.drawer-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, #6366f1 100%);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}

.drawer-trigger:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
}

.drawer-trigger:active {
  transform: scale(0.98);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.drawer-backdrop.is-open {
  opacity: 1;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--drawer-width);
  height: 100%;
  max-height: 100dvh;
  background: var(--bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(15, 23, 42, 0.15);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.35rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg) 100%);
}

.drawer-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.drawer-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
}

.drawer-close {
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: var(--section-bg);
  font-size: 1.35rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.drawer-close:hover {
  background: var(--border);
  color: var(--text);
  transform: rotate(90deg);
}

.drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.drawer-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.drawer-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 0 2px 2px 0;
}

.drawer-link:hover {
  background: var(--accent-soft);
  border-color: #c7d2fe;
  transform: translateX(4px);
  text-decoration: none;
}

.drawer-link.active {
  background: var(--accent-soft);
  border-color: #a5b4fc;
}

.drawer-link.active::before {
  transform: scaleY(1);
}

.drawer-num {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.7;
  min-width: 1.5rem;
}

.drawer-link.active .drawer-num {
  opacity: 1;
}

.drawer-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.drawer-text strong {
  font-size: 0.95rem;
}

.drawer-text small {
  font-size: 0.78rem;
  color: var(--muted);
}

.drawer-arrow {
  font-size: 1rem;
  color: var(--accent);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s, transform 0.2s;
}

.drawer-link:hover .drawer-arrow,
.drawer-link.active .drawer-arrow {
  opacity: 1;
  transform: translateX(0);
}

body.drawer-open {
  overflow: hidden;
}

header.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
}

.lesson-badge {
  display: inline-block;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  margin-bottom: 0.5rem;
}

.site-header h1 {
  font-size: 1.85rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.site-header p {
  color: var(--muted);
  font-size: 1rem;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

section.lesson-chapter {
  margin-bottom: 1.5rem;
  scroll-margin-top: 7.5rem;
}

.chapter-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(135deg, var(--accent-soft) 0%, #fff 70%);
  border: 1px solid #e0e7ff;
  border-radius: 14px 14px 0 0;
  border-bottom: none;
}

.chapter-num {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.chapter-head-text {
  min-width: 0;
  padding-top: 0.1rem;
}

.chapter-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-bottom: 0.2rem;
}

.chapter-desc {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.chapter-body {
  padding: 1.15rem 1.1rem 1.35rem;
  background: var(--section-bg);
  border: 1px solid var(--border);
  border-top: 1px solid #eef2ff;
  border-radius: 0 0 14px 14px;
}

.chapter-body > :first-child {
  margin-top: 0;
}

.chapter-subtitle,
.chapter-part-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent-soft);
}

.chapter-part {
  padding-top: 0.25rem;
}

.chapter-part + .chapter-part {
  margin-top: 1.5rem;
  padding-top: 1.35rem;
  border-top: 1px dashed var(--border);
}

.chapter-part-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.65rem;
}

section.lesson-chapter h3:not(.chapter-part-title):not(.chapter-subtitle) {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: var(--text);
}

ul, ol {
  padding-left: 1.35rem;
  margin-bottom: 0.85rem;
}

li {
  margin-bottom: 0.4rem;
}

.figure {
  text-align: center;
  margin: 1.25rem 0;
}

.figure img {
  max-width: 100%;
  height: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 1rem 0;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  text-align: left;
}

th {
  background: var(--section-bg);
  font-weight: 600;
}

.tune-table th,
.tune-table td {
  text-align: center;
}

.parts-table td:first-child {
  font-weight: 600;
  white-space: nowrap;
  width: 5.5rem;
}

.hold-caps {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
  font-size: 0.95rem;
}

.hold-caps p {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.hold-caps p:last-child {
  border-bottom: none;
}

.chords-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-top: 1.25rem;
}

@media (min-width: 520px) {
  .chords-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.chord-card {
  text-align: center;
}

.chord-card img {
  max-width: 100%;
  height: auto;
}

.chord-card span {
  display: block;
  font-weight: 600;
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.flow {
  text-align: center;
  font-weight: 600;
  font-size: 1.05rem;
  margin: 1rem 0;
}

.note {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

.tune-notes {
  margin: 0.75rem 0 1rem;
}

.tune-notes p {
  margin-bottom: 0.35rem;
}

.open-string-section {
  margin-top: 1.25rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.open-string-error {
  margin: 0;
  font-size: 0.85rem;
  color: #b45309;
}

.open-string-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
  text-align: center;
}

.open-string-notes {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-width: 20rem;
  margin: 0 auto;
}

.open-string-play {
  display: grid;
  grid-template-columns: 2rem 3rem 1fr auto;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.open-string-play:hover {
  background: var(--accent-soft);
  border-color: #a5b4fc;
}

.open-string-play.is-playing {
  background: #dbeafe;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.open-string-num {
  font-weight: 800;
  font-size: 1rem;
  color: var(--accent);
}

.open-string-pitch {
  font-weight: 700;
  font-size: 0.95rem;
}

.open-string-name {
  font-size: 0.85rem;
  color: var(--muted);
}

.open-string-icon {
  font-size: 1.1rem;
}

.chord-chart-guide {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.chord-chart-guide h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.chord-chart-intro {
  font-size: 0.88rem;
  margin-bottom: 0.6rem;
  color: var(--muted);
}

.chord-chart-list {
  margin: 0 0 0.65rem;
  padding-left: 1.2rem;
  font-size: 0.88rem;
  line-height: 1.55;
}

.chord-chart-list li {
  margin-bottom: 0.4rem;
}

.chord-chart-tip {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.sym {
  display: inline-block;
  min-width: 1.1rem;
  text-align: center;
  font-weight: 800;
  border-radius: 4px;
  padding: 0 0.2rem;
}

.sym-x {
  background: #fee2e2;
  color: #b91c1c;
}

.sym-o {
  background: #dcfce7;
  color: #15803d;
}

.chord-rich-note {
  margin: 0.75rem 0;
  padding: 0.65rem 0.85rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.chord-preview-note {
  text-align: center;
  margin-top: 0.5rem;
}

.chord-label {
  display: block;
  line-height: 1.35;
}

.chord-real-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
}

.chord-preview {
  margin-top: 0.65rem;
  padding: 0.55rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
}

.chord-preview-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.chord-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.chord-step {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chord-step.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chord-step.is-done {
  background: #dbeafe;
  border-color: #93c5fd;
}

.chord-preview-btn {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.chord-preview-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.chord-preview-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.chord-preview-status {
  min-height: 1.2em;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.practice-guide {
  margin: 0.75rem 0 1.25rem;
  padding: 1rem;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.practice-guide h3 {
  font-size: 0.95rem;
  margin-bottom: 0.65rem;
}

.practice-steps {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  font-size: 0.88rem;
  line-height: 1.55;
}

.practice-steps li {
  margin-bottom: 0.45rem;
}

.practice-loop-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
  text-align: center;
}

.practice-loop {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.5rem;
}

.practice-chord {
  font-weight: 800;
  font-size: 1.05rem;
  padding: 0.35rem 0.65rem;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
}

.practice-chord--repeat {
  background: var(--accent-soft);
}

.practice-arrow {
  font-weight: 700;
  color: var(--muted);
}

.practice-loop-more {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.practice-loop-sub {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.85rem;
}

.lesson-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.85rem;
}

.lesson-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  min-width: 8.5rem;
  box-sizing: border-box;
}

.lesson-action-btn--tuner {
  display: block;
  width: 100%;
  max-width: 18rem;
  margin: 0.85rem auto 0;
  background: #ecfdf5;
  color: #047857;
  border: 2px solid #6ee7b7;
}

.lesson-action-btn--metro {
  background: var(--accent);
  color: #fff;
}

.lesson-action-btn--link {
  background: #fff;
  color: var(--accent);
  border: 2px solid var(--accent);
}

.lesson-action-btn--song {
  background: #fef3c7;
  color: #b45309;
  border-color: #fbbf24;
}

.lesson-action-btn:hover {
  opacity: 0.92;
  filter: brightness(0.98);
}

code {
  font-family: ui-monospace, monospace;
  font-size: 0.95em;
}

footer.site-footer {
  text-align: center;
  padding: 2rem 1.5rem 4rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
