@import url("https://fonts.googleapis.com/css2?family=Tiro+Bangla:ital@0;1&display=swap");

/* =========================================================================
   1. DESIGN TOKENS
   A single source of truth for color, radius and shadow. Every rule below
   reads from these — nothing is redefined further down the file.
   ========================================================================= */
:root {
    --qmx-primary: #2563eb;
    --qmx-primary-dark: #1d4ed8;
    --qmx-primary-soft: #eff6ff;
    --qmx-accent: #6d28d9;
    --qmx-ink: #0f172a;
    --qmx-muted: #64748b;
    --qmx-line: #e2e8f0;
    --qmx-panel: #ffffff;
    --qmx-page: #f4f7fb;
    --qmx-success: #15803d;
    --qmx-success-soft: #ecfdf5;
    --qmx-warning: #b45309;
    --qmx-warning-soft: #fffbeb;
    --qmx-danger: #dc2626;
    --qmx-danger-soft: #fef2f2;

    --qmx-radius-sm: 10px;
    --qmx-radius: 16px;
    --qmx-radius-lg: 22px;
    --qmx-radius-pill: 999px;

    --qmx-shadow-sm: 0 8px 20px rgba(15, 23, 42, 0.06);
    --qmx-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
    --qmx-shadow-lg: 0 22px 50px rgba(15, 23, 42, 0.12);

    --qmx-font-display: "Tiro Bangla", "Times New Roman", serif;
    --qmx-font-body: "Times New Roman", "Tiro Bangla", serif;
    --qmx-font-ui: Arial, sans-serif;
}

/* =========================================================================
   2. PAGE SHELL
   ========================================================================= */
.page-container:has(.qmx-library-hero),
.page-container:has(.qmx-detail-hero),
.page-container:has(.qmx-editor-hero) {
    max-width: 1420px;
    padding-top: 24px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.qmx-eyebrow,
.qmx-card-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--qmx-primary);
    font-family: var(--qmx-font-ui);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    line-height: 1.2;
    text-transform: uppercase;
}

.qmx-feedback {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid;
    border-radius: 12px;
    font-family: var(--qmx-font-ui);
    font-size: 13px;
    font-weight: 700;
}

.qmx-feedback--success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.qmx-feedback--error {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

/* =========================================================================
   3. HERO BANNERS (library / detail / editor)
   ========================================================================= */
.qmx-library-hero,
.qmx-detail-hero,
.qmx-editor-hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    margin-bottom: 22px;
    padding: 26px 30px;
    overflow: hidden;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: var(--qmx-radius-lg);
    background:
        radial-gradient(circle at 100% 0, rgba(96, 165, 250, 0.25), transparent 34%),
        linear-gradient(135deg, #172554, #1d4ed8);
    color: #ffffff;
    box-shadow: 0 20px 46px rgba(30, 64, 175, 0.2);
}

.qmx-library-hero h1,
.qmx-detail-hero h1,
.qmx-editor-hero h1 {
    margin: 5px 0 7px;
    color: #ffffff;
    font-family: var(--qmx-font-display);
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.15;
}

.qmx-library-hero p,
.qmx-detail-hero p,
.qmx-editor-hero p {
    max-width: 780px;
    margin: 0;
    color: rgba(255, 255, 255, 0.84);
    line-height: 1.7;
}

.qmx-library-hero .qmx-eyebrow,
.qmx-detail-hero .qmx-eyebrow,
.qmx-editor-hero .qmx-eyebrow {
    color: #bfdbfe;
}

.qmx-library-hero__actions,
.qmx-detail-hero__actions,
.qmx-editor-hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.qmx-count-pill {
    display: grid;
    min-width: 110px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.1);
    text-align: center;
    backdrop-filter: blur(10px);
}

.qmx-count-pill strong {
    color: #ffffff;
    font-size: 25px;
    line-height: 1;
}

.qmx-count-pill span {
    margin-top: 5px;
    color: #dbeafe;
    font-size: 12px;
}

.qmx-back-link {
    display: inline-flex;
    margin-bottom: 8px;
    color: inherit;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    opacity: 0.86;
}

.qmx-back-link:hover {
    opacity: 1;
}

/* =========================================================================
   4. BUTTONS & SHARED CONTROLS
   ========================================================================= */
.qmx-primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--qmx-primary), var(--qmx-accent));
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.qmx-primary-button:hover {
    transform: translateY(-1px);
    background: linear-gradient(135deg, var(--qmx-primary-dark), #5b21b6);
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.3);
}

.qmx-text-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid #dbe4ee;
    border-radius: 12px;
    background: #ffffff;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.qmx-text-link:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.qmx-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #bfdbfe;
    border-top-color: var(--qmx-primary);
    border-radius: 50%;
    animation: qmxRotate 0.8s linear infinite;
}

.qmx-count-badge {
    display: inline-grid;
    min-width: 34px;
    height: 34px;
    padding: 0 12px;
    place-items: center;
    border-radius: var(--qmx-radius-pill);
    background: linear-gradient(135deg, var(--qmx-primary), var(--qmx-primary-dark));
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.22);
}

@keyframes qmxRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes qmxSkeleton {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* =========================================================================
   5. LIBRARY LAYOUT — filter sidebar + results list
   (Defined exactly once. This used to be duplicated further down the file
   with a second, conflicting version — that was the root cause of the
   broken layout.)
   ========================================================================= */
.qmx-library-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 330px);
    gap: 24px;
    align-items: start;
    padding-top: 8px;
}

.qmx-library-layout > .qmx-filter-sidebar {
    grid-column: 2;
    grid-row: 1;
}

.qmx-library-layout > .qmx-list-panel {
    grid-column: 1;
    grid-row: 1;
}

.qmx-filter-sidebar {
    position: sticky;
    top: 92px;
    align-self: start;
    max-height: calc(100vh - 106px);
    overflow: auto;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: #d8e2ee transparent;
}

.qmx-filter-sidebar::-webkit-scrollbar {
    width: 6px;
}

.qmx-filter-sidebar::-webkit-scrollbar-thumb {
    border-radius: var(--qmx-radius-pill);
    background: #d8e2ee;
}

.qmx-filter-card {
    display: grid;
    gap: 14px;
    padding: 20px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--qmx-radius-lg);
    background: var(--qmx-panel);
    box-shadow: var(--qmx-shadow);
    transition: box-shadow 0.2s ease;
}

.qmx-filter-card[data-busy="true"] {
    box-shadow: var(--qmx-shadow-lg);
}

.qmx-filter-card__heading {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--qmx-line);
    background: linear-gradient(180deg, #ffffff 80%, rgba(255, 255, 255, 0));
}

.qmx-filter-fields {
    display: contents;
}

.qmx-filter-heading__actions .qmx-filter-toggle {
    display: none;
}

.qmx-filter-heading {
    display: flex;
    gap: 12px;
    align-items: center;
}

.qmx-filter-heading__icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--qmx-primary), #818cf8);
    color: #ffffff;
    font-size: 18px;
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
}

.qmx-filter-heading > div {
    display: grid;
    gap: 3px;
}

.qmx-filter-heading h2 {
    margin: 0;
    color: var(--qmx-ink);
    font-family: var(--qmx-font-display);
    font-size: 21px;
}

.qmx-filter-heading__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.qmx-icon-action {
    display: inline-grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid #dfe7f0;
    border-radius: 12px;
    background: #ffffff;
    color: #475569;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.qmx-icon-action:hover,
.qmx-icon-action:focus-visible {
    border-color: #93c5fd;
    background: var(--qmx-primary-soft);
    color: var(--qmx-primary-dark);
    outline: none;
    transform: translateY(-1px);
}

.qmx-icon-action--primary {
    border-color: #bfdbfe;
    background: var(--qmx-primary-soft);
    color: var(--qmx-primary-dark);
}

.qmx-filter-pill-row {
    display: flex;
    align-items: center;
}

.qmx-filter-pill-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: var(--qmx-radius-pill);
    background: #f1f5f9;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
}

