/**
 * Step 3: Topic selector and selected topics panel
 * Styling to match question-generators reference (same dropdowns and layout)
 */
 .step-3-layout .right-panel .right-panel-topics-container{z-index: 999;}

/* Step 3 container and two-column layout */
.step-3-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    text-align: left;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    margin-top:30px;
}
.step-3-container .step-title,
.step-3-container .step-description {
    text-align: center;
}
.step-3-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    width: 100%;
    margin-top: 8px;
    min-height: 0;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}
/* Panel columns: support both class names */
.step-3-layout .step-3-left,
.step-3-layout .left-panel,
.step-3-layout #qg-left-panel-wrapper {
    flex: 2;
    min-width: 0;
    width: 100%;
}
.step-3-layout .step-3-right,
.step-3-layout .right-panel {
    flex: 0 0 320px;
    width: 320px;
    min-width: 320px;
    max-width: 320px;
}

/* Left panel: year navigation bar (tabs) */
.step-3-container .year-navigation-bar {
    display: flex;
    margin-bottom: 16px;
}
.step-3-container .year-nav-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.step-3-container .year-nav-item {
    padding: 8px 16px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.step-3-container .year-nav-item:hover {
    border-color: #3B82F6;
    color: #3B82F6;
}
.step-3-container .year-nav-item.active {
    background: #3B82F6;
    border-color: #3B82F6;
    color: #fff;
}

/* Left panel: year heading + header controls */
.step-3-container .year-header-section {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
    position: sticky;
    top: 100px;
    z-index: 99;
    background-color: var(--bg-white);
    padding-top: 12px;
    padding-bottom: 12px;
    margin-top: -12px;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: calc(50vw - 50%);
    padding-right: calc(50vw - 50%);
    box-sizing: border-box;
}

/* Search container (moved outside year header) */
.step-3-container .qg-search-container {
    width: 100%;
    margin-bottom: 16px;
}

.step-3-container .year-header-section {
    padding-left: calc(50vw - 50%);
    padding-right: calc(50vw - 50%);
}

.step-3-container .year-header-section .year-heading {
    margin-left: 0;
}

.step-3-container .year-header-section .header-controls {
    margin-right: 0;
}
.step-3-container .year-heading {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin: 0;
}
.step-3-container .header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.step-3-container .search-filter-group-header {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 220px;
}
.step-3-container .search-filter-group-header .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9CA3AF;
    pointer-events: none;
}
.step-3-container .filter-search-header {
    width: 100%;
    padding: 10px 36px 10px 40px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.step-3-container .filter-search-header:focus {
    outline: none;
    border-color: #6b7280;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.1);
}
.step-3-container .search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 6px;
    border: none;
    background: none;
    color: #9CA3AF;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.step-3-container .search-clear-btn:hover {
    color: #374151;
    background: #F3F4F6;
}
.step-3-container .filter-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.step-3-container .filter-label-text {
    font-size: 14px;
    color: #6B7280;
    font-weight: 500;
}
.step-3-container .step3-filter-select {
    padding: 8px 12px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: #374151;
    cursor: pointer;
    min-width: 120px;
}
.step-3-container .step3-filter-select:focus {
    outline: none;
    border-color: #3B82F6;
}

