/* ==========================================================================
   Acnoo Admin — Media library (picker modal, inline page, field buttons)
   Uses the admin design tokens from admin-theme.css (brand #0287FF).
   ========================================================================== */

/* ---------- Bulk upload rows: "Library" button next to the row's file input ---------- */
.acm-field {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
}

/* narrow columns: the Library button moves under the file input */
.acm-field > input[type="file"] {
    flex: 1 1 190px;
    min-width: 0;
}

.acm-pick-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--ac-blue-100);
    border-radius: var(--ac-radius-sm, 10px);
    background: var(--ac-blue-50);
    color: var(--ac-blue-text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.acm-pick-btn:hover,
.acm-pick-btn:focus-visible {
    background: var(--ac-blue);
    border-color: var(--ac-blue);
    color: #fff;
}

.acm-field-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.acm-field-note:empty,
.acm-field-note:has(> .acm-chip[hidden]) {
    display: none;
}

.acm-field-note {
    margin-top: 6px;
}

.acm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 3px 4px 3px 10px;
    border-radius: 999px;
    background: var(--ac-blue-50);
    color: var(--ac-blue-600);
    font-size: 12px;
    font-weight: 500;
}

.acm-chip[hidden] {
    display: none;
}

.acm-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.acm-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.acm-chip-x:hover {
    background: var(--ac-blue-100);
}

/* ==========================================================================
   Image field — one component on every page
   [ dashed preview box (image / "No image") ]  × in the corner
   [ Library ]  file name of a new pick
   ========================================================================== */
.acm-orig {
    display: none !important;
}

.acm-img {
    --acm-img-h: 185px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    max-width: 420px;
    min-width: 0;
    margin-top: 2px;
}