.qmx-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.qmx-active-chip,
.qmx-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 10px;
    border: 1px solid #dbeafe;
    border-radius: var(--qmx-radius-pill);
    background: var(--qmx-primary-soft);
    color: var(--qmx-primary-dark);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.qmx-active-chip__icon {
    display: inline-grid;
    width: 18px;
    height: 18px;
    place-items: center;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.12);
}

.qmx-filter-field {
    display: grid;
    gap: 8px;
}

.qmx-filter-field label {
    color: #334155;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.qmx-filter-field select,
.qmx-filter-field input[type="search"],
.qmx-filter-field input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid #dfe7f0;
    border-radius: 14px;
    background: #fcfdff;
    color: #0f172a;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.qmx-filter-field select[multiple] {
    padding: 8px;
}

.qmx-filter-field select:focus,
.qmx-filter-field input:focus {
    border-color: var(--qmx-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
    outline: none;
}

.qmx-filter-field select:disabled,
.qmx-filter-field input:disabled {
    cursor: not-allowed;
    opacity: 0.7;
    background: #f8fafc;
}

.qmx-filter-field.is-loading {
    position: relative;
}

.qmx-filter-field.is-loading::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 44px;
    width: 14px;
    height: 14px;
    border: 2px solid #bfdbfe;
    border-top-color: var(--qmx-primary);
    border-radius: 50%;
    animation: qmxRotate 0.8s linear infinite;
}

.qmx-search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid #dfe7f0;
    border-radius: 14px;
    background: #fcfdff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.qmx-search-box svg {
    width: 17px;
    height: 17px;
    color: #64748b;
    flex-shrink: 0;
}

.qmx-search-box input {
    width: 100%;
    min-height: 46px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-size: 14px;
}

.qmx-search-box:focus-within {
    border-color: var(--qmx-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.qmx-advanced-filters {
    border: 1px solid var(--qmx-line);
    border-radius: 16px;
    background: #f8fbff;
    padding: 10px 12px 0;
}

.qmx-advanced-filters > summary {
    cursor: pointer;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    list-style: none;
    padding-bottom: 10px;
}

.qmx-advanced-filters > summary::-webkit-details-marker {
    display: none;
}

.qmx-advanced-filters > summary::after {
    content: "▾";
    float: right;
    color: var(--qmx-muted);
}

.qmx-advanced-filters[open] > summary::after {
    content: "▴";
}

.qmx-advanced-filters__body {
    display: grid;
    gap: 12px;
    padding: 12px 0 14px;
}

/* =========================================================================
   6. RESULTS LIST — topbar, feed, cards, empty state, pagination
   ========================================================================= */
.qmx-list-panel {
    min-width: 0;
}

.qmx-question-list__topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    margin-bottom: 16px;
    border: 1px solid var(--qmx-line);
    border-radius: 18px;
    background: var(--qmx-panel);
    box-shadow: var(--qmx-shadow-sm);
}

.qmx-question-list__topbar strong {
    display: block;
    color: var(--qmx-ink);
    font-size: 17px;
}

.qmx-question-list__topbar span {
    margin-left: 8px;
    color: var(--qmx-muted);
    font-size: 13px;
}

.qmx-select-all-control {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--qmx-primary-dark);
    cursor: pointer;
    font-family: var(--qmx-font-ui);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.qmx-select-all-control input {
    width: 16px;
    height: 16px;
    accent-color: var(--qmx-primary);
    cursor: pointer;
}

#question-list {
    display: grid;
    gap: 16px;
    transition: opacity 0.2s ease;
}

#question-list.is-loading {
    opacity: 0.65;
    pointer-events: none;
}

.qmx-list-skeleton {
    display: grid;
    gap: 12px;
}

