:root {
    --bg: #0b1220;
    --bg-card: #121a2b;
    --bg-hover: #1a2438;
    --border: #2a3a55;
    --text: #e8eef8;
    --text-muted: #8ba0c0;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --accent: #22d3ee;
    --danger: #ef5350;
    --warning: #ffb74d;
    --sidebar-w: 240px;
    --radius: 12px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

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

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #0e1628 0%, #0b1220 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.35);
}

.brand strong {
    display: block;
    font-size: 0.95rem;
}

.brand small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.step-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.step-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    width: 100%;
}

.step-link:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.step-link.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.step-link.done .step-num {
    background: var(--primary);
    color: #fff;
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-label {
    font-size: 0.875rem;
}

.account-panel {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.account-guest {
    display: flex;
    gap: 8px;
}

.account-guest .btn {
    flex: 1;
}

.account-user {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* display:flex 가 hidden 속성을 덮어쓰지 않도록 */
.account-guest[hidden],
.account-user[hidden],
[hidden] {
    display: none !important;
}

.account-user-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.account-user-meta strong {
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.credit-badge {
    display: inline-flex;
    align-self: flex-start;
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(34, 211, 238, 0.12);
    color: var(--accent);
    border: 1px solid rgba(34, 211, 238, 0.28);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.cloud-hint {
    margin-top: 6px !important;
    font-size: 0.8rem !important;
    color: var(--text-muted) !important;
}

.cloud-hint.is-cloud {
    color: var(--primary) !important;
}

.lang-menu {
    position: relative;
    display: inline-block;
    z-index: 40;
}

.lang-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(18, 31, 24, 0.95);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 7px 12px;
    cursor: pointer;
    line-height: 1;
}

.lang-menu-btn:hover,
.lang-menu.open .lang-menu-btn {
    border-color: rgba(59, 130, 246, 0.55);
    background: rgba(59, 130, 246, 0.12);
}

.lang-menu-label {
    color: var(--text);
}

.lang-menu-current {
    color: var(--primary);
    font-weight: 700;
}

.lang-menu-caret {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.lang-menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 140px;
    padding: 6px;
    border: 1px solid #3a4f6e;
    border-radius: 12px;
    background: #152038;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 50;
}

.lang-menu-option {
    border: none;
    background: transparent;
    color: #f1f5fb;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.lang-menu-option:hover {
    background: rgba(59, 130, 246, 0.14);
}

.lang-menu-option.active {
    background: rgba(59, 130, 246, 0.22);
    color: #93c5fd;
}

/* 슬롯 누락 시 자동 생성되는 플로팅 전환 버튼 */
.lang-switch-floating {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 9999;
}

.auth-modal {
    max-width: 420px;
}

.auth-card {
    position: relative;
    padding: 28px 28px 24px;
    background:
        radial-gradient(120% 80% at 0% 0%, rgba(59, 130, 246, 0.12), transparent 55%),
        var(--bg-card);
}

.auth-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-right: 28px;
}

.auth-brand img {
    border-radius: 10px;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.auth-brand strong {
    display: block;
    font-size: 1rem;
}

.auth-brand small {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 18px;
    padding: 4px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
}

.auth-tab {
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 9px;
    padding: 11px 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}

.auth-tab.active {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.28);
}

.auth-form .form-group {
    margin-bottom: 14px;
}

.auth-form .form-group label {
    font-size: 0.82rem;
    letter-spacing: 0.01em;
}

.auth-form input {
    width: 100%;
    box-sizing: border-box;
}

.btn-block {
    width: 100%;
    justify-content: center;
    margin-top: 6px;
    padding: 13px 16px;
}

.form-error {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(239, 83, 80, 0.12);
    border: 1px solid rgba(239, 83, 80, 0.3);
    color: var(--danger);
    font-size: 0.875rem;
}

.projects-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow: auto;
    margin-top: 12px;
}

.projects-empty {
    color: #b7c7e0;
    font-size: 0.9rem;
    padding: 16px 0;
}

.project-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid #3a4f6e;
    border-radius: 10px;
    background: #1c2a40;
    color: #f1f5fb;
}

.project-row strong {
    display: block;
    font-size: 0.98rem;
    font-weight: 700;
    color: #f5f8fc;
    line-height: 1.4;
}

.project-row small {
    display: block;
    margin-top: 4px;
    color: #b7c7e0;
    font-size: 0.8rem;
}

.project-row-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.project-row-actions .btn-ghost {
    color: #d7e3f4;
    border-color: #45608a;
}

.project-row-actions .btn-ghost:hover {
    color: #fff;
    border-color: var(--primary);
}

@media (max-width: 720px) {
    .topbar-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .project-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Main */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 24px 32px 48px;
    max-width: 1200px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
    gap: 16px;
}

.topbar h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.topbar p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-badge {
    font-size: 0.75rem;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(239, 83, 80, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 83, 80, 0.3);
}

.status-badge.connected {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    border-color: rgba(59, 130, 246, 0.3);
}

/* Panels */
.panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card-wide {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

.card-actions-end {
    justify-content: flex-end;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.char-count {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Form elements */
textarea,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 14px 16px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

input[type="email"]::placeholder,
input[type="password"]::placeholder,
input[type="text"]::placeholder {
    color: #6f87a8;
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

#scriptInput {
    min-height: 320px;
    line-height: 1.8;
}

.readonly-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    max-height: 280px;
    overflow-y: auto;
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Progress */
.progress-bar-wrap {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--bg-hover);
    color: var(--text-muted);
}

.badge-warning {
    background: rgba(255, 183, 77, 0.15);
    color: var(--warning);
}

/* Prompt list */
.prompt-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 480px;
    overflow-y: auto;
}

.prompt-item {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    align-items: flex-start;
}

.prompt-item-meta {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 120px;
}

.prompt-item .num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.prompt-style-badge {
    display: block;
    width: 100%;
    padding: 4px 6px;
    border-radius: 6px;
    background: rgba(34, 211, 238, 0.12);
    border: 1px solid rgba(34, 211, 238, 0.3);
    color: #7dd3fc;
    font-size: 0.65rem;
    line-height: 1.25;
    text-align: center;
    word-break: keep-all;
}

.prompt-title-badge {
    display: block;
    width: 100%;
    padding: 4px 6px;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #93c5fd;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    word-break: keep-all;
}

.prompt-part-hint {
    display: block;
    width: 100%;
    font-size: 0.62rem;
    color: var(--text-muted);
    text-align: center;
}

.image-card .title-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 2;
    max-width: calc(100% - 16px);
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.72);
    color: #e8eef8;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-item textarea {
    flex: 1;
    min-height: 60px;
    padding: 8px 10px;
    font-size: 0.85rem;
    resize: none;
}

