.mg-page { width: var(--page); margin: 0 auto; }
.mg-page [hidden] { display: none !important; }
.mg-page.page-columns, .mg-page .page-columns, #mg-explorer.page-columns { display: block !important; }
.mg-page .page-columns > * { grid-column: auto !important; }
.mg-heading { max-width: 800px; margin: 3rem 0 1.5rem; }
.mg-heading .eyebrow { color: var(--gold); margin-bottom: .7rem; }
.mg-heading h1 { color: var(--paper); font-size: clamp(2.6rem, 5vw, 4.4rem); line-height: 1.06; margin: 0 0 1rem; }
.mg-heading h1 em { color: var(--gold); }
.mg-heading > p:last-child { color: var(--soft); font-size: 1.05rem; max-width: 64ch; }
.mg-loading { color: var(--soft); }
.mg-page button { font-family: var(--sans); }
.mg-page button:focus-visible, .mg-page input:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.mg-panel { position: relative; margin-bottom: 1.5rem; padding: clamp(1.25rem, 3vw, 1.9rem); border-radius: var(--radius); background: var(--paper); color: var(--ink); box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.mg-panel::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; border-radius: var(--radius) var(--radius) 0 0; background: var(--rainbow); }
.mg-panel .eyebrow { margin-bottom: .3rem; }
.mg-panel h2 { margin: 0 0 .5rem; padding: 0; border: 0; color: var(--ink); font-size: clamp(1.7rem, 3vw, 2.3rem); }
.mg-head { display: grid; gap: .8rem; margin-bottom: .6rem; }
.mg-presets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .45rem; }
.mg-presets button { display: grid; gap: .1rem; padding: .6rem .7rem; border: 2px solid transparent; border-radius: 10px; background: #231c2e; color: #fff5e1; text-align: left; cursor: pointer; }
.mg-presets button span { color: #cfc4dc; font-size: .72rem; }
.mg-presets button[aria-pressed="true"] { border-color: var(--gold); background: #3b2d52; }
.mg-presets .is-fiddle { background: #5b21b6; }
.mg-preset-note { margin: 0 0 1rem; color: #4a4040; font-size: .88rem; max-width: 90ch; }

/* The cabinet: walnut and a dark panel, like the modular systems */
.mg-cabinet { padding: 1rem; border-radius: 14px; background: linear-gradient(180deg, #5c3b22, #3e2715); box-shadow: inset 0 2px 0 rgba(255,255,255,.1); }
.mg-modules { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
.mg-module { padding: .8rem .85rem; border-radius: 8px; background: #1c1622; color: #fff5e1; box-shadow: inset 0 0 0 1px #3b3150; }
.mg-module h3 { margin: 0 0 .5rem; color: #f2c94c; font-family: var(--mono); font-size: .72rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.mg-knob { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 .4rem; margin-bottom: .45rem; font-size: .74rem; color: #cfc4dc; }
.mg-knob output { color: #fff5e1; font-family: var(--mono); font-size: .7rem; }
.mg-knob input { grid-column: 1 / -1; width: 100%; accent-color: #f2c94c; margin: .15rem 0 0; }
.mg-play { margin-top: .8rem; padding: .8rem; border-radius: 8px; background: #141018; }
.mg-k { margin: 0 0 .35rem; color: #b9adc9; font-family: var(--mono); font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; }
.mg-ribbon { position: relative; height: 36px; margin-bottom: .8rem; border-radius: 6px; background: linear-gradient(90deg, #2a2236, #3b2d52 50%, #2a2236); box-shadow: inset 0 0 0 1px #5b4a73; cursor: ew-resize; touch-action: none; }
.mg-ribbon i { position: absolute; top: 4px; bottom: 4px; left: 50%; width: 6px; margin-left: -3px; border-radius: 3px; background: #f2c94c; opacity: .35; }
.mg-ribbon.is-on i { opacity: 1; box-shadow: 0 0 10px #f2c94c; }
.mg-keywrap { container-type: inline-size; overflow-x: auto; scrollbar-width: none; }
.mg-shift { display: flex; justify-content: space-between; gap: .5rem; margin-top: .6rem; }
.mg-shift[hidden] { display: none; }
.mg-shift button { min-height: 40px; padding: .35rem .8rem; border: 1px solid #5b4a73; border-radius: 6px; background: #2a2236; color: #fff5e1; font: inherit; font-size: .85rem; cursor: pointer; }
.mg-keys { --w: max(30px, calc(100cqw / var(--whites, 15))); --bw: calc(var(--w) * .6); position: relative; width: calc(var(--whites, 15) * var(--w)); height: 150px; touch-action: none; user-select: none; -webkit-user-select: none; }
.mg-key { position: absolute; top: 0; padding: 0; cursor: pointer; }
.mg-key.is-white { width: var(--w); height: 100%; border: 1px solid #a89880; border-radius: 0 0 5px 5px; background: linear-gradient(180deg, #fffaf0, #ece0c8); z-index: 1; }
.mg-key.is-black { width: var(--bw); height: 60%; border: 0; border-radius: 0 0 4px 4px; background: linear-gradient(180deg, #2b2b2b, #0e0e0e); z-index: 2; }
.mg-key.is-down.is-white { background: #f2c94c; }
.mg-key.is-down.is-black { background: #8a6a1a; }
.mg-help { margin: 1rem 0 0; color: #4a4040; font-size: .85rem; max-width: 90ch; }
.mg-help kbd { padding: 0 .3rem; border: 1px solid #bbaeaa; border-radius: 4px; background: #fffaf0; color: var(--ink); font-family: var(--mono); font-size: .75em; box-shadow: none; }

.mg-story > p:not(.eyebrow), .mg-story li { max-width: 80ch; }
.mg-story ul { padding-left: 1.2rem; }
.mg-story li { margin-bottom: .5rem; }
.mg-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.mg-step { padding: 1rem 1.1rem; border: 1px solid var(--paper-line); border-radius: 10px; background: #fffaf0; font-size: .9rem; }
.mg-step h3 { margin: .4rem 0 .3rem; color: var(--ink); font-size: 1.15rem; }
.mg-step p { margin: 0; }
.mg-n { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: var(--ink); color: var(--gold); font-family: var(--mono); font-size: .72rem; }
.mg-story a { color: var(--pink-ink); }
.mg-method { max-width: 90ch; margin: 1.75rem 0; color: var(--soft); font-size: .82rem; }
.mg-method a { color: var(--gold); }
.mg-signoff { margin: 2rem 0; text-align: center; font-family: var(--serif); font-size: 1.2rem; }

@media (max-width: 1000px) { .mg-modules, .mg-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } .mg-presets { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .mg-modules, .mg-steps { grid-template-columns: minmax(0, 1fr); } .mg-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); } .mg-cabinet { padding: .6rem; } .mg-rack { padding: .25rem; } }
.mg-ribbon:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* The patch panel: modules, jacks and sagging cords */
.mg-rack { padding: .4rem; border-radius: 10px; background: #0f0b12; }
.mg-svg { display: block; width: 100%; height: auto; overflow: visible; user-select: none; -webkit-user-select: none; font-family: var(--mono); }
.mg-rack-bg { fill: #141018; }
.mg-face { fill: #1c1622; stroke: #3b3150; stroke-width: 1.5; }
.mg-screw { fill: #5a5066; }
.mg-mname { fill: #f2c94c; font-size: 13px; letter-spacing: .1em; }
.mg-trace { fill: none; stroke: #cfc4dc; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mg-ik-w { fill: #efe5cf; } .mg-ik-b { fill: #141018; }
.mg-sum { fill: none; stroke: #cfc4dc; stroke-width: 2; }
.mg-spk { fill: #3b3150; stroke: #cfc4dc; stroke-width: 2; stroke-linejoin: round; }
.mg-waves { fill: none; stroke: #5a5066; stroke-width: 2.5; stroke-linecap: round; }
.mg-waves.is-on { stroke: #e23d80; filter: drop-shadow(0 0 4px #e23d80); }
.mg-lamp { fill: #3b2d52; }
.mg-lamp.is-on { fill: #e23d80; filter: drop-shadow(0 0 4px #e23d80); }
.mg-jack { cursor: grab; outline: none; touch-action: none; }
.mg-svg.is-dragging, .mg-svg.is-dragging .mg-jack { cursor: grabbing; }
.mg-hit { fill: transparent; }
.mg-ring { fill: none; stroke: #8e8798; stroke-width: 3; }
.mg-jack.is-out .mg-ring { stroke: #c9a227; }
.mg-nut { fill: #c9ccd1; stroke: #6f737a; stroke-width: 1.5; }
.mg-hole { fill: #0b080d; }
.mg-jlabel { fill: #cfc4dc; font-size: 11.5px; }
.mg-jack.is-out .mg-jlabel { fill: #f2c94c; }
.mg-jack:hover .mg-ring { stroke: #fff5e1; }
.mg-jack:focus-visible .mg-ring { stroke: #fff5e1; stroke-width: 4; }
.mg-jack:focus-visible .mg-hit { fill: rgba(242, 201, 76, .18); }
.mg-jack.is-pending .mg-ring { stroke: #fff5e1; stroke-width: 4; stroke-dasharray: 6 4; }
.mg-jack.is-pending .mg-hit { fill: rgba(255, 245, 225, .2); }
.mg-jack.is-ok .mg-ring, .mg-jack.is-target .mg-ring { stroke: #3fb56b; stroke-width: 4; }
.mg-jack.is-target .mg-hit { fill: rgba(63, 181, 107, .25); }
.mg-jack.is-wrong .mg-ring { stroke: #e0452b; stroke-width: 4; }
.mg-cords { pointer-events: none; }
.mg-cord-back { fill: none; stroke: rgba(0, 0, 0, .55); stroke-width: 9; stroke-linecap: round; }
.mg-cord-line { fill: none; stroke: var(--c); stroke-width: 6; stroke-linecap: round; }
.mg-plug circle { fill: var(--c); stroke: #0b080d; stroke-width: 2.5; }
.mg-plug .mg-plug-tip { fill: rgba(0, 0, 0, .35); stroke: none; }
.mg-cord.is-ghost { opacity: .75; }
.mg-cord.is-ghost .mg-cord-line { stroke-dasharray: .02 .015; }
@media (prefers-reduced-motion: no-preference) {
  .mg-cord.is-new path { stroke-dasharray: 1 1; stroke-dashoffset: 1; animation: mg-draw .55s ease-out var(--d) forwards; }
  .mg-cord.is-new .mg-plug-1 { opacity: 0; animation: mg-plug .15s linear calc(var(--d) + .5s) forwards; }
  .mg-jack.is-pending .mg-ring { animation: mg-spin 1.2s linear infinite; }
}
@keyframes mg-draw { to { stroke-dashoffset: 0; } }
@keyframes mg-plug { to { opacity: 1; } }
@keyframes mg-spin { to { stroke-dashoffset: -20; } }
.mg-patchbar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .6rem; margin: .7rem 0 .9rem; }
.mg-status { flex: 1 1 22rem; margin: 0; padding: .55rem .8rem; border-left: 4px solid #3fb56b; border-radius: 6px; background: #141018; color: #fff5e1; font-size: .86rem; line-height: 1.45; }
.mg-status.is-patching { border-left-color: #f2c94c; background: #2a2236; }
.mg-clear { min-height: 40px; padding: .4rem .8rem; border: 1px solid #5b4a73; border-radius: 6px; background: #2a2236; color: #fff5e1; font-size: .85rem; cursor: pointer; }
.mg-cabinet > .mg-k { color: #e6d6bd; }
.mg-page button.mg-clear:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.mg-svg:focus { outline: none; }
@media (max-width: 560px) { #mg-explorer .mg-panel { padding-left: .75rem; padding-right: .75rem; } .mg-cabinet { padding: .45rem; } .mg-rack { padding: 0; } }
.mg-rack, .mg-svg, .mg-svg * { overflow-anchor: none; }