.qmx-list-skeleton__row {
    height: 104px;
    border-radius: var(--qmx-radius-lg);
    background: linear-gradient(90deg, #f8fafc 25%, #eef2f7 50%, #f8fafc 75%);
    background-size: 200% 100%;
    animation: qmxSkeleton 1.2s linear infinite;
}

.qmx-list-skeleton__row--short {
    width: 62%;
}

.qmx-question-feed {
    display: grid;
    gap: 16px;
}

.qmx-question-card {
    overflow: hidden;
    border: 1px solid var(--qmx-line);
    border-radius: var(--qmx-radius);
    background: var(--qmx-panel);
    box-shadow: var(--qmx-shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.qmx-question-card:hover {
    transform: translateY(-2px);
    border-color: #bfd2f5;
    box-shadow: var(--qmx-shadow-lg);
}

.qmx-question-set-creator {
    display: grid;
    justify-items: center;
    gap: 14px;
    position: sticky;
    bottom: 18px;
    z-index: 20;
    width: 100%;
    margin: 28px 0 8px;
    padding: 10px 0;
    pointer-events: none;
}

.qmx-question-set-creator > .qmx-primary-button {
    min-width: 210px;
    padding: 13px 28px;
    pointer-events: auto;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

.qmx-selection-count {
    display: inline-grid;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 12px;
    line-height: 1;
}

.qmx-question-set-form {
    width: min(100%, 620px);
    padding: 18px;
    border: 1px solid var(--qmx-line);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: var(--qmx-shadow-sm);
    pointer-events: auto;
}

.qmx-question-sets-page {
    max-width: 1280px;
    margin: 0 auto;
}

.qmx-question-sets-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
    padding: 26px 30px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: var(--qmx-radius-lg);
    background: linear-gradient(135deg, #172554, #2563eb);
    color: #ffffff;
    box-shadow: var(--qmx-shadow);
}

.qmx-question-sets-hero h1 {
    margin: 6px 0 5px;
    color: #ffffff;
    font-family: var(--qmx-font-display);
    font-size: 32px;
}

.qmx-question-sets-hero p {
    margin: 0;
    color: #dbeafe;
}

.qmx-question-sets-hero .qmx-eyebrow {
    color: #bfdbfe;
}

.qmx-question-sets-hero__action {
    flex: 0 0 auto;
    padding: 12px 18px;
    background: #ffffff;
    color: var(--qmx-primary-dark);
}

.qmx-question-sets-hero__action:hover {
    background: #eff6ff;
    color: var(--qmx-primary-dark);
}

.qmx-question-set-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.qmx-question-set-card {
    overflow: hidden;
    border: 1px solid var(--qmx-line);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: var(--qmx-shadow-sm);
    color: inherit;
    text-decoration: none;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.qmx-question-set-card:hover {
    border-color: #93c5fd;
    box-shadow: var(--qmx-shadow);
    color: inherit;
    transform: translateY(-2px);
}

.qmx-question-set-card__link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.qmx-question-set-card__link:hover {
    color: inherit;
}

.qmx-question-set-card__header,
.qmx-question-set-card__meta,
.qmx-question-set-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
}

.qmx-question-set-card__header {
    padding: 12px 14px;
    border-bottom: 1px solid #e8eef6;
}

.qmx-question-set-card__header h2 {
    overflow: hidden;
    margin: 5px 0 0;
    color: var(--qmx-ink);
    font-size: 17px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qmx-question-set-status {
    padding: 5px 9px;
    border-radius: 999px;
    background: #eff6ff;
    color: var(--qmx-primary-dark);
    font-family: var(--qmx-font-ui);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.qmx-question-set-card__meta {
    padding: 10px 14px;
    justify-content: flex-start;
    flex-wrap: wrap;
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 11px;
}

.qmx-question-set-card__meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.qmx-question-set-card__summary {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 22px 18px;
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 13px;
}

.qmx-question-set-card__summary i {
    color: var(--qmx-primary);
    font-size: 18px;
}

.qmx-question-set-card__questions {
    display: grid;
    gap: 8px;
    padding: 0 18px 16px;
}

.qmx-question-set-card__questions > div {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    column-gap: 9px;
    padding: 9px 10px;
    border: 1px solid #edf2f7;
    border-radius: 10px;
    background: #fbfdff;
}

.qmx-question-set-card__questions > div > span {
    grid-row: span 2;
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 7px;
    background: var(--qmx-primary-soft);
    color: var(--qmx-primary-dark);
    font-family: var(--qmx-font-ui);
    font-size: 11px;
    font-weight: 800;
}

.qmx-question-set-card__questions strong {
    color: #172554;
    font-family: var(--qmx-font-ui);
    font-size: 12px;
}

.qmx-question-set-card__questions p {
    overflow: hidden;
    margin: 3px 0 0;
    color: var(--qmx-muted);
    font-size: 13px;
    line-height: 1.45;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qmx-question-set-card__questions small {
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 11px;
}

.qmx-question-set-card__footer {
    min-height: 48px;
    padding: 8px 10px;
    justify-content: flex-end;
    border-top: 1px solid #e8eef6;
}

.qmx-set-move-form {
    margin-right: auto;
}

.qmx-set-move-form select {
    max-width: 145px;
    min-height: 32px;
    padding: 0 28px 0 9px;
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    background: #f8fafc;
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 11px;
}

.qmx-question-set-organizer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid var(--qmx-line);
    border-radius: 12px;
    background: #ffffff;
}

.qmx-file-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--qmx-line);
    border-radius: 12px;
    background: #ffffff;
}

.qmx-file-breadcrumbs,
.qmx-file-toolbar__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.qmx-file-breadcrumbs > i {
    color: #94a3b8;
    font-size: 10px;
}

.qmx-file-breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.qmx-file-breadcrumb.is-current {
    color: var(--qmx-ink);
}

.qmx-file-toolbar__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    background: #ffffff;
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}

.qmx-file-toolbar__button:hover,
.qmx-file-toolbar__button--primary {
    border-color: var(--qmx-primary);
    background: var(--qmx-primary);
    color: #ffffff;
}

.qmx-file-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.qmx-file-card {
    position: relative;
    display: flex;
    min-height: 112px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    padding: 14px 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: var(--qmx-shadow-sm);
    cursor: pointer;
    outline: none;
    text-align: center;
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.qmx-file-card__serial {
    position: absolute;
    top: 8px;
    left: 9px;
    display: grid;
    width: 19px;
    height: 19px;
    place-items: center;
    border-radius: 6px;
    background: #f1f5f9;
    color: #64748b;
    font-family: var(--qmx-font-ui);
    font-size: 10px;
    font-weight: 800;
}

.qmx-file-card:hover,
.qmx-file-card:focus-visible {
    border-color: #bfdbfe;
    box-shadow: var(--qmx-shadow);
}

.qmx-file-card.is-selected {
    border-color: var(--qmx-primary);
    background: #eff6ff;
    box-shadow: 0 0 0 2px #bfdbfe;
}

.qmx-file-card__icon {
    color: var(--qmx-primary);
    font-size: 34px;
}

.qmx-file-card--folder .qmx-file-card__icon {
    color: #f59e0b;
}

.qmx-file-card strong {
    overflow: hidden;
    max-width: 100%;
    color: var(--qmx-ink);
    font-family: var(--qmx-font-ui);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qmx-file-card span {
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 10px;
}

.qmx-file-card__menu-toggle {
    position: absolute;
    top: 7px;
    right: 7px;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--qmx-muted);
    cursor: pointer;
}

.qmx-file-card__menu-toggle:hover,
.qmx-file-card__menu-toggle:focus-visible {
    background: #eff6ff;
    color: var(--qmx-primary);
}

.qmx-file-card__menu {
    position: absolute;
    z-index: 20;
    top: 38px;
    right: 7px;
    display: none;
    min-width: 150px;
    padding: 6px;
    border: 1px solid #dbe4f0;
    border-radius: 9px;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
    text-align: left;
}

.qmx-file-card__menu.is-open {
    display: block;
}

.qmx-file-card__menu > a,
.qmx-file-card__menu form button {
    display: block;
    width: 100%;
    padding: 7px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--qmx-ink);
    font: inherit;
    font-size: 11px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.qmx-file-card__menu > a:hover,
.qmx-file-card__menu form button:hover {
    background: #eff6ff;
    color: var(--qmx-primary);
}

.qmx-file-card__menu .qmx-file-card__menu-danger {
    color: #dc2626;
}

.qmx-file-card__menu .qmx-file-card__menu-danger:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.qmx-file-card__menu form {
    margin: 2px 0 0;
    padding-top: 4px;
    border-top: 1px solid #eef2f7;
}

.qmx-file-card__menu form label {
    display: block;
    padding: 5px 8px;
    color: var(--qmx-muted);
    font-size: 10px;
}

.qmx-file-card__menu form select {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 5px;
    border: 1px solid #dbe4f0;
    border-radius: 6px;
    font-size: 10px;
}

.qmx-file-move-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 10px;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #eff6ff;
    color: var(--qmx-primary-dark);
    font-family: var(--qmx-font-ui);
    font-size: 12px;
}

.qmx-file-move-toolbar select {
    min-height: 32px;
    margin-left: auto;
    padding: 0 26px 0 9px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #ffffff;
    color: var(--qmx-ink);
    font-size: 11px;
}

.qmx-question-set-folders {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.qmx-folder-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}

.qmx-folder-chip:hover,
.qmx-folder-chip.is-active {
    border-color: #bfdbfe;
    background: var(--qmx-primary-soft);
    color: var(--qmx-primary-dark);
}

.qmx-folder-chip span {
    display: inline-grid;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    place-items: center;
    border-radius: 999px;
    background: #e2e8f0;
    font-size: 10px;
}

.qmx-folder-create-form {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
}

.qmx-folder-create-form input {
    width: 150px;
    min-height: 32px;
    padding: 0 9px;
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    font-family: var(--qmx-font-ui);
    font-size: 11px;
}

.qmx-question-sets-empty {
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 72px 24px;
    border: 1px dashed #bfdbfe;
    border-radius: 18px;
    background: #ffffff;
    text-align: center;
}

.qmx-question-sets-empty > i {
    color: var(--qmx-primary);
    font-size: 34px;
}

.qmx-question-sets-empty h2,
.qmx-question-sets-empty p {
    margin: 0;
}

.qmx-question-sets-empty p {
    color: var(--qmx-muted);
}

.qmx-question-sets-empty__dashboard-link {
    min-height: 48px;
    padding: 12px 26px;
    border-radius: 14px;
    font-size: 13px;
    text-decoration: none;
}

.qmx-question-sets-empty__dashboard-link i {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.qmx-question-sets-empty__dashboard-link:hover i {
    transform: translateX(3px);
}

.qmx-question-set-detail-page {
    max-width: 1120px;
    margin: 0 auto;
}

.qmx-question-set-detail-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    position: relative;
    margin-bottom: 20px;
    padding: 26px 30px 27px 34px;
    overflow: hidden;
    border: 1px solid #dbe5f1;
    border-left: 6px solid var(--qmx-primary);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.07);
}

.qmx-question-set-detail-hero::after {
    position: absolute;
    top: 0;
    right: 0;
    width: 34%;
    height: 100%;
    background: linear-gradient(90deg, transparent, #eff6ff);
    content: "";
    pointer-events: none;
}

.qmx-question-set-detail-hero__content,
.qmx-question-set-detail-hero__actions,
.qmx-question-set-detail-hero__action {
    position: relative;
    z-index: 1;
}

.qmx-question-set-detail-hero__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.qmx-question-set-detail-hero__print-form {
    display: flex;
    margin: 0;
}

.qmx-question-set-detail-hero h1 {
    margin: 7px 0 8px;
    color: var(--qmx-ink);
    font-family: var(--qmx-font-display);
    font-size: clamp(28px, 4vw, 38px);
    line-height: 1.15;
}

.qmx-question-set-detail-hero p {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin: 0;
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 13px;
    font-weight: 700;
}

.qmx-question-set-detail-hero p span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.qmx-question-set-detail-hero p i {
    color: var(--qmx-primary);
}

.qmx-question-set-detail-hero__action {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 11px;
    background: var(--qmx-primary);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
    white-space: nowrap;
}

.qmx-question-set-detail-hero__action:hover {
    background: var(--qmx-primary-dark);
}

.qmx-subset-list {
    margin-bottom: 18px;
    padding: 20px;
    border: 1px solid #dbe7f5;
    border-radius: 18px;
    background: linear-gradient(145deg, #ffffff 0%, #f7fbff 100%);
    box-shadow: 0 12px 28px rgba(30, 64, 175, 0.07);
}

.qmx-subset-list__heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.qmx-subset-list__heading h2 {
    margin: 5px 0 0;
    color: var(--qmx-ink);
    font-size: 23px;
    letter-spacing: -0.01em;
}

.qmx-subset-list__heading > span {
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--qmx-primary-soft);
    color: var(--qmx-primary-dark);
    font-family: var(--qmx-font-ui);
    font-size: 11px;
    font-weight: 800;
}

.qmx-subset-list__items {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.qmx-subset-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    min-height: 72px;
    padding: 12px 13px;
    border: 1px solid #dce8f6;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.82);
    color: inherit;
    text-decoration: none;
    box-shadow: 0 3px 8px rgba(30, 64, 175, 0.04);
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.qmx-subset-item:hover {
    border-color: #60a5fa;
    background: #eff6ff;
    color: inherit;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 10px 18px rgba(37, 99, 235, 0.12);
}

.qmx-subset-item__number {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 11px;
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
    color: #ffffff;
    font-family: var(--qmx-font-ui);
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 5px 10px rgba(37, 99, 235, 0.22);
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.qmx-subset-item strong,
.qmx-subset-item span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qmx-subset-item strong {
    color: var(--qmx-ink);
    font-family: var(--qmx-font-ui);
    font-size: 14px;
    font-weight: 800;
}

.qmx-subset-item div span {
    margin-top: 4px;
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 11px;
}

.qmx-subset-item > .qmx-subset-item__number {
    display: grid;
    place-items: center;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}

.qmx-subset-item > i {
    margin-left: auto;
    color: #2563eb;
    font-size: 13px;
    opacity: 0.65;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.qmx-subset-item:hover > i {
    opacity: 1;
    transform: translate(2px, -2px);
}

@media (max-width: 720px) {
    .qmx-subset-list {
        padding: 15px;
    }

    .qmx-subset-list__items {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .qmx-subset-list__items {
        grid-template-columns: 1fr;
    }
}

.qmx-feedback--info {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.qmx-subset-modal[hidden] {
    display: none;
}

.qmx-subset-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 20px;
}

.qmx-subset-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
}

.qmx-subset-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 560px);
    padding: 26px;
    border: 1px solid #dbe5f1;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.qmx-subset-modal__dialog h2 {
    margin: 7px 0 5px;
    color: var(--qmx-ink);
    font-size: 25px;
}

.qmx-subset-modal__intro {
    margin: 0 0 20px;
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 13px;
    line-height: 1.55;
}

.qmx-subset-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    color: var(--qmx-muted);
    cursor: pointer;
}

.qmx-subset-fieldset {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 14px;
    padding: 0;
    border: 0;
}

.qmx-subset-fieldset legend {
    width: 100%;
    margin-bottom: 7px;
    color: var(--qmx-ink);
    font-family: var(--qmx-font-ui);
    font-size: 12px;
    font-weight: 800;
}

.qmx-subset-fieldset label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    color: var(--qmx-muted);
    font-family: var(--qmx-font-ui);
    font-size: 11px;
    font-weight: 700;
}

.qmx-subset-capacity {
    margin-bottom: 16px;
    padding: 11px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 9px;
    background: #eff6ff;
    color: var(--qmx-primary-dark);
    font-family: var(--qmx-font-ui);
    font-size: 12px;
    line-height: 1.5;
}

.qmx-subset-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}

.qmx-subset-form-grid label {
    display: grid;
    gap: 6px;
    color: var(--qmx-ink);
    font-family: var(--qmx-font-ui);
    font-size: 12px;
    font-weight: 800;
}

.qmx-subset-form-grid input,
.qmx-subset-form-grid select {
    box-sizing: border-box;
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    background: #ffffff;
    color: var(--qmx-ink);
    font-family: var(--qmx-font-ui);
    font-size: 12px;
}

.qmx-subset-generate-button {
    width: 100%;
    min-height: 42px;
    padding: 0 16px;
}

.qmx-set-question-list {
    display: grid;
    gap: 16px;
}

.qmx-set-question-card {
    overflow: hidden;
    border: 1px solid var(--qmx-line);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: var(--qmx-shadow-sm);
}

.qmx-set-question-card > header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid #e8eef6;
}

