/* Cosmere-inspired color palette */
:root {
    --primary-color: #2c5aa0;
    --secondary-color: #8b4513;
    --accent-color: #d4af37;
    --text-color: #2c3e50;
    --light-text: #7f8c8d;
    --background: #f8f9fa;
    --card-background: #ffffff;
    --border-color: #e9ecef;
    --success-color: #27ae60;
    --ai-glow: #3498db;
    --sticky-height: 80px;
}

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

body {
    font-family: 'Crimson Text', serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto var(--sticky-height);
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px 0;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 10px;
    color: white;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.title {
    font-family: 'Cinzel', serif;
    font-size: 2.2rem;
    font-weight: 600;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-style: italic;
}

.form-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.character-sheet,
.character-bio {
    background: var(--card-background);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
}

.character-sheet h2,
.character-bio h2 {
    font-family: 'Cinzel', serif;
    color: var(--primary-color);
    font-size: 1.6rem;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 8px;
}

.character-sheet h3,
.character-bio h3 {
    font-family: 'Cinzel', serif;
    color: var(--secondary-color);
    font-size: 1.2rem;
    margin: 20px 0 10px 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.attributes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 15px;
}

.form-group {
    position: relative;
    margin-bottom: 15px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: #fafafa;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.bio-field {
    position: relative;
}

.ai-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ai-glow);
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 0 10px var(--ai-glow);
}

.ai-indicator.updated {
    opacity: 1;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 15px 20px;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    border-top: 3px solid var(--accent-color);
}

.btn {
    font-family: 'Cinzel', serif;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 8px;
    color: white;
    flex: 1;
    max-width: 200px;
}

