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

:root {
    --bg-primary: #181825;
    --bg-secondary: #1e1e32;
    --bg-panel: #252540;
    --bg-input: #1a1a30;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --accent-blue: #4a9eff;
    --accent-green: #50c878;
    --accent-purple: #a78bfa;
    --accent-amber: #f59e0b;
    --accent-teal: #2dd4bf;
    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --border: #2e2e4a;
    --border-subtle: #252540;
    --radius: 8px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);

    --sidebar-bg: #1a1a30;
    --content-bg: #1c1828;
    --history-bg: #1a1e2e;
    --header-bg: linear-gradient(135deg, #1e1e36, #1a2038);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent), #ff9a9e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Buttons */
.btn-icon {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.btn-icon:hover {
    background: var(--bg-panel);
}

.btn-discord {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #5865F2;
    text-decoration: none;
}
.btn-discord:hover {
    background: rgba(88, 101, 242, 0.15);
    color: #4752c4;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(233, 69, 96, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    width: 100%;
    margin-top: 12px;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: var(--accent);
    color: white;
}

/* Main Layout */
.main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 300px;
    min-width: 240px;
    max-width: 600px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

/* Panel Group (Accordion) */
.panel-group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
}

.panel-group-header {
    padding: 10px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--bg-panel);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s, background 0.2s;
    border-left: 3px solid transparent;
}

.panel-group[data-group="basic"] .panel-group-header {
    border-left-color: var(--accent-blue);
    color: #8ec5ff;
}

.panel-group[data-group="enhance"] .panel-group-header {
    border-left-color: var(--accent-purple);
    color: #c4b5fd;
}

.panel-group[data-group="control"] .panel-group-header {
    border-left-color: var(--accent-teal);
    color: #7ee8d4;
}

.panel-group[data-group="post"] .panel-group-header {
    border-left-color: var(--accent-amber);
    color: #fbbf4e;
}

.panel-group-header::before {
    content: '▶';
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.panel-group.open .panel-group-header::before {
    transform: rotate(90deg);
}

.panel-group-header:hover {
    color: var(--text-primary);
}

.panel-group-body {
    display: none;
    padding: 6px;
    gap: 6px;
}

.panel-group.open .panel-group-body {
    display: flex;
    flex-direction: column;
}

/* Compact Row */
.compact-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.compact-row label {
    margin-bottom: 4px;
}

/* Sidebar Resizer */
.sidebar-resizer {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    transition: background 0.2s;
    flex-shrink: 0;
}

.sidebar-resizer:hover,
.sidebar-resizer.active {
    background: var(--accent);
}

.panel {
    background: var(--bg-panel);
    border-radius: var(--radius);
    padding: 14px;
    flex-shrink: 0;
}

.panel h2 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.panel label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.panel label:last-child {
    margin-bottom: 0;
}

/* Optional Panel with Toggle */
.optional-panel {
    border: 1px solid var(--border);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
}

.panel-header h2 {
    margin-bottom: 0;
}

.panel-body {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.panel-body.hidden {
    display: none;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center;
    width: 40px;
    height: 22px;
    margin-bottom: 0 !important;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-input);
    border-radius: 22px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent-green);
    border-color: var(--accent-green);
}

.toggle input:checked + .toggle-slider::before {
    left: 20px;
    background: white;
}

/* Inputs */
select, input[type="number"], input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="file"] {
    width: 100%;
    padding: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    margin-right: 8px;
}

select:focus, input:focus, textarea:focus {
    border-color: var(--accent);
}

textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

/* Size Row */
.size-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.size-row label {
    flex: 1;
    margin-bottom: 0;
}

.size-row span {
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding-top: 16px;
}

/* Seed Row */
.seed-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.seed-row input {
    flex: 1;
}

.seed-row button {
    font-size: 1.2rem;
}

.panel small {
    color: var(--text-secondary);
    font-size: 0.7rem;
    margin-top: 4px;
    display: block;
}

/* LoRA Rows */
.lora-row {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 6px;
}

.lora-row select {
    flex: 1;
    min-width: 0;
}

.lora-row .lora-strength {
    width: 55px;
    flex-shrink: 0;
}

.lora-row .lora-remove {
    font-size: 0.8rem;
    padding: 2px 6px;
    color: var(--accent);
    flex-shrink: 0;
}