.qmx-set-question-card > header > div {
    min-width: 0;
    flex: 1;
}

.qmx-set-question-remove-form {
    margin-left: auto;
}

.qmx-set-question-card > header strong,
.qmx-set-question-card > header span:not(.qmx-question-number) {
    display: block;
}

.qmx-set-question-card > header strong {
    color: #172554;
    font-family: var(--qmx-font-ui);
}

.qmx-set-question-card > header span:not(.qmx-question-number) {
    margin-top: 4px;
    color: var(--qmx-muted);
    font-size: 12px;
}

.qmx-set-question-card__body {
    padding: 18px 22px;
}

.qmx-set-question-text {
    color: var(--qmx-ink);
    font-size: 17px;
    line-height: 1.8;
    white-space: pre-wrap;
}

.qmx-set-option-grid,
.qmx-set-creative-parts {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.qmx-set-option-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.qmx-set-option-grid > div,
.qmx-set-creative-parts > div {
    display: flex;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fbfdff;
}

.qmx-set-creative-parts > div {
    display: block;
}

.qmx-set-creative-parts > div > strong {
    display: inline-block;
    margin-right: 8px;
}

.qmx-set-creative-parts .qmx-content-with-media {
    display: inline;
}

.qmx-set-creative-parts .qmx-answer-panel {
    width: 100%;
    box-sizing: border-box;
    margin-top: 14px;
}

.qmx-set-option-grid strong,
.qmx-set-creative-parts strong {
    flex: 0 0 auto;
    color: var(--qmx-primary-dark);
}

@media (max-width: 640px) {
    .qmx-question-sets-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 22px;
    }

    .qmx-question-set-grid {
        grid-template-columns: 1fr;
    }

    .qmx-question-set-organizer {
        align-items: stretch;
        flex-direction: column;
    }

    .qmx-folder-create-form input {
        flex: 1;
        width: auto;
    }

    .qmx-set-move-form select {
        max-width: 125px;
    }

    .qmx-set-option-grid {
        grid-template-columns: 1fr;
    }

}

@media (min-width: 641px) and (max-width: 980px) {
    .qmx-question-set-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .qmx-question-set-organizer {
        align-items: flex-start;
        flex-direction: column;
    }
}

.qmx-question-set-form label {
    display: block;
    margin-bottom: 8px;
    color: var(--qmx-ink);
    font-family: var(--qmx-font-ui);
    font-size: 13px;
    font-weight: 700;
}

.qmx-question-set-form__row {
    display: flex;
    gap: 10px;
}

.qmx-question-set-form input[type="text"] {
    min-width: 0;
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
}

