:root {
  --bg: #f4f1ea;
  --text: #181818;
  --muted: #666666;
  --line: rgba(0, 0, 0, 0.14);
  --card: rgba(255, 255, 255, 0.72);
  --ok: #1f7a3f;
  --warn: #9a6a00;
  --error: #b3261e;
  --selected: #1d4ed8;
  --playhead: #e11d48;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Yu Gothic", "YuGothic",
    "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

.page {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 80px;
}

.checker-header {
  padding: 48px 0 40px;
  border-bottom: 1px solid var(--line);
}

.top-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}

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

.language-control,
.tempo-control,
.timbre-control,
.playback-control,
.exercise-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
  font-size: 0.86rem;
}

.language-control select,
.tempo-control input,
.timbre-control select,
.playback-control select,
.exercise-control select {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: none;
}

.tempo-control input { width: 70px; }
.timbre-control select, .playback-control select { min-width: 150px; }
.exercise-control select { min-width: 220px; }

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 4.8rem);
  line-height: 1.05;
  letter-spacing: -0.06em;
}

h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.lead {
  max-width: 860px;
  margin: 24px 0 0;
  font-size: 1.05rem;
  color: var(--muted);
}

.checker-panel, .result-section {
  margin-top: 32px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px;
}

.hidden-input {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.score-tools, .playback-tools, .exercise-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 22px;
  align-items: center;
}

