/* انیمیشن لودینگ با رنگ سفید/خاکستری مینیمال */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* موقعیت‌دهی اسپینر روی تام‌نیل و عکس اصلی */
.thumb-wrapper {
    position: relative;
    width: 64px;
    height: 64px;
    border: 2px solid transparent;
    border-radius: 16px;
    box-sizing: border-box;
    flex-shrink: 0;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.thumb-wrapper .thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
    display: block;
    border: none !important;
}
.thumb-wrapper:hover:not(.active) {
    border-color: rgba(10, 132, 255, 0.35);
    box-shadow: 0 0 8px rgba(10, 132, 255, 0.22);
}
.thumb-wrapper.active {
    border-color: var(--accent, #0a84ff);
    box-shadow: 0 0 12px rgba(10, 132, 255, 0.55);
}
.thumb-add.thumb-add-active {
    color: var(--accent, #0a84ff);
    border-color: var(--accent, #0a84ff);
    background: rgba(10, 132, 255, 0.08);
}
.spinner-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 10;
}
.thumb-wrapper.is-loading .spinner-container { display: none; }
.thumb-wrapper.is-loading .thumb-img { opacity: 1; }

.generation-failed {
    position: relative;
    background: rgba(0, 0, 0, 0.45) !important;
}

.generation-error-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    text-align: center;
    width: 100%;
    height: 100%;
    min-height: 80px;
    box-sizing: border-box;
}

.generation-error-text {
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
    color: #ff8a8a;
    max-width: 100%;
}

.generation-retry-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}
.generation-retry-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.22); }
.generation-retry-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.generation-retry-btn svg { width: 20px; height: 20px; }

.thumb-wrapper.is-error .thumb-img { opacity: 0.25; }

.thumb-error-overlay {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 14px;
}

.thumb-error-label {
    font-size: 9px;
    color: #ff8a8a;
    text-align: center;
    line-height: 1.2;
}

.thumb-retry-btn { width: 32px; height: 32px; }
.thumb-retry-btn svg { width: 16px; height: 16px; }

.s3-muted { color: #86868b; text-align: center; width: 100%; font-size: 13px; }

/* ===== Stage 3 layout: one screen, no vertical scroll ===== */
#stage-3 {
    overflow: hidden;
}

#stage-3 .s3-stage {
    flex: 1;
    min-height: 0;
    height: 100%;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 8px 28px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    box-sizing: border-box;
    overflow: hidden;
}

#stage-3 .s3-icon-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #f5f5f7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}
#stage-3 .s3-icon-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}
#stage-3 .s3-icon-btn.is-active {
    background: #0a84ff;
    color: #fff;
}
#stage-3 #toggle-style-btn.is-expanded,
#stage-3 #toggle-style-btn.is-expanded:hover {
    transform: rotate(180deg);
}

#stage-3 .s3-text-btn {
    height: 28px;
    padding: 0 12px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: #f5f5f7;
    font-size: 12px;
    font-weight: 500;
}
#stage-3 .s3-text-btn:hover { transform: none; background: rgba(255, 255, 255, 0.16); }
#stage-3 .s3-text-btn.danger { background: #ff453a; color: #fff; }
#stage-3 .s3-text-btn.danger:hover { background: #ff6961; }
#stage-3 .s3-text-btn:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

/* Style picker */
#stage-3 .style-header {
    flex: 0 0 auto;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 48px;
    gap: 10px;
    z-index: 5;
}
#stage-3 #s3-image-gen-wrap {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
}
#stage-3 .style-header h3 {
    margin: 0;
    color: #f5f5f7;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
}
#stage-3 .status-text {
    position: static;
    transform: none;
    font-size: 14px;
    color: #e8e8ed;
}
#stage-3 .s3-header-actions {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 7px;
}
#stage-3 .s3-add-wrap { position: relative; }
#stage-3 .s3-add-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 40;
    min-width: 220px;
    padding: 6px;
    border-radius: 14px;
    background: rgba(28, 28, 30, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
#stage-3 .s3-add-menu[hidden] { display: none; }
#stage-3 .s3-add-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #f5f5f7;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
}
#stage-3 .s3-add-menu button:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: none;
    box-shadow: none;
}
#stage-3 .s3-add-menu svg {
    flex-shrink: 0;
    color: #a1a1a6;
}
#stage-3 .s3-header-actions.is-selecting #s3-add-btn,
#stage-3 .s3-header-actions.is-selecting #s3-select-all-btn,
#stage-3 .s3-header-actions.is-selecting #s3-unselect-all-btn,
#stage-3 .s3-header-actions.is-selecting #s3-delete-btn,
#stage-3 .s3-header-actions.is-selecting #s3-layout-btn { display: none; }
#stage-3.is-selecting #s3-image-gen-wrap { display: none !important; }
#stage-3 .s3-select-actions {
    display: none;
    align-items: center;
    gap: 6px;
}
#stage-3 .s3-header-actions.is-selecting .s3-select-actions { display: flex; }