.qmx-question-set-form .qmx-question-set-save {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

@media (max-width: 640px) {
    .qmx-question-set-form__row {
        flex-direction: column;
    }
}

.qmx-question-card__header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding: 16px 18px;
    border-bottom: 1px solid #e8eef6;
    background: linear-gradient(180deg, #ffffff, #fbfdff);
}

.qmx-question-identity {
    display: flex;
    min-width: 0;
    gap: 12px;
    align-items: flex-start;
}

.qmx-question-select {
    display: inline-grid;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    place-items: center;
    cursor: pointer;
}

.qmx-question-select input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.qmx-question-select span {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.qmx-question-select input:checked + span {
    border-color: var(--qmx-primary);
    background: var(--qmx-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.qmx-question-select input:checked + span::after {
    width: 9px;
    height: 5px;
    border-bottom: 2px solid #ffffff;
    border-left: 2px solid #ffffff;
    content: '';
    transform: rotate(-45deg) translate(1px, -1px);
}

.qmx-question-select input:focus-visible + span {
    outline: 3px solid rgba(37, 99, 235, 0.25);
    outline-offset: 2px;
}

.qmx-question-number {
    display: inline-grid;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 10px;
    background: var(--qmx-primary);
    color: #ffffff;
    font-family: var(--qmx-font-ui);
    font-size: 14px;
    font-weight: 800;
}

.qmx-reference-code {
    display: inline-block;
    margin-bottom: 8px;
    color: #172554;
    font-family: "Times New Roman", serif;
    font-size: 19px;
    font-weight: 800;
    text-decoration: none;
}

.qmx-reference-code:hover {
    color: var(--qmx-primary);
}

.qmx-badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.qmx-badge {
    display: inline-flex;
    min-height: 25px;
    align-items: center;
    padding: 4px 9px;
    border-radius: var(--qmx-radius-pill);
    background: #eef2ff;
    color: #4338ca;
    font-family: var(--qmx-font-ui);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
}

.qmx-badge--type {
    background: #e0f2fe;
    color: #0369a1;
}

.qmx-badge--status[data-status="verified"] {
    background: #dcfce7;
    color: #166534;
}

.qmx-badge--status[data-status="needs_correction"],
.qmx-badge--status[data-status="rejected"] {
    background: #fee2e2;
    color: #991b1b;
}

.qmx-badge--status[data-status="pending_review"] {
    background: #fef3c7;
    color: #92400e;
}

.qmx-card-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 7px;
    align-items: center;
}

.qmx-icon-button {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #ffffff;
    color: #334155;
    font-family: var(--qmx-font-ui);
    font-size: 15px;
    line-height: 1;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.qmx-icon-button:hover {
    border-color: #93c5fd;
    background: var(--qmx-primary-soft);
    color: var(--qmx-primary-dark);
}

.qmx-icon-button--primary {
    border-color: var(--qmx-primary);
    background: var(--qmx-primary);
    color: #ffffff;
}

.qmx-icon-button--primary:hover {
    background: var(--qmx-primary-dark);
    color: #ffffff;
}

.qmx-icon-button--danger {
    border-color: #fecaca;
    background: #fff;
    color: var(--qmx-danger);
}

.qmx-icon-button--danger:hover {
    border-color: #fca5a5;
    background: var(--qmx-danger-soft);
    color: #b91c1c;
}

.qmx-delete-question-form {
    display: contents;
}

.qmx-question-card__content {
    padding: 20px 22px;
}

.qmx-math-content {
    max-width: 100%;
    color: #111827;
    font-family: var(--qmx-font-body);
    font-size: 17px;
    line-height: 1.95;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.qmx-math-content--inline {
    display: inline;
}

.qmx-question-stem {
    margin-bottom: 10px;
    color: #111827;
    font-size: 18px;
}

.qmx-question-card__content > .qmx-content-with-media {
    margin-bottom: 10px;
}

.qmx-question-card__content > .qmx-content-with-media .qmx-content-paragraph {
    line-height: 1.55;
}

.qmx-content-paragraph {
    display: block;
    margin: 0 0 14px;
}

.qmx-content-paragraph:last-child {
    margin-bottom: 0;
}

.qmx-math-content mjx-container {
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
    padding: 2px 0;
}

.qmx-math-content mjx-container[display="true"] {
    display: block;
    width: 100%;
    margin: 0.7em 0 !important;
    text-align: center !important;
}

.qmx-answer-panel .qmx-content-paragraph {
    margin-bottom: 5px;
    line-height: 1.55;
}

.qmx-answer-panel .qmx-content-paragraph mjx-container[display="true"] {
    margin: 0.25em 0 !important;
}

.qmx-option-grid,
.qmx-detail-option-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.qmx-option-item,
.qmx-detail-option {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    min-width: 0;
    gap: 11px;
    align-items: flex-start;
    padding: 12px 13px;
    border: 1px solid #dce6f2;
    border-radius: 12px;
    background: #fbfdff;
}

.qmx-option-item > .qmx-content-with-media,
.qmx-detail-option > .qmx-detail-option__content {
    min-width: 0;
}

.qmx-option-item > .qmx-content-with-media {
    align-self: center;
}

.qmx-option-item > .qmx-content-with-media > .qmx-content-paragraph {
    display: inline-flex;
    align-items: center;
    min-height: 29px;
    width: 100%;
    margin: 0 !important;
    line-height: 1.4;
    white-space: nowrap;
}

.qmx-option-item .qmx-math-content mjx-container[display="true"] {
    display: inline-block !important;
    width: auto !important;
    margin: 0 !important;
    vertical-align: middle;
    text-align: left !important;
}

.qmx-option-item .qmx-math-content > mjx-container {
    display: inline-block !important;
    width: auto !important;
    margin: 0 !important;
    vertical-align: middle;
}

.qmx-option-item.is-correct-visible,
.qmx-detail-option.is-correct-visible {
    border-color: #86efac;
    background: var(--qmx-success-soft);
}

.qmx-option-label {
    display: inline-grid;
    flex: 0 0 auto;
    width: 29px;
    height: 29px;
    place-items: center;
    border-radius: 50%;
    background: #e8f0ff;
    color: #1d4ed8;
    font-family: var(--qmx-font-display);
    font-size: 13px;
    font-weight: 800;
}

.qmx-option-text,
.qmx-part-text {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    line-height: 1.75;
}

.qmx-correct-mark {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-grid;
    width: 23px;
    height: 23px;
    place-items: center;
    border-radius: 50%;
    background: #16a34a;
    color: #ffffff;
    font-family: var(--qmx-font-ui);
    font-size: 12px;
    font-weight: 900;
}

.qmx-creative-part-list {
    display: grid;
    gap: 9px;
    margin-top: 14px;
}

.qmx-creative-part {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: flex-start;
    padding: 11px 13px;
    border-left: 3px solid #3b82f6;
    border-radius: 0 10px 10px 0;
    background: #f8fafc;
}

.qmx-part-body {
    min-width: 0;
}

.qmx-creative-part > .qmx-answer-panel {
    grid-column: 1 / -1;
    min-width: 0;
}

.qmx-part-meta {
    display: grid;
    gap: 5px;
    justify-items: center;
    color: var(--qmx-muted);
    font-size: 10px;
}

.qmx-answer-actions {
    margin-top: 16px;
}

.qmx-answer-toggle {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid #86efac;
    border-radius: 10px;
    background: #f0fdf4;
    color: var(--qmx-success);
    font-family: var(--qmx-font-display);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.qmx-answer-toggle::after {
    content: "⌄";
    font-family: var(--qmx-font-ui);
    font-size: 15px;
    transition: transform 0.18s ease;
}

.qmx-answer-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

.qmx-answer-toggle--compact {
    margin-top: 12px;
}

.qmx-answer-panel {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    background: #f0fdf4;
}

.qmx-answer-panel--columns {
    width: 100%;
    box-sizing: border-box;
}

.qmx-answer-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.qmx-answer-columns .qmx-answer-block + .qmx-answer-block {
    margin-top: 0;
    padding-top: 0;
    padding-left: 16px;
    border-top: 0;
    border-left: 1px solid #bbf7d0;
}

.qmx-answer-columns .qmx-answer-block:only-child {
    grid-column: 1 / -1;
}

@media (max-width: 720px) {
    .qmx-answer-columns {
        grid-template-columns: 1fr;
    }

    .qmx-answer-columns .qmx-answer-block + .qmx-answer-block {
        padding-top: 12px;
        padding-left: 0;
        border-left: 0;
        border-top: 1px solid #bbf7d0;
    }
}

.qmx-answer-block + .qmx-answer-block {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #bbf7d0;
}

.qmx-answer-block > strong {
    display: block;
    margin-bottom: 7px;
    color: #166534;
}

.qmx-answer-option-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.qmx-answer-chip {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 50%;
    background: #16a34a;
    color: #ffffff;
    font-weight: 800;
}

.qmx-answer-inline {
    display: inline-block;
    font-size: 15px;
}

.qmx-question-card__footer {
    display: flex;
    justify-content: space-between;
    gap: 13px;
    align-items: center;
    padding: 12px 18px;
    border-top: 1px solid #e8eef6;
    background: #f8fafc;
}

.qmx-meta-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--qmx-muted);
    font-size: 11px;
}

.qmx-meta-list strong {
    color: #334155;
}

.qmx-source-pill {
    display: inline-flex;
    max-width: 44%;
    min-height: 27px;
    align-items: center;
    padding: 5px 9px;
    border-radius: var(--qmx-radius-pill);
    background: #fef3c7;
    color: #92400e;
    font-size: 11px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.qmx-source-pill--empty {
    background: #e2e8f0;
    color: #64748b;
}

.qmx-empty-state {
    padding: 46px 24px;
    border: 1px solid var(--qmx-line);
    border-radius: var(--qmx-radius-lg);
    background: var(--qmx-panel);
    box-shadow: var(--qmx-shadow-sm);
    text-align: center;
}

.qmx-empty-state__icon {
    display: grid;
    width: 54px;
    height: 54px;
    margin: 0 auto 13px;
    place-items: center;
    border-radius: 50%;
    background: var(--qmx-primary-soft);
    color: var(--qmx-primary);
    font-size: 27px;
    font-weight: 900;
}

.qmx-empty-state h2 {
    margin-bottom: 7px;
}

.qmx-empty-state p {
    margin-bottom: 20px;
    color: var(--qmx-muted);
}

.qmx-pagination {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    padding: 13px 16px;
    margin-top: 4px;
    border: 1px solid var(--qmx-line);
    border-radius: 14px;
    background: var(--qmx-panel);
    box-shadow: var(--qmx-shadow-sm);
    color: var(--qmx-muted);
    font-size: 13px;
}

.qmx-pagination__actions {
    display: flex;
    gap: 8px;
}

.qmx-pagination__count {
    color: var(--qmx-muted);
}

.qmx-page-button {
    display: inline-flex;
    min-height: 35px;
    align-items: center;
    padding: 7px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #ffffff;
    color: #1e293b;
    font-weight: 700;
    text-decoration: none;
}

.qmx-page-button:hover {
    border-color: #93c5fd;
    background: var(--qmx-primary-soft);
}

.qmx-page-button.is-disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

/* =========================================================================
   7. DETAIL PAGE (questions.show)
   ========================================================================= */
.qmx-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
    gap: 22px;
    align-items: start;
}

.qmx-detail-main {
    display: grid;
    min-width: 0;
    gap: 18px;
}

.qmx-detail-sidebar {
    position: sticky;
    top: 86px;
    display: grid;
    gap: 16px;
}

.qmx-detail-card,
.qmx-meta-card {
    margin: 0;
    padding: 22px;
    border: 1px solid var(--qmx-line);
    border-radius: var(--qmx-radius-lg);
    background: var(--qmx-panel);
    box-shadow: var(--qmx-shadow);
}

.qmx-detail-card__heading {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--qmx-line);
}

.qmx-detail-card__heading h2,
.qmx-meta-card h2 {
    margin: 0;
    color: var(--qmx-ink);
    font-family: var(--qmx-font-display);
    font-size: 24px;
}

.qmx-card-score {
    display: grid;
    min-width: 70px;
    justify-items: center;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--qmx-primary-soft);
    color: var(--qmx-primary-dark);
}

.qmx-card-score strong {
    font-size: 20px;
}

.qmx-card-score span {
    font-size: 10px;
    text-transform: uppercase;
}

.qmx-detail-question-body .qmx-math-content {
    font-size: 19px;
    line-height: 2;
}

.qmx-detail-option {
    min-height: 70px;
    align-items: center;
}

.qmx-detail-option__content {
    flex: 1;
    min-width: 0;
}

.qmx-detail-option__content .qmx-content-paragraph {
    margin: 0;
    font-size: 16px;
}

.qmx-detail-parts {
    display: grid;
    gap: 13px;
}

.qmx-detail-part {
    padding: 16px;
    border: 1px solid #dce6f2;
    border-radius: 14px;
    background: #fbfdff;
}

.qmx-detail-part__heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.qmx-detail-part__heading > div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.qmx-source-history,
.qmx-revision-list {
    display: grid;
    gap: 12px;
}

.qmx-source-card {
    padding: 15px;
    border: 1px solid #dce6f2;
    border-radius: 13px;
    background: #fbfdff;
}

.qmx-source-card__top {
    display: flex;
    justify-content: space-between;
    gap: 13px;
    align-items: flex-start;
}

.qmx-source-card__top p {
    margin: 4px 0 0;
    color: var(--qmx-muted);
}

.qmx-source-year {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: var(--qmx-radius-pill);
    background: #fef3c7;
    color: #92400e;
    font-weight: 800;
}

.qmx-source-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px 14px;
    margin-top: 12px;
    color: var(--qmx-muted);
    font-size: 13px;
}

.qmx-source-grid strong {
    color: #334155;
}

.qmx-source-note {
    margin: 12px 0 0;
    padding: 10px;
    border-radius: 9px;
    background: #f1f5f9;
    color: #475569;
}

.qmx-history-details {
    padding: 0;
    overflow: hidden;
}

.qmx-history-details > summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 18px 22px;
    cursor: pointer;
    color: var(--qmx-ink);
    font-weight: 800;
    list-style: none;
}