/* Segmented control (Topic | Term) - match reference */
.step-3-container .segmented-control {
    display: inline-flex;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.step-3-container .segment-button {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
}
.step-3-container .segment-button:hover {
    background: #F3F4F6;
}
.step-3-container .segment-button.active {
    background: #3B82F6;
    color: #fff;
}
.step-3-container .segment-button + .segment-button {
    border-left: 1px solid #E5E7EB;
}
.step-3-container .segment-button.active + .segment-button,
.step-3-container .segment-button + .segment-button.active {
    border-left-color: transparent;
}

/* Left panel: white, clean */
.step-3-container .step-3-left,
.step-3-container .left-panel {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 20px;
}
.step-3-container .panel-section.filter-panel {
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    background: #fff;
    padding: 12px;
    margin-bottom: 0;
    margin-top: 4px;
}
.step-3-container .topics-list {
    max-height: 480px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.step-3-container .topics-list .empty-message {
    padding: 16px;
    color: #6B7280;
    font-size: 14px;
    text-align: center;
}
/* Term/Year accordion (dropdown section) */
.step-3-container .term-accordion {
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.step-3-container .term-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: none;
    background: #fff;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background 0.2s;
}
.step-3-container .term-header:hover {
    background: #F3F4F6;
}
.step-3-container .term-header-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.step-3-container .term-selected-count {
    background: #3B82F6;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
}
.step-3-container .term-caret {
    font-size: 16px;
    color: #6B7280;
    flex-shrink: 0;
}
.step-3-container .term-content {
    display: none;
    border-top: 1px solid #E5E7EB;
    background: #FAFAFA;
}
.step-3-container .term-accordion.expanded .term-content {
    display: block;
}
/* Dropdown item row (checkbox + number + name) */
.step-3-container .dropdown-item-row {
    display: flex;
    align-items: center;
    padding: 6px 14px 6px 12px;
    gap: 10px;
    border-bottom: 1px solid #E5E7EB;
    font-size: 14px;
    transition: background 0.15s;
}
.step-3-container .dropdown-item-row:last-child {
    border-bottom: none;
}
.step-3-container .dropdown-item-row:hover:not(.disabled) {
    background: #F3F4F6;
}
.step-3-container .dropdown-item-row.disabled {
    opacity: 0.6;
}
.step-3-container .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}
.step-3-container .dropdown-item-row.disabled .dropdown-item {
    cursor: not-allowed;
}
.step-3-container .topic-checkbox.dropdown-checkbox {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: #3B82F6;
}
.step-3-container .dropdown-item-number {
    flex-shrink: 0;
    color: #6B7280;
    font-size: 13px;
    min-width: 1.5em;
}
.step-3-container .dropdown-item-name {
    flex: 1;
    min-width: 0;
    color: #111827;
    font-weight: 500;
}
/* Load More button for pagination */
.step-3-container .load-more-container {
    padding: 12px;
    text-align: center;
    border-top: 1px solid #E5E7EB;
    background: #FAFAFA;
}
.step-3-container .load-more-btn {
    padding: 8px 16px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}
.step-3-container .load-more-btn:hover {
    background: #F3F4F6;
    border-color: #9CA3AF;
    color: #111827;
}
.step-3-container .load-more-btn:active {
    transform: translateY(1px);
}

/* Right panel: grey background, white cards */
.step-3-layout .step-3-right,
.step-3-layout .right-panel {
    display: flex;
    flex-direction: column;
    background: transparent;
    border-radius: 0;
    padding: 0;
    gap: 12px;
    align-self: flex-start;
    overflow-y: auto;
    z-index: 99;
}

/* Desktop (>=901px): spacer reserves layout space; panel stays inline until scroll pushes left panel up, then fixed via JS */
@media (min-width: 901px) {
    .step-3-layout .step-3-right-panel-desktop-spacer {
        flex: 1;
        min-width: 0;
    }
    .step-3-layout .right-panel.step-3-right-panel-desktop {
        /* default: in flow, inline with qg-left-panel-wrapper; JS applies position:fixed only when left panel scrolls out of view */
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        z-index: 99;
    }
    .step-3-layout .right-panel.step-3-right-panel-desktop.is-sticky {
        position: fixed;
        top: 50px;
        /* left and width set by JS from spacer rect */
    }
}

/* Fallback for .step-3-right when stacked (900px and below) */
@media (max-width: 900px) {
    .step-3-layout .step-3-right,
    .step-3-layout .right-panel {
        position: sticky;
        top: 120px;
        max-height: calc(100vh - 140px);
    }
}

/* Right panel search container - sits outside grey box */
.step-3-layout .right-panel .right-panel-search-container {
    width: 100%;
    margin-bottom: 8px;
    flex-shrink: 0;
}

/* Right panel topics container (grey box) */
.step-3-layout .right-panel .right-panel-topics-container {
    width: 100%;
    flex: 0 1 auto;
    min-height: 0;
    background: #F3F4F6;
    border-radius: 12px;
    padding: 16px;
}

/* Search bar in right panel - sits on top of selected topics box */
.step-3-layout .right-panel .qg-search-filter-group-header {
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 0;
    margin-top: 0;
}

.step-3-layout .right-panel .qg-search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    z-index: 1;
}

