.mhg-lab {
    --lab-accent: #8c692a;
    --lab-accent-dark: #6f521f;
    --lab-bg: #faf8f3;
    --lab-bg-alt: #f3eee4;
    --lab-ui: #f8f8f8;
    --lab-border: #ddd7cc;
    --lab-text: #222;
    --lab-text-secondary: #444;
    --lab-text-muted: #666;
    box-sizing: border-box;
    width: 100%;
    max-width: 940px;
    margin: .75rem auto 2rem;
    color: var(--lab-text);
    font-size: 16px;
    line-height: 1.55;
}

.mhg-lab *,
.mhg-lab *::before,
.mhg-lab *::after { box-sizing: border-box; }

.mhg-lab__work { display: grid; gap: 1.25rem; margin-top: 1.25rem; }
.mhg-lab__work[hidden] { display: none; }

.mhg-lab__panel,
.mhg-lab__challenge {
    margin: 0;
    padding: clamp(1.25rem, 2.8vw, 2rem);
    border: 1px solid var(--lab-border);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(66, 53, 31, .045);
}

.mhg-lab__panel--track { background: var(--lab-bg); }
.mhg-lab__panel--audio { background: var(--lab-ui); }

.mhg-lab h2,
.mhg-lab h3 {
    margin: 0 0 1rem;
    color: var(--lab-text);
    font-family: inherit;
    font-weight: 700;
    letter-spacing: -.015em;
    line-height: 1.25;
}

.mhg-lab h2 { font-size: clamp(1.25rem, 1.05rem + .7vw, 1.65rem); }
.mhg-lab h3 { font-size: clamp(1.08rem, 1rem + .35vw, 1.3rem); }

.mhg-lab__field-label,
.mhg-lab legend {
    display: block;
    color: var(--lab-text-secondary);
    font-size: .88rem;
    font-weight: 700;
}