/* ControlNet Description */
.cn-model-desc {
    font-size: 0.7rem;
    color: var(--accent);
    padding: 4px 0;
    min-height: 1.2em;
}

.cn-tip {
    font-size: 0.65rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: block;
    margin-top: 6px;
}

/* File Preview */
.file-preview {
    margin-top: 8px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.file-preview img {
    width: 100%;
    height: auto;
    max-height: 150px;
    object-fit: contain;
    display: block;
    background: var(--bg-input);
}

/* Content Area */
.content {
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    gap: 16px;
    flex: 1;
    min-width: 0;
    background: var(--content-bg);
}

.prompt-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(30, 30, 50, 0.5);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 16px;
}

.prompt-area .prompt-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Prompt Block */
.prompt-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prompt-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.prompt-block:first-child .prompt-label-row > span:first-child {
    color: var(--accent-green);
    font-weight: 600;
}

.prompt-block:nth-child(2) .prompt-label-row > span:first-child {
    color: var(--accent);
    font-weight: 600;
}

.btn-copy-prompt {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy-prompt:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

/* Prompt Tools */
.prompt-tools {
    display: flex;
    gap: 4px;
}

/* Wildcard */
.wildcard-hint {
    font-size: 0.7rem;
    color: var(--accent);
    padding: 4px 8px;
    background: rgba(233,69,96,0.1);
    border-radius: 4px;
    margin-top: 4px;
}

.wildcard-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 4px;
    max-height: 250px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.wildcard-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.wildcard-search-input {
    width: 120px;
    padding: 3px 8px;
    font-size: 0.7rem;
}

.wildcard-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    overflow-y: auto;
    max-height: 200px;
}

.wildcard-group-label {
    width: 100%;
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--border);
}

.wildcard-item {
    padding: 3px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.15s;
    white-space: nowrap;
}

.wildcard-item:hover {
    border-color: var(--accent);
    background: rgba(233,69,96,0.1);
}

.wildcard-tabs {
    display: flex;
    gap: 4px;
}

.wildcard-tabs .tab {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.wildcard-tabs .tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.wildcard-tabs .tab:hover {
    border-color: var(--accent);
}

.wildcard-custom {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.wc-custom-form input[type="text"],
.wc-custom-form textarea {
    width: 100%;
    font-size: 0.8rem;
}

.wc-custom-form textarea {
    resize: vertical;
}

.wc-custom-actions {
    display: flex;
    gap: 6px;
}

.wc-import-label {
    cursor: pointer;
    text-align: center;
}

.wc-custom-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wc-custom-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.75rem;
}

.wc-custom-item .wc-name {
    color: var(--accent);
    cursor: pointer;
    font-weight: 600;
}

.wc-custom-item .wc-name:hover {
    text-decoration: underline;
}

.wc-custom-item .wc-count {
    color: var(--text-secondary);
    font-size: 0.65rem;
}

.wc-custom-item .wc-remove {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0 4px;
}

/* Tag Picker */
.tag-picker {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.tag-group-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-wrap: nowrap;
    background: #1e2844;
}

.tag-tabs {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.tag-tabs .tab, .tag-subtabs .tab {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.tag-tabs .tab {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 5px 12px;
}

.tag-tabs .tab:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.tag-tabs .tab.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.tag-subtabs .tab:hover {
    border-color: var(--accent-purple);
    color: var(--text-primary);
}

.tag-subtabs .tab.active {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
    color: white;
}

.tag-search {
    width: 120px;
    padding: 4px 8px;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.tag-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 6px 10px;
    overflow-y: auto;
    max-height: 160px;
    border-bottom: 1px solid var(--border);
    min-height: 30px;
    background: #141420;
}

.tag-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 10px;
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
}

.tag-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 8px;
    border-radius: 5px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-input);
    transition: all 0.15s;
    min-width: 60px;
    text-align: center;
}

.tag-item:hover {
    border-color: var(--accent);
}

.tag-item.selected {
    background: rgba(233, 69, 96, 0.15);
    border-color: var(--accent);
}

.tag-item .tag-desc {
    font-size: 0.7rem;
    color: var(--text-primary);
    font-weight: 500;
}

