﻿* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .container {
            background: white;
            border-radius: 12px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
            width: 100%;
            max-width: none;
            min-height: calc(100vh - 40px);
            padding: 40px;
        }

        h1 {
            color: #333;
            margin-bottom: 30px;
            text-align: center;
            font-size: 28px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 8px;
            color: #555;
            font-weight: 500;
        }

        input[type="password"],
        input[type="text"] {
            width: 100%;
            padding: 12px;
            border: 2px solid #ddd;
            border-radius: 6px;
            font-size: 14px;
            transition: border-color 0.3s;
        }

        input[type="password"]:focus,
        input[type="text"]:focus {
            outline: none;
            border-color: #667eea;
        }

        button {
            width: 100%;
            padding: 12px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
        }

        button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
        }

        button:active {
            transform: translateY(0);
        }

        button:disabled {
            background: #ccc;
            cursor: not-allowed;
            transform: none;
        }

        .results {
            margin-top: 40px;
            display: none;
        }

        .results.show {
            display: block;
        }

        h2 {
            color: #333;
            margin-bottom: 20px;
            font-size: 20px;
            border-bottom: 2px solid #667eea;
            padding-bottom: 10px;
        }

        .gallery-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }

        .gallery-header h2 {
            margin-bottom: 0;
            flex: 1;
        }

        .file-list {
            list-style: none;
            max-height: 400px;
            overflow-y: auto;
            border: 1px solid #eee;
            border-radius: 6px;
            background: #f9f9f9;
        }

        .file-item {
            padding: 12px 15px;
            border-bottom: 1px solid #eee;
            display: flex;
            align-items: center;
            transition: background-color 0.2s;
        }

        .file-item:last-child {
            border-bottom: none;
        }

        .file-item:hover {
            background-color: #f0f0f0;
        }

        .file-icon {
            margin-right: 10px;
            color: #667eea;
            font-size: 18px;
        }

        .file-name {
            color: #333;
            flex: 1;
            word-break: break-all;
            font-family: 'Courier New', monospace;
            font-size: 14px;
        }

        .loading {
            text-align: center;
            padding: 20px;
            color: #667eea;
        }

        .spinner {
            border: 4px solid #f3f3f3;
            border-top: 4px solid #667eea;
            border-radius: 50%;
            width: 30px;
            height: 30px;
            animation: spin 1s linear infinite;
            margin: 0 auto 10px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .error {
            background-color: #fee;
            color: #c33;
            padding: 15px;
            border-radius: 6px;
            margin-top: 20px;
            border-left: 4px solid #c33;
        }

        .success {
            background-color: #efe;
            color: #3a3;
            padding: 15px;
            border-radius: 6px;
            margin-top: 20px;
            border-left: 4px solid #3a3;
        }

        .file-count {
            color: #666;
            font-size: 14px;
            margin-top: 10px;
            text-align: center;
        }

        .gallery {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }

        .lora-block {
            position: relative;
            overflow: hidden;
            border-radius: 8px;
            cursor: pointer;
            transition: transform 0.3s, box-shadow 0.3s;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            height: 250px;
            background: #f0f0f0;
        }

        .lora-block:hover {
            transform: translateY(-8px);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
        }

        .lora-image {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .lora-loading-overlay {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            gap: 8px;
            background: rgba(255, 255, 255, 0.55);
            pointer-events: none;
            z-index: 1;
        }

        .lora-name-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.9), rgba(118, 75, 162, 0.9));
            color: white;
            padding: 12px;
            font-weight: 600;
            font-size: 14px;
            word-break: break-all;
            max-height: 60px;
            overflow: hidden;
            z-index: 2;
        }

        .lora-card-actions {
            position: absolute;
            top: 10px;
            right: 10px;
            z-index: 3;
        }

        .lora-hide-btn {
            width: 34px;
            height: 34px;
            padding: 0;
            border-radius: 999px;
            font-size: 16px;
            line-height: 34px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        .lora-hide-btn:hover:not(:disabled) {
            transform: translateY(-1px);
            box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
        }

        .lora-hide-btn:disabled {
            background: #ccc;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        .lora-block.is-hiding {
            opacity: 0.7;
        }

        .detail-view {
            display: none;
        }

        .detail-view.active {
            display: block;
        }

        .detail-header {
            display: flex;
            align-items: center;
            gap: 15px;
            margin-bottom: 20px;
            border-bottom: 2px solid #667eea;
            padding-bottom: 15px;
        }

        .back-btn {
            background: none;
            border: none;
            color: #667eea;
            font-size: 24px;
            cursor: pointer;
            padding: 0;
            width: 40px;
            min-width: 40px;
            height: 40px;
            flex: 0 0 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            transform: none;
            box-shadow: none;
            transition: background-color 0.2s;
        }

        .back-btn:hover {
            background-color: #f0f0f0;
            border-radius: 8px;
            transform: none;
            box-shadow: none;
        }

        .detail-title {
            font-size: 22px;
            font-weight: 600;
            color: #333;
            flex: 1;
        }

        .no-image {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
            color: #999;
            font-size: 12px;
            text-align: center;
            padding: 20px;
        }

        .detail-row {
            margin-bottom: 30px;
            padding: 20px;
            background: #f9f9f9;
            border-radius: 8px;
        }

        .detail-row h3 {
            margin-bottom: 15px;
            color: #333;
            font-size: 16px;
        }

        .image-json-container {
            display: flex;
            gap: 20px;
            align-items: flex-start;
        }

        .preview-image {
            flex-shrink: 0;
            max-width: 300px;
            height: auto;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }

        .json-info {
            flex: 1;
            background: white;
            padding: 15px;
            border-radius: 6px;
            border: 1px solid #eee;
            overflow-y: auto;
            max-height: 300px;
        }

        .json-info pre {
            margin: 0;
            font-family: 'Courier New', monospace;
            font-size: 12px;
            color: #333;
            line-height: 1.4;
        }

        .upload-container {
            display: flex;
            gap: 15px;
            align-items: flex-end;
        }

        .upload-input-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .upload-input-group label {
            margin: 0;
            font-weight: 600;
            color: #555;
            font-size: 14px;
        }

        .upload-input-group input {
            padding: 10px;
            border: 2px solid #ddd;
            border-radius: 6px;
            font-size: 14px;
            width: 120px;
            transition: border-color 0.3s;
        }

        .upload-input-group input:focus {
            outline: none;
            border-color: #667eea;
        }

        .upload-btn {
            padding: 10px 30px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 6px;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
            margin: 0;
            width: auto;
        }

        .upload-btn:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
        }

        .upload-btn:disabled {
            background: #ccc;
            cursor: not-allowed;
        }

        .images-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
            gap: 10px;
        }

        .image-item {
            width: 100%;
            height: 120px;
            border-radius: 6px;
            overflow: hidden;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }

        .image-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .upload-status {
            margin-top: 15px;
            padding: 12px;
            border-radius: 6px;
            display: none;
        }

        .upload-status.show {
            display: block;
        }

        .upload-status.success {
            background-color: #efe;
            color: #3a3;
            border-left: 4px solid #3a3;
        }

        .upload-status.error {
            background-color: #fee;
            color: #c33;
            border-left: 4px solid #c33;
        }

        .upload-status.loading {
            background-color: #f5f5f5;
            color: #667eea;
            border-left: 4px solid #667eea;
        }

        .scene-section {
            margin-top: 18px;
        }

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

        .scene-title {
            font-size: 14px;
            font-weight: 700;
            color: #333;
            margin: 0;
        }

        .scene-btn {
            width: auto;
            min-width: 96px;
            padding: 8px 14px;
            font-size: 13px;
            line-height: 1;
            margin: 0;
            white-space: nowrap;
        }

        .scene-table-wrapper {
            border: 1px solid #eee;
            border-radius: 8px;
            overflow: hidden;
            background: #fff;
        }

        .scene-table {
            width: 100%;
            border-collapse: collapse;
            table-layout: fixed;
        }

        .scene-table thead th {
            text-align: left;
            font-size: 13px;
            font-weight: 700;
            color: #555;
            background: #f9f9f9;
            padding: 10px;
            border-bottom: 1px solid #eee;
        }

        .scene-table thead th:nth-child(3),
        .scene-table td:nth-child(3) {
            width: 150px;
            text-align: center;
            white-space: nowrap;
        }

        .scene-table thead th:nth-child(4),
        .scene-table td:nth-child(4) {
            width: 140px;
            text-align: center;
            white-space: nowrap;
        }

        .scene-table thead th:nth-child(5),
        .scene-table td:nth-child(5) {
            width: 90px;
            text-align: center;
            white-space: nowrap;
        }

        .scene-table td {
            padding: 10px;
            border-bottom: 1px solid #f0f0f0;
            vertical-align: top;
        }

        .scene-table tr:last-child td {
            border-bottom: none;
        }

        .scene-textarea {
            width: 100%;
            min-height: 70px;
            resize: none;
            overflow: hidden;
            padding: 10px;
            border: 2px solid #ddd;
            border-radius: 6px;
            font-size: 13px;
            line-height: 1.4;
            font-family: inherit;
        }

        .scene-textarea:focus {
            outline: none;
            border-color: #667eea;
        }

        .scene-remove-btn {
            width: auto;
            min-width: 64px;
            padding: 6px 10px;
            font-size: 12px;
            font-weight: 700;
            line-height: 1;
            border-radius: 6px;
            background: linear-gradient(135deg, #e04a4a 0%, #c63b3b 100%);
            color: #fff;
            box-shadow: 0 3px 10px rgba(224, 74, 74, 0.25);
            transform: none;
        }

        .scene-remove-btn:hover:not(:disabled) {
            transform: translateY(-1px);
            box-shadow: 0 6px 16px rgba(224, 74, 74, 0.35);
        }

        .scene-remove-btn:active:not(:disabled) {
            transform: translateY(0);
            box-shadow: 0 2px 8px rgba(224, 74, 74, 0.25);
        }

        .scene-gemini-btn {
            width: auto;
            min-width: 96px;
            padding: 6px 10px;
            font-size: 12px;
            font-weight: 700;
            line-height: 1.2;
            border-radius: 6px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #fff;
            box-shadow: none;
            transform: none;
        }

        .scene-gemini-btn:disabled {
            background: #ccc;
            cursor: not-allowed;
        }

        .scene-action-cell {
            width: 110px;
            text-align: center;
            vertical-align: top;
            white-space: nowrap;
        }

        .scene-action-stack {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
        }

        .scene-checkbox-cell {
            width: 140px;
            text-align: center;
            vertical-align: middle;
        }

        .scene-enable-cell {
            width: 90px;
            text-align: center;
            vertical-align: middle;
        }

        .scene-enable-checkbox {
            appearance: none;
            width: 36px;
            height: 20px;
            border-radius: 999px;
            border: 2px solid #c9c9c9;
            background: #e6e6e6;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto;
            transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.1s;
        }

        .scene-enable-checkbox::after {
            content: '';
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: #fff;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
            transform: translateX(-7px);
            transition: transform 0.2s ease;
        }

        .scene-enable-checkbox:checked {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-color: #667eea;
            box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
        }

        .scene-enable-checkbox:checked::after {
            transform: translateX(7px);
        }

        .scene-enable-checkbox:focus-visible {
            outline: none;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.35);
        }

        .scene-row-disabled {
            opacity: 0.65;
        }

        .scene-row-disabled .scene-textarea {
            background: #f5f5f5;
        }

        .scene-checkbox {
            appearance: none;
            width: 44px;
            height: 24px;
            border-radius: 999px;
            border: 2px solid #c9c9c9;
            background: #e6e6e6;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto;
            transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.1s;
        }

        .scene-checkbox::after {
            content: '';
            width: 18px;
            height: 18px;
            border-radius: 50%;
            background: #fff;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
            transform: translateX(-10px);
            transition: transform 0.2s ease;
        }

        .scene-checkbox:checked {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-color: #667eea;
            box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
        }

        .scene-checkbox:checked::after {
            transform: translateX(10px);
        }

        .scene-checkbox:focus-visible {
            outline: none;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.35);
        }

        .scene-footer {
            margin-top: 10px;
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }

        .scene-footer .scene-btn {
            min-width: 110px;
        }

        .scene-ai-btn {
            min-width: 140px;
        }

        #generalScenesStatus,
        #characterScenesStatus {
            margin-top: 10px;
        }

        .runpod-summary {
            font-size: 13px;
            font-weight: 600;
            color: inherit;
            margin-bottom: 10px;
            line-height: 1.35;
            word-break: break-word;
        }

        .runpod-progress-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
            max-height: 280px;
            overflow: auto;
            padding-right: 4px;
        }

        .runpod-progress-row {
            display: grid;
            grid-template-columns: minmax(36px, 320px) 1fr 64px;
            align-items: center;
            gap: 10px;
        }

        .runpod-progress-label {
            font-size: 12px;
            font-weight: 700;
            color: #555;
            text-align: left;
            line-height: 1.2;
            overflow-wrap: anywhere;
            word-break: break-word;
        }

        .runpod-progress-bar {
            height: 10px;
            background: #eaeaea;
            border-radius: 999px;
            overflow: hidden;
            border: 1px solid #e1e1e1;
        }

        .runpod-progress-fill {
            height: 100%;
            width: 0%;
            border-radius: 999px;
            transition: width 0.2s ease;
        }

        .runpod-progress-fill.is-waiting {
            background: #cfcfcf;
        }

        .runpod-progress-fill.is-queued {
            background: #b8c4f3;
        }

        .runpod-progress-fill.is-submitting,
        .runpod-progress-fill.is-running,
        .runpod-progress-fill.is-uploading {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        .runpod-progress-fill.is-done {
            background: #3a3;
        }

        .runpod-progress-fill.is-failed {
            background: #c33;
        }

        .runpod-progress-state {
            font-size: 12px;
            font-weight: 700;
            color: #555;
            text-align: right;
        }

        .target-folder-section {
            margin-top: 20px;
        }

        .target-folder-toolbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 10px;
        }

        .target-folder-title {
            font-size: 14px;
            font-weight: 600;
            color: #555;
            word-break: break-all;
            margin: 0;
            flex: 1;
        }

        .sort-btn {
            width: auto;
            min-width: 100px;
            padding: 8px 14px;
            font-size: 13px;
            font-weight: 600;
            line-height: 1;
            white-space: nowrap;
        }

        .target-folder-images {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
            gap: 12px;
            align-items: stretch;
        }

        .target-folder-item {
            width: 100%;
            min-height: 180px;
            border-radius: 8px;
            overflow: hidden;
            background: #fff;
            border: 1px solid #eee;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .target-folder-loading {
            width: 100%;
            height: 100%;
            min-height: 180px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 8px;
            background: #fafafa;
            color: #666;
            font-size: 12px;
            font-weight: 600;
        }

        .target-folder-loading.is-error {
            color: #c33;
            background: #fff5f5;
        }

        .mini-spinner {
            border: 3px solid #f0f0f0;
            border-top: 3px solid #667eea;
            border-radius: 50%;
            width: 18px;
            height: 18px;
            animation: spin 1s linear infinite;
        }

        .loading-text {
            line-height: 1;
        }

        .target-folder-item img {
            display: block;
            width: 100%;
            height: 100%;
            max-width: 100%;
            max-height: 256px;
            object-fit: contain;
            background: #fafafa;
            cursor: zoom-in;
        }

        body.no-scroll {
            overflow: hidden;
        }

        .image-lightbox {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.75);
            display: grid;
            grid-template-rows: minmax(0, 1fr) auto;
            align-items: center;
            justify-items: center;
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.2s ease;
            z-index: 9999;
            padding: 0;
            width: 100vw;
            height: 100vh;
            height: 100dvh;
            overflow: hidden;
            pointer-events: none;
        }

        .image-lightbox.is-active {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        .image-lightbox .lightbox-main {
            grid-row: 1;
            max-width: 100vw;
            max-height: calc(100vh - 92px);
            max-height: calc(100dvh - 92px);
            border-radius: 10px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
            cursor: zoom-out;
            background: #fff;
            object-fit: contain;
        }

        .image-lightbox .lightbox-loading {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            padding: 12px 16px;
            border-radius: 10px;
            background: rgba(0, 0, 0, 0.65);
            color: #fff;
            font-size: 12px;
            font-weight: 600;
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.2s ease;
        }

        .image-lightbox .lightbox-loading.is-visible {
            opacity: 1;
            visibility: visible;
        }

        .lightbox-thumbs {
            grid-row: 2;
            margin-top: 0;
            display: flex;
            gap: 10px;
            overflow-x: auto;
            overflow-y: hidden;
            max-width: 100vw;
            padding: 6px 8px 10px;
            width: 100%;
            justify-content: center;
            flex-wrap: nowrap;
            max-height: 92px;
        }

        .lightbox-thumb {
            border: 2px solid transparent;
            border-radius: 8px;
            padding: 0;
            background: transparent;
            cursor: pointer;
            width: 64px;
            height: 64px;
            flex: 0 0 auto;
            overflow: hidden;
        }

        .lightbox-thumb.is-loading {
            background: rgba(255, 255, 255, 0.1);
        }

        .lightbox-thumb-loading {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

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

        .lightbox-thumb.is-active {
            border-color: #fff;
            box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
        }

        .lightbox-nav {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            width: 44px;
            height: 44px;
            border: none;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.9);
            color: #333;
            font-size: 28px;
            font-weight: 700;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            padding: 0;
        }

        .lightbox-nav:hover:not(:disabled) {
            background: #fff;
        }

        .lightbox-nav:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .lightbox-prev {
            left: 12px;
        }

        .lightbox-next {
            right: 12px;
        }

        .target-folder-empty {
            font-size: 13px;
            color: #666;
            padding: 8px 0;
        }