#stage-3 #s3-layout-btn .s3-layout-rows { display: none; }
#stage-3.s3-cols #s3-layout-btn .s3-layout-cols { display: none; }
#stage-3.s3-cols #s3-layout-btn .s3-layout-rows { display: block; }
#stage-3.s3-cols #s3-layout-btn { background: rgba(255, 255, 255, 0.16); }

#stage-3 .s3-panels {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
}

#stage-3 .style-section-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 12px 18px 18px;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    transition: opacity 0.42s ease, transform 0.48s cubic-bezier(0.22, 1, 0.36, 1);
}
#stage-3.s3-collapsed .style-section-wrapper {
    opacity: 0;
    transform: translateY(-18px) scale(0.98);
    pointer-events: none;
}

#stage-3 .style-content {
    overflow: visible;
    max-height: none;
    opacity: 1;
    margin-top: 0;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
#stage-3.s3-collapsed .style-content {
    opacity: 0;
    transform: translateY(-10px);
}

/* Style tiles: one row until they overflow, then a 2-row lookbook grid */
#stage-3 .s3-style-dock {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 14px;
    width: 100%;
    max-width: 100%;
}
#stage-3 .s3-style-dock.is-two-rows {
    align-items: center;
}
#stage-3 .s3-style-rail {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: flex-end;
    gap: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 0 1 auto;
    min-width: 0;
    width: max-content;
    max-width: calc(100% - 86px);
    margin: 0;
    padding: 6px 4px 8px 8px;
    scrollbar-width: none;
}
#stage-3 .s3-style-rail.is-two-rows {
    display: grid;
    grid-template-rows: auto auto;
    grid-auto-flow: column;
    grid-auto-columns: auto;
    justify-content: start;
    align-items: end;
    column-gap: 18px;
    row-gap: 12px;
}
#stage-3 .s3-style-rail::-webkit-scrollbar { display: none; }

#stage-3 .s3-style-tile {
    flex: 0 0 auto;
    width: 72px;
    border: none;
    padding: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transform: none;
}
#stage-3 .s3-style-tile:hover { transform: none; background: transparent; box-shadow: none; }

#stage-3 .s3-style-cover {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    overflow: hidden;
    position: relative;
    background: #1c1c1e;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
#stage-3 .s3-style-cover img,
#stage-3 .s3-style-cover .s3-style-fallback {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
#stage-3 .s3-style-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: radial-gradient(circle at 30% 20%, #3a3a3c, #1c1c1e);
}
#stage-3 .s3-style-tile:hover .s3-style-cover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
}
#stage-3 .s3-style-tile.selected .s3-style-cover {
    box-shadow: 0 0 0 2.5px #0a84ff, 0 10px 22px rgba(10, 132, 255, 0.28);
    transform: translateY(-2px);
}
#stage-3 .s3-style-tile-label {
    max-width: 80px;
    font-size: 11px;
    font-weight: 500;
    color: #a1a1a6;
    letter-spacing: -0.1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}
#stage-3 .s3-style-tile.selected .s3-style-tile-label {
    color: #f5f5f7;
}

#stage-3 .s3-style-add {
    flex: 0 0 auto;
    position: static;
    z-index: 3;
    padding-left: 0;
}
#stage-3 .s3-style-add .s3-style-add-cover {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1.5px dashed rgba(255, 255, 255, 0.28);
    box-shadow: none;
    color: #f5f5f7;
}
#stage-3 .s3-style-add:hover .s3-style-add-cover {
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-3px) scale(1.04);
    box-shadow: none;
}
#stage-3 .s3-style-owned .s3-style-cover {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(10, 132, 255, 0.28);
}
#stage-3 .s3-style-edit {
    position: absolute;
    right: 5px;
    bottom: 5px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.72);
    color: #f5f5f7;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.18s ease, background 0.18s ease;
}
#stage-3 .s3-style-owned:hover .s3-style-edit,
#stage-3 .s3-style-owned:focus-within .s3-style-edit {
    opacity: 1;
    pointer-events: auto;
}
#stage-3 .s3-style-edit:hover {
    background: #0a84ff;
}