.tag-item .tag-text {
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

.tag-item .tag-weight {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--accent);
    color: white;
    font-size: 0.55rem;
    padding: 1px 4px;
    border-radius: 8px;
    display: none;
}

.tag-item.selected .tag-weight {
    display: block;
}

/* Artist tags */
.tag-item.tag-artist {
    padding: 6px 10px;
}

.tag-item.tag-artist .tag-text {
    font-size: 0.72rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-top: 0;
}

.tag-item.tag-artist .tag-desc {
    font-size: 0.58rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 2px;
}

/* Collapse */
.tag-collapse-header {
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    transition: all 0.2s;
}

.tag-collapse-header:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.tag-collapse-header.expanded {
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
}

.tag-picker-collapse .tag-picker {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Action Bar */
.action-bar {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-dzmm {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.btn-dzmm:hover {
    background: linear-gradient(135deg, #5a6fd6, #6a4198);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}


.progress-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border-radius: 20px;
    padding: 4px;
    height: 28px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple), var(--accent));
    border-radius: 20px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-container span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: right;
    padding-right: 8px;
}

/* Result Area */
.result-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.placeholder {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 60px;
    border: 2px dashed rgba(74, 158, 255, 0.3);
    border-radius: var(--radius);
    text-align: center;
    width: 100%;
    background: rgba(74, 158, 255, 0.03);
}

.result-image {
    max-width: 100%;
    max-height: 500px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    object-fit: contain;
}

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

/* History Panel */
.history-panel {
    width: 200px;
    background: var(--history-bg);
    border-left: 1px solid var(--border);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.history-panel h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-amber);
    margin-bottom: 12px;
}

.history-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
}

.history-item {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.history-item:hover {
    border-color: var(--accent);
}

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

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    min-width: 360px;
    max-width: 90vw;
    box-shadow: var(--shadow);
}

.modal-content h2 {
    margin-bottom: 16px;
    font-size: 1.2rem;
}

.modal-content label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.tutorial-content {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.tutorial-body h3 {
    color: var(--accent);
    margin: 18px 0 8px;
    font-size: 1rem;
}

.tutorial-body h3:first-child {
    margin-top: 0;
}

.tutorial-body p,
.tutorial-body ul,
.tutorial-body ol {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 6px 0;
    line-height: 1.6;
}

.tutorial-body ul,
.tutorial-body ol {
    padding-left: 20px;
}

.tutorial-body code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.82rem;
    color: var(--accent);
}

.tutorial-body pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.82rem;
    overflow-x: auto;
    margin: 8px 0;
    color: var(--text-primary);
}

.preview-content {
    position: relative;
    padding: 12px;
    max-width: 90vw;
    max-height: 90vh;
}

.preview-content img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius);
}

.close-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--accent);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* History Overlay */
.history-item {
    position: relative;
}

.history-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 4px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    opacity: 0;
    transition: opacity 0.2s;
}

.history-item:hover .history-overlay {
    opacity: 1;
}

.btn-history-ref {
    background: var(--accent);
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    color: white;
    transition: transform 0.15s;
}

.btn-history-ref:hover {
    transform: scale(1.1);
}

/* Preview Actions */
.preview-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 10px;
}

/* Regional Canvas */
.regional-canvas-wrap {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
    background: var(--bg-input);
}

.regional-canvas-wrap canvas {
    width: 100%;
    height: auto;
    display: block;
    cursor: crosshair;
}

.regional-presets {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.btn-preset {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-preset:hover {
    border-color: var(--accent);
    background: var(--bg-panel);
}

/* Region Row */
.region-row {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
}

.region-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
}

.region-header .region-remove {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 6px;
}

.region-pos {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 4px;
    margin-bottom: 6px;
}

.region-pos label {
    font-size: 0.7rem;
    margin-bottom: 0;
}

.region-pos input {
    padding: 4px 6px;
    font-size: 0.75rem;
}

.region-prompt {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
    resize: vertical;
    font-family: inherit;
}

.region-prompt:focus {
    border-color: var(--accent);
    outline: none;
}

/* Image Compare Slider */
.compare-content {
    max-width: 800px;
    width: 90vw;
}

.compare-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius);
    cursor: ew-resize;
    user-select: none;
    -webkit-user-select: none;
}

.compare-img {
    width: 100%;
    display: block;
}

