/* ==========================================
   MangaStudio - Project Details Page (Step 1)
   Apple Minimalist Design System
   ========================================== */

/* Step Container */
.step-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

/* Step Header */
.step-header {
    margin-bottom: 40px;
}

.step-header-row {
    display: flex;
    align-items: flex-start;
    gap: 24px;
}

.step-title-group {
    flex: 1;
}

.step-header h2 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.step-header p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Generate Section */
.generate-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 32px;
    margin-bottom: 40px;
}

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

.generate-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.generate-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* Disabled option input */
.option-input-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-secondary);
}

/* Content Grid - Two Column Layout */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 32px;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Card Header with Title Group */
.card-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

/* AI Icon */
.ai-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
}

.ai-icon {
    color: var(--accent);
    transition: var(--transition);
}

.ai-icon-disabled {
    color: var(--text-tertiary);
    opacity: 0.5;
}

/* Concept Textarea */
.concept-container {
    width: 100%;
}

.concept-textarea {
    width: 100%;
    min-height: 150px;
    padding: 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.7;
    color: var(--text-secondary);
    background: var(--bg-primary);
    resize: vertical;
    transition: var(--transition);
}

.concept-textarea:not([readonly]) {
    border-color: var(--accent);
    color: var(--text-primary);
    background: white;
}

.concept-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.concept-textarea[readonly] {
    background: var(--bg-secondary);
    cursor: default;
    border-color: transparent;
}

/* Manga Title Input States */
.manga-title-input[readonly] {
    cursor: default;
}

.manga-title-input:not([readonly]) {
    background: var(--bg-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--accent);
}

/* YouTube Titles */
.youtube-titles-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.youtube-title-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.youtube-title-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.youtube-title-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.youtube-title-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.youtube-titles-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.youtube-titles-loading {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.youtube-title-loading-line {
    height: 44px;
    border-radius: var(--radius-md);
}

.youtube-titles-list.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.youtube-title-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.youtube-title-item:hover {
    background: #ebebed;
}

.youtube-title-text {
    font-size: 14px;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.5;
    word-break: break-word;
}

.btn-remove-title {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    margin-left: 12px;
}

.btn-remove-title:hover {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
}

.youtube-titles-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-tertiary);
}

.youtube-titles-empty p {
    font-size: 14px;
    margin-bottom: 4px;
}

.youtube-titles-hint {
    font-size: 12px;
}

/* Chapters Section */
.chapter-count-badge {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.chapters-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chapter-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    transition: var(--transition);
    cursor: pointer;
}

.chapter-item:hover {
    background: #ebebed;
}

.chapter-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.chapter-info {
    flex: 1;
    min-width: 0;
}

