/* Folk Music Generator frontend – scoped typography to avoid theme font-size leakage. */
.fmg-wrap {
    box-sizing: border-box;
    border: 1px solid #ddd;
    padding: 16px;
    border-radius: 8px;
    background: #fff;
    font-size: 16px !important;
    line-height: 1.5 !important;
    font-family: inherit;
    color: inherit;
}
.fmg-wrap *, .fmg-wrap *::before, .fmg-wrap *::after { box-sizing: border-box; }

/* Keep the complete UI on one readable base size, independent of the WP theme. */
.fmg-wrap label,
.fmg-wrap select,
.fmg-wrap input,
.fmg-wrap textarea,
.fmg-wrap button,
.fmg-wrap summary,
.fmg-wrap details,
.fmg-wrap p,
.fmg-wrap li,
.fmg-wrap table,
.fmg-wrap th,
.fmg-wrap td,
.fmg-wrap pre,
.fmg-wrap code,
.fmg-wrap .fmg-status,
.fmg-wrap .fmg-profile-status,
.fmg-wrap .fmg-knowledge-status,
.fmg-wrap .fmg-title-status,
.fmg-wrap .fmg-style-note,
.fmg-wrap .fmg-runtime-info {
    font-size: 16px !important;
    line-height: 1.5 !important;
}

.fmg-wrap h3 { font-size: 20px !important; line-height: 1.3 !important; }
.fmg-wrap h4 { font-size: 18px !important; line-height: 1.35 !important; }

/* Die Rolle ist eine lokal mitgelieferte Rasterillustration. Der Text bleibt
   als echtes HTML darüber liegen und ist dadurch lesbar und zugänglich. */
.fmg-bard-scroll {
    position: relative;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    width: calc(100% - 16px);
    max-width: 860px;
    aspect-ratio: 2098 / 750;
    min-height: 270px;
    margin: 2px auto 28px;
    padding: 62px 88px 66px;
    color: #3e2915;
    background: transparent url("../images/bard-scroll.png") center / 100% 100% no-repeat;
    border: 0;
    filter: drop-shadow(0 12px 12px rgba(52, 31, 12, .24));
    font-family: Georgia, "Times New Roman", serif;
    text-align: center;
}
.fmg-bard-scroll-inner { position: relative; z-index: 1; }
.fmg-bard-scroll h2 {
    margin: 0 0 10px;
    color: #3e2915;
    font: 700 25px/1.25 Georgia, "Times New Roman", serif !important;
}
.fmg-bard-scroll ol {
    display: inline-block;
    margin: 0 auto 10px;
    padding-left: 1.5em;
    text-align: left;
}
.fmg-bard-scroll li {
    margin: 3px 0;
    font: italic 18px/1.45 Georgia, "Times New Roman", serif !important;
}
.fmg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 13px;
}
.fmg-grid label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-weight: 600;
}
.fmg-grid select,
.fmg-grid input {
    padding: 9px 10px;
    min-height: 44px;
}

.fmg-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}
.fmg-actions button {
    padding: 10px 16px;
    min-height: 44px;
    cursor: pointer;
    font-size: 16px !important;
    line-height: 1.25 !important;
}
.fmg-actions button:disabled { opacity: .5; cursor: not-allowed; }