.step-3-layout .right-panel .qg-filter-search-header {
    width: 100%;
    padding: 0.625rem 2.75rem 0.625rem 2.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #111827;
    background-color: #ffffff;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    height: 40px;
    box-sizing: border-box;
    line-height: 1.5;
}

.step-3-layout .right-panel .qg-filter-search-header:hover {
    border-color: #d1d5db;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.step-3-layout .right-panel .qg-filter-search-header:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.step-3-layout .right-panel .qg-search-clear-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: all 0.15s ease;
    z-index: 1;
}

.step-3-layout .right-panel .qg-search-clear-btn:hover {
    background-color: #f3f4f6;
    color: #6b7280;
}

/* Make selected topics card sit directly below search bar with no gap */
.step-3-layout .right-panel .qg-search-filter-group-header {
    margin-bottom: 12px;
}

.step-3-layout .right-panel .selected-topics-card {
    margin-top: 0;
}
/* Right panel: Resource Options section */
.step-3-layout .right-panel .panel-section {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 16px;
}
.step-3-layout .right-panel .panel-section h2 {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 12px 0;
}
.step-3-layout .option-group {
    margin-bottom: 14px;
}
.step-3-layout .option-group:last-child {
    margin-bottom: 0;
}
.step-3-layout .option-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}
.step-3-layout .option-label .required {
    color: #EF4444;
}
/* Custom resource type dropdown */
.step-3-layout .custom-resource-dropdown {
    position: relative;
    width: 100%;
    margin-left: 0.5rem;
}
.step-3-layout .resource-dropdown-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.2s;
}
.step-3-layout .resource-dropdown-trigger:hover {
    border-color: #9CA3AF;
}
.step-3-layout .custom-resource-dropdown.open .resource-dropdown-trigger {
    border-color: #3B82F6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.step-3-layout .resource-dropdown-text {
    flex: 1;
    text-align: left;
}
.step-3-layout .resource-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 4px 0 0 0;
    padding: 4px 0;
    list-style: none;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 280px;
    overflow-y: auto;
    z-index: 20;
    display: none;
}
.step-3-layout .custom-resource-dropdown.open .resource-dropdown-menu {
    display: block;
}
.step-3-layout .resource-dropdown-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 10px 12px;
    color: #111827;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
}
.step-3-layout .resource-dropdown-item:hover {
    background: #F3F4F6;
}
.step-3-layout .resource-dropdown-detail {
    font-size: 12px;
    color: #6B7280;
}
.step-3-layout .resource-info-icon-wrapper {
    margin-left: auto;
    position: relative;
    display: none;
}
.step-3-layout .resource-info-icon {
    color: #9CA3AF;
    display: none;
}
.step-3-layout .resource-type-error-modal {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    padding: 8px 12px;
    background: #FEE2E2;
    color: #B91C1C;
    font-size: 13px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: none;
    z-index: 25;
}
.step-3-layout .resource-type-error-modal.visible {
    display: block;
}
/* Create Resource button */
.step-3-layout .action-section {
    flex-shrink: 0;
}
.step-3-layout .create-btn-wrapper {
    position: relative;
}
.step-3-layout .create-resource-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: #3B82F6;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}
.step-3-layout .create-resource-btn:hover:not(:disabled) {
    background: #2563EB;
}
.step-3-layout .create-resource-btn:disabled {
    background: #9CA3AF;
    cursor: not-allowed;
}
.step-3-layout .create-btn-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: #374151;
    color: #fff;
    font-size: 13px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 10;
}
.step-3-layout .create-btn-wrapper:hover .create-btn-tooltip {
    opacity: 1;
    visibility: visible;
}
/* Selected topics card (new structure with progress bar + count) */
.step-3-layout .selected-topics-card {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    max-height: calc(100vh - 250px);
    height: auto;
    overflow: hidden;
}
.step-3-layout .selected-topics-list {
    flex: 1;
    min-height: 0;
}
.step-3-layout .selected-topics-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    margin-bottom: 12px;
}
.step-3-layout .selection-progress-bar {
    flex: 1;
    height: 6px;
    background: #E5E7EB;
    border-radius: 3px;
    overflow: hidden;
}
.step-3-layout .progress-bar-fill {
    height: 100%;
    width: 0%;
    background: #3B82F6;
    border-radius: 3px;
    transition: width 0.2s, background-color 0.2s;
}
.step-3-layout .progress-bar-fill.panel-progress-valid {
    background: var(--success-green);
}
.step-3-layout .progress-bar-fill.panel-progress-invalid {
    background: #EF4444;
}
.step-3-layout .selection-count {
    font-size: 13px;
    font-weight: 500;
    color: #6B7280;
    flex-shrink: 0;
    white-space: nowrap;
}
.saved-codes-invalid-msg {
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    margin-top: 8px;
    margin-bottom: 0;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}
