:root {
    --ml-ink: #202a2c;
    --ml-muted: #697476;
    --ml-line: #dce3de;
    --ml-surface: #ffffff;
    --ml-green: #6ea900;
    --ml-yellow: #dda31d;
    --ml-takeout: #00a88f;
    --ml-red: #d85f4b;
}

.ml-library,
.ml-library * { box-sizing: border-box; }

.ml-library {
    position: relative;
    margin-top: 34px;
    padding-top: 28px;
    border-top: 1px solid #d5ddd7;
    color: var(--ml-ink);
    font-family: "DM Sans", sans-serif;
}

.ml-library-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.ml-library-head h2,
.ml-library-head p { margin: 0; }

.ml-library-head h2 {
    font-family: "Fraunces", serif;
    font-size: 1.65rem;
    line-height: 1.15;
}

.ml-eyebrow {
    display: block;
    margin-bottom: 4px;
    color: #4d7c0f;
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
}

.ml-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(300px, 100%);
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--ml-line);
    border-radius: 8px;
    background: #fff;
    color: #78837b;
}

.ml-search:focus-within {
    border-color: var(--ml-green);
    box-shadow: 0 0 0 3px rgba(110, 169, 0, .13);
}

.ml-search input {
    min-width: 0;
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ml-ink);
    font: inherit;
    font-size: .8rem;
}

.ml-columns-scroll {
    overflow-x: auto;
    padding: 1px 1px 12px;
    scrollbar-color: #aab6ac transparent;
    scrollbar-width: thin;
}

.ml-columns-scroll:focus-visible {
    outline: 3px solid rgba(110, 169, 0, .18);
    outline-offset: 2px;
}

.ml-columns {
    display: grid;
    grid-template-columns: 300px 520px 350px 350px;
    align-items: start;
    gap: 14px;
    min-width: 1562px;
}

.ml-column {
    --ml-category: #79867e;
    overflow: hidden;
    border: 1px solid var(--ml-line);
    border-top: 4px solid var(--ml-category);
    border-radius: 8px;
    background: #edf1ed;
}

.ml-column-user_created { --ml-category: var(--ml-red); }
.ml-column-batcher { --ml-category: var(--ml-yellow); }
.ml-column-assembly { --ml-category: var(--ml-green); }
.ml-column-takeout { --ml-category: var(--ml-takeout); }

.ml-column-head {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    min-height: 62px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--ml-line);
    background: rgba(255, 255, 255, .72);
}

.ml-column-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: color-mix(in srgb, var(--ml-category) 13%, white);
    color: var(--ml-category);
}

.ml-column-head h3 { margin: 0; font-size: .9rem; font-weight: 800; }
.ml-column-head span { color: var(--ml-muted); font-size: .65rem; font-weight: 700; }

.ml-create,
.ml-info-button,
.ml-card-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #87928a;
    cursor: pointer;
}

.ml-info-button {
    border: 1px solid color-mix(in srgb, var(--ml-category) 45%, #dce3de);
    border-radius: 50%;
    background: #fff;
    color: var(--ml-category);
}

.ml-create:hover,
.ml-create:focus-visible,
.ml-info-button:hover,
.ml-info-button:focus-visible,
.ml-card-menu:hover,
.ml-card-menu:focus-visible {
    background: #e5ebe5;
    color: var(--ml-category, #4d7c0f);
    outline: 2px solid rgba(110, 169, 0, .16);
}

.ml-column-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ml-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 780px;
    min-height: 210px;
    padding: 10px;
    overflow-y: auto;
    scrollbar-color: #b2bdb4 transparent;
    scrollbar-width: thin;
}

.ml-card {
    --ml-card-color: #79867e;
    overflow: hidden;
    flex: 0 0 auto;
    border: 1px solid #dce3de;
    border-radius: 8px;
    background: var(--ml-surface);
    box-shadow: 0 3px 9px rgba(32, 42, 44, .06);
}

.ml-card-user_created { --ml-card-color: var(--ml-red); }
.ml-card-batcher { --ml-card-color: var(--ml-yellow); }
.ml-card-assembly { --ml-card-color: var(--ml-green); }
.ml-card-takeout { --ml-card-color: var(--ml-takeout); }

.ml-card:hover { box-shadow: 0 7px 18px rgba(32, 42, 44, .11); }

.ml-card-head {
    padding: 11px 10px 9px;
    border-bottom: 1px solid #edf0ed;
}

.ml-card-heading { min-width: 0; }
.ml-card-heading h4,
.ml-card-heading p { margin: 0; }
.ml-card-heading h4 { font-size: .84rem; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.ml-card-heading p { margin-top: 3px; color: var(--ml-muted); font-size: .65rem; line-height: 1.35; overflow-wrap: anywhere; }

.ml-card-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    color: var(--ml-card-color);
    font-size: .57rem;
    font-weight: 800;
    text-transform: uppercase;
}

.ml-card-body { padding: 10px; }

.ml-user-facts,
.ml-user-meta,
.ml-kit-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.ml-user-fact,
.ml-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 7px;
    border-radius: 5px;
    background: #f0f4ee;
    color: #526057;
    font-size: .63rem;
    font-weight: 700;
}