.s3-style-create-card {
    max-width: 460px !important;
    padding: 32px 28px 24px !important;
}
.s3-style-create-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
    z-index: 2;
}
.s3-style-create-top {
    display: flex;
    align-items: center;
    gap: 14px;
}
.s3-style-create-drop {
    width: 96px;
    height: 96px;
    flex: 0 0 96px;
    border-radius: 22px;
    border: 1.5px dashed rgba(255, 255, 255, 0.22);
    background: rgba(0, 0, 0, 0.28) center/cover no-repeat;
    color: #a1a1a6;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    padding: 0;
}
.s3-style-create-drop.is-dragover,
.s3-style-create-drop:hover {
    border-color: #0a84ff;
    background-color: rgba(10, 132, 255, 0.08);
}
.s3-style-create-drop.has-image {
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.16);
}
.s3-style-create-drop.has-image .s3-style-create-hint { opacity: 0; }
.s3-style-create-drop.has-image:hover .s3-style-create-hint {
    opacity: 1;
    background: rgba(0, 0, 0, 0.55);
}
.s3-style-create-drop.is-busy {
    pointer-events: none;
}
.s3-style-create-drop.is-busy .s3-style-create-hint {
    opacity: 0 !important;
}
.s3-style-create-hint {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-align: center;
    padding: 8px;
}
.s3-style-create-drop img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.s3-style-create-drop img[hidden] {
    display: none;
}
.s3-style-create-extract {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.s3-style-create-extract p {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: #88888e;
}
.s3-style-create-extract-btn,
.s3-style-create-save {
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease, opacity 0.2s ease;
}
.s3-style-create-extract-btn {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #f5f5f7;
    font-size: 13px;
    text-align: center;
}
.s3-style-create-extract-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.16);
}
.s3-style-create-extract-btn:disabled,
.s3-style-create-save:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.s3-style-create-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #a1a1a6;
}
.s3-style-create-field input,
.s3-style-create-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.28);
    color: #f5f5f7;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    font-weight: 500;
    font-size: 13px;
    outline: none;
}
.s3-style-create-field textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.45;
}
.s3-style-prompt-wrap {
    position: relative;
}
.s3-style-prompt-thinking {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.22);
    pointer-events: none;
    z-index: 2;
}
.s3-style-prompt-thinking[hidden] { display: none !important; }
.s3-style-create-field.is-thinking textarea {
    color: transparent;
    caret-color: transparent;
    pointer-events: none;
}
.s3-style-create-field.is-thinking textarea::placeholder {
    color: transparent;
}
.s3-dots {
    display: flex;
    align-items: center;
    gap: 6px;
}
.s3-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f5f5f7;
    opacity: 0.25;
    animation: s3-dot 1.2s ease-in-out infinite;
}
.s3-dots span:nth-child(2) { animation-delay: 0.16s; }
.s3-dots span:nth-child(3) { animation-delay: 0.32s; }
.s3-style-create-field input:focus,
.s3-style-create-field textarea:focus {
    border-color: rgba(10, 132, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.18);
}
.s3-style-create-status {
    min-height: 18px;
    margin: 0;
    font-size: 12px;
    color: #88888e;
}
.s3-style-create-status[data-kind="error"] { color: #ff6b6b; }
.s3-style-create-status[data-kind="ok"] { color: #7ee0a3; }
.s3-style-create-edit-actions {
    display: flex;
    gap: 8px;
}
.s3-style-create-edit-actions[hidden] { display: none !important; }
.s3-style-create-delete,
.s3-style-create-publish {
    flex: 1;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.s3-style-create-delete {
    border: 1px solid rgba(255, 107, 107, 0.45);
    background: rgba(255, 107, 107, 0.1);
    color: #ff8a8a;
}
.s3-style-create-delete:hover:not(:disabled) {
    background: rgba(255, 107, 107, 0.22);
}
.s3-style-create-publish {
    border: 1px solid rgba(10, 132, 255, 0.45);
    background: rgba(10, 132, 255, 0.14);
    color: #7ec8ff;
}
.s3-style-create-publish:hover:not(:disabled) {
    background: rgba(10, 132, 255, 0.24);
}
.s3-style-create-delete:disabled,
.s3-style-create-publish:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.s3-style-create-save {
    margin-top: 2px;
    padding: 11px 18px;
    border-radius: 999px;
    background: #f5f5f7;
    color: #111;
    font-size: 14px;
}

#stage-3 .s3-extract-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    padding: 16px 18px 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    overflow: visible;
}

#stage-3 .s3-extract-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 28px;
    width: 100%;
    max-width: 620px;
}

#stage-3 .s3-extract-settings,
#stage-3 .s3-extract-types {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
}