.step-3-layout .clear-all-container {
    flex-shrink: 0;
    margin-top: 12px;
    margin-bottom: 0;
    position: relative;
    z-index: 1;
}
.step-3-layout .clear-all-btn {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #6B7280;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
}
.step-3-layout .clear-all-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}
.step-3-layout .selected-topics-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}
.step-3-layout .clear-topics-btn {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #EF4444;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, border-color 0.2s;
}
.step-3-layout .clear-topics-btn:hover {
    background: #FEE2E2;
    border-color: #FECACA;
}
.step-3-layout .selected-topics-card .selected-topics-list {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    flex: 1;
}

/* Selected list: white cards on grey */
.step-3-layout .selected-topics-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    flex: 1;
}
.step-3-layout .selected-topic-item {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: box-shadow 0.2s, opacity 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.step-3-layout .selected-topic-item:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}
.step-3-layout .selected-topic-item .quantity-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    background-color: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 4px;
    padding: 1px 2px;
    flex-shrink: 0;
}
.step-3-layout .selected-topic-item .quantity-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    transition: background-color 0.2s, color 0.2s;
    padding: 0;
    line-height: 1;
}
.step-3-layout .selected-topic-item .quantity-btn:hover:not(:disabled) {
    background-color: #3B82F6;
    color: #fff;
}
.step-3-layout .selected-topic-item .quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.step-3-layout .selected-topic-item .quantity-value {
    min-width: 18px;
    text-align: center;
    font-weight: 600;
    color: #111827;
    font-size: 12px;
    padding: 0 2px;
}
.step-3-layout .selected-topic-item .selected-topic-name-display {
    flex: 1;
    min-width: 0;
    position: relative;
}
.step-3-layout .selected-topic-item .selected-topic-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    color: #111827;
}
.step-3-layout .selected-topic-item .selected-topic-tooltip {
    position: fixed;
    padding: 6px 10px;
    background: #374151;
    color: #fff;
    font-size: 13px;
    white-space: normal;
    max-width: 300px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
    z-index: 1000;
    pointer-events: none;
    word-wrap: break-word;
}
/* Only show tooltip when JS has positioned it above (class added after position set) - prevents flash below */
.step-3-layout .selected-topic-item .selected-topic-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
}
.step-3-layout .selected-topic-item .remove-btn {
    background: none;
    border: none;
    color: #EF4444;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    transition: background-color 0.2s;
}
.step-3-layout .selected-topic-item .remove-btn:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Drag to reorder */
.step-3-layout .selected-topic-item .drag-handle {
    cursor: grab;
    color: #9ca3af;
    padding: 4px 2px;
    margin: -4px 0;
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1;
    user-select: none;
    -webkit-user-select: none;
}
.step-3-layout .selected-topic-item .drag-handle:active {
    cursor: grabbing;
}
.step-3-layout .selected-topic-item.dragging {
    opacity: 0.5;
}
.step-3-layout .selected-topics-list .drag-placeholder,
.step-3-layout #selected-topics-list-desktop .drag-placeholder {
    flex-shrink: 0;
    background: rgba(59, 130, 246, 0.08);
    border: 2px dashed #93c5fd;
    border-radius: 8px;
    margin-bottom: 4px;
}
.step-3-layout .selected-topics-list .drop-indicator,
.step-3-layout #selected-topics-list-desktop .drop-indicator {
    height: 2px;
    background: #3B82F6;
    margin: 2px 0;
    flex-shrink: 0;
    border-radius: 1px;
}