.prompt-item .status-icon {
    flex-shrink: 0;
    font-size: 1.2rem;
}

/* Image grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    max-height: 600px;
    overflow-y: auto;
}

.image-card {
    aspect-ratio: 16/9;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, border-color 0.2s;
}

.image-card:hover {
    transform: scale(1.03);
    border-color: var(--primary);
}

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

.image-card .overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.image-card .num-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.7);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}

.image-card.loading .overlay::after {
    content: "";
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.image-card.error {
    border-color: var(--danger);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Meta grid */
.meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.thumbnail-preview {
    aspect-ratio: 16/9;
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.thumbnail-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-preview .placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Subtitle */
.subtitle-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.upload-zone p {
    margin-bottom: 8px;
}

.upload-zone small {
    color: var(--text-muted);
}

.compare-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    gap: 12px;
}

.compare-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.compare-options input[type="number"] {
    width: 60px;
    padding: 6px 8px;
    text-align: center;
}

.diff-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.diff-item {
    display: grid;
    grid-template-columns: 80px 1fr 1fr auto;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.85rem;
    align-items: center;
}

.diff-item .time {
    color: var(--accent);
    font-family: monospace;
    font-size: 0.75rem;
}

.diff-item .old {
    color: var(--danger);
    text-decoration: line-through;
}

.diff-item .new {
    color: var(--primary);
}

.diff-item .chars {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Modal — 화면 정중앙 (dialog는 color 상속이 안 되어 명시 필요) */
.modal {
    border: none;
    padding: 0;
    background: transparent;
    color: var(--text);
    max-width: 480px;
    width: min(92vw, 480px);
    margin: auto;
    position: fixed;
    inset: 0;
    max-height: min(90vh, 920px);
    height: fit-content;
}

.modal::backdrop {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
}

.modal-lg {
    max-width: 800px;
    width: min(92vw, 800px);
}

.modal-content {
    background: #152038;
    border: 1px solid #3a4f6e;
    border-radius: var(--radius);
    padding: 24px;
    max-height: min(90vh, 920px);
    overflow: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    color: #f1f5fb;
}

.modal-content .hint,
.modal-content .hint-inline {
    color: #b7c7e0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #f1f5fb;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.btn-close:hover {
    color: var(--text);
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 10px;
    color: var(--text) !important;
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
}

#modelCheckInfo {
    display: block;
    margin-top: 8px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.modal-prompt {
    margin: 12px 0 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

#imageModalImg {
    width: 100%;
    border-radius: 8px;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    font-size: 0.9rem;
}

.toast.success { border-left: 3px solid var(--primary); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 18, 32, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    gap: 16px;
}

.loading-overlay .spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.style-picker-box {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.1), rgba(59, 130, 246, 0.06));
}

.style-picker-box h3 {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.style-picker-box > p {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 14px;
}

.style-mode-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.style-mode-row-4 {
    grid-template-columns: repeat(4, 1fr);
}

.text-density-block {
    margin-bottom: 14px;
}

.text-density-block h4 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--text);
    font-weight: 600;
}