.qmx-history-details > summary::-webkit-details-marker {
    display: none;
}

.qmx-history-details[open] > summary {
    border-bottom: 1px solid var(--qmx-line);
}

.qmx-revision-list {
    padding: 18px 22px;
}

.qmx-revision-item {
    padding: 13px;
    border: 1px solid #e2e8f0;
    border-radius: 11px;
    background: #f8fafc;
}

.qmx-revision-item > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.qmx-definition-list {
    display: grid;
    gap: 0;
    margin: 14px 0 0;
}

.qmx-definition-list > div {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 11px;
    padding: 10px 0;
    border-bottom: 1px solid #edf2f7;
}

.qmx-definition-list > div:last-child {
    border-bottom: 0;
}

.qmx-definition-list dt {
    color: var(--qmx-muted);
    font-size: 12px;
}

.qmx-definition-list dd {
    margin: 0;
    color: #1e293b;
    font-size: 13px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.qmx-meta-group {
    margin-top: 15px;
}

.qmx-meta-group > strong {
    display: block;
    margin-bottom: 8px;
    color: #475569;
    font-size: 12px;
}

.qmx-meta-card--source {
    background:
        radial-gradient(circle at 100% 0, rgba(253, 230, 138, 0.45), transparent 42%),
        #ffffff;
}

.qmx-meta-card--source p {
    margin-bottom: 8px;
    color: var(--qmx-muted);
}

.qmx-large-year {
    color: #92400e;
    font-size: 29px;
}

/* =========================================================================
   8. EDITOR PAGE (questions.create / questions.edit) + live preview drawer
   ========================================================================= */
.qmx-editor-page-container {
    width: min(100%, 1380px);
    max-width: 1380px;
}

.qmx-editor-layout {
    display: block;
}

.qmx-editor-main,
.qmx-question-form {
    width: 100%;
    max-width: none;
    min-width: 0;
}

.qmx-question-form > .card,
.qmx-media-section > .card {
    border-color: var(--qmx-line);
    border-radius: var(--qmx-radius-lg);
    box-shadow: var(--qmx-shadow);
}

.qmx-question-form textarea {
    min-height: 132px;
    padding-top: 13px;
    font-family: var(--qmx-font-body);
    font-size: 16px;
    line-height: 1.65;
}

.qmx-question-form input,
.qmx-question-form select,
.qmx-question-form textarea {
    border-radius: 10px;
}

.qmx-question-form .section-title {
    color: var(--qmx-ink);
    font-family: var(--qmx-font-display);
}

.qmx-media-section {
    margin-top: 22px;
}

.question-media-figure img {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: var(--qmx-shadow-sm);
}

.qmx-math-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: -2px 0 7px;
}