.compare-container .compare-img:first-child {
    position: absolute;
    top: 0;
    left: 0;
    clip-path: inset(0 50% 0 0);
}

.compare-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    background: white;
    box-shadow: 0 0 8px rgba(0,0,0,0.5);
    z-index: 10;
    pointer-events: none;
}

.compare-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.compare-handle::before {
    content: '◀▶';
    font-size: 10px;
    color: #333;
    letter-spacing: -2px;
}

.compare-label {
    position: absolute;
    top: 10px;
    padding: 3px 10px;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 0.7rem;
    border-radius: 4px;
    z-index: 5;
    pointer-events: none;
}

.compare-label-left { left: 10px; }
.compare-label-right { right: 10px; }

/* Utility */
.hidden {
    display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ==================== 工作流模式 ==================== */
.mode-switcher {
    display: flex;
    gap: 0;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: rgba(20, 20, 40, 0.8);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
}

.mode-tab {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.mode-tab:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

.mode-tab:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.mode-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.mode-tab:not(.active):hover {
    background: var(--bg-panel);
    color: var(--text-primary);
}

.mode-content {
    display: block;
}

.mode-content.hidden {
    display: none;
}

/* Workflow panel */
.wf-section {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.wf-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.wf-header-row h2 {
    font-size: 14px;
    font-weight: 600;
}

.wf-actions {
    display: flex;
    gap: 6px;
}

.btn-sm {
    padding: 4px 10px !important;
    font-size: 12px !important;
}

#sel-workflow {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
}

.wf-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.wf-info.hidden {
    display: none;
}

.wf-params {
    padding: 12px;
    overflow-y: auto;
}

.wf-placeholder {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 32px 12px;
}

/* Dynamic form groups */
.wf-group {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.wf-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    user-select: none;
}

.wf-group-header:hover {
    background: var(--bg-panel);
}

.wf-group-header .wf-group-toggle {
    font-size: 11px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.wf-group.open .wf-group-toggle {
    transform: rotate(90deg);
}

.wf-group-body {
    display: none;
    padding: 8px 12px;
}

.wf-group.open .wf-group-body {
    display: block;
}

.wf-field {
    margin-bottom: 8px;
}

.wf-field label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.wf-field input[type="number"],
.wf-field input[type="text"],
.wf-field select,
.wf-field textarea {
    width: 100%;
    padding: 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
}

.wf-field textarea {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.wf-field input[type="checkbox"] {
    width: auto;
}

.wf-field-row {
    display: flex;
    gap: 8px;
}

.wf-field-row .wf-field {
    flex: 1;
}

.wf-warning {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 12px;
    color: #ffc107;
    margin-bottom: 12px;
}

#txt-wf-paste {
    width: 100%;
    min-height: 200px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: 'Consolas', monospace;
    font-size: 12px;
    padding: 10px;
    resize: vertical;
    margin-bottom: 12px;
}

/* LoRA Manager Widget */
.wf-lora-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lora-manager-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
}

.lora-active-label {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
    overflow: hidden;
}

.lora-active-label input[type="checkbox"] {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.lora-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: 12px;
}

.lora-strength-inp {
    width: 66px !important;
    min-width: 66px;
    max-width: 66px;
    flex-shrink: 0;
    padding: 3px 6px;
    font-size: 12px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-align: center;
    box-sizing: border-box;
    -moz-appearance: textfield;
}

.lora-strength-inp::-webkit-outer-spin-button,
.lora-strength-inp::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* TriggerWord Toggle Widget */
.wf-trigger-words {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tw-tag {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    opacity: 0.5;
}

.tw-tag.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    opacity: 1;
}

.tw-tag:hover {
    border-color: var(--accent);
    opacity: 0.85;
}

/* Responsive - Tablet */
@media (max-width: 1000px) {
    .main {
        flex-direction: column;
    }

    .sidebar-resizer {
        display: none;
    }

    .sidebar {
        width: 100% !important;
        max-width: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: none;
        overflow-y: auto;
    }

    .history-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 200px;
    }

    .history-grid {
        flex-direction: row;
    }

    .history-item {
        width: 80px;
        min-width: 80px;
    }
}

/* Responsive - Mobile */
@media (max-width: 640px) {
    .app {
        height: auto;
        min-height: 100vh;
    }

    .header {
        padding: 8px 12px;
    }

    .header h1 {
        font-size: 1.1rem;
    }

    .main {
        flex-direction: column;
        overflow: visible;
    }

    .sidebar-resizer {
        display: none;
    }

    .sidebar {
        width: 100% !important;
        max-width: none;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 8px;
        overflow-y: auto;
    }

    .mode-switcher {
        margin-bottom: 8px;
    }

    .mode-tab {
        padding: 8px 16px;
        font-size: 14px;
    }

    .content {
        padding: 12px;
    }

    .prompt-area {
        gap: 12px;
    }

    .prompt-block textarea {
        font-size: 14px;
        min-height: 60px;
    }

    .prompt-label-row {
        flex-wrap: wrap;
        gap: 4px;
    }

    .tag-picker {
        max-height: 250px;
        overflow-y: auto;
    }

    .tag-tabs, .tag-subtabs {
        flex-wrap: wrap;
        gap: 4px;
    }

    .tag-tabs .tab, .tag-subtabs .tab {
        padding: 6px 10px;
        font-size: 12px;
    }

    .tag-grid {
        gap: 4px;
    }

    .tag-item {
        padding: 6px 8px;
        font-size: 11px;
    }

    .compact-row {
        flex-direction: column;
        gap: 8px;
    }

    .compact-row label {
        width: 100%;
    }

    .action-bar {
        padding: 12px;
    }

    .btn-primary {
        width: 100%;
        padding: 14px;
        font-size: 16px;
    }

    .result-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .result-actions button {
        flex: 1;
        min-width: calc(50% - 4px);
    }

    .history-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 160px;
        padding: 8px;
    }

    .history-grid {
        flex-direction: row;
        gap: 6px;
    }

    .history-item {
        width: 70px;
        min-width: 70px;
    }

    /* Workflow mode mobile */
    .wf-header-row {
        flex-wrap: wrap;
        gap: 6px;
    }

    .wf-group-body {
        padding: 6px 8px;
    }

    .wf-field label {
        font-size: 12px;
    }

    .wf-field textarea, .wf-field input, .wf-field select {
        font-size: 14px;
    }

    .lora-manager-item {
        padding: 8px;
    }

    .lora-name {
        font-size: 13px;
    }

    .tw-tag {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* Modals mobile */
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .tutorial-content {
        padding: 16px;
    }

    .compare-content {
        width: 95%;
    }

    .preview-content img {
        max-height: 70vh;
    }

    /* Seed row mobile */
    .seed-row {
        flex-direction: row;
    }

    /* Regional prompt mobile */
    .regional-canvas-wrap {
        max-width: 100%;
    }

    .regional-canvas-wrap canvas {
        width: 100%;
        height: auto;
    }

    .region-pos {
        flex-wrap: wrap;
    }

    .region-pos label {
        width: calc(50% - 4px);
    }

    /* Wildcard panel mobile */
    .wildcard-panel {
        max-height: 300px;
    }
}

/* ==================== 主题系统 ==================== */

/* 主题切换按钮 */
.theme-btn {
    position: relative;
}

.theme-panel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    display: flex;
    gap: 6px;
    box-shadow: var(--shadow);
    z-index: 100;
}