.playback-tools, .exercise-tools {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.playback-hint, .exercise-description {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.exercise-description {
  flex-basis: 100%;
  min-width: 220px;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  margin-right: 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.level-badge.beginner {
  color: #1f7a3f;
  border-color: rgba(31, 122, 63, 0.32);
  background: rgba(31, 122, 63, 0.08);
}

.level-badge.intermediate {
  color: #9a6a00;
  border-color: rgba(154, 106, 0, 0.32);
  background: rgba(154, 106, 0, 0.08);
}

.level-badge.advanced {
  color: #7c2d12;
  border-color: rgba(124, 45, 18, 0.32);
  background: rgba(124, 45, 18, 0.08);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid var(--text);
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--text); color: #ffffff; }
.button.small { min-height: 38px; padding: 0 16px; font-size: 0.86rem; }

.score-box {
  margin: 22px 0 26px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.68);
}

.score-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.score-head h2 { margin: 0 0 4px; }
.score-head p { margin: 0; color: var(--muted); font-size: 0.92rem; }

.score-status {
  font-size: 0.86rem;
  color: var(--muted);
  white-space: nowrap;
}

.score-editor {
  width: 100%;
  min-height: 360px;
  display: block;
  border-radius: 16px;
  background: #ffffff;
  cursor: crosshair;
  user-select: none;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.score-editor:focus {
  outline: 2px solid rgba(29, 78, 216, 0.35);
  outline-offset: 4px;
}

.staff-line { stroke: #181818; stroke-width: 1.2; }
.measure-line { stroke: rgba(0, 0, 0, 0.26); stroke-width: 1.15; }
.subdivision-line { stroke: rgba(0, 0, 0, 0.11); stroke-width: 0.8; }
.measure-barline { stroke: rgba(0, 0, 0, 0.26); stroke-width: 1.15; }
.measure-barline.final-thin { stroke: rgba(0, 0, 0, 0.55); stroke-width: 1.4; }
.measure-barline.final-thick { stroke: rgba(0, 0, 0, 0.88); stroke-width: 3.2; }
.ledger-line { stroke: #181818; stroke-width: 1.1; }
.slot-marker { fill: rgba(0, 0, 0, 0.12); }
.downbeat-marker { fill: rgba(0, 0, 0, 0.24); }
.voice-label { font-size: 13px; fill: rgba(0, 0, 0, 0.62); font-weight: 600; }

.note-label {
  font-size: 12px;
  fill: rgba(0, 0, 0, 0.64);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.note-label.selected { fill: var(--selected); font-weight: 700; }
.note-label.playing { fill: var(--playhead); font-weight: 700; }

.note-head {
  fill: #181818;
  stroke: #181818;
  stroke-width: 1;
}

.note-head.cantus {
  fill: rgba(0, 0, 0, 0.35);
  stroke: rgba(0, 0, 0, 0.35);
}

.note-head.selected { fill: var(--selected); stroke: var(--selected); }
.note-head.playing { fill: var(--playhead); stroke: var(--playhead); }

.note-stem { stroke: #181818; stroke-width: 1.4; }
.note-stem.cantus { stroke: rgba(0, 0, 0, 0.35); }
.note-stem.selected { stroke: var(--selected); }
.note-stem.playing { stroke: var(--playhead); }

.flag { stroke: #181818; stroke-width: 1.3; fill: none; }
.flag.selected { stroke: var(--selected); }
.flag.playing { stroke: var(--playhead); }

.playhead-line {
  stroke: var(--playhead);
  stroke-width: 3;
  stroke-linecap: round;
  pointer-events: none;
}

.playhead-halo {
  fill: rgba(225, 29, 72, 0.08);
  stroke: rgba(225, 29, 72, 0.22);
  stroke-width: 1;
  pointer-events: none;
}

.accidental {
  font-size: 20px;
  fill: #181818;
  font-family: "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", serif;
  dominant-baseline: middle;
  pointer-events: none;
}

.accidental.cantus { fill: rgba(0, 0, 0, 0.35); }
.accidental.selected { fill: var(--selected); }
.accidental.playing { fill: var(--playhead); }

.current-notes {
  margin: 0 0 24px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
}

.current-notes h2 { margin-bottom: 10px; }
.current-notes p { margin: 4px 0; color: var(--muted); }
.current-notes strong { color: var(--text); }

.result-section { margin-top: 24px; }

.summary-box {
  margin-bottom: 18px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--muted);
}

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

.result-item {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.result-item.ok { border-left: 5px solid var(--ok); }
.result-item.warn { border-left: 5px solid var(--warn); }
.result-item.error { border-left: 5px solid var(--error); }

.result-label {
  display: inline-block;
  margin-right: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.result-item.ok .result-label { color: var(--ok); }
.result-item.warn .result-label { color: var(--warn); }
.result-item.error .result-label { color: var(--error); }

@media (max-width: 820px) {
  .page {
    width: min(100% - 24px, 1080px);
    padding-top: 32px;
    padding-bottom: 56px;
  }

  .checker-header { padding-top: 32px; }
  .top-controls, .score-head { display: block; }
  .language-control { margin-top: 12px; }
  .score-status { margin-top: 8px; }
  .score-box { padding: 14px; }
  .score-editor { min-height: 310px; }
}

@media (max-width: 520px) {
  .page { width: min(100% - 18px, 1080px); }

  .checker-panel, .result-section {
    padding: 18px;
    border-radius: 18px;
  }

  .score-box { border-radius: 18px; }
  .button { width: 100%; }

  .score-tools, .playback-tools, .exercise-tools {
    display: grid;
    grid-template-columns: 1fr;
  }

  .language-control, .tempo-control, .timbre-control, .playback-control, .exercise-control {
    width: 100%;
    justify-content: space-between;
  }

  .language-control select, .timbre-control select, .playback-control select, .exercise-control select {
    min-width: 0;
    width: 100%;
  }

  h1 { letter-spacing: -0.045em; }
}


.note-head.open {
  fill: #ffffff;
  stroke: #181818;
  stroke-width: 1.6;
}

.note-head.open.cantus {
  fill: #ffffff;
  stroke: rgba(0, 0, 0, 0.42);
  stroke-width: 1.6;
}

.note-head.open.selected {
  fill: #ffffff;
  stroke: var(--selected);
  stroke-width: 2;
}

.note-head.open.playing {
  fill: #ffffff;
  stroke: var(--playhead);
  stroke-width: 2;
}


/* 2026-06-01 Module 2 Beta1 spec */
.result-section,
#result,
#summary {
  display: none !important;
}

.score-box {
  position: relative;
}

.analysis-inline-result {
  margin: 14px 0 0;
  padding: 0;
  color: rgba(20,20,20,0.78);
  line-height: 1.8;
}

.staff-mute-overlay {
  position: absolute;
  left: 10px;
  top: 86px;
  z-index: 20;
  pointer-events: none;
}

.staff-mute-button {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 1.6px solid rgba(20,20,20,0.38);
  background: rgba(255,255,255,0.92);
  color: rgba(20,20,20,0.86);
  font-size: 22px;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}

.staff-mute-button.counterpoint {
  top: 32px;
  left: 0;
}

.staff-mute-button.cantus {
  top: 168px;
  left: 0;
}

.staff-mute-button:hover {
  border-color: rgba(20,20,20,0.72);
}

.staff-mute-button.muted {
  border-color: #ff4f8b;
  background: #ff4f8b;
  color: #fff;
}

.language-control select {
  cursor: pointer;
}


/* Module language selector */
.module1-language-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 20px;
  background: #f7f4ef;
}

.module1-language-card {
  width: min(760px, 100%);
  background: rgba(255,255,255,0.84);
  border: 1px solid rgba(20,20,20,0.10);
  border-radius: 24px;
  padding: clamp(28px, 5vw, 54px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.08);
}

.module1-language-kicker {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(20,20,20,0.52);
}

.module1-language-title {
  margin: 0;
  font-size: clamp(32px, 6vw, 64px);
  line-height: 0.95;
  letter-spacing: -0.055em;
}

.module1-language-subtitle {
  margin: 18px 0 0;
  color: rgba(20,20,20,0.62);
  line-height: 1.7;
}

.module1-language-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 34px;
}

.module1-language-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 76px;
  padding: 18px 20px;
  border: 1px solid rgba(20,20,20,0.14);
  border-radius: 18px;
  background: rgba(255,255,255,0.72);
  color: inherit;
  text-decoration: none;
}

.module1-language-link strong {
  display: block;
  font-size: 18px;
}

.module1-language-link span {
  color: rgba(20,20,20,0.52);
  font-size: 13px;
}

.module1-language-arrow {
  font-size: 22px;
  color: rgba(20,20,20,0.48);
}

@media (max-width: 640px) {
  .module1-language-actions {
    grid-template-columns: 1fr;
  }
}


/* 2026-06-01 Module 2 image notation display */
.png-notation {
  pointer-events: none;
}

.png-staff {
  opacity: 1;
}

.png-staff-fallback-line {
  opacity: 0;
}

.png-clef {
  opacity: 1;
}

.clef-fallback {
  opacity: 0;
}

.png-notehead {
  opacity: 1;
}

.whole-note-fallback,
.accidental-fallback {
  opacity: 0;
}

.png-accidental {
  opacity: 1;
}


/* 2026-06-01 Module 2 PNG notehead cleanup */
.fallback-notehead,
.accidental-fallback,
.clef-fallback {
  opacity: 0 !important;
}

.selected-note-ring {
  fill: none;
  stroke: #ff4f8b;
  stroke-width: 1.6;
  pointer-events: none;
}


/* Module 2 measure barlines */
.measure-barline {
  stroke: #1d1d1d;
  stroke-width: 1.2;
  opacity: 0.85;
}
.measure-barline.end {
  stroke-width: 1.6;
}


/* 2026-06-01 Module 2 UI align to Module 1 Beta1 */
.exercise-tools {
  padding: 0;
  border: 0;
  background: transparent;
  margin-bottom: 12px;
}

.exercise-description {
  flex: 1 1 260px;
  min-width: 260px;
  margin-left: 2px;
}

.level-badge { display: none !important; }

.playback-tools {
  padding: 0;
  border: 0;
  background: transparent;
}

.score-editor {
  min-height: 390px;
}

.staff-mute-overlay {
  left: 64px;
  top: 154px;
}

.staff-mute-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.staff-mute-button.counterpoint {
  top: 0;
  left: 0;
}

.staff-mute-button.cantus {
  top: 115px;
  left: 0;
}

.note-label {
  font-size: 13px;
}

.measure-barline {
  stroke: rgba(0,0,0,0.42);
  stroke-width: 1.2;
}

.measure-barline.end {
  stroke-width: 1.5;
}

@media (max-width: 820px) {
  .staff-mute-overlay {
    left: 52px;
    top: 152px;
  }
}

@media (max-width: 520px) {
  .staff-mute-overlay {
    left: 42px;
    top: 170px;
  }
}


/* 2026-06-01 module2 bigger overall + clef alignment */
.score-editor {
  min-height: 392px;
}

.staff-mute-overlay {
  left: 70px;
  top: 160px;
}

.staff-mute-button.counterpoint {
  top: 2px;
}

.staff-mute-button.cantus {
  top: 126px;
}

.note-label {
  font-size: 14px;
}

.voice-label {
  font-size: 14px;
}

@media (max-width: 820px) {
  .staff-mute-overlay {
    left: 56px;
    top: 162px;
  }
  .staff-mute-button.cantus {
    top: 126px;
  }
}

@media (max-width: 520px) {
  .score-editor {
    min-height: 360px;
  }
  .staff-mute-overlay {
    left: 44px;
    top: 176px;
  }
  .staff-mute-button.cantus {
    top: 124px;
  }
}


/* Final override: move M buttons to the left of clefs */
.staff-mute-overlay {
  left: 6px !important;
  top: 168px !important;
}
.staff-mute-button.counterpoint {
  top: 0 !important;
}
.staff-mute-button.cantus {
  top: 128px !important;
}
@media (max-width: 820px) {
  .staff-mute-overlay { left: 4px !important; top: 170px !important; }
  .staff-mute-button.cantus { top: 128px !important; }
}
@media (max-width: 520px) {
  .staff-mute-overlay { left: 2px !important; top: 182px !important; }
  .staff-mute-button.cantus { top: 124px !important; }
}


/* Final fine-tune: keep M buttons fully visible and under labels */
.staff-mute-overlay {
  left: 18px !important;
  top: 168px !important;
}
.staff-mute-button.counterpoint {
  top: 18px !important;
}
.staff-mute-button.cantus {
  top: 146px !important;
}
@media (max-width: 820px) {
  .staff-mute-overlay { left: 14px !important; top: 170px !important; }
  .staff-mute-button.counterpoint { top: 18px !important; }
  .staff-mute-button.cantus { top: 146px !important; }
}
@media (max-width: 520px) {
  .staff-mute-overlay { left: 10px !important; top: 182px !important; }
  .staff-mute-button.counterpoint { top: 18px !important; }
  .staff-mute-button.cantus { top: 142px !important; }
}


/* 2026-06-01 module2 module1-layout rebuild */
.score-editor {
  min-height: 440px !important;
}

.png-staff {
  opacity: 1;
}

.png-notehead {
  opacity: 1;
}

.fallback-notehead,
.accidental-fallback,
.clef-fallback {
  opacity: 0 !important;
}

.staff-line.png-staff-fallback-line {
  opacity: 0 !important;
}

.note-label {
  font-size: 13px !important;
}

.voice-label {
  font-size: 14px !important;
}

.staff-mute-overlay {
  left: 18px !important;
  top: 188px !important;
}

.staff-mute-button {
  width: 34px !important;
  height: 34px !important;
  border-radius: 8px !important;
  font-size: 20px !important;
  font-weight: 800 !important;
}

.staff-mute-button.counterpoint {
  top: 18px !important;
  left: 0 !important;
}

.staff-mute-button.cantus {
  top: 172px !important;
  left: 0 !important;
}

.measure-barline {
  stroke: rgba(0, 0, 0, 0.42) !important;
  stroke-width: 1.15 !important;
}

.measure-barline.final-thin {
  stroke: rgba(0, 0, 0, 0.58) !important;
  stroke-width: 1.35 !important;
}

.measure-barline.final-thick {
  stroke: rgba(0, 0, 0, 0.9) !important;
  stroke-width: 3.2 !important;
}

.png-accidental.cantus {
  opacity: 1;
}

.exercise-tools {
  align-items: center;
}

.exercise-description {
  flex-basis: 100%;
}

@media (max-width: 820px) {
  .score-editor {
    min-height: 400px !important;
  }

  .staff-mute-overlay {
    left: 14px !important;
    top: 178px !important;
  }

  .staff-mute-button.cantus {
    top: 158px !important;
  }
}

@media (max-width: 520px) {
  .score-editor {
    min-height: 360px !important;
  }

  .staff-mute-overlay {
    left: 10px !important;
    top: 178px !important;
  }

  .staff-mute-button.cantus {
    top: 150px !important;
  }
}