.fmg-status { margin-top: 13px; font-weight: 600; min-height: 1.5em; }
.fmg-score-panel { margin-top: 19px; padding: 16px; border: 1px solid #ddd; border-radius: 8px; background: #fff; }
.fmg-score-panel h3 { margin-top: 0; }
.fmg-score { width: 100%; overflow: hidden; }
.fmg-score svg { max-width: 100%; height: auto; }
.fmg-score .abcjs-note_selected { fill: currentColor !important; }

.fmg-abc-details { margin-top: 16px; }
.fmg-abc-details summary { cursor: pointer; font-weight: 600; }
.fmg-abc { margin-top: 12px; max-height: 320px; overflow: auto; background: #f7f7f7; padding: 16px; white-space: pre-wrap; }

.fmg-library { margin-top: 16px; padding: 12px 16px; border: 1px solid #ddd; border-radius: 8px; background: #fff; }
.fmg-library summary { cursor: pointer; font-weight: 600; }
.fmg-library-status { margin: 10px 0; opacity: .8; }
.fmg-library-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fmg-library-item { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid #e5e5e5; border-radius: 6px; }
.fmg-library-item span { flex: 1 1 auto; min-width: 160px; }
.fmg-library-item button { padding: 8px 12px; min-height: 40px; cursor: pointer; font-size: 15px !important; }

.fmg-style-note { opacity: .8; margin: 8px 0 16px; }
.fmg-profile-status { margin: 11px 0 4px; padding: 9px 11px; border-radius: 6px; font-weight: 700; }
.fmg-profile-loaded { background: #edf8ef; border: 1px solid #76b77e; color: #225b2b; }
.fmg-profile-missing { background: #fff1f1; border: 1px solid #d28b8b; color: #7a2323; }
.fmg-knowledge-status { margin: 4px 0 8px; padding: 9px 11px; border-radius: 6px; font-weight: 600; }
.fmg-knowledge-loaded { background: #eef5ff; border: 1px solid #8daed6; color: #234d78; }
.fmg-knowledge-none { background: #f7f7f7; border: 1px solid #ccc; color: #555; }
.fmg-title-status { margin: 4px 0; }

.fmg-style-info { margin: 16px 0; border: 1px solid #d7d7d7; border-radius: 8px; background: #fff; }
.fmg-style-info > summary { cursor: pointer; font-weight: 700; padding: 13px 16px; }
.fmg-style-info-content { padding: 0 16px 16px; }
.fmg-style-info-content section + section { border-top: 1px solid #e4e4e4; margin-top: 16px; padding-top: 11px; }
.fmg-style-info h3 { margin: 8px 0; }
.fmg-style-info h4 { margin: 13px 0 6px; }
.fmg-style-info p { margin: 7px 0; }
.fmg-style-info ul { margin: 6px 0 11px 21px; }

.fmg-table-scroll { overflow-x: auto; }
.fmg-rule-table { border-collapse: collapse; width: 100%; font-size: 16px !important; }
.fmg-rule-table th,
.fmg-rule-table td {
    border: 1px solid #ddd;
    padding: 9px 10px;
    text-align: left;
    vertical-align: top;
    font-size: 16px !important;
    line-height: 1.5 !important;
}
.fmg-rule-table th { width: 28%; background: #f7f7f7; }
.fmg-rule-origin { background: #f7f7f7; padding: 9px 11px; border-radius: 6px; }
.fmg-rule-origin code,
.fmg-runtime-info code { overflow-wrap: anywhere; font-size: 15px !important; }

@media (max-width: 600px) {
    .fmg-wrap { padding: 12px; font-size: 16px !important; }
    .fmg-actions button { width: 100%; font-size: 16px !important; }
    .fmg-score-panel { padding: 8px; }
    .fmg-rule-table th { width: 38%; }
    .fmg-style-info-content { padding-left: 11px; padding-right: 11px; }
    .fmg-wrap h3 { font-size: 19px !important; }
    .fmg-wrap h4 { font-size: 17px !important; }
    .fmg-bard-scroll {
        width: 100%;
        min-height: 250px;
        aspect-ratio: auto;
        margin: 2px auto 24px;
        padding: 52px 40px 56px;
    }
    .fmg-bard-scroll h2 { font-size: 21px !important; }
    .fmg-bard-scroll li { font-size: 16px !important; }
}

.fmg-control-help {
    display: block;
    margin-top: 5px;
    font-size: 16px !important;
    line-height: 1.45 !important;
    font-weight: 400;
    opacity: .82;
}

/* 0.5.4: Corpus-Regler und platzsparende Info-Hilfe. */
.fmg-label-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.fmg-help {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.fmg-info-button {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    padding: 0 !important;
    border: 1px solid #777;
    border-radius: 50%;
    background: #fff;
    color: inherit;
    font: 700 14px/20px Arial, sans-serif !important;
    text-align: center;
    cursor: help;
}
.fmg-info-popover {
    position: absolute;
    z-index: 1000;
    top: calc(100% + 8px);
    right: 0;
    width: min(340px, calc(100vw - 48px));
    padding: 12px 14px;
    border: 1px solid #aaa;
    border-radius: 7px;
    background: #fff;
    color: #222;
    box-shadow: 0 6px 20px rgba(0,0,0,.18);
    font-size: 15px !important;
    line-height: 1.45 !important;
    font-weight: 400;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}
.fmg-help:hover .fmg-info-popover,
.fmg-help:focus-within .fmg-info-popover,
.fmg-help.is-open .fmg-info-popover {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.fmg-corpus-balance {
    margin: 16px 0 10px;
    padding: 12px 0 2px;
    border-top: 1px solid #e5e5e5;
}
.fmg-corpus-balance-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    flex-wrap: wrap;
    margin-bottom: 7px;
}
.fmg-corpus-balance-value { font-weight: 600; }
.fmg-corpus-weight {
    display: block;
    width: 100% !important;
    max-width: none !important;
    margin: 0;
    accent-color: currentColor;
}
.fmg-corpus-weight:disabled { opacity: .45; cursor: not-allowed; }
.fmg-corpus-balance-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    font-size: 14px !important;
    opacity: .78;
}
.fmg-corpus-balance-note {
    margin: 6px 0 0 !important;
    font-size: 15px !important;
    line-height: 1.4 !important;
    opacity: .82;
}

/* Der alte Inline-Hilfetext wird ab 0.5.4 nicht mehr verwendet. */
.fmg-control-help { display: none !important; }

@media (max-width: 600px) {
    .fmg-info-popover { right: auto; left: 0; width: min(300px, calc(100vw - 40px)); }
    .fmg-corpus-balance-head { display: block; }
    .fmg-corpus-balance-value { display: block; margin-top: 3px; }
}

/* 0.5.5: zusätzliche kreative Steuerungen */
.fmg-form:disabled,.fmg-contour:disabled{opacity:.65;cursor:not-allowed;}


/* 0.6.1: grafischer Noteneditor */
.fmg-score-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.fmg-score-head h3 { margin: 0; }
.fmg-edit-toggle,
.fmg-note-editor button {
    min-height: 40px;
    padding: 7px 12px;
    font-size: 16px !important;
    line-height: 1.25 !important;
    cursor: pointer;
}
.fmg-edit-toggle[aria-pressed="true"] { font-weight: 700; }
.fmg-note-editor {
    margin: 0 0 12px;
    padding: 11px 12px;
    border: 1px solid #d7d7d7;
    border-radius: 7px;
    background: #fafafa;
}
.fmg-note-editor-help { margin-bottom: 9px; }
.fmg-note-editor-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.fmg-note-selection {
    flex: 1 1 260px;
    min-width: 0;
    font-weight: 600;
}
.fmg-note-editor button:disabled { opacity: .45; cursor: not-allowed; }
.fmg-score.is-editing { cursor: ns-resize; }
.fmg-score.is-editing .abcjs-note { cursor: ns-resize; }
.fmg-score.is-editing .abcjs-note_selected { opacity: .75; }
@media (max-width: 600px) {
    .fmg-note-editor-controls button { flex: 1 1 calc(50% - 8px); }
    .fmg-note-selection { flex-basis: 100%; }
}


/* 0.6.3: Notenbearbeitung auf Smartphones bewusst deaktiviert. */
@media (max-width: 767px) and (pointer: coarse) {
    .fmg-edit-toggle,
    .fmg-note-editor { display: none !important; }
    .fmg-score.is-editing,
    .fmg-score.is-editing .abcjs-note { cursor: default !important; }
}


/* 0.7.3 – präziser Desktop-Noteneditor */
.fmg-score.is-editing .abcjs-note {
    cursor: grab;
    touch-action: none;
}
.fmg-score.is-editing .abcjs-note:active { cursor: grabbing; }
.fmg-score.is-editing .abcjs-note.fmg-note-selected {
    filter: drop-shadow(0 0 2px rgba(0,0,0,.45));
}
.fmg-score.is-editing .abcjs-note.fmg-drag-up,
.fmg-score.is-editing .abcjs-note.fmg-drag-down {
    transform: translateY(var(--fmg-drag-preview, 0px));
}
.fmg-score.is-editing .abcjs-note.fmg-drag-up { opacity: .72; }
.fmg-score.is-editing .abcjs-note.fmg-drag-down { opacity: .72; }

/* Perkussionsschalter */
.fmg-wrap .fmg-percussion-row { margin: 6px 0 14px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.fmg-wrap .fmg-percussion-label { display: inline-flex; align-items: center; gap: 7px; font-size: 16px !important; }
.fmg-wrap .fmg-percussion-label input { margin: 0; }
.fmg-wrap .fmg-percussion-note { font-size: 14px !important; opacity: .75; }
.fmg-wrap .fmg-percussion:disabled + span,
.fmg-wrap .fmg-percussion-label:has(input:disabled) { opacity: .5; }

/* Schlagwerk-Abschnitt in der Infobox */
.fmg-wrap .fmg-percussion-info .fmg-percussion-origin { opacity: .85; }
.fmg-wrap .fmg-percussion-info .fmg-drum-vel { opacity: .65; font-size: 14px !important; }
.fmg-wrap .fmg-percussion-caveat { border-left: 3px solid currentColor; padding-left: 12px; opacity: .9; }

/* Klartext-Anzeige in der Infobox */
.fmg-wrap .fmg-plain-summary { border-left: 3px solid currentColor; padding: 2px 0 2px 14px; margin-bottom: 18px; }
.fmg-wrap .fmg-plain-summary h4 { margin-top: 0; }
.fmg-wrap .fmg-group-intro { margin: 2px 0 8px; opacity: .8; font-size: 15px !important; }
.fmg-wrap .fmg-hint { display: block; font-weight: 400; opacity: .7; font-size: 14px !important; margin-top: 2px; }
.fmg-wrap .fmg-unit { opacity: .7; font-size: 14px !important; }
.fmg-wrap .fmg-coverage-caveat { opacity: .8; }
.fmg-wrap .fmg-rule-table th { vertical-align: top; }

.fmg-wrap .fmg-unmatched { margin-top: 18px; opacity: .9; }
.fmg-wrap .fmg-unmatched ul { margin: 6px 0 0 20px; }

/* Gruppierte Zahlenlisten, etwa Rhythmuszellen */
.fmg-wrap .fmg-groups { display: flex; flex-wrap: wrap; gap: 6px; }
.fmg-wrap .fmg-group { display: inline-block; padding: 2px 9px; border: 1px solid currentColor; border-radius: 12px; font-size: 15px !important; opacity: .9; }

/* Aufklappbare Erklärung unter dem Generator */
.fmg-wrap .fmg-explanation-box { margin-top: 22px; border: 1px solid currentColor; border-radius: 10px; padding: 12px 16px; }
.fmg-wrap .fmg-explanation-box > summary { cursor: pointer; font-weight: 600; font-size: 17px !important; }
.fmg-wrap .fmg-explanation-box[open] > summary { margin-bottom: 14px; }
/* Volle Spaltenbreite nutzen. Die frühere Begrenzung auf 78 Zeichen war für
   eine schmale Textspalte gedacht und ließ auf breiten Bildschirmen die Hälfte
   des Platzes ungenutzt -- besonders störend bei den Tabellen. */
.fmg-wrap .fmg-explanation { max-width: none; }
/* Silbentrennung statt harter Umbrüche mitten im Wort. Lange deutsche
   Komposita wie "Bewegungsgewichte" wurden in engen Tabellenspalten sonst
   irgendwo zerschnitten. */
.fmg-wrap .fmg-explanation td,
.fmg-wrap .fmg-explanation th { hyphens: auto; overflow-wrap: break-word; }
/* In den Erklärtabellen richten sich die Spalten nach dem Inhalt; die feste
   Kopfspaltenbreite von 28 % gilt nur für die zweispaltigen Regeltabellen. */
.fmg-wrap .fmg-explanation .fmg-rule-table th { width: auto; }
.fmg-wrap .fmg-explanation .fmg-table-scroll { margin: 14px 0 20px; }
.fmg-wrap .fmg-explanation h3 { margin: 30px 0 12px; padding-bottom: 6px; border-bottom: 1px solid currentColor; font-size: 21px !important; }
.fmg-wrap .fmg-explanation h4 { margin: 0 0 8px; font-size: 17px !important; }
.fmg-wrap .fmg-explanation p, .fmg-wrap .fmg-explanation li { font-size: 16px !important; line-height: 1.65; }
.fmg-wrap .fmg-x-lead { font-size: 17px !important; opacity: .95; }
.fmg-wrap .fmg-x-says { margin: 14px 0; padding: 10px 16px; border-left: 3px solid currentColor; font-style: italic; }
.fmg-wrap .fmg-x-note,
.fmg-wrap .fmg-x-warning { margin: 16px 0; padding: 12px 16px; border: 1px solid currentColor; border-radius: 8px; }
.fmg-wrap .fmg-x-warning { border-width: 2px; }
.fmg-wrap .fmg-x-steps { margin: 0; padding-left: 26px; }
.fmg-wrap .fmg-x-steps > li { margin: 0 0 22px; padding-left: 6px; }
.fmg-wrap .fmg-explanation pre { padding: 14px 16px; border-radius: 8px; overflow-x: auto; font-size: 15px !important; line-height: 1.5; }
.fmg-wrap .fmg-x-flow { margin: 18px 0; padding: 16px; border: 1px solid currentColor; border-radius: 10px; text-align: center; }
.fmg-wrap .fmg-x-flow span { display: block; font-size: 16px !important; line-height: 1.5; }
.fmg-wrap .fmg-x-arrow { font-size: 20px !important; opacity: .7; }

/* Tempo-Regler */
.fmg-wrap .fmg-tempo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 12px 0 4px; }
.fmg-wrap .fmg-tempo-label { font-size: 16px !important; font-weight: 600; }
.fmg-wrap .fmg-tempo { flex: 1 1 220px; max-width: 340px; }
.fmg-wrap .fmg-tempo-out { font-size: 16px !important; font-variant-numeric: tabular-nums; min-width: 16ch; }
.fmg-wrap .fmg-tempo-reset { font-size: 14px !important; padding: 4px 10px; }
.fmg-wrap .fmg-tempo:disabled { opacity: .5; }

/* Deutsche Lesart des Titels */
.fmg-wrap .fmg-title-translation { margin: 4px 0 10px; font-size: 17px !important; font-style: italic; opacity: .85; }

/* Klangauswahl für die Wiedergabe */
.fmg-wrap .fmg-voice-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 14px 0 4px; }
.fmg-wrap .fmg-voice-label { font-size: 16px !important; font-weight: 600; }
.fmg-wrap .fmg-voice { font-size: 16px !important; padding: 4px 8px; }
.fmg-wrap .fmg-voice-hint { font-size: 14px !important; opacity: .75; flex: 1 1 260px; }

/* Der Info-Knopf am Instrument benutzt dasselbe Muster wie der bei
   "Variation"; eigene Regeln braucht er nicht. Nur der Inhalt ist laenger,
   deshalb etwas mehr Platz. */
.fmg-wrap .fmg-instrument-note { min-width: 260px; }

/* Auf schmalen Schirmen stehen die Herunterladen-Knöpfe unter den Noten.
   Erst sieht man das Ergebnis, dann entscheidet man, ob man es mitnimmt. */
@media (max-width: 767px) {
  .fmg-wrap { display: flex; flex-direction: column; }
  .fmg-wrap .fmg-actions-download { order: 99; margin-top: 14px; }
  .fmg-wrap .fmg-score-panel { order: 50; }
  .fmg-wrap .fmg-voice-row,
  .fmg-wrap .fmg-tempo-row,
  .fmg-wrap .fmg-percussion-row { order: 40; }
}