#stage-3 .s3-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0;
    padding: 6px 10px;
    min-width: 0;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
}
#stage-3 .s3-field > span {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: #f5f5f7;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 78px;
}

#stage-3 .vision-select {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 6px 8px;
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    font-size: 12px;
    min-width: 110px;
    flex: 1;
}
#stage-3 .vision-select option {
    background-color: #1c1c1e;
    color: #ffffff;
}
#stage-3 .vision-select:focus { border-color: rgba(255, 255, 255, 0.4); }
#stage-3 .vision-select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#stage-3 .s3-model-trigger {
    flex: 1;
    min-width: 0;
    max-width: none;
    height: 28px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-family: inherit;
}
#stage-3 .s3-model-trigger:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
#stage-3 .s3-model-trigger .smp-trigger-name {
    min-width: 0;
    flex: 1;
    text-align: left;
}

#stage-3 .vision-checkbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
    width: 100%;
    box-sizing: border-box;
}
#stage-3 .vision-checkbox-row label {
    min-width: 68px;
    font-size: 12px;
    color: #f5f5f7;
}
#stage-3 .s3-extract-type-hint {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.3;
    letter-spacing: 0.01em;
    color: #86868b;
}
#stage-3 .vision-checkbox {
    accent-color: #0a84ff;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

#stage-3 .s3-extract-hint {
    margin: 4px 2px 0;
    padding: 8px 2px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 11px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.015em;
    color: #86868b;
}
#stage-3 .s3-extract-hint span {
    display: block;
}

#stage-3 #btn-generate-assets {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #111;
    border-radius: 999px;
    border: none;
    background: #f5f5f7;
    box-shadow: none;
}
#stage-3 #btn-generate-assets:hover {
    background: #fff;
    transform: none;
    box-shadow: none;
}

#stage-3 .info-tooltip {
    position: relative;
    cursor: help;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    font-size: 10px;
    color: #fff;
}
#stage-3 .info-tooltip:hover .tooltip-text {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
#stage-3 .tooltip-text {
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: rgba(20, 20, 22, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: #fff;
    width: 200px;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    pointer-events: none;
}

/* Asset rows */
#stage-3 .s3-assets-board {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 42px;
    width: 100%;
    padding-top: 28px;
    box-sizing: border-box;
    opacity: 0;
    transform: translateY(22px) scale(0.985);
    pointer-events: none;
    transition: opacity 0.48s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
#stage-3.s3-collapsed .s3-assets-board {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#stage-3.s3-cols .s3-assets-board {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 36px;
    padding-top: 28px;
    padding-bottom: 8px;
}
#stage-3.s3-cols .s3-asset-row {
    flex: 0 1 200px;
    width: 200px;
    max-width: 200px;
    height: 100%;
    min-height: 0;
}
#stage-3.s3-cols .carousel-wrapper {
    flex: 1;
    min-height: 0;
    align-items: flex-start;
}
#stage-3.s3-cols .scroll-btn { display: none; }
#stage-3.s3-cols .card-grid {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
    height: 100%;
    padding: 2px 0 8px;
    gap: 12px;
    justify-content: flex-start;
    align-items: center;
}
#stage-3.s3-cols .s3-asset-card {
    flex: 0 0 auto;
    width: 180px;
}

#stage-3 .s3-asset-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    padding: 0;
}

#stage-3 .s3-row-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    position: relative;
    min-height: 28px;
    margin-bottom: 14px;
    border: none;
}
#stage-3.s3-cols .s3-row-head {
    justify-content: center;
}
#stage-3 .s3-row-head h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.2px;
    color: #f5f5f7;
}

#stage-3 .carousel-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 0;
}

#stage-3 .scroll-btn {
    position: absolute;
    z-index: 10;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(28, 28, 30, 0.72);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    box-shadow: none;
}
#stage-3 .carousel-wrapper:hover .scroll-btn { opacity: 1; }
#stage-3 .scroll-btn:hover {
    background: rgba(58, 58, 60, 0.95);
    transform: none;
}
#stage-3 .scroll-btn.left { left: 4px; }
#stage-3 .scroll-btn.right { right: 4px; }

#stage-3 .card-grid {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    gap: 12px;
    padding: 2px 36px 2px 0;
    width: max-content;
    max-width: 100%;
    margin: 0;
    scrollbar-width: none;
    min-height: 118px;
    align-items: center;
    justify-content: flex-start;
}
#stage-3 .card-grid::-webkit-scrollbar { display: none; }
#stage-3 .card-grid:empty {
    width: 100%;
    max-width: 100%;
    justify-content: center;
}
#stage-3 .card-grid:empty::after {
    content: attr(data-empty);
    color: #636366;
    font-size: 12px;
    letter-spacing: 0.2px;
}