.qmx-math-tool {
    display: inline-flex;
    min-height: 29px;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    font-family: "Times New Roman", serif;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.qmx-math-tool:hover {
    border-color: #93c5fd;
    background: var(--qmx-primary-soft);
    color: var(--qmx-primary-dark);
}

.qmx-latex-help {
    margin: 6px 0 0;
    color: var(--qmx-muted);
    font-size: 11px;
}

/* -- live preview drawer -- */
.qmx-preview-toggle {
    display: inline-flex;
}

.qmx-preview-backdrop {
    position: fixed;
    inset: 0;
    z-index: 990;
    background: rgba(15, 23, 42, 0.56);
    backdrop-filter: blur(3px);
}

.qmx-preview-backdrop[hidden] {
    display: none;
}

.qmx-live-preview {
    position: fixed;
    inset: 70px 0 0 auto;
    z-index: 1000;
    display: flex;
    width: min(680px, calc(100vw - 24px));
    flex-direction: column;
    overflow: hidden;
    border-radius: 22px 0 0 0;
    background: var(--qmx-panel);
    box-shadow: var(--qmx-shadow-lg);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(104%);
    transition: transform 0.24s ease, opacity 0.2s ease, visibility 0.2s ease;
}

.qmx-live-preview.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
}

body.qmx-preview-open {
    overflow: hidden;
}

.qmx-live-preview__header {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 auto;
    padding: 16px 18px;
    border-bottom: 1px solid var(--qmx-line);
    background:
        radial-gradient(circle at 100% 0, rgba(147, 197, 253, 0.25), transparent 40%),
        #ffffff;
}

.qmx-live-preview h2 {
    margin: 0;
    font-family: var(--qmx-font-display);
    font-size: 20px;
}

.qmx-live-preview__header-actions {
    display: flex;
    align-items: center;
    gap: 9px;
}

.qmx-preview-status {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 5px 9px;
    border-radius: var(--qmx-radius-pill);
    background: #dcfce7;
    color: #166534;
    font-size: 11px;
    font-weight: 800;
}