.btn-primary {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.btn-primary:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.secondary-actions {
    margin-top: 10px;
}

.loading {
    text-align: center;
    padding: 40px;
    background: var(--card-background);
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 40px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.loading p {
    font-size: 1.2rem;
    color: var(--light-text);
    font-style: italic;
}

/* Image container - will be overridden by later rules */

/* Responsive Design */
@media (max-width: 768px) {
    .form-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .title {
        font-size: 1.8rem;
    }

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

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

    .actions {
        padding: 10px 15px;
    }

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

    .btn {
        width: 180px;
        font-size: 0.65rem;
        padding: 8px 0px;
        margin: 0;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .character-sheet,
    .character-bio {
        padding: 15px;
    }

    .attributes-grid {
        grid-template-columns: 1fr;
    }

    .title {
        font-size: 1.5rem;
    }

    .btn {
        width: 160px;
        font-size: 0.65rem;
        letter-spacing: 0px;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

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

.bio-

/* AI-generated field styling - high specificity */
textarea.ai-generated,
input.ai-generated,
.bio-field.ai-generated,
.form-group textarea.ai-generated,
.form-group input.ai-generated,
.form-group .bio-field.ai-generated {
    background-color: rgba(138, 43, 226, 0.15) !important;
    border-color: rgba(138, 43, 226, 0.4) !important;
    transition: background-color 0.3s ease, border-color 0.3s ease !important;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.form-group .bio-field.user-edited {
    background-color: #fafafa !important;
    border-color: var(--border-color) !important;
}

.version-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 2px 6px;
    font-size: 11px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.version-prev,
.version-next {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
    color: var(--primary-color);
    transition: all 0.2s ease;
    border-radius: 3px;
}

.version-prev:hover,
.version-next:hover {
    background: var(--primary-color);
    color: white;
}

.version-prev:disabled,
.version-next:disabled {
    color: #ccc;
    cursor: not-allowed;
}

.version-counter {
    margin: 0 6px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 10px;
    min-width: 25px;
    text-align: center;
}

/* Image refinement styles */
.image-refinement {
    margin-top: 20px;
    padding: 20px;
    background: var(--card-background);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.image-refinement h3 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
}

.refinement-inputs {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.refinement-inputs .form-group {
    margin-bottom: 0;
}

.refinement-inputs label {
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.refinement-inputs textarea {
    min-height: 50px;
}

.refinement-inputs small {
    color: var(--light-text);
    font-size: 0.8rem;
    margin-top: 5px;
    display: block;
}

.btn-secondary {
    background: var(--accent-color);
    color: var(--text-color);
    border: 2px solid var(--accent-color);
}

.btn-secondary:hover {
    background: #f4d03f;
    transform: translateY(-1px);
}

/* Hel
p Button */
.help-button {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 100;
}

.help-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 600px;
    width: 95%;
    max-height: 100vh;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 15px 15px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 25px;
    line-height: 1.6;
}

.modal-body h3 {
    color: var(--primary-color);
    font-family: 'Cinzel', serif;
    margin: 20px 0 10px 0;
    font-size: 1.1rem;
}

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

.modal-body p {
    margin: 10px 0;
    color: var(--text-color);
}

.modal-body ul,
.modal-body ol {
    margin: 10px 0;
    padding-left: 20px;
}

.modal-body li {
    margin: 8px 0;
    color: var(--text-color);
}

.modal-body strong {
    color: var(--primary-color);
}

.modal-note {
    background: rgba(44, 90, 160, 0.1);
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    margin: 20px 0 0 0;
    border-radius: 0 8px 8px 0;
    font-style: italic;
}

/* Mobile Modal Adjustments */
@media (max-width: 768px) {
    .help-button {
        top: 15px;
        right: 15px;
        width: 25px;
        height: 25px;
        font-size: 14px;
    }

    .modal-content {
        width: 95%;
        max-height: 100vh;
    }

    .modal-header {
        padding: 15px 20px;
    }

    .modal-header h2 {
        font-size: 1.2rem;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-body h3 {
        font-size: 1rem;
    }
}

/* Remove A
I indicators */
.ai-indicator {
    display: none !important;
}

/* Expand button for textareas */
.expand-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 5;
    color: var(--text-color);
}

.expand-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

/* Text editing modal */
.text-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(5px);
}

.text-modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 900px;
    height: 80vh;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
    padding: 20px;
}

.text-modal-shrink {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    color: var(--text-color);
}

.text-modal-shrink:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.text-modal-textarea {
    width: 100%;
    height: 100%;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    background: #fafafa;
}

.text-modal-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
    background: white;
}

/* Image container improvements */
.image-container {
    padding: 20px;
    margin-top: 20px;
    background: var(--card-background);
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
}

.image-display {
    text-align: center;
    margin-bottom: 20px;
}

.image-display img {
    max-width: 100%;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 3px solid var(--accent-color);
}

/* Desktop two-column layout for image */
@media (min-width: 768px) {
    .image-container {
        display: grid;
        grid-template-columns: 400px 1fr !important;
        gap: 30px !important;
        align-items: start !important;
    }

    .image-display {
        margin-bottom: 0 !important;
        grid-column: 1 !important;
    }

    .image-refinement {
        grid-column: 2 !important;
    }

    .image-display img {
        max-width: 400px !important;
        width: 100% !important;
    }
}

/* Mobile adjustments */
@media (max-width: 767px) {

    .text-modal-content {
        width: 95%;
        height: 85vh;
    }

    .text-modal-header {
        padding: 15px 20px;
    }

    .text-modal-header h3 {
        font-size: 1.2rem;
    }

    .text-modal-body {
        padding: 20px;
    }
}/* AI
 Progress Indicator */
.ai-progress {
    margin-top: 15px;
    padding: 0 20px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #fff);
    border-radius: 2px;
    animation: progressPulse 2s ease-in-out infinite;
    width: 0%;
    transition: width 0.3s ease;
}

@keyframes progressPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.progress-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    text-align: center;
    display: block;
}/
* Alignment Grid */
.alignment-group {
    grid-column: 1 / -1; /* Span full width */
}

.alignment-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.alignment-tile {
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alignment-tile:hover {
    border-color: var(--primary-color);
    background: rgba(44, 90, 160, 0.05);
    transform: translateY(-1px);
}

.alignment-tile.selected {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 90, 160, 0.3);
}

.alignment-label {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.2;
}

/* Mobile responsiveness for alignment grid */
@media (max-width: 768px) {
    .alignment-tile {
        padding: 10px 6px;
        min-height: 50px;
    }
    
    .alignment-label {
        font-size: 0.75rem;
    }
}/
* Mobile Warning */
.mobile-warning {
    margin-top: 5px;
    padding: 5px 10px;
    background: rgba(255, 193, 7, 0.2);
    border-radius: 4px;
    border-left: 3px solid #ffc107;
}

.mobile-warning small {
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.8rem;
}