.acm-img-box {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: var(--acm-img-h);
    padding: 10px;
    border: 1.5px dashed #c5cede;
    border-radius: 12px;
    background: var(--ac-surface-2, #f8fafc);
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.acm-img-box:hover {
    border-color: var(--ac-brand, #0287ff);
    background: var(--ac-blue-50, #eef6ff);
}

.acm-img-box:focus-visible {
    outline: none;
    border-color: var(--ac-brand, #0287ff);
    box-shadow: 0 0 0 3px rgba(2, 135, 255, 0.22);
}

.acm-img.is-set .acm-img-box {
    border-style: solid;
    border-color: var(--ac-border, #e2e8f0);
    background: #fff;
}

.acm-img.is-set .acm-img-box:hover {
    border-color: var(--ac-brand, #0287ff);
}

.acm-img.is-new .acm-img-box {
    border-color: var(--ac-brand, #0287ff);
}

.acm-img-pic {
    position: absolute;
    inset: 10px;
    display: block;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    object-fit: contain;
}

.acm-img-pic[hidden],
.acm-img-thumbs[hidden],
.acm-img-new[hidden],
.acm-img-x[hidden],
.acm-img-error[hidden] {
    display: none !important;
}

.acm-img-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--ac-faint, #94a3b8);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    pointer-events: none;
}

.acm-img-empty i {
    font-size: 28px;
    color: #b6c0d1;
}

.acm-img.is-set .acm-img-empty {
    display: none;
}

.acm-img.is-broken .acm-img-empty {
    color: var(--ac-muted, #64748b);
}

/* Empty state lives INSIDE the box: cloud icon, "Upload image", a library
   button and the recommended size — all centred in the dashed drop area. */
.acm-img-empty-icon {
    font-size: 30px;
    color: var(--ac-brand, #0287ff);
}

.acm-img-empty-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--ac-ink, #0f172a);
}

.acm-img-empty .acm-img-lib {
    margin-top: 2px;
    height: 32px;
    padding: 0 14px;
    font-size: 12.5px;
    pointer-events: none; /* the whole box is the click target */
}

.acm-img-empty .ac-size-hint {
    justify-content: center;
    margin: 2px 0 0;
    font-size: 11.5px;
    text-align: center;
}

/* several images (multiple fields) */
.acm-img-thumbs {
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.acm-img-thumbs img,
.acm-img-thumb-blank,
.acm-img-more {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    border: 1px solid var(--ac-border, #e2e8f0);
    object-fit: cover;
    background: #fff;
}

.acm-img-thumb-blank,
.acm-img-more {
    display: grid;
    place-items: center;
    color: var(--ac-muted, #64748b);
    font-size: 13px;
    font-weight: 600;
}

.acm-img-new {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    padding: 2px 8px;
    border-radius: 99px;
    background: var(--ac-brand, #0287ff);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    pointer-events: none;
}

.acm-img-x {
    position: absolute;
    top: 6px;
    inset-inline-end: 6px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--ac-border, #e2e8f0);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.96);
    color: var(--ac-ink, #0f172a);
    font-size: 13px;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.acm-img-x:hover,
.acm-img-x:focus-visible {
    border-color: var(--ac-red, #dc2626);
    background: var(--ac-red, #dc2626);
    color: #fff;
    outline: none;
}

.acm-img-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    min-width: 0;
}

.acm-img-lib {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: none;
    height: 38px;
    padding: 0 16px;
    border: 1.5px solid var(--ac-blue-100, #d9ecff);
    border-radius: 10px;
    background: var(--ac-blue-50, #eef6ff);
    color: var(--ac-blue-text, #006acc);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.acm-img-lib:hover,
.acm-img-lib:focus-visible {
    border-color: var(--ac-brand, #0287ff);
    background: var(--ac-brand, #0287ff);
    color: #fff;
    outline: none;
}

.acm-img-name {
    overflow: hidden;
    min-width: 0;
    color: var(--ac-muted, #64748b);
    font-size: 12.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.acm-img-hint {
    margin: -4px 0 0;
    color: var(--ac-muted, #64748b);
    font-size: 12px;
}

/* Recommended upload size (config/image_sizes.php) — advice only */
.ac-size-hint {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    max-width: 100%;
    margin: 6px 0 0;
    color: var(--ac-muted, #64748b);
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.ac-size-hint .fa-crop {
    flex: none;
    margin-top: 2px;
    color: var(--ac-brand, #0287ff);
}

.acm-img .ac-size-hint {
    margin-top: -4px;
}

/* Recommended size sits ABOVE the upload box (like the gallery fields). */
.acm-img .acm-img-tophint {
    margin: 0 0 8px;
}

.acm-img-actual {
    margin: -6px 0 0;
    color: var(--ac-text, #334155);
    font-size: 12px;
    font-weight: 600;
}

.acm-img-warn {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: -4px 0 0;
    padding: 6px 10px;
    border: 1px solid #fde68a;
    border-radius: 8px;
    background: #fffbeb;
    color: #92400e;
    font-size: 12px;
    line-height: 1.45;
}

.acm-img-warn .fa-exclamation-triangle {
    flex: none;
    margin-top: 2px;
    color: #d97706;
}

.acm-img-actual[hidden],
.acm-img-warn[hidden] {
    display: none;
}

.acm-img-error {
    margin: -4px 0 0;
    color: var(--ac-red, #dc2626);
    font-size: 12.5px;
    font-weight: 500;
}

.acm-img.is-invalid .acm-img-box {
    border-color: var(--ac-red, #dc2626);
    background: #fff7f7;
}

/* small icon fields in repeaters (landing / manage pages) */
.sample-form-wrp .acm-img,
.ac-rep-item .acm-img {
    --acm-img-h: 110px;
    max-width: 280px;
}

/* ==========================================================================
   The library
   One header line (title + subtitle · search · Upload · close), square image
   cards with the name under them, a round check on picked cards, and a
   footer with the hint, the counter and Cancel / Select. Brand #0287FF.
   ========================================================================== */
.acm {
    --acm-cols: 6;
    --acm-line: #dce0ec;
    --acm-brand: var(--ac-brand, #0287ff);
    --acm-brand-dark: var(--ac-blue-600, #0066c4);
    font-family: var(--ac-font, system-ui, sans-serif);
    color: var(--ac-text, #334155);
}

.acm[hidden] {
    display: none !important;
}

.acm--modal {
    position: fixed;
    inset: 0;
    z-index: 1090;
    display: grid;
    place-items: center;
    padding: 16px;
}

.acm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 30, 0.6);
}

.acm-box {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(1000px, 100%);
    max-height: 88vh;
    border-radius: 18px;
    background: var(--ac-surface, #fff);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.acm--modal .acm-box {
    height: 88vh;
}

.acm--inline .acm-box {
    max-height: none;
    border-radius: var(--ac-radius, 14px);
    box-shadow: var(--ac-shadow, 0 4px 16px rgba(15, 23, 42, 0.04));
    border: 1px solid var(--ac-border, #e5e8f0);
    width: 100%;
}

.acm-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--acm-line);
}

.acm-heading {
    flex: 1 1 auto;
    min-width: 0;
}

.acm-title {
    margin: 0;
    overflow: hidden;
    color: var(--ac-ink, #0f172a);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.acm-sub {
    margin: 2px 0 0;
    color: var(--ac-muted, #64748b);
    font-size: 12.5px;
    line-height: 1.4;
}

.acm-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 1 260px;
    min-width: 0;
    margin: 0;
}

.acm-search i {
    position: absolute;
    inset-inline-start: 13px;
    color: var(--ac-faint, #94a3b8);
    font-size: 13px;
    pointer-events: none;
}

.acm-search input {
    width: 100%;
    height: 42px;
    padding: 0 12px 0 36px;
    border: 1.5px solid var(--acm-line);
    border-radius: 10px;
    background: var(--ac-surface, #fff);
    color: var(--ac-ink, #0f172a);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.acm-search input:focus {
    border-color: var(--acm-brand);
    box-shadow: 0 0 0 3px rgba(2, 135, 255, 0.16);
}

.acm-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1.5px solid var(--acm-line);
    border-radius: 10px;
    background: var(--ac-surface, #fff);
    color: var(--ac-ink, #0f172a);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.acm-x:hover,
.acm-x:focus-visible {
    border-color: var(--ac-blue-300, #99ccff);
    background: var(--ac-blue-100, #d9ecff);
    color: var(--ac-blue-600, #0066c4);
    outline: none;
}

/* Super Admin: "Show missing (N)" · "Clean missing files" */
.acm-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    padding: 8px 20px;
    min-height: 42px;
    border-bottom: 1px solid var(--acm-line);
    background: var(--ac-surface-2, #f8fafc);
    font-size: 13px;
}

.acm-filters[hidden] {
    display: none;
}

.acm-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--ac-text, #334155);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.acm-toggle input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.acm-toggle-ui {
    position: relative;
    flex: none;
    width: 32px;
    height: 18px;
    border-radius: 99px;
    background: #cbd5e1;
    transition: background-color 0.15s;
}

.acm-toggle-ui::after {
    content: "";
    position: absolute;
    top: 2px;
    inset-inline-start: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.3);
    transition: transform 0.15s;
}

.acm-toggle input:checked + .acm-toggle-ui {
    background: var(--acm-brand);
}

.acm-toggle input:checked + .acm-toggle-ui::after {
    transform: translateX(14px);
}

.acm-toggle input:focus-visible + .acm-toggle-ui {
    box-shadow: 0 0 0 3px rgba(2, 135, 255, 0.3);
}

.acm-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 2px;
    border: 0;
    background: none;
    color: var(--ac-blue-text, #006acc);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.acm-link-btn[hidden] {
    display: none;
}

.acm-link-btn:hover,
.acm-link-btn:focus-visible {
    color: var(--ac-blue-700, #00569f);
    text-decoration: underline;
    outline: none;
}

/* upload progress */
.acm-uploads {
    display: grid;
    gap: 6px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--ac-border, #e5e8f0);
    background: var(--ac-surface-2, #f8fafc);
    max-height: 132px;
    overflow-y: auto;
}

.acm-uploads[hidden] {
    display: none;
}

.acm-up {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(80px, 200px) 44px;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}

.acm-up-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ac-ink, #0f172a);
}

.acm-up-bar {
    height: 6px;
    border-radius: 99px;
    background: var(--ac-blue-100, #d9ecff);
    overflow: hidden;
}

.acm-up-bar span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--acm-brand);
    transition: width 0.2s;
}

.acm-up-pct {
    text-align: end;
    color: var(--ac-muted, #64748b);
}

.acm-up.is-done .acm-up-pct {
    color: var(--ac-green, #059669);
}

.acm-up.is-error {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
}

.acm-up-err {
    color: var(--ac-red, #dc2626);
}

/* grid */
.acm-body {
    position: relative;
    flex: 1 1 auto;
    min-height: 220px;
    padding: 18px 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--ac-surface, #fff);
}

.acm--inline .acm-body {
    overflow: visible;
}

.acm-grid {
    display: grid;
    grid-template-columns: repeat(var(--acm-cols), minmax(0, 1fr));
    gap: 12px;
}

.acm-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0;
    border: 2px solid var(--acm-line);
    border-radius: 14px;
    background: var(--ac-surface-2, #f3f5fa);
    color: inherit;
    text-align: start;
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.acm-card:hover {
    border-color: var(--ac-blue-300, #99ccff);
}

.acm-card:focus-visible {
    outline: none;
    border-color: var(--acm-brand);
    box-shadow: 0 0 0 3px rgba(2, 135, 255, 0.3);
}

.acm-card.is-on {
    border-color: var(--acm-brand);
    box-shadow: 0 0 0 3px rgba(2, 135, 255, 0.2);
}

.acm-thumb {
    display: block;
    aspect-ratio: 1 / 1;
    background: var(--ac-surface-2, #f3f5fa);
    overflow: hidden;
}

.acm-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.acm-check {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    display: none;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--acm-brand);
    color: #fff;
    font-size: 11px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
}

.acm-card.is-on .acm-check {
    display: grid;
}

.acm-meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 6px 9px;
    background: var(--ac-surface, #fff);
    min-width: 0;
}

.acm-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ac-ink, #0f172a);
}

.acm-dims {
    font-size: 11px;
    color: var(--ac-muted, #6b728c);
    font-variant-numeric: tabular-nums;
}

/* Missing files (only listed with "Show missing"): compact and muted */
.acm-card.is-missing {
    align-self: start;
    border-style: dashed;
    border-color: #d5dbe6;
    background: var(--ac-surface, #fff);
    cursor: not-allowed;
}

.acm-card.is-missing .acm-thumb {
    display: grid;
    place-items: center;
    aspect-ratio: 2 / 1;
    background: #f3f5f9;
}

.acm-card.is-missing .acm-thumb i {
    color: #a3adbf;
    font-size: 18px;
}

.acm-card.is-missing .acm-name {
    color: var(--ac-muted, #64748b);
    font-weight: 600;
}

.acm-card.is-missing .acm-dims {
    color: var(--ac-faint, #94a3b8);
}

.acm--inline .acm-card.is-missing {
    cursor: pointer;
}

.acm-badge {
    display: inline-block;
    margin-inline-end: 3px;
    padding: 0 6px;
    border-radius: 6px;
    background: #334155;
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.6;
}

/* empty states */
.acm-empty[hidden],
.acm-more[hidden] {
    display: none;
}

.acm-empty-msg {
    margin: 40px 0;
    text-align: center;
    color: var(--ac-muted, #64748b);
}

.acm-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 440px;
    margin: 28px auto;
    padding: 34px 24px;
    border: 2px dashed #cfd8e6;
    border-radius: 18px;
    background: var(--ac-surface-2, #f8fafc);
    text-align: center;
}

.acm-empty-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 14px;
    border-radius: 18px;
    background: var(--ac-blue-50, #eef6ff);
    color: var(--acm-brand);
    font-size: 28px;
}

.acm-empty-state h3 {
    margin: 0 0 6px;
    color: var(--ac-ink, #0f172a);
    font-size: 17px;
    font-weight: 700;
}

.acm-empty-state p {
    margin: 0;
    color: var(--ac-muted, #64748b);
    font-size: 13.5px;
}

.acm .acm-empty-state .acm-btn-lg {
    margin: 20px 0 12px;
}

@media (hover: none) {
    /* phones / tablets: no drag & drop hint */
    .acm-empty-state .acm-empty-hint {
        display: none;
    }
}

.acm-empty-state .acm-empty-hint {
    color: var(--ac-text, #334155);
    font-size: 13px;
}

.acm-empty-state .acm-empty-types {
    margin-top: 4px;
    color: var(--ac-faint, #94a3b8);
    font-size: 12px;
}

.acm-empty-search {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 48px 0;
    color: var(--ac-muted, #64748b);
    text-align: center;
}

.acm-empty-search i {
    color: var(--ac-faint, #94a3b8);
    font-size: 24px;
}

.acm-empty-search p {
    margin: 0;
}

.acm.is-empty .acm-foot .acm-hint {
    visibility: hidden;
}

.acm-more {
    display: flex;
    justify-content: center;
    padding: 18px 0 6px;
    min-height: 24px;
}

.acm-spin {
    width: 22px;
    height: 22px;
    border: 3px solid var(--ac-blue-100, #d9ecff);
    border-top-color: var(--acm-brand);
    border-radius: 50%;
    visibility: hidden;
}

.acm-more.is-busy .acm-spin {
    visibility: visible;
    animation: acm-spin 0.7s linear infinite;
}

@keyframes acm-spin {
    to {
        transform: rotate(360deg);
    }
}

/* drag & drop */
.acm-drop {
    position: absolute;
    inset: 8px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--acm-brand);
    border-radius: var(--ac-radius, 14px);
    background: rgba(238, 246, 255, 0.95);
    color: var(--ac-blue-text, #006acc);
    text-align: center;
    pointer-events: none;
}

.acm-drop[hidden] {
    display: none;
}

.acm-drop i {
    display: block;
    margin-bottom: 8px;
    font-size: 34px;
}

.acm-drop b {
    display: block;
    font-size: 16px;
}

.acm-drop span {
    font-size: 13px;
}

/* footer */
.acm-foot {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    border-top: 1px solid var(--acm-line);
    background: var(--ac-surface, #fff);
}

.acm-hint {
    flex: 0 1 auto;
    min-width: 0;
    color: var(--ac-muted, #64748b);
    font-size: 12.5px;
}

.acm-sp {
    flex: 1 1 auto;
}

.acm-count {
    flex: 0 0 auto;
    color: var(--ac-muted, #64748b);
    font-size: 13.5px;
    white-space: nowrap;
}

.acm-count.has-sel {
    color: var(--ac-blue-text, #006acc);
    font-weight: 600;
}

.acm-actions {
    display: flex;
    flex: none;
    gap: 10px;
}

/* buttons: primary = solid brand #0287FF with white text */
.acm .acm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    min-width: 96px;
    margin: 0;
    padding: 0 18px;
    border: 1.5px solid transparent;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.acm .acm-btn i {
    font-size: 14px;
}

.acm .acm-btn[hidden] {
    display: none;
}

.acm .acm-btn-primary {
    border-color: var(--acm-brand);
    background: var(--acm-brand);
    color: #fff;
}

.acm .acm-btn-primary:hover,
.acm .acm-btn-primary:focus-visible {
    border-color: var(--acm-brand-dark);
    background: var(--acm-brand-dark);
    color: #fff;
    outline: none;
}

.acm .acm-btn-primary:focus-visible {
    box-shadow: 0 0 0 3px rgba(2, 135, 255, 0.3);
}

.acm .acm-btn-primary:disabled {
    border-color: #d5dde8;
    background: #e8edf4;
    color: #5f6c80;
    cursor: not-allowed;
    box-shadow: none;
}

.acm .acm-btn-lg {
    height: 48px;
    padding: 0 26px;
    font-size: 15px;
}

.acm .acm-btn-line {
    border-color: var(--acm-line);
    background: var(--ac-surface, #fff);
    color: var(--ac-ink, #0f172a);
}

.acm .acm-btn-line:hover,
.acm .acm-btn-line:focus-visible {
    border-color: var(--ac-blue-300, #99ccff);
    background: var(--ac-blue-100, #d9ecff);
    color: var(--ac-blue-600, #0066c4);
    outline: none;
}

.acm .acm-btn-danger {
    border-color: #f3c4c4;
    background: var(--ac-surface, #fff);
    color: var(--ac-red, #dc2626);
}

.acm .acm-btn-danger:hover,
.acm .acm-btn-danger:focus-visible {
    border-color: var(--ac-red, #dc2626);
    background: var(--ac-red, #dc2626);
    color: #fff;
    outline: none;
}

.acm-upload-btn {
    flex: none;
}

/* the note popup opens above the library; only while it is shown, so a
   library opened from inside another modal stays above that modal's backdrop */
body.acm-open:has(#ac-note-modal.show) .modal-backdrop {
    z-index: 1095;
}

body.acm-open #ac-note-modal {
    z-index: 1100;
}

body.acm-open {
    overflow: hidden;
}

/* ---------- Responsive: 6 per row on desktop ---------- */
@media (max-width: 991.98px) {
    .acm {
        --acm-cols: 4;
    }

    .acm-hint {
        display: none;
    }
}

@media (max-width: 700px) {
    .acm {
        --acm-cols: 3;
    }

    .acm--modal {
        padding: 10px;
    }

    .acm--modal .acm-box {
        height: calc(100vh - 20px);
        height: calc(100dvh - 20px);
        max-height: none;
    }

    /* [title / subtitle ……… Upload ✕] / [search full width] */
    .acm-head {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 14px;
    }

    .acm-heading {
        order: 1;
        flex: 1 1 0;
    }

    .acm-title {
        font-size: 16.5px;
    }

    .acm-sub {
        font-size: 12px;
    }

    .acm-upload-btn {
        order: 2;
    }

    .acm .acm-upload-btn {
        min-width: 0;
        height: 40px;
        padding: 0 14px;
    }

    .acm-x {
        order: 3;
        width: 40px;
        height: 40px;
    }

    .acm-search {
        order: 4;
        flex: 1 1 100%;
    }

    .acm-search input {
        height: 42px;
    }

    .acm-filters {
        padding: 8px 14px;
    }

    .acm-body {
        padding: 12px 14px;
    }

    .acm-grid {
        gap: 10px;
    }

    .acm-uploads {
        padding: 8px 14px;
    }

    .acm-foot {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .acm-sp {
        display: none;
    }

    .acm-count {
        flex: 1 1 100%;
        text-align: center;
        font-size: 13px;
    }

    .acm-actions {
        flex: 1 1 100%;
    }

    .acm .acm-actions .acm-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 0 10px;
    }

    .acm-meta {
        padding: 5px 7px;
    }

    .acm-empty-state {
        margin: 12px auto;
        padding: 26px 16px;
    }

    .acm-img {
        max-width: 100%;
    }
}

@media (max-width: 360px) {
    .acm {
        --acm-cols: 2;
    }
}

/* General Settings logo/image fields: compact boxes (about half the default
   height), no big top white-space, and no redundant "Selected: SVG" line. */
.settings-image-upload .acm-img {
    --acm-img-h: 92px;
    max-width: 360px;
}
.settings-image-upload .acm-img-actual {
    display: none !important;
}
.settings-image-upload .title {
    top: -9px;
}