.qmx-preview-close {
    display: inline-grid;
    width: 36px;
    height: 36px;
    padding: 0;
    place-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    color: #334155;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.qmx-preview-close:hover,
.qmx-preview-close:focus-visible {
    border-color: #93c5fd;
    background: var(--qmx-primary-soft);
    color: var(--qmx-primary-dark);
    outline: none;
}

.qmx-live-preview__body {
    flex: 1 1 auto;
    display: grid;
    gap: 13px;
    padding: 18px;
    overflow: auto;
    overscroll-behavior: contain;
}

.qmx-preview-section {
    padding: 13px;
    border: 1px solid #dce6f2;
    border-radius: 13px;
    background: #fbfdff;
}

.qmx-preview-label {
    display: block;
    margin-bottom: 9px;
    color: var(--qmx-primary-dark);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.qmx-preview-content {
    min-height: 48px;
    font-family: var(--qmx-font-body);
    font-size: 16px;
    line-height: 1.85;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.qmx-preview-content--answer {
    color: #166534;
}

.qmx-preview-content.is-json-warning {
    padding: 12px 13px;
    border: 1px solid #f59e0b;
    border-radius: 10px;
    background: var(--qmx-warning-soft);
    color: #92400e;
    font-family: var(--qmx-font-display);
    font-size: 14px;
    line-height: 1.7;
}

.qmx-preview-option-grid {
    display: grid;
    gap: 8px;
}

.qmx-preview-option {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    padding: 9px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
}

.qmx-preview-option.is-correct {
    border-color: #86efac;
    background: #f0fdf4;
}

.qmx-preview-option__label,
.qmx-preview-part__label {
    display: inline-grid;
    flex: 0 0 auto;
    width: 25px;
    height: 25px;
    place-items: center;
    border-radius: 50%;
    background: #e8f0ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 800;
}

.qmx-preview-option__text,
.qmx-preview-part__text {
    min-width: 0;
    font-family: var(--qmx-font-body);
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.qmx-preview-parts {
    display: grid;
    gap: 8px;
}

.qmx-preview-part {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 9px;
    align-items: flex-start;
    padding: 9px;
    border-left: 3px solid #3b82f6;
    border-radius: 0 10px 10px 0;
    background: #ffffff;
}

.qmx-preview-content mjx-container[display="true"],
.qmx-preview-option__text mjx-container[display="true"],
.qmx-preview-part__text mjx-container[display="true"] {
    min-width: max-content;
    margin: 0.75em 0 !important;
}

.qmx-live-preview__footer {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 12px;
    flex: 0 0 auto;
    padding: 11px 16px;
    border-top: 1px solid var(--qmx-line);
    background: #f8fafc;
    color: var(--qmx-muted);
    font-size: 11px;
}

.qmx-live-preview__footer code {
    color: var(--qmx-accent);
}

.qmx-floating-preview-button {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 220;
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 0;
    border-radius: var(--qmx-radius-pill);
    background: linear-gradient(135deg, var(--qmx-primary), var(--qmx-accent));
    color: #ffffff;
    box-shadow: 0 15px 35px rgba(37, 99, 235, 0.3);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.qmx-floating-preview-button:hover,
.qmx-floating-preview-button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 18px 38px rgba(37, 99, 235, 0.38);
    outline: none;
}

body.qmx-preview-open .qmx-floating-preview-button {
    opacity: 0;
    pointer-events: none;
}

.qmx-question-form .question-form-actions {
    box-sizing: border-box;
}

/* =========================================================================
   9. RESPONSIVE
   ========================================================================= */
@media (max-width: 1120px) {
    .qmx-editor-page-container {
        max-width: 100%;
    }

    .qmx-live-preview {
        inset: 62px 0 0 auto;
        width: min(620px, 100vw);
        border-radius: 18px 0 0 0;
    }
}

@media (max-width: 1100px) {
    .qmx-library-layout {
        grid-template-columns: 1fr;
    }

    .qmx-library-layout > .qmx-filter-sidebar,
    .qmx-library-layout > .qmx-list-panel {
        grid-column: auto;
        grid-row: auto;
    }

    .qmx-filter-sidebar {
        position: relative;
        top: auto;
        max-height: none;
        padding-right: 0;
    }

    .qmx-filter-fields {
        display: grid;
        gap: 14px;
    }

    .qmx-filter-card:not(.is-filter-expanded) .qmx-filter-fields {
        display: none;
    }

    .qmx-filter-heading__actions .qmx-filter-toggle {
        display: inline-grid;
        place-items: center;
    }

    .qmx-filter-toggle i {
        transition: transform .2s ease;
    }

    .qmx-filter-card.is-filter-expanded .qmx-filter-toggle i {
        transform: rotate(180deg);
    }
}

@media (max-width: 940px) {
    .qmx-detail-layout {
        grid-template-columns: 1fr;
    }

    .qmx-detail-sidebar {
        position: static;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .qmx-filter-card {
        padding: 16px;
    }

    .qmx-filter-card__heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .qmx-question-list__topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

@media (max-width: 720px) {
    .qmx-question-set-detail-hero {
        align-items: flex-start;
        flex-direction: column;
        gap: 18px;
        padding: 22px 22px 22px 26px;
    }

    .qmx-question-set-detail-hero::after {
        width: 55%;
    }

    .qmx-question-set-detail-hero__action {
        width: 100%;
    }

    .qmx-question-set-detail-hero__actions {
        width: 100%;
    }

    .qmx-question-set-detail-hero__print-form {
        width: 100%;
    }

    .qmx-library-hero,
    .qmx-detail-hero,
    .qmx-editor-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 22px;
    }

    .qmx-library-hero__actions,
    .qmx-detail-hero__actions,
    .qmx-editor-hero__actions {
        width: 100%;
        justify-content: flex-start;
    }

    .qmx-question-card__header,
    .qmx-question-card__footer,
    .qmx-pagination {
        align-items: flex-start;
        flex-direction: column;
    }

    .qmx-card-actions {
        width: 100%;
    }

    .qmx-card-actions .qmx-icon-button {
        flex: 1;
    }

    .qmx-option-grid,
    .qmx-detail-option-grid,
    .qmx-source-grid,
    .qmx-detail-sidebar {
        grid-template-columns: 1fr;
    }

    .qmx-source-pill {
        max-width: 100%;
    }

    .qmx-pagination__actions {
        width: 100%;
    }

    .qmx-page-button {
        flex: 1;
        justify-content: center;
    }

    .qmx-live-preview {
        inset: 54px 0 0 0;
        width: 100vw;
        border-radius: 0;
    }

    .qmx-live-preview__header,
    .qmx-live-preview__body {
        padding: 13px 14px;
    }

    .qmx-floating-preview-button {
        right: 14px;
        bottom: 14px;
    }
}

@media (max-width: 480px) {
    .qmx-question-card__content,
    .qmx-detail-card,
    .qmx-meta-card {
        padding: 16px;
    }

    .qmx-question-card__header {
        padding: 14px;
    }

    .qmx-reference-code {
        font-size: 16px;
    }

    .qmx-math-content,
    .qmx-question-stem,
    .qmx-detail-question-body .qmx-math-content {
        font-size: 16px;
    }

    .qmx-detail-card__heading,
    .qmx-detail-part__heading {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* =========================================================================
   10. PRINT
   ========================================================================= */
@media print {
    .topbar,
    .qmx-detail-hero__actions,
    .qmx-back-link,
    .qmx-answer-toggle,
    .qmx-detail-sidebar,
    .qmx-history-details,
    .qmx-card-actions,
    .qmx-preview-backdrop,
    .qmx-live-preview,
    .qmx-floating-preview-button,
    .qmx-preview-toggle {
        display: none !important;
    }

    body {
        background: #ffffff;
    }

    .page-container {
        max-width: none !important;
        padding: 0 !important;
    }

    .qmx-detail-hero {
        margin: 0 0 12px;
        padding: 0 0 12px;
        border: 0;
        border-bottom: 2px solid #111827;
        border-radius: 0;
        background: none;
        color: #111827;
        box-shadow: none;
    }

    .qmx-detail-hero h1,
    .qmx-detail-hero p,
    .qmx-detail-hero .qmx-eyebrow {
        color: #111827;
    }

    .qmx-detail-layout {
        display: block;
    }

    .qmx-detail-card {
        break-inside: avoid;
        margin-bottom: 12px;
        padding: 12px;
        border-color: #64748b;
        box-shadow: none;
    }

    .qmx-answer-panel[hidden] {
        display: block;
    }
}



/* =========================================================================
   11. MULTI-SELECT SEARCHABLE DROPDOWN  (.qmf-*)
   ========================================================================= */
.qmf-widget {
    position: relative;
    display: grid;
    gap: 0;
}

.qmf-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
    min-height: 42px;
    padding: 4px 10px 4px 12px;
    border: 1px solid #dfe7f0;
    border-radius: 12px;
    background: #fcfdff;
    cursor: text;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.qmf-widget.is-open .qmf-search-wrap {
    border-color: var(--qmx-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
    border-radius: 12px 12px 0 0;
}

.qmf-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
    padding: 2px 0;
}

.qmf-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px 3px 9px;
    border-radius: 999px;
    background: var(--qmx-primary);
    color: #ffffff;
    font-family: var(--qmx-font-ui);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qmf-tag__remove {
    display: inline-grid;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    border: none;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    font-family: var(--qmx-font-ui);
    transition: background 0.15s ease;
}

.qmf-tag__remove:hover {
    background: rgba(255, 255, 255, 0.45);
}

.qmf-input {
    flex: 1;
    min-width: 80px;
    height: 30px;
    border: none;
    background: transparent;
    color: #0f172a;
    font-size: 13px;
    outline: none;
    padding: 0 4px;
}

.qmf-input::placeholder {
    color: #94a3b8;
}

.qmf-clear {
    display: inline-grid;
    width: 22px;
    height: 22px;
    place-items: center;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    font-family: var(--qmx-font-ui);
    transition: background 0.15s ease, color 0.15s ease;
}

.qmf-clear:hover {
    background: #cbd5e1;
    color: #1e293b;
}

.qmf-clear[hidden] {
    display: none;
}

.qmf-chevron {
    display: inline-grid;
    width: 22px;
    height: 22px;
    place-items: center;
    flex-shrink: 0;
    color: #94a3b8;
    font-size: 12px;
    transition: transform 0.18s ease;
    pointer-events: none;
    font-family: var(--qmx-font-ui);
}

.qmf-widget.is-open .qmf-chevron {
    transform: rotate(180deg);
}

/* Dropdown panel */
.qmf-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 200;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--qmx-primary);
    border-top: none;
    border-radius: 0 0 12px 12px;
    background: #ffffff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
    scrollbar-width: thin;
    scrollbar-color: #d8e2ee transparent;
}

.qmf-panel[hidden] {
    display: none;
}

.qmf-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 13px;
    border: none;
    background: transparent;
    color: #1e293b;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease;
    font-family: inherit;
}

.qmf-option:hover,
.qmf-option:focus-visible {
    background: #eff6ff;
    outline: none;
}

.qmf-option.is-selected {
    background: #eff6ff;
    color: var(--qmx-primary-dark);
    font-weight: 700;
}

.qmf-option__check {
    display: inline-grid;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    place-items: center;
    border: 2px solid #cbd5e1;
    border-radius: 4px;
    background: #ffffff;
    color: #ffffff;
    font-size: 10px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.qmf-option.is-selected .qmf-option__check {
    border-color: var(--qmx-primary);
    background: var(--qmx-primary);
}

.qmf-option__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qmf-option__sub {
    color: #94a3b8;
    font-size: 11px;
    flex-shrink: 0;
}

.qmf-empty,
.qmf-loading {
    padding: 12px 14px;
    color: #94a3b8;
    font-size: 13px;
    text-align: center;
    font-family: var(--qmx-font-ui);
}

.qmf-select-all {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 13px;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    text-align: left;
    font-family: var(--qmx-font-ui);
    transition: background 0.12s ease;
}

.qmf-select-all:hover {
    background: #f1f5f9;
    color: var(--qmx-primary-dark);
}

/* Loading spinner */
.qmf-widget.is-loading .qmf-search-wrap::after {
    content: "";
    position: absolute;
    right: 38px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid #bfdbfe;
    border-top-color: var(--qmx-primary);
    border-radius: 50%;
    animation: qmxRotate 0.8s linear infinite;
}

/* Disabled state */
.qmf-widget.is-disabled .qmf-search-wrap {
    cursor: not-allowed;
    opacity: 0.65;
    background: #f8fafc;
}

.qmf-widget.is-disabled .qmf-input {
    pointer-events: none;
}

/* Math in options */
.qmf-option mjx-container {
    display: inline !important;
    margin: 0 !important;
}

/* Filter dropdown slot */
.qmx-filter-dropdowns {
    display: grid;
    gap: 14px;
}