/* The engraver needs Noto Music's own glyph metrics for clefs, braces and accidentals (see learn-course.css). */
@font-face { font-family: 'Noto Music'; src: url('assets/fonts/NotoMusic.woff2') format('woff2'); font-display: block;
  unicode-range: U+25CC, U+2669-266F, U+1D000-1D0F5, U+1D100-1D245; }
@font-face { font-family: 'KM Bravura'; src: url('assets/fonts/Bravura.woff') format('woff'); font-display: block; }

/* Minnesinger Worksheets: the builder (worksheets.html, and the teacher page of the class site).
   Wide on purpose: your worksheets and the block palette on the left, the blocks you are editing in the middle, and the page
   exactly as it prints on the right. On a narrower window the middle and the right are two tabs (Edit, Preview). */
.ws-main { max-width: 1900px; margin: 0 auto; padding: 18px 22px 70px; }
.ws-intro h1 { margin: 0 0 4px; font: 800 28px 'Outfit', var(--ui, system-ui); color: var(--text, #1f2350); }
.ws-intro p { margin: 0 0 14px; max-width: 980px; color: var(--muted, #545a7d); line-height: 1.5; }

.wk { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; align-items: start; font-family: var(--ui, 'Nunito', system-ui, sans-serif); color: var(--text, #1f2350); }
.wk button, .wk select, .wk input, .wk textarea { font: inherit; }
.wk button { cursor: pointer; padding: 6px 11px; border: 1px solid #c9bfa8; border-radius: 9px; background: #fff; color: var(--text, #1f2350); font-weight: 700; font-size: 13.5px; }
.wk button:hover:not(:disabled) { background: #f4efe3; }
.wk button:disabled { opacity: .45; cursor: default; }
.wk button.primary { background: var(--text, #1f2350); color: #fff; border-color: var(--text, #1f2350); }
.wk button.primary:hover:not(:disabled) { background: #2d336c; }
.wk button.danger { color: #a52a14; border-color: #e1b5aa; }
.wk button:focus-visible, .wk input:focus-visible, .wk select:focus-visible, .wk textarea:focus-visible, .wm-canvas:focus-visible { outline: 3px solid #2f5bd3; outline-offset: 1px; }
.wk input[type=text], .wk input[type=number], .wk select, .wk textarea { padding: 7px 9px; border: 1px solid #c9bfa8; border-radius: 9px; background: #fff; color: #15151f; font-size: 14.5px; min-width: 0; }
.wk label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; font-weight: 800; color: #3a3d5c; }
.wk label.chk, .wk label.wk-chk { flex-direction: row; align-items: center; gap: 7px; font-weight: 700; font-size: 13.5px; }
.wk .wide { grid-column: 1 / -1; }
.wk-hint, .wb-hint, .wm-hint { color: var(--muted, #545a7d); font-size: 13px; line-height: 1.45; margin: 4px 0; }

/* library + palette */
.wk-lib { background: var(--panel, #fffdf8); border: 1px solid var(--line, #ddd2bd); border-radius: 14px; padding: 14px; position: sticky; top: 56px; max-height: calc(100vh - 70px); overflow: auto; }
.wk-lib h2 { margin: 0; font: 800 17px 'Outfit', var(--ui); }
.wk-lib h3 { margin: 16px 0 6px; font: 800 12px var(--ui); letter-spacing: .07em; text-transform: uppercase; color: var(--muted, #545a7d); }
.wk-lib-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.wk-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 3px; }
.wk-item { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 0; padding: 6px 9px !important; }
.wk-item[aria-current="true"] { background: #e9eefc !important; border-color: #2f5bd3 !important; }
.wk-item span { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-item small { color: var(--muted, #545a7d); font-weight: 600; }
.wk-none { color: var(--muted, #545a7d); font-size: 13px; padding: 4px; }
.wk-lib-b { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.wk-msg { min-height: 1.2em; margin: 6px 0 0; font-size: 13px; color: var(--accent, #c8391f); }
.wk-add { display: flex; flex-direction: column; gap: 5px; }
.wk-add button { text-align: left; display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; }
.wk-add small { font-weight: 600; color: var(--muted, #545a7d); font-size: 12px; }
.wk-share { margin-top: 12px; padding-top: 4px; border-top: 1px solid var(--line, #ddd2bd); }
.wk-cls { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.wk-cls label { flex-direction: row; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 700; }

/* the sheet's top bar and blocks */
.wk-top { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 14px; background: var(--panel, #fffdf8); border: 1px solid var(--line, #ddd2bd); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.wk-title { flex: 2 1 240px; }
.wk-sub { flex: 2 1 220px; }
.wk-spacer { flex: 1 1 0; }
.wk-saved { font-size: 13px; font-weight: 700; color: var(--muted, #545a7d); align-self: center; }
.wk-saved.ok { color: #1d6b3a; }
.wk-problems { background: #fff4e0; border: 1px solid #e8c88f; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: 13.5px; }
.wk-problems span { margin-left: 10px; }
.wk-tabs { display: none; gap: 6px; margin-bottom: 10px; }
.wk-tabs button[aria-selected="true"] { background: var(--text, #1f2350); color: #fff; border-color: var(--text, #1f2350); }
.wk-blocks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wk-empty { padding: 28px; text-align: center; color: var(--muted, #545a7d); border: 2px dashed #d6cdb8; border-radius: 14px; }
.wb { background: var(--panel, #fffdf8); border: 1px solid var(--line, #ddd2bd); border-radius: 12px; position: relative; }
.wb.open { border-color: #9aa6d6; box-shadow: 0 2px 10px rgba(31, 35, 80, .08); }
.wb.drag { opacity: .45; }
.wb.drop-above::before, .wb.drop-below::after { content: ''; position: absolute; left: 0; right: 0; height: 4px; background: #2f5bd3; border-radius: 3px; }
.wb.drop-above::before { top: -6px; }
.wb.drop-below::after { bottom: -6px; }
.wb-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
.wb-grip { cursor: grab; font-size: 20px; padding: 0 6px; color: #8b8fa8; user-select: none; touch-action: none; }
.wb-toggle { flex: 1; text-align: left; display: flex; gap: 10px; align-items: baseline; min-width: 0; background: transparent !important; border: 0 !important; padding: 4px 6px !important; }
.wb-toggle b { font-weight: 800; white-space: nowrap; }
.wb-toggle span { color: var(--muted, #545a7d); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-btns { display: flex; gap: 4px; }
.wb-btns button { padding: 3px 9px; }
.wb-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; padding: 4px 14px 14px; align-items: end; }
.wb-body textarea { resize: vertical; width: 100%; box-sizing: border-box; }
.wb-body input[type=text] { width: 100%; box-sizing: border-box; }
.wb-body input[type=number] { width: 90px; }
.wb-time { display: flex; align-items: center; gap: 4px; }
.wb-time input { width: 60px !important; }
.wb-seed { font-weight: 800; font-size: 15px; }
.wb-choices { display: flex; flex-direction: column; gap: 5px; }
.wb-ch { flex-direction: row !important; align-items: center; gap: 8px !important; }
.wb-ch span { width: 18px; font-weight: 800; }
.wb-ch input[type=text] { flex: 1; }
.wb-music { grid-column: 1 / -1; }

/* the music editor */
.wm { display: flex; flex-direction: column; gap: 8px; }
.wm-setup { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: end; }
.wm-time { display: flex; align-items: center; gap: 4px; }
.wm-time input { width: 56px; }
.wm-bars { display: flex; align-items: center; gap: 6px; }
.wm-bars output { min-width: 22px; text-align: center; font-weight: 800; }
.wm-tools { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
.wm-grp { display: inline-flex; gap: 4px; align-items: center; }
.wm button[aria-pressed="true"] { background: #e3e9fb !important; border-color: #2f5bd3 !important; box-shadow: inset 0 0 0 1px #2f5bd3; }
.wm-dur { display: inline-flex; flex-direction: column; align-items: center; min-width: 42px; padding: 2px 6px !important; line-height: 1.1; }
.wm-dur .g { font: 22px 'Noto Music', 'Segoe UI Symbol', serif; }
.wm-dur small { font-size: 10px; color: var(--muted, #545a7d); }
.wm-acc { min-width: 34px; font: 700 17px 'Noto Music', 'Segoe UI Symbol', serif !important; }
.wm-acc[data-acc="auto"] { font: 800 13px var(--ui, system-ui) !important; }
.wm-dlg { width: min(1200px, 97vw); max-height: 94vh; border: 0; border-radius: 16px; padding: 0; background: var(--panel, #fffdf8); box-shadow: 0 20px 70px rgba(20, 22, 60, .45); overflow: auto; color: var(--text, #1f2350); }
.wm-dlg::backdrop { background: rgba(20, 22, 50, .5); }
.wm-dlg-h { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line, #ddd2bd); position: sticky; top: 0; background: var(--panel, #fffdf8); z-index: 2; }
.wm-dlg-h h2 { margin: 0; font: 800 18px 'Outfit', var(--ui); flex: 1; }
.wm-dlg-hint { color: var(--muted, #545a7d); font-size: 13px; }
.wm-host { padding: 14px 18px 20px; }
.wb-musicbox { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.wb-musicprev { width: 100%; background: #fff; border: 1px solid #e2dac6; border-radius: 8px; padding: 8px 10px; box-sizing: border-box; }
.wb-musicprev .cp-music { margin: 0; }
.wm-canvas { background: #fff; border: 1px solid #cfc6b0; border-radius: 10px; padding: 10px 10px 4px; cursor: crosshair; outline-offset: 2px; touch-action: manipulation; }
.wm-sys { margin: 0 0 6px; }
.wm-sys svg { display: block; width: 100%; height: auto; }
.wm-status { margin: 0; font-size: 13.5px; color: var(--muted, #545a7d); min-height: 1.3em; }
.wm-insp { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; background: #eef2ff; border: 1px solid #b9c6f0; border-radius: 10px; padding: 7px 10px; }
.wm-insp[hidden] { display: none; }
.wm-pn { margin-right: 6px; }
.wm-chordin { flex-direction: row !important; align-items: center; gap: 6px !important; }
.wm-chordin input { width: 110px; }
.wm-more { border-top: 1px dashed #d6cdb8; padding-top: 6px; }
.wm-more summary { cursor: pointer; font-weight: 800; font-size: 13.5px; padding: 4px 0; }
.wm-words, .wm-chords, .wm-import { margin: 8px 0; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; }
.wm-words label, .wm-chords label { flex: 1 1 100%; }
.wm-words textarea, .wm-chords input { width: 100%; box-sizing: border-box; }
.wm-row { display: flex; gap: 10px; align-items: center; margin: 6px 0; }

/* the preview: a desk with the page on it */
.wk-prev { display: none; background: #e9e4d6; border: 1px solid var(--line, #ddd2bd); border-radius: 14px; padding: 8px 10px 14px; position: sticky; top: 56px; max-height: calc(100vh - 70px); overflow: auto; }
.wk-prev-h { padding: 4px 6px 0; font-size: 13px; color: var(--muted, #545a7d); }
.wk-prev .cp-sheet { margin: 10px auto; }
.wk-prev .cp-doc > .cp-foot { margin-bottom: 4px; }
.wk-err { color: #a52a14; padding: 14px; }

/* wide: three columns, no tabs */
@media (min-width: 1380px) {
  .wk { grid-template-columns: 270px minmax(460px, 1fr) minmax(0, 860px); }
  .wk-prev { display: block; }
}
/* medium: the middle is Edit or Preview */
@media (min-width: 900px) and (max-width: 1379px) {
  .wk-tabs { display: flex; }
  .wk[data-tab="preview"] .wk-edit .wk-blocks, .wk[data-tab="preview"] .wk-edit .wk-empty { display: none; }
  .wk[data-tab="preview"] .wk-prev { display: block; position: static; max-height: none; grid-column: 2; grid-row: 1; margin-top: 54px; }
  .wk[data-tab="preview"] .wk-edit { grid-column: 2; grid-row: 1; }
  .wk[data-tab="edit"] .wk-prev { display: none; }
}
/* narrow: one column */
@media (max-width: 899px) {
  .ws-main { padding: 12px 12px 60px; }
  .wk { grid-template-columns: 1fr; }
  .wk-lib { position: static; max-height: none; }
  .wk-tabs { display: flex; }
  .wk[data-tab="edit"] .wk-prev { display: none; }
  .wk[data-tab="preview"] .wk-prev { display: block; position: static; max-height: none; }
  .wk[data-tab="preview"] .wk-edit .wk-blocks, .wk[data-tab="preview"] .wk-edit .wk-empty, .wk[data-tab="preview"] .wk-edit .wk-top { display: none; }
  .wb-body { grid-template-columns: 1fr; padding: 4px 10px 12px; }
  .wb-toggle span { display: none; }
  .wm-dur { min-width: 38px; }
}

/* the print rules for the whole page come from learn-course-print.css (body.cp-printing) */
@media print {
  body.wsbody .topbar, body.wsbody .ws-intro { display: none !important; }
}