.chapter-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.chapter-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chapter-status {
    flex-shrink: 0;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-empty {
    background: var(--bg-secondary);
    color: var(--text-tertiary);
}

.status-draft {
    background: rgba(255, 149, 0, 0.1);
    color: #ff9500;
}

.status-complete {
    background: rgba(52, 199, 89, 0.1);
    color: #34c759;
}

/* Chapters Empty State */
.chapters-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.chapters-empty-icon {
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.chapters-empty-icon svg {
    width: 48px;
    height: 48px;
}

.chapters-empty p {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.chapters-empty span {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Characters Grid */
.characters-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Add Character Modal */
.add-character-form .form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.add-character-form .form-row.is-single {
    grid-template-columns: minmax(0, 1fr);
}

.add-character-form .modal-input {
    margin-bottom: 0;
}

.add-character-form .form-helper {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-tertiary);
}

.add-character-form .npc-only {
    display: none;
}

.add-character-form .npc-only.is-visible {
    display: block;
}

/* Sidebar Placeholder Text */
.sidebar-placeholder-text {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
    font-style: italic;
}

/* Step Footer */
.step-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}

/* Disabled Button States */
.btn-disabled,
.btn.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Tooltip Badge */
.tooltip-badge {
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-sm);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        order: -1;
    }

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

@media (max-width: 768px) {
    .step-container {
        padding: 24px 16px 60px;
    }

    .step-header-row {
        flex-direction: column;
        gap: 16px;
    }

    .step-header h2 {
        font-size: 24px;
    }

    .generate-section {
        padding: 20px;
    }

    .generate-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .generate-options {
        grid-template-columns: 1fr;
    }

    .characters-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .add-character-form .form-row {
        grid-template-columns: 1fr;
    }

    .chapter-item {
        flex-wrap: wrap;
        gap: 12px;
    }

    .chapter-status {
        order: 3;
        width: 100%;
    }

    .chapter-item .btn {
        order: 4;
        width: 100%;
    }

    .step-footer {
        flex-direction: column;
    }

    .step-footer .btn {
        width: 100%;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .card-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .youtube-title-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .btn-remove-title {
        align-self: flex-end;
        margin-left: 0;
    }
}

/* ==========================================
   Character Section Styles
   ========================================== */

/* Character count badge */
.character-count {
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* Character role groups */
.character-role-group {
    margin-bottom: 16px;
}

.character-role-group:last-child {
    margin-bottom: 0;
}

.role-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* Character detail modal */
.character-detail-content {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 24px;
}

#characterDetailModal .modal {
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#characterDetailModal .modal-body {
    overflow-y: auto;
}

.character-sheet-placeholder {
    width: 200px;
    height: 280px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.character-sheet-placeholder.is-clickable {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.character-sheet-placeholder.is-clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.character-sheet-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-lg);
}

.character-detail-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-section {
    margin-bottom: 16px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.detail-section p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.tag-skill {
    background: #e8f4fd;
    color: var(--accent-color);
}

.no-data {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 13px;
}

/* Character Edit Mode */
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.detail-header h4 {
    margin-bottom: 0;
}

.btn-edit {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-tertiary);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-edit:hover {
    background: var(--bg-secondary);
    color: var(--accent-color);
}

.edit-container {
    margin-top: 8px;
}

.edit-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.edit-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.add-tag-container {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.add-tag-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.add-tag-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.add-tag-input::placeholder {
    color: var(--text-tertiary);
}

.tag-editable {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding-right: 6px;
}

.tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: var(--text-tertiary);
    padding: 0 2px;
    margin-left: 2px;
    transition: color 0.2s ease;
}

.tag-remove:hover {
    color: #dc3545;
}

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

.editable-text {
    transition: opacity 0.2s ease;
}

/* Responsive for character modal */
@media (max-width: 768px) {
    .character-detail-content {
        grid-template-columns: 1fr;
    }

    .character-sheet-placeholder {
        width: 100%;
        height: 200px;
    }
}

/* ==========================================
   Scenario Section Styles
   ========================================== */

/* Scenario count badge */
.scenario-count {
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* Scenarios Grid */
.scenarios-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.scenario-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
}

.scenario-card:hover {
    transform: scale(1.02);
}

.scenario-icon {
    height: 80px;
    background: linear-gradient(135deg, #d4e8d4 0%, #a8c8a8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scenario-icon svg {
    width: 40px;
    height: 40px;
    color: #4a7c4a;
}

.scenario-name {
    padding: 8px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Scenario detail modal */
.scenario-detail-content {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 24px;
}

.scenario-sheet-placeholder {
    width: 200px;
    height: 200px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.scenario-detail-image {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.scenario-detail-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Scenario Type Badge */
.scenario-type-badge {
    display: inline-block;
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: capitalize;
}

/* Scenario Variations */
.variations-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.variation-item {
    background: var(--bg-secondary);
    padding: 10px 12px;
    border-radius: var(--radius-md);
}

.variation-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.variation-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    margin: 0;
}

.no-variations {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 13px;
    margin: 0;
}

/* Scenario Appearances */
.appearances-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 12px;
}

.appearances-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.appearance-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.appearance-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.appearance-item:first-child {
    padding-top: 0;
}

.appearance-chapter {
    font-weight: 600;
    color: var(--text-primary);
}

.appearance-context {
    color: var(--text-secondary);
}

.appearance-variation {
    color: var(--accent-color);
    font-size: 12px;
}

.no-appearances {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 13px;
    margin: 0;
}

/* ==========================================
   World Entities Section Styles
   ========================================== */

.world-entity-count {
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.world-entities-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.world-entity-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
}

.world-entity-card:hover {
    transform: scale(1.02);
}

.world-entity-icon {
    height: 80px;
    background: linear-gradient(135deg, #e3f1ff 0%, #c7dcf5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2563eb;
}

.world-entity-icon svg {
    width: 40px;
    height: 40px;
}

.world-entity-name {
    padding: 8px 8px 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.world-entity-type {
    padding: 0 8px 10px;
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* World entity detail modal */
.world-entity-detail-content {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 24px;
}

.world-entity-sheet-placeholder {
    width: 200px;
    height: 200px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.world-entity-detail-image {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.world-entity-detail-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.world-entity-type-badge {
    display: inline-block;
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.world-entity-appearance {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 12px;
}

.appearance-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metadata-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 12px;
}

.metadata-item + .metadata-item {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.metadata-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.metadata-value {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.no-metadata {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 13px;
    margin: 0;
}

/* Responsive for scenario modal */
@media (max-width: 768px) {
    .scenario-detail-content {
        grid-template-columns: 1fr;
    }

    .scenario-sheet-placeholder {
        width: 100%;
        height: 150px;
    }

    .world-entity-detail-content {
        grid-template-columns: 1fr;
    }

    .world-entity-sheet-placeholder {
        width: 100%;
        height: 150px;
    }
}

/* ==========================================
   Markdown Rendering Styles
   ========================================== */

/* Headings */
.md-heading {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 16px 0 8px 0;
    padding: 0;
    line-height: 1.4;
}

.md-heading:first-child {
    margin-top: 0;
}

.md-subheading {
    font-size: 0.95rem;
    font-weight: 600;
    color: #424245;
    margin: 12px 0 6px 0;
    padding: 0;
    line-height: 1.4;
}

/* Thinking Block (Analysis) */
.thinking-block {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 12px 16px;
    margin: 12px 0;
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.thinking-header svg {
    opacity: 0.6;
}

.thinking-content {
    font-size: 0.875rem;
    color: #424245;
    line-height: 1.6;
    font-style: italic;
}

/* Concept Display (non-editable view with markdown) */
.concept-display {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    transition: max-height 0.4s ease;
    overflow: hidden;
}

.concept-display.concept-collapsed {
    max-height: 200px;
}

.concept-display.concept-expanded {
    max-height: none;
}

.concept-display .md-heading {
    font-size: 1rem;
    margin: 12px 0 6px 0;
}

.concept-display .md-subheading {
    font-size: 0.9rem;
    margin: 10px 0 4px 0;
}

.concept-display .thinking-block {
    display: none; /* Hide thinking blocks in main concept view */
}

/* Concept Fade Overlay */
.concept-fade {
    position: relative;
    height: 60px;
    margin-top: -60px;
    background: linear-gradient(to bottom, transparent, var(--bg-secondary));
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.concept-fade.hidden {
    opacity: 0;
    height: 0;
    margin-top: 0;
}

/* Concept Toggle Button */
.concept-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    border: none;
    background: transparent;
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: var(--radius-sm);
}

.concept-toggle-btn:hover {
    background: rgba(0, 113, 227, 0.05);
}

.concept-toggle-btn svg {
    transition: transform 0.3s ease;
}

.concept-toggle-btn.expanded svg {
    transform: rotate(180deg);
}

.concept-toggle-btn.hidden {
    display: none;
}

/* ==========================================
   Concept Refiner Chat Styles
   ========================================== */

.refiner-chat-container {
    display: flex;
    flex-direction: column;
    height: 450px;
    max-height: 60vh;
}

.refiner-chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.refiner-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.refiner-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.refiner-message-ai {
    align-self: flex-start;
}

.refiner-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border-light);
}

.refiner-message-ai .refiner-avatar {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.refiner-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.6;
}

.refiner-message-user .refiner-bubble {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.refiner-message-ai .refiner-bubble {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: 4px;
}

.refiner-message-ai .refiner-bubble p {
    margin: 0;
}

/* Markdown in AI bubble */
.refiner-message-ai .refiner-bubble .md-heading {
    font-size: 1rem;
    margin: 12px 0 6px 0;
}

.refiner-message-ai .refiner-bubble .md-heading:first-child {
    margin-top: 0;
}

.refiner-message-ai .refiner-bubble .md-subheading {
    font-size: 0.9rem;
    margin: 10px 0 4px 0;
}

.refiner-message-ai .refiner-bubble .thinking-block {
    background: rgba(0, 113, 227, 0.05);
    border-left-color: var(--accent);
    margin: 12px 0;
}

/* Typing Indicator */
.refiner-typing {
    display: flex;
    gap: 12px;
    align-items: center;
}

.refiner-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.refiner-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.refiner-typing-dot:nth-child(1) { animation-delay: 0s; }
.refiner-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.refiner-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Chat Input */
.refiner-chat-input-container {
    display: flex;
    gap: 12px;
    padding-top: 16px;
}

.refiner-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.refiner-chat-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.refiner-chat-input:disabled {
    background: var(--bg-secondary);
    cursor: not-allowed;
}

/* ==========================================
   Agent Workflow Pipeline
   LangChain-style horizontal nodes
   ========================================== */

.agent-workflow-container {
    margin-top: 24px;
    padding: 24px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
}

.workflow-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 24px;
}

.workflow-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.workflow-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Nodes Container - Horizontal Layout */
.workflow-nodes {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: 16px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

.workflow-nodes::-webkit-scrollbar {
    height: 6px;
}

.workflow-nodes::-webkit-scrollbar-track {
    background: transparent;
}

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

/* Individual Node */
.workflow-node {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 140px;
    padding: 16px 12px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    transition: all 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    flex-shrink: 0;
}

/* Node Icon */
.node-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--bg-primary);
    border-radius: 50%;
    margin-bottom: 12px;
    transition: all 0.4s ease;
}

.node-icon svg {
    color: var(--text-tertiary);
    transition: all 0.4s ease;
}

/* Node Content */
.node-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
}

.node-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.node-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    max-width: 120px;
}

/* Node Status Badge */
.node-status {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 4px;
}

.node-status.status-finished {
    background: rgba(52, 199, 89, 0.15);
    color: #34c759;
}

.node-status.status-pending {
    background: var(--bg-secondary);
    color: var(--text-tertiary);
}

.node-status.status-error {
    background: rgba(255, 59, 48, 0.15);
    color: #ff3b30;
}

.node-status.status-running {
    background: rgba(0, 113, 227, 0.15);
    color: var(--accent);
}

.node-status.status-approved {
    background: rgba(52, 199, 89, 0.15);
    color: #34c759;
}

/* Manual Approval Button */
.node-manual-approval {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
}

.btn-manual-approval {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: var(--transition);
}

.btn-manual-approval:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-manual-approval.is-approved {
    background: rgba(52, 199, 89, 0.12);
    border-color: rgba(52, 199, 89, 0.35);
    color: #1f7a3f;
}

.btn-manual-approval:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Check Icon (for completed) */
.node-check {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #34c759;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.4);
    animation: nodeCheckPop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.node-check svg {
    color: white;
}

@keyframes nodeCheckPop {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* Lock Icon (for locked) */
.node-lock {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node-lock svg {
    color: var(--text-tertiary);
}

/* Retry Button (for error state) */
.node-retry {
    margin-top: 8px;
}

.btn-retry {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 500;
    color: #ff3b30;
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-retry:hover {
    background: rgba(255, 59, 48, 0.2);
}

/* ==========================================
   Node States
   ========================================== */

/* Completed Node */
.workflow-node.node-completed {
    background: rgba(52, 199, 89, 0.08);
    border-color: #34c759;
    cursor: default;
}

.workflow-node.node-completed .node-icon {
    background: rgba(52, 199, 89, 0.15);
}

.workflow-node.node-completed .node-icon svg {
    color: #34c759;
}

/* Approved Node (manual) */
.workflow-node.node-approved {
    background: rgba(52, 199, 89, 0.06);
    border-color: rgba(52, 199, 89, 0.6);
}

.workflow-node.node-approved .node-icon {
    background: rgba(52, 199, 89, 0.12);
}

.workflow-node.node-approved .node-icon svg {
    color: #34c759;
}

/* Locked Node */
.workflow-node.node-locked {
    background: var(--bg-secondary);
    border-color: var(--border-light);
    opacity: 0.7;
}

.workflow-node.node-locked .node-title {
    color: var(--text-secondary);
}

/* Error Node */
.workflow-node.node-error {
    background: rgba(255, 59, 48, 0.08);
    border-color: #ff3b30;
}

.workflow-node.node-error .node-icon {
    background: rgba(255, 59, 48, 0.15);
}

.workflow-node.node-error .node-icon svg {
    color: #ff3b30;
}

/* Rejected Node (Orange/Amber) */
.workflow-node.node-rejected {
    background: rgba(255, 149, 0, 0.08);
    border-color: #ff9500;
}

.workflow-node.node-rejected .node-icon {
    background: rgba(255, 149, 0, 0.15);
}

.workflow-node.node-rejected .node-icon svg {
    color: #ff9500;
}

.node-status.status-rejected {
    background: rgba(255, 149, 0, 0.12);
    color: #ff9500;
}

/* Running Node */
.workflow-node.node-running {
    background: rgba(0, 113, 227, 0.08);
    border-color: var(--accent);
    animation: nodeRunningPulse 1.5s ease-in-out infinite;
}

.workflow-node.node-running .node-icon {
    background: rgba(0, 113, 227, 0.15);
    animation: nodeIconSpin 2s linear infinite;
}

.workflow-node.node-running .node-icon svg {
    color: var(--accent);
}

@keyframes nodeRunningPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(0, 113, 227, 0.1); }
}

@keyframes nodeIconSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================
   Retrying State (Yellow)
   ========================================== */

/* Retrying Node */
.workflow-node.node-retrying {
    background: rgba(255, 204, 0, 0.08);
    border-color: #ffcc00;
    animation: nodeRetryingPulse 1.5s ease-in-out infinite;
}

.workflow-node.node-retrying .node-icon {
    background: rgba(255, 204, 0, 0.15);
    animation: nodeIconSpin 2s linear infinite;
}

.workflow-node.node-retrying .node-icon svg {
    color: #e6b800;
}

@keyframes nodeRetryingPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 204, 0, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(255, 204, 0, 0.1); }
}

/* Retrying Status Badge */
.node-status.status-retrying {
    background: rgba(255, 204, 0, 0.15);
    color: #e6b800;
}

/* ==========================================
   Connector Lines
   ========================================== */

.workflow-connector {
    width: 40px;
    height: 3px;
    background: var(--border-light);
    flex-shrink: 0;
    position: relative;
    transition: all 0.4s ease;
}

.workflow-connector.connector-completed {
    background: #34c759;
}

.workflow-connector.connector-completed::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #34c759;
    border-radius: 50%;
    animation: connectorDotPulse 2s ease-in-out infinite;
}

@keyframes connectorDotPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 0.7; }
}

.workflow-connector.connector-locked {
    background: var(--border-light);
}

.workflow-connector.connector-running {
    background: linear-gradient(90deg, #34c759, var(--accent));
    animation: connectorFlow 1s linear infinite;
    background-size: 200% 100%;
}

.workflow-connector.connector-retrying {
    background: linear-gradient(90deg, #34c759, #ffcc00);
    animation: connectorFlow 1s linear infinite;
    background-size: 200% 100%;
}

.workflow-connector.connector-rejected {
    background: linear-gradient(90deg, #34c759, #ff9500);
    animation: connectorFlow 1s linear infinite;
    background-size: 200% 100%;
}

@keyframes connectorFlow {
    0% { background-position: 100% 0; }
    100% { background-position: 0 0; }
}

/* ==========================================
   Workflow Actions (Continue Button)
   ========================================== */

.workflow-actions {
    display: flex;
    justify-content: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.btn-workflow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
}

.btn-workflow svg {
    transition: transform 0.2s ease;
}

.btn-workflow:hover svg {
    transform: translateX(2px);
}

/* ==========================================
   Unlock Animation
   ========================================== */

.workflow-node.node-unlocking {
    animation: nodeUnlock 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes nodeUnlock {
    0% {
        opacity: 0.7;
        transform: scale(1);
        border-color: var(--border-light);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        border-color: var(--accent);
    }
}

/* ==========================================
   Responsive Design for Workflow
   ========================================== */

@media (max-width: 1024px) {
    .workflow-nodes {
        padding-bottom: 12px;
    }

    .workflow-node {
        min-width: 120px;
        padding: 12px 10px;
    }

    .node-icon {
        width: 38px;
        height: 38px;
    }

    .node-title {
        font-size: 11px;
        max-width: 100px;
    }

    .workflow-connector {
        width: 24px;
    }
}

@media (max-width: 768px) {
    .agent-workflow-container {
        padding: 16px;
        margin-top: 20px;
    }

    .workflow-nodes {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .workflow-node {
        flex-direction: row;
        min-width: auto;
        width: 100%;
        padding: 14px 16px;
        gap: 12px;
    }

    .node-icon {
        margin-bottom: 0;
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }

    .node-content {
        align-items: flex-start;
        text-align: left;
        flex: 1;
    }

    .node-title {
        max-width: none;
    }

    .node-check,
    .node-lock {
        position: static;
        margin-left: auto;
    }

    .workflow-connector {
        width: 3px;
        height: 20px;
        margin-left: 35px;
    }

    .workflow-connector.connector-completed::after {
        display: none;
    }
}

@media (max-width: 480px) {
    .workflow-node {
        padding: 12px;
    }

    .node-icon {
        width: 36px;
        height: 36px;
    }

    .node-icon svg {
        width: 18px;
        height: 18px;
    }

    .workflow-connector {
        margin-left: 30px;
        height: 16px;
    }
}

/* ==========================================================================
   Node Start Button (Agent 2 - Character Creator)
   Minimalist Play Icon Design
   ========================================================================== */

.node-start-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    color: var(--accent, #0071e3);
    border: 2px solid var(--accent, #0071e3);
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    z-index: 20;
}

.node-start-btn svg {
    width: 18px;
    height: 18px;
    margin-left: 2px; /* Visual centering for play icon */
    fill: var(--accent, #0071e3);
    stroke: none;
}

/* Show button on hover for startable nodes */
.workflow-node.node-startable:hover .node-start-btn {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Hide button when node is completed or running */
.workflow-node.node-completed .node-start-btn,
.workflow-node.node-running .node-start-btn {
    display: none;
}

.workflow-node.node-approved .node-start-btn {
    display: none;
}

/* Button hover state */
.node-start-btn:hover {
    background: var(--accent, #0071e3);
    color: white;
    transform: translate(-50%, -50%) scale(1.08);
}

.node-start-btn:hover svg {
    fill: white;
}

/* Button active state */
.node-start-btn:active {
    transform: translate(-50%, -50%) scale(0.95);
}

/* Ensure startable nodes have relative positioning */
.workflow-node.node-startable {
    position: relative;
    cursor: pointer;
}

/* Dim node content on hover to highlight button */
.workflow-node.node-startable:hover .node-icon,
.workflow-node.node-startable:hover .node-content,
.workflow-node.node-startable:hover .node-lock {
    opacity: 0.2;
    transition: opacity 0.2s ease;
}

/* Add subtle highlight border on hover */
.workflow-node.node-startable:hover {
    border-color: var(--accent, #0071e3);
    background: transparent;
}

/* ==========================================================================
   Error State with Retry Button
   ========================================================================== */

/* Allow interaction on error nodes for retry */
.workflow-node.node-error {
    pointer-events: auto;
    cursor: pointer;
}

/* Show start button on error state for retry */
.workflow-node.node-error.node-startable .node-start-btn {
    display: flex;
    border-color: #ff3b30;
    color: #ff3b30;
}

.workflow-node.node-error.node-startable .node-start-btn svg {
    fill: #ff3b30;
}

.workflow-node.node-error.node-startable:hover .node-start-btn {
    background: #ff3b30;
    color: white;
}

.workflow-node.node-error.node-startable:hover .node-start-btn svg {
    fill: white;
}

/* Rejected state with retry via play button */
.workflow-node.node-rejected {
    pointer-events: auto;
    cursor: pointer;
}

.workflow-node.node-rejected.node-startable .node-start-btn {
    display: flex;
    border-color: #ff9500;
    color: #ff9500;
}

.workflow-node.node-rejected.node-startable .node-start-btn svg {
    fill: #ff9500;
}

.workflow-node.node-rejected.node-startable:hover .node-start-btn {
    background: #ff9500;
    color: white;
}

.workflow-node.node-rejected.node-startable:hover .node-start-btn svg {
    fill: white;
}

/* ==========================================
   Character Prompt Section - Apple Style
   ========================================== */

/* Prompt Section Container */
.prompt-section {
    margin-top: 16px;
}

/* Generate Prompt Button - Apple Minimalist Style */
.btn-generate-prompt {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-generate-prompt:hover {
    background: var(--bg-primary);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-generate-prompt svg {
    width: 14px;
    height: 14px;
}

/* Prompt Preview Container */
.prompt-preview-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Prompt Preview Text - Truncated */
.prompt-preview-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--radius-md);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 100px;
}

/* Edit Prompt Button - Apple Style */
.btn-edit-prompt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    color: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: flex-start;
}

.btn-edit-prompt:hover {
    background: rgba(0, 113, 227, 0.08);
}

.btn-edit-prompt svg {
    width: 14px;
    height: 14px;
}

/* Prompt Loading State */
.prompt-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-secondary);
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spinSmall 0.8s linear infinite;
}

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

/* Prompt Edit Textarea in Modal */
.prompt-edit-textarea {
    min-height: 300px;
    font-size: 14px;
    line-height: 1.7;
    resize: vertical;
}

/* ==========================================
   Character Sheet Section - Apple Style
   ========================================== */

/* Sheet Section Container */
.sheet-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* No Prompt Message */
.sheet-no-prompt-message {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    text-align: center;
}

.sheet-no-prompt-message p {
    font-size: 13px;
    color: var(--text-tertiary);
    margin: 0;
    font-style: italic;
}

/* Sheet Generator Container */
.sheet-generator-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Sheet Preview */
.sheet-preview {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
    margin-bottom: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sheet-preview img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    max-height: 300px;
}

.sheet-preview:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.sheet-upload {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.sheet-upload-input {
    display: none;
}

.sheet-upload-name {
    font-size: 12px;
    color: var(--text-tertiary);
}

.sheet-upload-name.has-file {
    color: var(--text-secondary);
}

.sheet-upload-hint {
    font-size: 11px;
    color: var(--text-tertiary);
}

.sheet-versions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.sheet-versions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.sheet-versions-empty,
.sheet-versions-loading {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
}

.sheet-version-card {
    display: grid;
    grid-template-columns: 70px 1fr;
    grid-template-rows: auto auto;
    grid-template-areas:
        "thumb meta"
        "thumb actions";
    align-items: start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

.sheet-version-card.is-current {
    border-color: rgba(0, 113, 227, 0.3);
    background: rgba(0, 113, 227, 0.06);
}

.sheet-version-thumb {
    grid-area: thumb;
    align-self: start;
    width: 70px;
    height: 70px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: white;
    border: 1px solid var(--border-light);
    cursor: pointer;
}

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

.sheet-version-meta {
    grid-area: meta;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.sheet-version-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.sheet-version-note {
    font-size: 12px;
    color: var(--text-secondary);
}

.sheet-version-date {
    font-size: 11px;
    color: var(--text-tertiary);
}

.sheet-version-actions {
    grid-area: actions;
    display: flex;
    flex-direction: row;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    grid-column: 1 / -1;
}

.sheet-version-actions .btn {
    padding: 6px 10px;
    width: 100%;
    justify-content: center;
}

/* Sheet preview modal */
.sheet-preview-modal .sheet-preview-card {
    max-width: 980px;
    width: min(90vw, 980px);
}

.sheet-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}


.sheet-preview-body {
    padding-top: 12px;
}

.sheet-preview-image {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    justify-content: center;
}

.sheet-preview-image img {
    max-height: 70vh;
    width: 100%;
    object-fit: contain;
}

/* Generate Sheet Button - Apple Minimalist Style */
.sheet-generator-container .btn-generate-sheet {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    /* Override NPC card styles */
    position: relative;
    opacity: 1;
    top: auto;
    right: auto;
    height: auto;
}

.btn-generate-sheet:hover {
    background: #005bb5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.btn-generate-sheet:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-generate-sheet:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-generate-sheet svg {
    width: 14px;
    height: 14px;
}

/* Sheet Loading State */
.sheet-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    text-align: center;
}

.sheet-loading span {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Sheet Error State */
.sheet-error {
    padding: 12px 16px;
    background: rgba(255, 59, 48, 0.08);
    border: 1px solid rgba(255, 59, 48, 0.2);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.sheet-error p {
    font-size: 13px;
    color: #ff3b30;
    margin: 0;
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sheet-preview img {
        max-height: 200px;
    }

    .btn-generate-sheet {
        padding: 14px 16px;
        font-size: 15px;
    }

    .sheet-version-card {
        grid-template-columns: 60px 1fr;
    }

    .sheet-version-actions {
        flex-direction: row;
        justify-content: flex-end;
    }
}

/* ==========================================
   Reference Gallery - Character Sheet
   ========================================== */

.reference-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.btn-reference-gallery {
    gap: 6px;
}

.reference-hint {
    margin: 8px 0 10px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.reference-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    min-height: 64px;
}

.reference-empty {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 6px 4px;
}

.reference-selected-item {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-light);
    background: white;
}

.reference-selected-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.reference-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 14px;
    line-height: 18px;
    cursor: pointer;
}

.reference-gallery-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(29, 29, 31, 0.2);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 2050;
}

.reference-gallery-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.reference-gallery-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 380px;
    max-width: 90vw;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-light);
    box-shadow: -18px 0 40px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 2100;
    display: flex;
    flex-direction: column;
}

.reference-gallery-panel.open {
    transform: translateX(0);
}

.reference-gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-primary);
}

.reference-gallery-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}

.reference-gallery-close {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 999px;
}

.reference-gallery-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 20px 0;
}

.reference-gallery-search,
.reference-gallery-select {
    width: 100%;
}

.reference-upload {
    margin: 16px 20px 10px;
    padding: 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.reference-upload-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.reference-upload-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}

.reference-upload-row-single {
    grid-template-columns: 1fr;
}

.reference-upload-row .option-input {
    width: 100%;
    min-width: 0;
}

.reference-upload-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.reference-file-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    left: -9999px;
}

.reference-file-name {
    font-size: 12px;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: none;
    margin-top: 6px;
}

.reference-upload-actions .btn {
    white-space: nowrap;
}

.reference-file-name.has-file {
    display: block;
}

.reference-dropzone {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: 1px dashed var(--border-light);
    background: var(--bg-primary);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.reference-dropzone:hover {
    border-color: rgba(0, 113, 227, 0.4);
    color: var(--accent);
    background: #f4f8ff;
}

.reference-dropzone.dragover {
    border-color: var(--accent);
    color: var(--accent);
    background: #eef5ff;
    box-shadow: 0 6px 18px rgba(0, 113, 227, 0.2);
}

.reference-upload-hint {
    font-size: 11px;
    color: var(--text-tertiary);
}

.reference-gallery-grid {
    padding: 0 20px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    overflow-y: auto;
    flex: 1;
}

.reference-gallery-empty {
    font-size: 13px;
    color: var(--text-tertiary);
    padding: 24px 4px;
}

.reference-card {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    background: var(--bg-primary);
    text-align: left;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    padding: 0;
}

.reference-card img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    background: var(--bg-secondary);
}

.reference-card-meta {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reference-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.reference-card-info {
    font-size: 11px;
    color: var(--text-tertiary);
}

.reference-card.selected {
    border-color: rgba(0, 113, 227, 0.5);
    box-shadow: 0 8px 22px rgba(0, 113, 227, 0.2);
    transform: translateY(-2px);
}

.reference-card:hover {
    border-color: rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
    .reference-gallery-panel {
        width: 100%;
    }

    .reference-upload-row {
        grid-template-columns: 1fr;
    }

    .reference-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}