.ml-user-fact i,
.ml-meta-chip i { color: var(--ml-card-color); }
.ml-user-meta { margin-top: 8px; }

.ml-kit-segments {
    display: grid;
    grid-template-columns: .9fr 1.1fr 1.1fr .8fr;
    margin-top: 10px;
    border: 1px solid #e5e9e5;
    border-radius: 7px;
    background: #fbfcfa;
}

.ml-kit-segment {
    min-width: 0;
    padding: 9px;
}

.ml-kit-segment + .ml-kit-segment { border-left: 1px solid #dfe5df; }
.ml-kit-segment h5 { margin: 0 0 7px; color: #7a5a0b; font-size: .6rem; font-weight: 800; text-transform: uppercase; }
.ml-base-name { display: block; font-size: .68rem; line-height: 1.38; overflow-wrap: anywhere; }

.ml-meal-name + .ml-meal-name { margin-top: 8px; padding-top: 8px; border-top: 1px solid #e5e9e5; }
.ml-meal-name strong { display: block; font-size: .67rem; line-height: 1.32; overflow-wrap: anywhere; }
.ml-meal-name span { display: block; margin-top: 2px; color: #7c8780; font-size: .56rem; font-weight: 700; text-transform: uppercase; }

.ml-component-list {
    overflow: hidden;
    border: 1px solid #e3e8e3;
    border-radius: 7px;
}

.ml-component { padding: 8px 9px; background: #fbfcfa; }
.ml-component + .ml-component { border-top: 1px solid #e3e8e3; }
.ml-component-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(82px, 42%);
    align-items: start;
    gap: 8px;
}
.ml-component strong { min-width: 0; font-size: .68rem; line-height: 1.3; overflow-wrap: anywhere; }
.ml-component span {
    min-width: 0;
    padding: 3px 5px;
    border-radius: 4px;
    background: #edf6df;
    color: #4d7c0f;
    font-size: .59rem;
    font-weight: 800;
    line-height: 1.3;
    overflow-wrap: anywhere;
    text-align: right;
}
.ml-component small { display: block; margin-top: 3px; color: var(--ml-muted); font-size: .58rem; line-height: 1.3; }

.ml-takeout-dish { padding: 0; background: transparent; }
.ml-takeout-dish span { display: block; color: #6d7a72; font-size: .57rem; font-weight: 800; text-transform: uppercase; }
.ml-takeout-dish strong { display: block; margin-top: 3px; font-size: .78rem; line-height: 1.3; }

.ml-source-links { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.ml-source-links a { display: inline-flex; align-items: center; gap: 4px; color: #28678f; font-size: .6rem; font-weight: 700; text-decoration: none; }
.ml-source-links a:hover { text-decoration: underline; }

.ml-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 2px 10px 10px;
    border: 0;
    background: transparent;
}

.ml-add-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 29px;
    padding: 5px 9px;
    border: 0;
    border-radius: 6px;
    background: var(--ml-card-color);
    color: #fff;
    font-size: .62rem;
    font-weight: 800;
    cursor: pointer;
}
.ml-add-button:hover,
.ml-add-button:focus-visible { filter: brightness(.92); outline: 3px solid color-mix(in srgb, var(--ml-card-color) 22%, transparent); }

.ml-nutrition-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 7px 10px;
    border: 0;
    border-top: 1px solid #edf0ed;
    background: #fff;
    color: #59645d;
    font-size: .61rem;
    font-weight: 800;
    cursor: pointer;
}
.ml-nutrition-toggle i { color: var(--ml-card-color); }

.ml-nutrition-panel { padding: 8px 10px 10px; border-top: 1px solid #edf0ed; background: #f8faf7; }
.ml-nutrition-meal + .ml-nutrition-meal { margin-top: 10px; padding-top: 10px; border-top: 1px solid #dfe5df; }
.ml-nutrition-meal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ml-nutrition-meal-head strong { font-size: .68rem; line-height: 1.3; }
.ml-nutrition-meal-head span { color: #7a857e; font-size: .56rem; font-weight: 800; text-transform: uppercase; }
.ml-nutrition-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin-top: 7px; }
.ml-nutrient { display: grid; grid-template-columns: 13px minmax(0, 1fr); align-items: center; gap: 1px 4px; min-width: 0; }
.ml-nutrient i { grid-row: 1 / span 2; color: var(--ml-card-color); font-size: .6rem; }
.ml-nutrient b { font-size: .61rem; white-space: nowrap; }
.ml-nutrient small { color: #7a857e; font-size: .53rem; }
.ml-nutrient.is-compact {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ml-nutrient.is-compact i { grid-row: auto; }
.ml-no-nutrition { margin: 6px 0 0; color: #7b8580; font-size: .6rem; }

.ml-day-menu {
    position: fixed;
    z-index: 1090;
    width: 168px;
    padding: 6px;
    border: 1px solid #d6ddd8;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(32, 42, 44, .18);
}
.ml-day-menu[hidden] { display: none; }
.ml-day-menu-title { padding: 5px 7px 7px; color: #7b8580; font-size: .58rem; font-weight: 800; text-transform: uppercase; }
.ml-day-menu-item { display: flex; align-items: center; gap: 7px; width: 100%; padding: 7px; border: 0; border-radius: 5px; background: transparent; color: var(--ml-ink); font-size: .7rem; font-weight: 700; text-align: left; cursor: pointer; }
.ml-day-menu-item i { color: var(--ml-green); }
.ml-day-menu-item .fa-kitchen-set { font-size: .85rem; }
.ml-day-menu-item.is-all { margin-bottom: 4px; border-bottom: 1px solid #e7ece8; border-radius: 5px 5px 0 0; }
.ml-day-menu-item:hover,
.ml-day-menu-item:focus-visible { background: #eef5e9; outline: none; }

.ml-empty { display: grid; place-items: center; align-content: center; gap: 7px; min-height: 150px; border: 1px dashed #c2ccc4; border-radius: 8px; color: #7d8880; font-size: .68rem; font-weight: 700; }
.ml-empty i { font-size: 1.2rem; }

body.ml-modal-open { overflow: hidden; }

.ml-info-modal {
    position: fixed;
    z-index: 1100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(24, 32, 33, .56);
}

.ml-info-modal[hidden] { display: none; }

.ml-info-dialog {
    position: relative;
    width: min(760px, 100%);
    max-height: min(720px, calc(100vh - 40px));
    padding: 26px;
    overflow-y: auto;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(20, 28, 29, .28);
}

.ml-info-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: #eef2ef;
    color: #536057;
    cursor: pointer;
}

.ml-info-close:hover,
.ml-info-close:focus-visible { color: #202a2c; outline: 3px solid rgba(110, 169, 0, .18); }
.ml-info-eyebrow { display: block; color: #4d7c0f; font-size: .65rem; font-weight: 800; text-transform: uppercase; }
.ml-info-dialog h2 { margin: 4px 42px 0 0; font-family: "Fraunces", serif; font-size: 1.65rem; }
.ml-info-explanation { max-width: 650px; margin: 9px 0 20px; color: var(--ml-muted); font-size: .85rem; line-height: 1.55; }
.ml-info-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .8fr); gap: 22px; align-items: start; }
.ml-info-section-label { display: block; margin-bottom: 7px; color: #707b74; font-size: .62rem; font-weight: 800; text-transform: uppercase; }

.ml-info-sample {
    --sample-color: #79867e;
    overflow: hidden;
    border: 1px solid #dce3de;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(32, 42, 44, .08);
}
.ml-info-sample[data-category="user_created"] { --sample-color: var(--ml-red); }
.ml-info-sample[data-category="batcher"] { --sample-color: var(--ml-yellow); }
.ml-info-sample[data-category="assembly"] { --sample-color: var(--ml-green); }
.ml-info-sample[data-category="takeout"] { --sample-color: var(--ml-takeout); }
.ml-info-sample header { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 8px; padding: 12px; border-bottom: 1px solid #edf0ed; }
.ml-info-sample-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: color-mix(in srgb, var(--sample-color) 14%, white); color: var(--sample-color); }
.ml-info-sample header small { display: block; color: var(--sample-color); font-size: .56rem; font-weight: 800; text-transform: uppercase; }
.ml-info-sample header strong { display: block; margin-top: 2px; font-size: .78rem; line-height: 1.3; }
.ml-info-sample header p { margin: 3px 0 0; color: var(--ml-muted); font-size: .62rem; line-height: 1.35; }
.ml-info-sample-details { display: grid; gap: 7px; padding: 12px; }
.ml-info-detail { display: flex; align-items: center; gap: 7px; color: #526057; font-size: .66rem; font-weight: 700; }
.ml-info-detail b { display: inline-grid; place-items: center; flex: 0 0 20px; width: 20px; height: 20px; border-radius: 50%; background: color-mix(in srgb, var(--sample-color) 14%, white); color: var(--sample-color); font-size: .58rem; }
.ml-info-sample footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-top: 1px solid #edf0ed; color: var(--ml-muted); font-size: .59rem; font-weight: 700; }
.ml-info-sample-add { padding: 5px 8px; border-radius: 5px; background: var(--sample-color); color: #fff; }
.ml-info-guidance p { margin: 0; color: #4e5952; font-size: .78rem; line-height: 1.55; }
.ml-info-guidance ol { margin: 14px 0 0; padding-left: 18px; color: #5e6962; font-size: .7rem; line-height: 1.5; }
.ml-info-guidance li + li { margin-top: 7px; }

@media (max-width: 760px) {
    .ml-library { margin-top: 26px; padding-top: 22px; }
    .ml-library-head { align-items: flex-start; flex-direction: column; gap: 12px; }
    .ml-library-head h2 { font-size: 1.45rem; }
    .ml-search { width: 100%; }
    /* Requirement 8: category columns stack full-width and scroll vertically
       with the page instead of forcing a ~1500px-wide horizontal scroller. */
    .ml-columns-scroll { overflow-x: visible; padding: 1px 0 4px; }
    .ml-columns {
        grid-template-columns: 1fr;
        min-width: 0;
        gap: 16px;
    }
    .ml-column { border-top-width: 3px; }
    .ml-card-list { max-height: 420px; }
    .ml-info-modal { padding: 10px; }
    .ml-info-dialog { max-height: calc(100vh - 20px); padding: 22px 16px 18px; }
    .ml-info-dialog h2 { font-size: 1.4rem; }
    .ml-info-layout { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .ml-library-head h2 { font-size: 1.25rem; }
    .ml-column-head { min-height: 54px; padding: 8px 10px; gap: 7px; }
    .ml-column-icon { width: 28px; height: 28px; font-size: .8rem; }
    .ml-column-head h3 { font-size: .82rem; }
    .ml-card-list { max-height: 340px; padding: 8px; gap: 8px; }
    .ml-card-head { padding: 9px 8px 7px; }
    .ml-card-body { padding: 8px; }
    .ml-kit-segments { grid-template-columns: 1fr 1fr; }
    .ml-nutrition-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}