  :root {
    --primary: #2b5a9e;
    --primary-light: #d6e4f5;
    --accent: #5fb4e8;
    --bg: #f5f7fa;
    --card: #ffffff;
    --border: #e1e6ed;
    --text: #1f2937;
    --muted: #6b7280;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
  }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Microsoft YaHei", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
  }
  header {
    background: linear-gradient(135deg, var(--primary), #4a7bc3);
    color: white;
    padding: 24px 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  }
  header h1 { margin: 0; font-size: 22px; font-weight: 600; }
  header p { margin: 4px 0 0; opacity: 0.9; font-size: 13px; }
  .container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px;
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 24px;
  }
  @media (max-width: 1024px) { .container { grid-template-columns: 1fr; } }
  .panel {
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  }
  .panel h2 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .panel h2 .badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
  }
  .field { margin-bottom: 12px; }
  .field label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
    font-weight: 500;
  }
  .field input, .field textarea, .field select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s;
  }
  .field input:focus, .field textarea:focus, .field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(95,180,232,0.15);
  }
  .field textarea { resize: vertical; min-height: 60px; }
  .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .tabs {
    display: flex;
    background: var(--bg);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 16px;
  }
  .tab {
    flex: 1;
    padding: 8px 12px;
    text-align: center;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    transition: all 0.15s;
  }
  .tab.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  }
  .tab-content { display: none; }
  .tab-content.active { display: block; }
  .uploader {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--bg);
  }
  .uploader:hover { border-color: var(--accent); background: #f0f7fc; }
  .uploader.has-file {
    border-style: solid;
    border-color: var(--success);
    background: #ecfdf5;
  }
  .uploader-icon { font-size: 24px; opacity: 0.5; margin-bottom: 4px; }
  .uploader-text { font-size: 12px; color: var(--muted); }
  .uploader-hint {
    margin-top: 4px;
    font-size: 11px;
    color: var(--muted);
  }
  .uploader-filename {
    font-size: 11px;
    color: var(--success);
    margin-top: 4px;
    word-break: break-all;
  }
  .preview-thumb {
    max-width: 100%;
    max-height: 80px;
    border-radius: 4px;
    margin-top: 8px;
    object-fit: contain;
  }
  .upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }
  .upload-grid .uploader { padding: 12px 8px; }
  .reference-uploader {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 18px 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--bg);
  }
  .reference-uploader:hover,
  .reference-uploader.dragging {
    border-color: var(--accent);
    background: #f0f7fc;
  }
  .reference-uploader.compact {
    padding: 12px;
  }
  .reference-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 10px;
  }
  .reference-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    overflow: hidden;
  }
  .reference-thumb-wrap {
    height: 104px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
  }
  .reference-thumb {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
  .reference-meta {
    padding: 8px;
  }
  .reference-name {
    font-size: 11px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
  }
  .reference-ratio {
    color: var(--muted);
    font-size: 10px;
    margin: -2px 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .reference-category {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    background: white;
  }
  .reference-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
  }
  .reference-remove {
    border: none;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 0;
  }
  .asset-library {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
    background: #fbfcfe;
  }
  .asset-library-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
  }
  .asset-title {
    font-size: 13px;
    font-weight: 600;
  }
  .asset-subtitle {
    margin-top: 2px;
    font-size: 11px;
    color: var(--muted);
  }
  .asset-list {
    display: grid;
    gap: 8px;
  }
  .asset-list.empty {
    display: block;
    color: var(--muted);
    font-size: 12px;
  }
  .asset-item {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px;
    background: white;
  }
  .asset-item.active {
    border-color: var(--accent);
    background: #f0f7fc;
  }
  .asset-thumb {
    width: 44px;
    height: 44px;
    border-radius: 4px;
    background: var(--bg);
    object-fit: contain;
    border: 1px solid var(--border);
  }
  .asset-name {
    font-size: 12px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .asset-note {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .asset-actions {
    display: flex;
    gap: 4px;
  }
  .mini-btn {
    border: 1px solid var(--border);
    background: white;
    color: var(--primary);
    border-radius: 6px;
    padding: 6px 9px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
  }
  .mini-btn:hover {
    border-color: var(--accent);
    background: var(--primary-light);
  }
  .mini-btn.muted {
    color: var(--muted);
  }
  .mini-btn.danger {
    color: var(--danger);
  }
  .style-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
  }
  .style-preview img {
    max-width: 100%;
    max-height: 90px;
    object-fit: contain;
    border-radius: 4px;
    margin-top: 8px;
  }
  .task-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }
  .task-list {
    display: grid;
    gap: 8px;
  }
  .task-list.empty {
    display: block;
    color: var(--muted);
    font-size: 12px;
  }
  .task-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfe;
    padding: 10px;
  }
  .task-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 3px;
  }
  .task-meta {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 8px;
  }
  .task-item-actions {
    display: flex;
    gap: 6px;
  }
  .file-library {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 2px;
  }
  .file-library.empty {
    display: block;
    color: var(--muted);
    font-size: 12px;
  }
  .file-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    overflow: hidden;
  }
  .file-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: var(--bg);
    display: block;
    cursor: zoom-in;
  }
  .file-meta {
    padding: 7px;
  }
  .file-title {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .file-note {
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .file-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-top: 6px;
  }
  .file-actions .mini-btn {
    padding: 4px 6px;
    font-size: 11px;
  }
  .checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
  }
  .checkbox-item:hover { background: var(--bg); }
  .checkbox-item input[type="checkbox"] { margin-top: 2px; }
  .checkbox-item.checked {
    border-color: var(--accent);
    background: #f0f7fc;
  }
  .btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
  }
  .btn-primary {
    background: var(--primary);
    color: white;
  }
  .btn-primary:hover:not(:disabled) { background: #234a85; transform: translateY(-1px); }
  .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
  .btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
  }
  .btn-secondary:hover { background: #e5e9f0; }
  .settings-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 500;
  }
  .settings-body { display: none; padding: 4px 0 12px; }
  .settings-body.open { display: block; }
  .api-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #fef3c7;
    color: #92400e;
  }
  .api-status.connected { background: #d1fae5; color: #065f46; }
  .api-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
  }
  .result-area {
    min-height: 600px;
  }
  .placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--muted);
    text-align: center;
  }
  .placeholder-icon { font-size: 48px; opacity: 0.3; margin-bottom: 16px; }
  .result-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  }
  .result-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
  }
  .result-card img {
    width: 100%;
    display: block;
    cursor: zoom-in;
  }
  .result-card-actions {
    padding: 10px 12px;
    background: white;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
  }
  .result-card-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
  }
  .icon-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
  }
  .icon-btn:hover { background: var(--primary-light); border-color: var(--accent); }
  .loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px 20px;
  }
  .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .log {
    background: #1e293b;
    color: #cbd5e1;
    padding: 12px;
    border-radius: 6px;
    font-family: "SF Mono", Monaco, monospace;
    font-size: 11px;
    max-height: 150px;
    overflow-y: auto;
    margin-top: 12px;
    white-space: pre-wrap;
    word-break: break-all;
  }
  .log-entry { margin-bottom: 4px; }
  .log-entry.error { color: #fca5a5; }
  .log-entry.success { color: #86efac; }
  .log-entry.info { color: #93c5fd; }
  .alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
  }
  .alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 3px solid var(--warning);
  }
  .alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 3px solid var(--danger);
  }
  .prompt-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 11px;
    color: var(--muted);
    max-height: 120px;
    overflow-y: auto;
    margin-top: 8px;
    white-space: pre-wrap;
    font-family: "SF Mono", Monaco, monospace;
  }
  .section-divider {
    margin: 16px 0 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.85);
    display: none; align-items: center; justify-content: center;
    z-index: 100; padding: 20px;
  }
  .modal.open { display: flex; }
  .modal img { max-width: 100%; max-height: 95vh; border-radius: 4px; }
  .modal-close {
    position: absolute; top: 16px; right: 16px;
    background: white; border: none; border-radius: 50%;
    width: 36px; height: 36px; cursor: pointer; font-size: 18px;
  }