/* Asset cards: photo tiles, image-first, little chrome */
#stage-3 .s3-asset-card {
    flex: 0 0 180px;
    width: 180px;
    aspect-ratio: 16 / 10;
    height: auto;
    padding: 0;
    margin: 0;
    text-align: left;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #161618;
    box-shadow: none;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.48s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.52s cubic-bezier(0.22, 1, 0.36, 1),
                border-color 0.2s ease;
}
#stage-3 .s3-asset-card.s3-card-enter {
    opacity: 0;
    transform: translateY(16px) scale(0.94);
    pointer-events: none;
}
#stage-3 .s3-asset-card:hover {
    transform: translateY(-2px) scale(1);
    background: #161618;
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: none;
}
#stage-3 .s3-asset-card.selected,
#stage-3 .s3-asset-card.is-checked {
    border-color: #0a84ff;
    box-shadow: 0 0 0 1px #0a84ff;
}

#stage-3 .s3-asset-card .image-container,
#stage-3 .s3-asset-card img {
    width: 100%;
    height: 100%;
    border-radius: 0;
    aspect-ratio: auto;
    object-fit: cover;
    background: #111;
}
#stage-3 .s3-asset-card .image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 0;
}

#stage-3 .s3-card-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    margin: 0 !important;
    padding: 16px 8px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
    pointer-events: none;
}

#stage-3 .s3-card-placeholder {
    font-size: 22px;
    color: #636366;
}

#stage-3 .s3-asset-card .s3-check {
    appearance: none;
    -webkit-appearance: none;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    width: 22px;
    height: 22px;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.82);
    background: rgba(10, 10, 12, 0.38);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    display: block;
    opacity: 0;
    transform: scale(0.86);
    cursor: pointer;
    pointer-events: auto;
    color: transparent;
    font-size: 0;
    line-height: 0;
    transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
#stage-3 .s3-asset-card .s3-check::after {
    content: '';
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background: #fff;
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.16s ease, transform 0.16s ease;
}
#stage-3 .s3-asset-card:hover .s3-check,
#stage-3.is-selecting .s3-asset-card .s3-check,
#stage-3 .s3-asset-card.is-checked .s3-check {
    opacity: 1;
    transform: scale(1);
}
#stage-3 .s3-asset-card.is-checked .s3-check {
    background: #0a84ff;
    border-color: #0a84ff;
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.22), 0 6px 16px rgba(10, 132, 255, 0.32);
}
#stage-3 .s3-asset-card.is-checked .s3-check::after {
    opacity: 1;
    transform: scale(1);
}

#stage-3 .s3-asset-row.is-thinking .card-grid:empty::after {
    display: none;
}

#stage-3 .s3-thinking {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #a1a1a6;
    font-size: 12px;
    letter-spacing: 0.3px;
    pointer-events: none;
}
#stage-3 .s3-asset-row.is-thinking .s3-thinking { display: flex; }

#stage-3 .s3-dots {
    display: flex;
    align-items: center;
    gap: 6px;
}
#stage-3 .s3-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f5f5f7;
    opacity: 0.25;
    animation: s3-dot 1.2s ease-in-out infinite;
}
#stage-3 .s3-dots span:nth-child(2) { animation-delay: 0.16s; }
#stage-3 .s3-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes s3-dot {
    0%, 80%, 100% { opacity: 0.22; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

#hover-preview-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    background: rgba(15, 15, 20, 0.85);
    padding: 10px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transform: translate(-50%, -100%);
    margin-top: -20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}
#hover-preview-tooltip.show { opacity: 1; }
#hover-preview-tooltip img {
    width: 320px;
    border-radius: 10px;
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

@media (max-height: 820px) {
    #stage-3 .s3-style-rail {
        max-width: calc(100% - 72px);
    }
    #stage-3 .s3-style-tile,
    #stage-3 .s3-style-cover {
        width: 58px;
    }
    #stage-3 .s3-style-cover {
        height: 58px;
        border-radius: 18px;
    }
    #stage-3 .s3-style-tile { gap: 5px; }
    #stage-3 .s3-asset-card {
        flex: 0 0 156px;
        width: 156px;
    }
    #stage-3 .card-grid { min-height: 100px; }
    #stage-3 .s3-assets-board { gap: 28px; }
}