.style-mode-btn {
    appearance: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 12px;
    background: rgba(0, 0, 0, 0.22);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.style-mode-btn strong {
    display: block;
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.style-mode-btn span {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.style-mode-btn:hover {
    border-color: rgba(59, 130, 246, 0.55);
    background: rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

.style-mode-btn.active {
    border-color: var(--accent);
    background: rgba(34, 211, 238, 0.16);
    box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.3);
}

.style-mode-btn.active span {
    color: #7dd3fc;
}

.style-picker-box h3 .style-count {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--accent);
}

.style-chip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
    overflow: visible;
    padding-top: 4px;
}

.style-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.style-chip {
    appearance: none;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.22);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.82rem;
    line-height: 1.3;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s;
}

.style-chip-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    overflow: visible;
    text-align: left;
    position: relative;
    z-index: 1;
}

.style-chip-media {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 7px 7px 0 0;
    line-height: 0;
}

.style-chip-preview {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #0a100c;
}

.style-chip-ko {
    display: block;
    padding: 8px 10px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}

.style-chip-tip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(6px);
    width: max(100%, 220px);
    max-width: 280px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(34, 211, 238, 0.45);
    background: rgba(12, 20, 16, 0.96);
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.45;
    text-align: left;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 40;
}

.style-chip-tip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(34, 211, 238, 0.45);
}

.style-chip-card:hover,
.style-chip-card:focus-visible {
    z-index: 5;
}

.style-chip-card:hover .style-chip-tip,
.style-chip-card:focus-visible .style-chip-tip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.style-chip:hover {
    border-color: rgba(34, 211, 238, 0.55);
    background: rgba(34, 211, 238, 0.08);
    transform: translateY(-1px);
}

.style-chip.active {
    border-color: var(--accent);
    background: rgba(34, 211, 238, 0.12);
    box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.35), 0 8px 20px rgba(0, 0, 0, 0.25);
}

.style-chip.active .style-chip-media::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: #0b1220;
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    z-index: 2;
}

.style-chip.active .style-chip-ko {
    color: #e0f2fe;
}

.style-avoid-label {
    margin-top: 14px !important;
    margin-bottom: 8px !important;
    font-size: 0.82rem !important;
    color: var(--text-muted);
}

.style-avoid-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.style-avoid-chip {
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px dashed rgba(239, 83, 80, 0.45);
    background: rgba(239, 83, 80, 0.08);
    color: #ef9a9a;
    font-size: 0.75rem;
    text-decoration: line-through;
    opacity: 0.9;
}

.auto-run-box {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(34, 211, 238, 0.06));
}

.auto-run-box h3 {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.auto-run-box p {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 14px;
}

.web-search-box {
    margin-top: 16px;
    padding: 20px;
    border: 1px solid rgba(66, 165, 245, 0.35);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(66, 165, 245, 0.12), rgba(255, 255, 255, 0.03));
}

.web-search-box h3 {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.web-search-box p {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 14px;
}

.web-search-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.web-search-row label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.web-search-row input[type="number"] {
    width: 88px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-elevated, rgba(0, 0, 0, 0.25));
    color: var(--text);
    font-size: 1rem;
}

.web-search-note {
    margin-top: 10px !important;
    margin-bottom: 0 !important;
    font-size: 0.82rem !important;
    opacity: 0.9;
}

.image-card .source-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(30, 136, 229, 0.92);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
}

.image-card .source-badge.entity {
    background: rgba(255, 143, 0, 0.95);
}

.modal-source {
    margin: 12px 0 16px;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(66, 165, 245, 0.1);
    border: 1px solid rgba(66, 165, 245, 0.25);
    font-size: 0.9rem;
    line-height: 1.5;
}

.modal-source ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.modal-source a {
    color: #64b5f6;
}

.hint-inline {
    color: var(--text-muted);
    font-size: 0.85rem;
    align-self: center;
}

.pipeline-steps {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 280px;
}

.pipe-step {
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: left;
}

.pipe-step.pipe-active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.pipe-step.pipe-done {
    color: var(--primary);
}

/* Responsive */
@media (max-width: 900px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }

    .main {
        margin-left: 0;
        padding: 16px;
    }

    .app {
        flex-direction: column;
    }

    .step-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 12px;
    }

    .step-link {
        flex-direction: column;
        min-width: 80px;
        text-align: center;
        padding: 8px;
    }

    .step-label {
        font-size: 0.7rem;
    }

    .meta-grid,
    .subtitle-layout {
        grid-template-columns: 1fr;
    }

    .style-mode-row {
        grid-template-columns: 1fr;
    }

    .style-mode-row-4 {
        grid-template-columns: 1fr 1fr;
    }

    .diff-item {
        grid-template-columns: 1fr;
    }
}