.theme-panel.hidden {
    display: none;
}

.theme-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.theme-dot:hover {
    transform: scale(1.15);
}

.theme-dot.active {
    border-color: white;
    box-shadow: 0 0 8px rgba(255,255,255,0.3);
}

.theme-dot[data-theme="default"] { background: linear-gradient(135deg, #1a1a2e, #e94560); }
.theme-dot[data-theme="cyberpunk"] { background: linear-gradient(135deg, #0a0a14, #00d4ff); }
.theme-dot[data-theme="forest"] { background: linear-gradient(135deg, #0f1a14, #10b981); }
.theme-dot[data-theme="sunset"] { background: linear-gradient(135deg, #1a1410, #f59e0b); }
.theme-dot[data-theme="lavender"] { background: linear-gradient(135deg, #1a1428, #a78bfa); }
.theme-dot[data-theme="light"] { background: linear-gradient(135deg, #f0f0f5, #3b82f6); }

/* 赛博朋克主题 */
[data-theme="cyberpunk"] {
    --bg-primary: #0a0a14;
    --bg-secondary: #0e0e1c;
    --bg-panel: #141428;
    --bg-input: #0c0c1a;
    --accent: #00d4ff;
    --accent-hover: #33dfff;
    --accent-blue: #00d4ff;
    --accent-green: #00ff88;
    --accent-purple: #ff00ff;
    --accent-amber: #ffdd00;
    --accent-teal: #00ffc8;
    --text-primary: #e0f0ff;
    --text-secondary: #6688aa;
    --border: #1a2a3e;
    --border-subtle: #141e2e;
    --shadow: 0 4px 12px rgba(0, 212, 255, 0.1);
    --sidebar-bg: #0c0c18;
    --content-bg: #0a0a12;
    --history-bg: #0c0e18;
    --header-bg: linear-gradient(135deg, #0e0e1c, #0a1628);
}

[data-theme="cyberpunk"] .header h1 {
    background: linear-gradient(135deg, #00d4ff, #ff00ff);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="cyberpunk"] .tag-group-row {
    background: #0e1828;
}

[data-theme="cyberpunk"] .tag-subtabs {
    background: #080810;
}

[data-theme="cyberpunk"] .progress-bar {
    background: linear-gradient(90deg, #00d4ff, #ff00ff, #ffdd00);
}

/* 森林主题 */
[data-theme="forest"] {
    --bg-primary: #0f1a14;
    --bg-secondary: #132218;
    --bg-panel: #1a2e20;
    --bg-input: #111e16;
    --accent: #10b981;
    --accent-hover: #34d399;
    --accent-blue: #38bdf8;
    --accent-green: #10b981;
    --accent-purple: #8b9cf7;
    --accent-amber: #fbbf24;
    --accent-teal: #2dd4bf;
    --text-primary: #e0f0e8;
    --text-secondary: #7aa08a;
    --border: #1e3828;
    --border-subtle: #1a2e22;
    --shadow: 0 4px 12px rgba(16, 185, 129, 0.1);
    --sidebar-bg: #111e16;
    --content-bg: #0e1a12;
    --history-bg: #121e18;
    --header-bg: linear-gradient(135deg, #132218, #0e2016);
}

[data-theme="forest"] .header h1 {
    background: linear-gradient(135deg, #10b981, #a3e635);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="forest"] .tag-group-row {
    background: #1a3024;
}

[data-theme="forest"] .tag-subtabs {
    background: #0c1610;
}

[data-theme="forest"] .progress-bar {
    background: linear-gradient(90deg, #10b981, #a3e635, #fbbf24);
}

/* 日落主题 */
[data-theme="sunset"] {
    --bg-primary: #1a1410;
    --bg-secondary: #221a14;
    --bg-panel: #2e2218;
    --bg-input: #1e1610;
    --accent: #f59e0b;
    --accent-hover: #fbbf24;
    --accent-blue: #fb923c;
    --accent-green: #a3e635;
    --accent-purple: #f472b6;
    --accent-amber: #f59e0b;
    --accent-teal: #fbbf24;
    --text-primary: #f0e8e0;
    --text-secondary: #a08a70;
    --border: #382e1e;
    --border-subtle: #2e2418;
    --shadow: 0 4px 12px rgba(245, 158, 11, 0.1);
    --sidebar-bg: #1e1810;
    --content-bg: #1a140e;
    --history-bg: #1e1a14;
    --header-bg: linear-gradient(135deg, #221a14, #281e12);
}

[data-theme="sunset"] .header h1 {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="sunset"] .tag-group-row {
    background: #2e2416;
}

[data-theme="sunset"] .tag-subtabs {
    background: #14100c;
}

[data-theme="sunset"] .progress-bar {
    background: linear-gradient(90deg, #f59e0b, #ef4444, #f472b6);
}

/* 薰衣草主题 */
[data-theme="lavender"] {
    --bg-primary: #1a1428;
    --bg-secondary: #201830;
    --bg-panel: #2a2040;
    --bg-input: #1c1630;
    --accent: #a78bfa;
    --accent-hover: #c4b5fd;
    --accent-blue: #818cf8;
    --accent-green: #a3e635;
    --accent-purple: #a78bfa;
    --accent-amber: #fbbf24;
    --accent-teal: #c084fc;
    --text-primary: #ece8f4;
    --text-secondary: #8a80a0;
    --border: #322850;
    --border-subtle: #282040;
    --shadow: 0 4px 12px rgba(167, 139, 250, 0.1);
    --sidebar-bg: #1c1630;
    --content-bg: #181226;
    --history-bg: #1c182e;
    --header-bg: linear-gradient(135deg, #201830, #1e1838);
}

[data-theme="lavender"] .header h1 {
    background: linear-gradient(135deg, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="lavender"] .tag-group-row {
    background: #28204a;
}

[data-theme="lavender"] .tag-subtabs {
    background: #141020;
}

[data-theme="lavender"] .progress-bar {
    background: linear-gradient(90deg, #818cf8, #a78bfa, #f472b6);
}

/* 纯白亮色主题 */
[data-theme="light"] {
    --bg-primary: #f5f5fa;
    --bg-secondary: #ffffff;
    --bg-panel: #eef0f5;
    --bg-input: #ffffff;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-purple: #8b5cf6;
    --accent-amber: #f59e0b;
    --accent-teal: #14b8a6;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --border-subtle: #eef0f5;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --sidebar-bg: #f8f9fc;
    --content-bg: #f0f2f8;
    --history-bg: #f5f7fa;
    --header-bg: linear-gradient(135deg, #ffffff, #f0f2f8);
}

[data-theme="light"] .header h1 {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="light"] .tag-group-row {
    background: #e8ecf4;
}

[data-theme="light"] .tag-subtabs {
    background: #f0f2f8;
}

[data-theme="light"] .progress-bar {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
}

[data-theme="light"] .btn-icon {
    color: var(--text-secondary);
}

[data-theme="light"] .btn-primary:hover {
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

[data-theme="light"] .placeholder {
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.03);
}

[data-theme="light"] select,
[data-theme="light"] input[type="number"],
[data-theme="light"] input[type="text"],
[data-theme="light"] textarea {
    border-color: #d1d5db;
}

[data-theme="light"] .panel-group[data-group="basic"] .panel-group-header {
    color: #2563eb;
}

[data-theme="light"] .panel-group[data-group="enhance"] .panel-group-header {
    color: #7c3aed;
}

[data-theme="light"] .panel-group[data-group="control"] .panel-group-header {
    color: #0d9488;
}

[data-theme="light"] .panel-group[data-group="post"] .panel-group-header {
    color: #d97706;
}

/* ==================== 提示词标签可视化编辑器 ==================== */
.prompt-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 6px 8px;
    min-height: 0;
    max-height: 200px;
    overflow-y: auto;
    border-radius: 0 0 var(--radius) var(--radius);
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border);
    border-top: none;
    margin-top: -1px;
    transition: min-height 0.2s;
}

.prompt-tags:empty {
    display: none;
}

.prompt-tag {
    display: inline-flex;
    align-items: flex-start;
    gap: 3px;
    padding: 3px 6px;
    border-radius: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-primary);
    cursor: grab;
    user-select: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    max-width: 200px;
    position: relative;
    flex-shrink: 0;
}

.prompt-tag:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 0 6px rgba(74, 158, 255, 0.2);
}

.prompt-tag.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.prompt-tag.drag-over {
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(233, 69, 96, 0.3);
}

.prompt-tag-text-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    overflow: hidden;
    line-height: 1.2;
}

.prompt-tag-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prompt-tag-weight {
    font-size: 10px;
    color: var(--accent-amber);
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    cursor: default;
}

.prompt-tag-actions {
    display: none;
    align-items: center;
    gap: 2px;
    margin-left: 2px;
}

.prompt-tag:hover .prompt-tag-actions {
    display: inline-flex;
}

.prompt-tag-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 11px;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.15s, color 0.15s;
}

.prompt-tag-btn:hover {
    opacity: 1;
}

.prompt-tag-btn.btn-weight-up:hover { color: var(--accent-green); }
.prompt-tag-btn.btn-weight-down:hover { color: var(--accent); }
.prompt-tag-btn.btn-tag-copy:hover { color: var(--accent-blue); }
.prompt-tag-btn.btn-tag-delete:hover { color: #ff4444; }

.prompt-tag-input {
    background: var(--bg-input);
    border: 1px solid var(--accent-blue);
    color: var(--text-primary);
    font-size: 12px;
    padding: 1px 4px;
    border-radius: 3px;
    width: 100px;
    outline: none;
}

.prompt-tags-bar {
    position: relative;
}

.prompt-tags-bar:has(.prompt-tags:empty) .btn-translate-toggle {
    display: none;
}

.btn-translate-toggle {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-panel);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    z-index: 1;
}

.btn-translate-toggle:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.btn-translate-toggle.active {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

.prompt-tag-zh {
    font-size: 10px;
    color: var(--accent-teal);
    white-space: nowrap;
    line-height: 1.2;
}

/* ==================== 元数据解析弹窗 ==================== */
.modal-meta-content {
    max-width: 620px;
    max-height: 85vh;
    overflow-y: auto;
}

.meta-source {
    font-size: 13px;
    color: var(--accent-blue);
    margin-bottom: 10px;
    font-weight: 600;
}

.meta-source.meta-no-data {
    color: var(--accent);
}

.meta-preview {
    text-align: center;
    margin-bottom: 12px;
}

.meta-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 6px;
    border: 1px solid var(--border);
    object-fit: contain;
}

.meta-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meta-field {
    display: flex;
    gap: 8px;
    padding: 5px 8px;
    background: var(--bg-input);
    border-radius: 4px;
    font-size: 12px;
    align-items: flex-start;
}

.meta-field-label {
    min-width: 70px;
    color: var(--text-secondary);
    font-weight: 600;
    flex-shrink: 0;
}

.meta-field-value {
    color: var(--text-primary);
    word-break: break-all;
    flex: 1;
    max-height: 80px;
    overflow-y: auto;
    line-height: 1.4;
}

.meta-raw {
    margin-top: 10px;
}

.meta-raw-toggle {
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 0;
    user-select: none;
}

.meta-raw-toggle:hover {
    color: var(--accent-blue);
}

.meta-raw pre {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px;
    font-size: 11px;
    max-height: 200px;
    overflow: auto;
    margin-top: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-secondary);
}

/* ========== NAI 在线生图模式 ========== */
.btn-nai {
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    border: none;
    color: #fff;
}
.btn-nai:hover {
    background: linear-gradient(135deg, #0f766e, #0d9488);
}

.nai-apikey-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.nai-apikey-row input {
    flex: 1;
}

.nai-size-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.nai-size-btn {
    flex: 1;
    min-width: 100px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    text-align: center;
    transition: all .2s;
}
.nai-size-btn:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}
.nai-size-btn.active {
    border-color: #14b8a6;
    background: rgba(20,184,166,.15);
    color: #14b8a6;
    font-weight: 600;
}

.nai-upscale-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 13px;
}

.nai-premium-badge {
    font-size: 11px;
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    color: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}

.nai-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
}
.nai-slider-row label {
    min-width: 80px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.nai-slider-row input[type="range"] {
    flex: 1;
    accent-color: #14b8a6;
}
.nai-slider-val {
    min-width: 32px;
    text-align: right;
    font-size: 13px;
    color: #14b8a6;
    font-weight: 600;
}

.nai-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}
.nai-toggles label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary);
}
.nai-toggles input[type="checkbox"] {
    accent-color: #14b8a6;
}

.nai-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.5;
}

.nai-upload-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
}
.nai-upload-zone:hover {
    border-color: #14b8a6;
    background: rgba(20,184,166,.05);
}
.nai-upload-zone.nai-premium-zone {
    border-color: rgba(168,85,247,.3);
}
.nai-upload-zone.nai-premium-zone:hover {
    border-color: #a855f7;
    background: rgba(168,85,247,.05);
}

.nai-remove-img {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nai-character-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.nai-character-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
}
.nai-character-item h3 {
    font-size: 13px;
    margin: 0 0 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nai-character-item textarea {
    width: 100%;
    min-height: 40px;
    resize: vertical;
    font-size: 12px;
}

.nai-vibe-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.nai-video-frames {
    display: flex;
    gap: 12px;
}
.nai-frame-col {
    flex: 1;
}
.nai-frame-col h3 {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 6px;
}
.nai-frame-zone {
    min-height: 100px;
    padding: 16px;
}
.nai-frame-col .file-preview {
    position: relative;
}
.nai-frame-col .file-preview img {
    width: 100%;
    border-radius: 6px;
}