.mhg-lab input[type="search"],
.mhg-lab select,
.mhg-lab textarea {
    display: block;
    width: 100%;
    min-height: 48px;
    margin-top: .45rem;
    padding: .7rem .85rem;
    border: 1px solid var(--lab-border);
    border-radius: 9px;
    background: #fff;
    color: var(--lab-text);
    font: inherit;
    line-height: 1.4;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.mhg-lab textarea { min-height: 112px; resize: vertical; }
.mhg-lab input::placeholder,
.mhg-lab textarea::placeholder { color: #777; opacity: 1; }

.mhg-lab__help {
    margin: .45rem 0 0;
    color: var(--lab-text-muted);
    font-size: .88rem;
}

.mhg-lab__results {
    display: grid;
    gap: .6rem;
    margin-top: 1rem;
    color: var(--lab-text-muted);
}

.mhg-lab__track {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    min-height: 58px;
    padding: .8rem 2.75rem .8rem .9rem;
    overflow: hidden;
    border: 1px solid var(--lab-border);
    border-radius: 10px;
    background: #fff;
    color: var(--lab-text);
    text-align: left;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
}

.mhg-lab__track::after {
    content: "›";
    position: absolute;
    top: 50%;
    right: 1rem;
    color: var(--lab-accent);
    font-size: 1.45rem;
    line-height: 1;
    transform: translateY(-50%);
}

.mhg-lab__track:hover { border-color: #bda982; background: var(--lab-bg); transform: translateY(-1px); }
.mhg-lab__track[aria-pressed="true"] { border-color: var(--lab-accent); background: var(--lab-bg-alt); }
.mhg-lab__track[aria-pressed="true"]::after { content: "✓"; font-size: 1rem; font-weight: 700; }
.mhg-lab__track strong { color: var(--lab-text); font-size: .98rem; }
.mhg-lab__track small { margin-top: .15rem; color: var(--lab-text-muted); font-size: .82rem; }

.mhg-lab__selected {
    margin: -.35rem 0 .9rem;
    color: var(--lab-text-secondary);
    font-weight: 700;
}

.mhg-lab__player {
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
    aspect-ratio: 16 / 9;
    background: #222;
}

.mhg-lab__player iframe { display: block; width: 100%; height: 100%; border: 0; }

.mhg-lab__controls { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: end; }
.mhg-lab__controls fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.mhg-lab__controls legend { margin-bottom: .45rem; }
.mhg-lab__controls fieldset label { display: inline-flex; margin: 0 .45rem .35rem 0; cursor: pointer; }
.mhg-lab__controls input[type="radio"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.mhg-lab__controls input[type="radio"] + span {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: .65rem .9rem;
    border: 1px solid var(--lab-border);
    border-radius: 9px;
    background: #fff;
    color: var(--lab-text-secondary);
    font-weight: 600;
    transition: border-color .18s ease, background-color .18s ease;
}
.mhg-lab__controls input[type="radio"]:checked + span { border-color: var(--lab-accent); background: var(--lab-bg-alt); color: var(--lab-accent-dark); }

.mhg-lab__challenge {
    border-color: #cbbb9d;
    background: linear-gradient(135deg, #fff 0%, var(--lab-bg) 100%);
    box-shadow: 0 10px 26px rgba(89, 66, 28, .07);
}

.mhg-lab__challenge-heading { display: flex; flex-wrap: wrap; gap: .65rem 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.15rem; }
.mhg-lab__challenge-heading h2 { margin: 0; }
.mhg-lab__badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: .28rem .65rem;
    border: 1px solid #d6c5a4;
    border-radius: 999px;
    background: var(--lab-bg-alt);
    color: var(--lab-accent-dark);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .025em;
    text-transform: uppercase;
}

.mhg-lab__challenge-list { display: grid; gap: .75rem; margin-bottom: 1.15rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mhg-lab__challenge article { min-width: 0; padding: 1rem; border: 1px solid var(--lab-border); border-radius: 11px; background: #fff; }
.mhg-lab__challenge article strong { display: inline-block; margin-bottom: .45rem; padding: .2rem .55rem; border-radius: 999px; background: var(--lab-bg-alt); color: var(--lab-accent-dark); font-size: .74rem; letter-spacing: .035em; text-transform: uppercase; }
.mhg-lab__challenge article p { margin: 0; color: var(--lab-text); font-size: .95rem; }

.mhg-lab__button,
.mhg-lab button.mhg-lab__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: .65rem 1rem;
    border: 1px solid var(--lab-border);
    border-radius: 9px;
    background: #fff;
    color: var(--lab-text);
    font: inherit;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease, color .18s ease, transform .18s ease;
}
.mhg-lab__button:hover { border-color: #c7bda9; background: var(--lab-bg-alt); transform: translateY(-1px); }
.mhg-lab__button--primary,
.mhg-lab button.mhg-lab__button--primary { border-color: var(--lab-accent); background: var(--lab-accent); color: #fff; }
.mhg-lab__button--primary:hover,
.mhg-lab button.mhg-lab__button--primary:hover { border-color: var(--lab-accent-dark); background: var(--lab-accent-dark); color: #fff; }
.mhg-lab__button--quiet { color: var(--lab-text-secondary); }
.mhg-lab button:disabled { opacity: .52; cursor: not-allowed; transform: none; }

.mhg-lab__checks { display: grid; gap: .65rem; margin-bottom: 1.2rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mhg-lab__checks label { position: relative; min-width: 0; cursor: pointer; }
.mhg-lab__checks input { position: absolute; top: 1rem; left: .9rem; width: 18px; height: 18px; margin: 0; accent-color: var(--lab-accent); }
.mhg-lab__checks span { display: flex; align-items: center; min-height: 52px; padding: .7rem .8rem .7rem 2.55rem; border: 1px solid var(--lab-border); border-radius: 9px; background: var(--lab-ui); color: var(--lab-text-secondary); font-size: .92rem; transition: border-color .18s ease, background-color .18s ease; }
.mhg-lab__checks label:hover span { border-color: #bda982; background: var(--lab-bg); }
.mhg-lab__checks input:checked + span { border-color: var(--lab-accent); background: var(--lab-bg-alt); color: var(--lab-text); font-weight: 600; }

.mhg-lab__audio { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin-top: 1rem; }
.mhg-lab__audio audio { width: 100%; margin-top: .45rem; }
.mhg-lab__save-area { padding: .25rem 0; text-align: center; }
.mhg-lab__save { width: min(100%, 430px); }
.mhg-lab__status { min-height: 1.5em; margin: .65rem 0 0; color: var(--lab-text-secondary); font-size: .9rem; font-weight: 600; }

.mhg-lab button:focus-visible,
.mhg-lab input:focus-visible,
.mhg-lab select:focus-visible,
.mhg-lab textarea:focus-visible {
    border-color: var(--lab-accent-dark);
    outline: 3px solid rgba(140, 105, 42, .25);
    outline-offset: 2px;
    box-shadow: 0 0 0 1px var(--lab-accent-dark);
}

@media (max-width: 720px) {
    .mhg-lab { margin-top: .5rem; }
    .mhg-lab__work { gap: 1rem; margin-top: 1rem; }
    .mhg-lab__panel,
    .mhg-lab__challenge { padding: 1.15rem; border-radius: 13px; }
    .mhg-lab__controls,
    .mhg-lab__challenge-list,
    .mhg-lab__checks { grid-template-columns: 1fr; }
    .mhg-lab__challenge-heading { align-items: flex-start; flex-direction: column; }
    .mhg-lab__audio .mhg-lab__button { flex: 1 1 calc(50% - .55rem); }
}

@media (max-width: 430px) {
    .mhg-lab__controls fieldset label { display: flex; margin-right: 0; }
    .mhg-lab__controls input[type="radio"] + span { width: 100%; }
    .mhg-lab__audio .mhg-lab__button { flex-basis: 100%; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .mhg-lab *,
    .mhg-lab *::before,
    .mhg-lab *::after { scroll-behavior: auto !important; transition: none !important; }
}