/* Empty state on grey panel */
.step-3-layout .selected-topics-list .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    min-height: 200px;
}
.step-3-layout .selected-topics-list .empty-state-icon {
    margin-bottom: 16px;
    color: #D1D5DB;
    display: flex;
    align-items: center;
    justify-content: center;
}
.step-3-layout .selected-topics-list .empty-state-icon svg {
    width: 48px;
    height: 48px;
}
.step-3-layout .selected-topics-list .empty-state p {
    margin: 0 0 8px 0;
    font-weight: 500;
    font-size: 15px;
    color: #374151;
}
.step-3-layout .selected-topics-list .empty-state-subtitle {
    font-size: 13px;
    color: #9CA3AF;
    font-weight: 400;
}

/* Additional Options (collapsible) */
.step-3-layout .additional-options-section {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    overflow: hidden;
}
.step-3-layout .additional-options-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border: none;
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}
.step-3-layout .additional-options-toggle:hover {
    background: #F9FAFB;
}
.step-3-layout .additional-options-content {
    display: none;
    padding: 0 14px 14px;
    border-top: 1px solid #E5E7EB;
}
.step-3-layout .additional-options-content.open {
    display: block;
}
.step-3-layout .additional-options-content .option-group {
    padding-top: 12px;
}
.step-3-layout .option-input {
    width: 100%;
    padding: 8px 36px 8px 10px;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
.step-3-layout .title-input-wrapper {
    position: relative;
}
.step-3-layout .title-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px;
    border: none;
    background: none;
    color: #9CA3AF;
    cursor: pointer;
    border-radius: 4px;
}
.step-3-layout .title-clear-btn:hover {
    color: #374151;
}
.step-3-layout .game-code-input-group {
    display: flex;
    gap: 8px;
}
.step-3-layout .game-code-input {
    flex: 1;
}
.step-3-layout .submit-game-code-btn {
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: #3B82F6;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}
.step-3-layout .random-order-toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.step-3-layout .toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.step-3-layout .toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}
.step-3-layout .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #E5E7EB;
    border-radius: 24px;
    transition: 0.2s;
}
.step-3-layout .toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.step-3-layout .toggle-input:checked + .toggle-slider {
    background: #3B82F6;
}
.step-3-layout .toggle-input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Responsive - stacking at 900px and below; side-by-side from 901px up */

@media (max-width: 900px) {
    /* Hide question structures and examples when stacked */
    .step-3-container .topic-structures {
        display: none !important;
    }
    
    .step-3-container .topic-example-link {
        display: none !important;
    }
    
    /* Right panel - show mobile version at top, hide desktop */
    .step-3-right-panel-mobile {
        display: flex;
        flex-direction: column;
        width: 100%;
        margin-bottom: 20px;
        order: -1;
        background: transparent;
        border-radius: 0;
        padding: 0;
        gap: 12px;
    }
    
    .step-3-right-panel-mobile .right-panel-topics-container {
        width: 100%;
        flex: 0 1 auto;
        min-height: 0;
        background: #F3F4F6;
        border-radius: 12px;
        padding: 16px;
    }
    
    /* Apply all desktop right panel styles to mobile version */
    .step-3-right-panel-mobile .selected-topics-card {
        display: flex;
        flex-direction: column;
        background: transparent;
        border: none;
        border-radius: 0;
        padding: 0;
        min-height: 200px;
        height: 100%;
    }
    
    .step-3-right-panel-mobile .selected-topics-header {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        flex-shrink: 0;
        margin-bottom: 12px;
    }
    
    .step-3-right-panel-mobile .selection-progress-bar {
        flex: 1;
        height: 6px;
        background: #E5E7EB;
        border-radius: 3px;
        overflow: hidden;
    }
    
    .step-3-right-panel-mobile .progress-bar-fill {
        height: 100%;
        width: 0%;
        background: #3B82F6;
        border-radius: 3px;
        transition: width 0.2s, background-color 0.2s;
    }
    
    .step-3-right-panel-mobile .selection-count {
        font-size: 13px;
        font-weight: 500;
        color: #6B7280;
        flex-shrink: 0;
        white-space: nowrap;
    }
    
    .step-3-right-panel-mobile .selected-topics-list {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        gap: 8px;
        overflow: visible;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item {
        background: #fff !important;
        border: 1px solid #E5E7EB !important;
        border-radius: 8px !important;
        padding: 8px 10px !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
        transition: box-shadow 0.2s, opacity 0.2s !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item .quantity-controls {
        display: flex !important;
        align-items: center !important;
        gap: 2px !important;
        background-color: #fff !important;
        border: 1px solid #E5E7EB !important;
        border-radius: 4px !important;
        padding: 1px 2px !important;
        flex-shrink: 0 !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item .quantity-btn {
        width: 20px !important;
        height: 20px !important;
        border: none !important;
        background: transparent !important;
        border-radius: 3px !important;
        cursor: pointer !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        color: #374151 !important;
        transition: background-color 0.2s, color 0.2s !important;
        padding: 0 !important;
        line-height: 1 !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item .quantity-btn:hover:not(:disabled) {
        background-color: #3B82F6 !important;
        color: #fff !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item .quantity-btn:disabled {
        opacity: 0.5 !important;
        cursor: not-allowed !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item .quantity-value {
        min-width: 18px !important;
        text-align: center !important;
        font-weight: 600 !important;
        color: #111827 !important;
        font-size: 12px !important;
        padding: 0 2px !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item .selected-topic-name-display {
        flex: 1 !important;
        min-width: 0 !important;
        position: relative !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item .selected-topic-text {
        display: block !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        color: #111827 !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item .selected-topic-tooltip {
        position: fixed !important;
        padding: 6px 10px !important;
        background: #374151 !important;
        color: #fff !important;
        font-size: 13px !important;
        white-space: normal !important;
        max-width: 300px !important;
        border-radius: 6px !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: opacity 0.2s, visibility 0.2s !important;
        z-index: 1000 !important;
        pointer-events: none !important;
        word-wrap: break-word !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item .selected-topic-tooltip.is-visible {
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item .remove-btn {
        background: none !important;
        border: none !important;
        color: #EF4444 !important;
        cursor: pointer !important;
        padding: 6px !important;
        border-radius: 6px !important;
        font-size: 18px !important;
        line-height: 1 !important;
        flex-shrink: 0 !important;
        transition: background-color 0.2s !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .selected-topic-item .remove-btn:hover {
        background-color: rgba(239, 68, 68, 0.1) !important;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 48px 24px;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .empty-state-icon {
        margin-bottom: 16px;
        color: #D1D5DB;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .empty-state-icon svg {
        width: 48px;
        height: 48px;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .empty-state p {
        margin: 0 0 8px 0;
        font-weight: 500;
        font-size: 15px;
        color: #374151;
    }
    
    .step-3-right-panel-mobile .selected-topics-list .empty-state-subtitle {
        font-size: 13px;
        color: #9CA3AF;
        font-weight: 400;
    }
    
    .step-3-right-panel-mobile .clear-all-container {
        flex-shrink: 0;
        margin-top: 12px;
        margin-bottom: 0;
    }
    
    .step-3-right-panel-mobile .clear-all-btn {
        width: 100%;
        padding: 8px 12px;
        font-size: 13px;
        font-weight: 500;
        color: #6B7280;
        background: transparent;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        font-family: inherit;
        transition: background 0.2s, color 0.2s;
    }
    
    .step-3-right-panel-mobile .clear-all-btn:hover {
        background: rgba(239, 68, 68, 0.1);
        color: #EF4444;
    }
    
    .step-3-right-panel-mobile .add-saved-codes-container {
        width: 100%;
        padding: 8px;
        margin: 0;
    }
    
    /* When stacked (this block is max-width: 900px): hide desktop panel */
    .step-3-right-panel-desktop {
        display: none !important;
    }
    
    .step-3-container .year-header-section {
        position: relative !important;
        top: 0 !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-top: 12px !important;
        padding-bottom: 12px !important;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 12px;
    }
    
    .step-3-container .year-header-section .qg-year-heading {
        width: 100%;
        margin-bottom: 0;
    }
    
    .step-3-container .year-header-section .qg-header-controls {
        width: 100%;
        flex-direction: row;
        gap: 12px;
        justify-content: stretch;
    }
    
    .step-3-container .year-header-section .qg-filter-controls {
        flex: 1;
        width: 100%;
    }
    
    .step-3-container .year-header-section .qg-filter-dropdown {
        width: 100%;
    }
    
    .step-3-container .qg-search-container {
        width: 100%;
        margin-bottom: 16px;
        padding-left: 0;
        padding-right: 0;
    }
    
    .step-3-container .qg-search-container .qg-search-filter-group-header {
        width: 100%;
        max-width: 100%;
    }
    
    .step-3-layout .selected-topics-card {
        max-height: calc(100vh - 250px);
        overflow: hidden;
    }
    
    .step-3-layout .selected-topics-list {
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    /* Column layout when stacked (900px and below) */
    .step-3-layout {
        flex-direction: column;
        gap: 16px;
    }
    
    .step-3-layout .right-panel.step-3-right-panel-desktop {
        display: none !important;
    }
}

/* From 901px up: side-by-side layout and panel position (stacking at 900px and below) */
@media (min-width: 901px) {
    .step-3-layout.resource-creator-layout {
        flex-direction: row !important;
        gap: 20px;
        display: flex !important;
    }
    
    .step-3-layout .right-panel.step-3-right-panel-desktop {
        display: flex !important;
        max-height: calc(100vh - 70px);
        order: 0 !important;
        flex: 0 0 320px !important;
        width: 320px !important;
        min-width: 320px !important;
        max-width: 320px !important;
    }
    
    .step-3-layout .right-panel.step-3-right-panel-mobile {
        display: none !important;
    }
    
    .step-3-layout #qg-left-panel-wrapper {
        flex: 2 !important;
        width: auto !important;
    }
    
    .step-3-right-panel-mobile {
        display: none;
    }
    
    .step-3-right-panel-desktop {
        display: flex;
        max-height: calc(100vh - 70px);
        flex: 0 0 320px;
        width: 320px;
        min-width: 320px;
        max-width: 320px;
    }
}

/* Topic Card and Dropdown Styles */
.step-3-container .topic-card {
    background-color: transparent;
    border: none;
    border-radius: 0;
    transition: all 0.2s;
    overflow: visible;
    margin-bottom: 0.25rem;
    box-shadow: none;
    padding: 0;
    min-height: auto;
}

.step-3-container .topic-card.expanded {
    background-color: transparent;
    box-shadow: none;
}

.step-3-container .topic-header-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: inherit;
    transition: all 0.2s;
    gap: 1rem;
    border-radius: 0;
}

.step-3-container .topic-header-link:hover {
    background-color: transparent;
}

.step-3-container .topic-card.expanded .topic-header-link {
    background-color: transparent;
    border-bottom: none;
}

.step-3-container .topic-card-name {
    font-size: 1rem;
    color: #374151;
    font-weight: 600;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.step-3-container .topic-selected-count {
    background: #3B82F6;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
}

.step-3-container .topic-structures {
    font-size: 0.875rem;
    color: #6b7280;
    flex-shrink: 0;
}

.step-3-container .topic-expand-icon {
    font-size: 1.25rem;
    color: #6b7280;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.step-3-container .topic-dropdown {
    padding: 0.25rem 0 0.5rem 0.5rem;
    background-color: transparent;
    border-top: none;
    display: none;
    flex-direction: column;
}

.step-3-container .topic-card.expanded .topic-dropdown {
    display: flex;
}

.step-3-container .topic-section {
    padding: 0.5rem 0.5rem 0.35rem;
}

.step-3-container .topic-section:last-child {
    padding-bottom: 0.5rem;
}

.step-3-container .topic-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.3rem 0.15rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #e5e7eb;
}

.step-3-container .topic-section-items {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
}

/* Unit Group Styles */
.step-3-container .unit-group {
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.step-3-container .unit-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: none;
    background: #fff;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background 0.2s;
}

.step-3-container .unit-group-header:hover {
    background: #F3F4F6;
}

.step-3-container .unit-group-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: #111827;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.step-3-container .unit-group-caret {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: #6b7280;
    transition: color 0.2s ease;
    font-size: 1.25rem;
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.step-3-container .unit-group-content {
    padding: 0.5rem 1rem 0.75rem;
    background-color: #ffffff;
    display: none;
    flex-direction: column;
    gap: 0px;
}

.step-3-container .unit-group.expanded .unit-group-content {
    display: flex;
}

.step-3-container .unit-group-content .topic-card {
    margin-bottom: 0.5rem;
}

.step-3-container .unit-group-content .topic-card:last-child {
    margin-bottom: 0;
}
