/**
 * LoveToRead.AI - Create Story Page CSS
 * Professional, sleek, minimal design
 */

/* CSS Variables */
:root {
    --primary-green: #2e7d32;
    --primary-green-light: #4caf50;
    --primary-green-lighter: #66bb6a;
    --primary-green-dark: #1b5e20;
    --accent-green: #81c784;
    --bg-green-light: #e8f5e9;
    --bg-green-lighter: #f1f8e9;
    
    --text-dark: #1a1a1a;
    --text-medium: #4a4a4a;
    --text-light: #6a6a6a;
    
    --white: #ffffff;
    --off-white: #fafafa;
    --border-light: #e0e0e0;
    --border-medium: #d0d0d0;
    
    --error-red: #d32f2f;
    --error-bg: #ffebee;
    --success-green: #2e7d32;
    --success-bg: #e8f5e9;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
    --shadow-xl: 0 8px 32px rgba(0,0,0,0.12);
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    
    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 14px;
    --border-radius-xl: 20px;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-green-lighter) 0%, var(--bg-green-light) 100%);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Page Wrapper */
.create-page-wrapper {
    padding: 120px 0 80px;
    min-height: 100vh;
}

.create-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Hero Section */
.hero-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 40px;
    margin-bottom: 48px;
}

.hero-content {
    flex: 1;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
    color: var(--primary-green);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.hero-badge i {
    font-size: 14px;
}

.hero-title {
    font-size: 56px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 12px;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-size: 18px;
    color: var(--text-medium);
    line-height: 1.5;
    max-width: 600px;
}

/* User Credits */
.user-credits {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--white);
    padding: 20px 28px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    border: 2px solid var(--primary-green-light);
    min-width: 200px;
}

.credits-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary-green), var(--primary-green-lighter));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 24px;
    flex-shrink: 0;
}

.credits-info {
    display: flex;
    flex-direction: column;
}

.credits-label {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.credits-amount {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary-green);
    line-height: 1;
    margin-top: 4px;
}

/* Messages */
.message-box {
    background: var(--white);
    border-radius: var(--border-radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.error-message {
    background: var(--error-bg);
    color: var(--error-red);
    border-left: 4px solid var(--error-red);
}

.success-message {
    background: var(--success-bg);
    color: var(--success-green);
    border-left: 4px solid var(--success-green);
}

/* Form */
.story-form {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Form Step */
.form-step {
    background: var(--white);
    border-radius: var(--border-radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-md);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 32px;
}

.step-number {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-green), var(--primary-green-lighter));
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.step-info {
    flex: 1;
}

.step-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
    line-height: 1.2;
}

.step-description {
    font-size: 15px;
    color: var(--text-medium);
    line-height: 1.4;
}

/* Option Grid */
.option-grid {
    display: grid;
    gap: 20px;
}

.option-grid.two-column {
    grid-template-columns: repeat(2, 1fr);
}

.option-card {
    position: relative;
    background: var(--off-white);
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    padding: 28px;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
}

.option-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.option-card:hover {
    border-color: var(--primary-green-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.option-card input[type="radio"]:checked + .option-content {
    opacity: 1;
}

.option-card:has(input[type="radio"]:checked) {
    background: var(--bg-green-light);
    border-color: var(--primary-green);
    border-width: 3px;
    box-shadow: var(--shadow-lg);
}

.option-card:has(input[type="radio"]:checked) .option-check {
    opacity: 1;
    transform: scale(1);
}

.option-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    opacity: 0.85;
    transition: opacity var(--transition-normal);
}

.option-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-green-light), var(--accent-green));
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 28px;
}

.option-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.option-description {
    font-size: 14px;
    color: var(--text-medium);
    line-height: 1.5;
}

.option-badge {
    display: inline-block;
    background: var(--primary-green);
    color: var(--white);
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    align-self: flex-start;
    margin-top: 4px;
}

.option-check {
    position: absolute;
    top: 20px;
    right: 20px;
    color: var(--primary-green);
    font-size: 28px;
    opacity: 0;
    transform: scale(0.8);
    transition: all var(--transition-normal);
}

/* Art Style Grid */
.art-style-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.art-style-card {
    position: relative;
    background: var(--off-white);
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.art-style-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.art-style-card:hover {
    border-color: var(--primary-green-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.art-style-card:has(input[type="radio"]:checked) {
    border-color: var(--primary-green);
    border-width: 3px;
    box-shadow: var(--shadow-lg);
}

.art-style-card:has(input[type="radio"]:checked) .art-check {
    opacity: 1;
}

.art-preview {
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--bg-green-light), var(--bg-green-lighter));
    display: flex;
    align-items: center;
    justify-content: center;
}

.art-preview-placeholder {
    color: var(--primary-green-light);
    font-size: 36px;
    opacity: 0.6;
}

.art-info {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.art-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.art-check {
    color: var(--primary-green);
    font-size: 20px;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

/* ===================================
   NEW CHARACTER SELECTION STYLES
   =================================== */

/* Characters Section */
.characters-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.characters-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.character-slot {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--off-white);
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    padding: 16px;
    transition: all var(--transition-normal);
}

/* Character Source Selector */
.character-source-selector {
    margin-bottom: 12px;
}

.source-tabs {
    display: flex;
    gap: 6px;
    background: var(--white);
    padding: 4px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-light);
}

.source-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    background: transparent;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    color: var(--text-light);
    font-size: 13px;
    font-weight: 600;
}

.source-tab i {
    font-size: 18px;
    transition: all var(--transition-fast);
}

.source-tab span {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.source-tab:hover {
    background: var(--bg-green-light);
    color: var(--primary-green);
}

.source-tab.active {
    background: var(--primary-green);
    color: var(--white);
}

/* Character Panels */
.character-panel {
    display: none;
    min-height: 200px;
}

.character-panel.active {
    display: block;
}

/* None Panel */
.none-panel {
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-character-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-light);
}

.empty-character-state i {
    font-size: 48px;
    color: var(--primary-green-light);
    opacity: 0.6;
}

.empty-character-state span {
    font-size: 14px;
    font-weight: 500;
}

/* AI Character Form (replaces empty state) */
.ai-character-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px 20px;
    width: 100%;
}

.ai-character-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: var(--bg-green-light);
    border-radius: 50%;
}

.ai-character-icon i {
    font-size: 28px;
    color: var(--primary-green);
}

.ai-character-info {
    text-align: center;
}

.ai-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-medium);
}

.ai-character-form .form-group {
    width: 100%;
    max-width: 280px;
}

.ai-character-form .detail-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
}

.ai-name-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1.5px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.ai-name-input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.ai-name-input::placeholder {
    color: var(--text-light);
}

.ai-name-hint {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-light);
    text-align: center;
}

/* Saved Characters Panel */
.saved-panel {
    overflow: hidden;
}

.saved-panel.active {
    padding: 0;
    margin: 0px;
    width: 100%;
}

.saved-characters-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
}

.saved-characters-container::-webkit-scrollbar {
    width: 6px;
}

.saved-characters-container::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: 3px;
}

.saved-characters-container::-webkit-scrollbar-thumb {
    background: var(--primary-green-light);
    border-radius: 3px;
}

.saved-characters-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-green);
}

.saved-characters-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px;
}

.loading-saved-characters,
.no-saved-characters {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-light);
}

.loading-saved-characters i {
    font-size: 32px;
    color: var(--primary-green-light);
    animation: spin 1s linear infinite;
}

.no-saved-characters i {
    font-size: 48px;
    color: var(--text-light);
    opacity: 0.4;
}

.no-saved-characters span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-medium);
}

.no-saved-characters small {
    font-size: 12px;
    color: var(--text-light);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.saved-character-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--white);
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    overflow: hidden;
}

.saved-character-card:hover {
    border-color: var(--primary-green-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.saved-character-card.selected {
    border-color: var(--primary-green);
    border-width: 3px;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

.saved-character-card.selected .saved-character-name-overlay {
    background: linear-gradient(to top, var(--primary-green) 0%, rgba(46, 125, 50, 0.85) 100%);
}

/* Character Sheet Image - Full Width */
.saved-character-sheet {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: linear-gradient(135deg, var(--bg-green-light), var(--bg-green-lighter));
}

.saved-character-sheet img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.saved-character-card:hover .saved-character-sheet img {
    transform: scale(1.03);
}

.sheet-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-green-light);
    font-size: 32px;
}

/* Name Overlay at Bottom */
.saved-character-name-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 10px 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.4) 70%, transparent 100%);
    transition: background var(--transition-normal);
}

.saved-character-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--white);
    text-align: center;
    line-height: 1.2;
    display: block;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Load More Characters Button */
.load-more-characters-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 16px;
    margin-top: 8px;
    background: var(--bg-green-light);
    border: 2px dashed var(--primary-green-light);
    border-radius: var(--border-radius-md);
    color: var(--primary-green);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.load-more-characters-btn:hover:not(:disabled) {
    background: var(--primary-green-light);
    border-style: solid;
    color: var(--white);
    transform: translateY(-1px);
}

.load-more-characters-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.load-more-characters-btn i {
    font-size: 12px;
}


/* Upload Panel */
.upload-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.character-upload {
    position: relative;
}

.character-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.character-label {
    display: block;
    cursor: pointer;
}

/* Empty state - dashed upload area */
.character-placeholder {
    aspect-ratio: 4/3;
    background: var(--white);
    border: 2px dashed var(--border-medium);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-light);
    transition: all var(--transition-normal);
    padding: 20px;
}

.character-placeholder i {
    font-size: 32px;
}

.character-placeholder span {
    font-size: 14px;
    font-weight: 600;
}

.character-placeholder small {
    font-size: 11px;
    color: var(--text-light);
    opacity: 0.8;
}

.character-label:hover .character-placeholder {
    border-color: var(--primary-green-light);
    background: var(--bg-green-light);
    color: var(--primary-green);
}

/* ===================================
   UNIFIED UPLOAD CARD (photo + fields)
   =================================== */

.character-upload-card {
    border: 2px solid var(--primary-green-light, #4caf50);
    border-radius: var(--border-radius-lg, 14px);
    overflow: hidden;
    background: var(--white, #ffffff);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    animation: slideDown 0.3s ease-out;
}

.upload-card-photo {
    position: relative;
}

.upload-card-photo .character-preview {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.upload-card-photo .character-label {
    display: block;
}

.character-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-character {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: var(--error-red);
    color: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.remove-character:hover {
    background: #b71c1c;
    transform: scale(1.1);
}

/* Fields area beneath the photo */
.upload-card-fields {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid var(--border-light, #e0e0e0);
    background: var(--bg-green-light, #f1f8f1);
}

.upload-card-fields .detail-input {
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
}

.upload-card-fields .detail-select {
    padding: 9px 12px;
    font-size: 13px;
}

.upload-card-fields .form-row {
    gap: 8px;
}

.upload-card-fields .character-type-toggle {
    margin: 0;
    align-self: flex-start;
}

.character-name-input {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.character-name-field {
    padding: 10px 14px;
    font-size: 14px;
    width: 100%;
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius-md);
    font-family: inherit;
    color: var(--text-dark);
    transition: all var(--transition-normal);
}

.character-name-field:focus {
    outline: none;
    border-color: var(--primary-green-light);
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.1);
}

.name-hint {
    font-size: 11px;
    color: var(--text-light);
    font-style: italic;
}

.character-note {
    background: var(--bg-green-light);
    border-left: 4px solid var(--primary-green);
    padding: 16px 20px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    color: var(--text-medium);
    line-height: 1.5;
}

.character-note i {
    color: var(--primary-green);
    font-size: 16px;
    margin-top: 2px;
    flex-shrink: 0;
}

/* Story Details Section */
.story-details-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
}

.form-label i {
    color: var(--primary-green-light);
    font-size: 16px;
}

.story-textarea {
    width: 100%;
    min-height: 140px;
    padding: 16px;
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius-md);
    font-size: 15px;
    font-family: inherit;
    color: var(--text-dark);
    resize: vertical;
    transition: all var(--transition-normal);
    line-height: 1.6;
}

.story-textarea:focus {
    outline: none;
    border-color: var(--primary-green-light);
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.1);
}

.story-textarea::placeholder {
    color: var(--text-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-select,
.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius-md);
    font-size: 15px;
    font-family: inherit;
    color: var(--text-dark);
    background: var(--white);
    transition: all var(--transition-normal);
}

.form-select {
    cursor: pointer;
}

.form-select:focus,
.form-input:focus {
    outline: none;
    border-color: var(--primary-green-light);
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.1);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.input-hint {
    font-size: 13px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-hint i {
    font-size: 12px;
    color: var(--primary-green-light);
}

.char-counter,
.word-counter {
    font-size: 13px;
    color: var(--text-medium);
    font-weight: 600;
    flex-shrink: 0;
}

/* Spelling Words Section */
.spelling-words-section {
    background: var(--off-white);
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}

.spelling-toggle {
    width: 100%;
    padding: 20px 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: inherit;
    transition: all var(--transition-normal);
}

.spelling-toggle:hover {
    background: var(--bg-green-light);
}

.spelling-toggle.active {
    background: var(--bg-green-light);
}

.toggle-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toggle-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-green-light);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--transition-normal);
    flex-shrink: 0;
}

.toggle-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.toggle-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.2;
}

.toggle-subtitle {
    font-size: 13px;
    color: var(--text-medium);
    line-height: 1.3;
}

.recommended-badge {
    background: var(--primary-green);
    color: var(--white);
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.recommended-badge i {
    font-size: 11px;
}

.spelling-panel {
    padding: 0 24px 24px;
    display: none;
}

.spelling-panel.active {
    display: block;
}

.spelling-benefits {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--bg-green-light);
    border-left: 4px solid var(--primary-green);
    border-radius: var(--border-radius-md);
    margin-top: 16px;
}

.benefit-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-dark);
}

.benefit-item i {
    color: var(--primary-green);
    font-size: 16px;
    flex-shrink: 0;
}

/* Form Actions */
.form-actions {
    background: var(--white);
    border-radius: var(--border-radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.generate-btn {
    width: 100%;
    padding: 18px 32px;
    background: linear-gradient(135deg, var(--primary-green), var(--primary-green-lighter));
    color: var(--white);
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
    font-family: inherit;
}

.generate-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-green-dark), var(--primary-green));
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-content i {
    font-size: 20px;
}

.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spinner-spin 0.6s linear infinite;
}

@keyframes spinner-spin {
    to { transform: rotate(360deg); }
}

.form-note {
    text-align: center;
    font-size: 14px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.form-note i {
    color: var(--primary-green-light);
    font-size: 16px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 24px;
}

.loading-modal {
    background: var(--white);
    border-radius: var(--border-radius-xl);
    padding: 48px;
    max-width: 560px;
    width: 100%;
    box-shadow: var(--shadow-xl);
}

.loading-header {
    text-align: center;
    margin-bottom: 40px;
}

.loading-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-green), var(--primary-green-lighter));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 36px;
    margin: 0 auto 20px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.loading-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.loading-subtitle {
    font-size: 15px;
    color: var(--text-medium);
}

.loading-stages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

.loading-stage {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: var(--off-white);
    border-radius: var(--border-radius-md);
    border: 2px solid var(--border-light);
    opacity: 0.4;
    transition: all var(--transition-normal);
}

.loading-stage.active {
    opacity: 1;
    border-color: var(--primary-green-light);
    background: var(--bg-green-light);
}

.loading-stage.complete {
    opacity: 1;
    border-color: var(--primary-green);
}

.stage-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stage-icon {
    width: 48px;
    height: 48px;
    background: var(--white);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--primary-green-light);
    flex-shrink: 0;
}

.loading-stage.active .stage-icon {
    background: var(--primary-green-light);
    color: var(--white);
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.loading-stage.complete .stage-icon {
    background: var(--primary-green);
    color: var(--white);
}

.stage-text {
    display: flex;
    flex-direction: column;
}

.stage-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.2;
}

.stage-desc {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.3;
}

.stage-check {
    width: 32px;
    height: 32px;
    background: var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 16px;
    opacity: 0;
    transition: all var(--transition-normal);
    flex-shrink: 0;
}

.loading-stage.complete .stage-check {
    background: var(--primary-green);
    opacity: 1;
}

.loading-progress {
    margin-top: 32px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 100px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-green), var(--primary-green-lighter));
    border-radius: 100px;
    width: 0%;
    transition: width 0.5s ease;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 1024px) {
    .hero-title {
        font-size: 48px;
    }

    .form-step {
        padding: 36px;
    }

    .art-style-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .characters-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .create-page-wrapper {
        padding: 100px 0 60px;
    }

    .create-container {
        padding: 0 16px;
    }

    .hero-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 24px;
        margin-bottom: 32px;
    }

    .hero-title {
        font-size: 40px;
    }

    .hero-subtitle {
        font-size: 16px;
    }

    .user-credits {
        align-self: stretch;
        padding: 16px 20px;
    }

    .credits-icon {
        width: 48px;
        height: 48px;
        font-size: 22px;
    }

    .credits-amount {
        font-size: 28px;
    }

    .form-step {
        padding: 28px 20px;
    }

    .step-header {
        gap: 16px;
        margin-bottom: 24px;
    }

    .step-number {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .step-title {
        font-size: 24px;
    }

    .step-description {
        font-size: 14px;
    }

    .option-grid.two-column {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .option-card {
        padding: 24px;
    }

    .option-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    .option-title {
        font-size: 18px;
    }

    .option-check {
        top: 16px;
        right: 16px;
        font-size: 24px;
    }

    .art-style-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .art-preview-placeholder {
        font-size: 28px;
    }

    .art-info {
        padding: 12px;
    }

    .art-title {
        font-size: 13px;
    }

    .art-check {
        font-size: 18px;
    }

    .characters-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .character-slot {
        padding: 14px;
    }

    .source-tab {
        padding: 8px 6px;
    }

    .source-tab i {
        font-size: 16px;
    }

    .source-tab span {
        font-size: 10px;
    }

    .saved-character-card {
        padding: 10px;
    }

    .saved-character-avatar {
        width: 48px;
        height: 48px;
    }

    .saved-character-name {
        font-size: 13px;
    }



    .character-placeholder {
        padding: 30px 15px;
    }

    .story-textarea {
        min-height: 120px;
        padding: 14px;
        font-size: 15px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .input-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .char-counter,
    .word-counter {
        align-self: flex-end;
    }

    .spelling-toggle {
        padding: 16px 20px;
    }

    .toggle-icon {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .toggle-title {
        font-size: 15px;
    }

    .toggle-subtitle {
        font-size: 12px;
    }

    .recommended-badge {
        padding: 5px 12px;
        font-size: 11px;
    }

    .spelling-panel {
        padding: 0 20px 20px;
    }

    .form-actions {
        padding: 28px 20px;
    }

    .generate-btn {
        padding: 16px 28px;
        font-size: 16px;
    }

    .loading-modal {
        padding: 36px 24px;
    }

    .loading-icon {
        width: 72px;
        height: 72px;
        font-size: 32px;
    }

    .loading-title {
        font-size: 22px;
    }

    .loading-subtitle {
        font-size: 14px;
    }

    .loading-stages {
        gap: 12px;
    }

    .loading-stage {
        padding: 16px;
    }

    .stage-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .stage-title {
        font-size: 15px;
    }

    .stage-desc {
        font-size: 12px;
    }

    .stage-check {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .create-page-wrapper {
        padding: 90px 0 50px;
    }

    .create-container {
        padding: 0 12px;
    }

    .hero-badge {
        font-size: 12px;
        padding: 6px 12px;
    }

    .hero-title {
        font-size: 32px;
    }

    .hero-subtitle {
        font-size: 15px;
    }

    .user-credits {
        padding: 14px 16px;
    }

    .credits-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .credits-label {
        font-size: 11px;
    }

    .credits-amount {
        font-size: 24px;
    }

    .story-form {
        gap: 24px;
    }

    .form-step {
        padding: 24px 16px;
        border-radius: var(--border-radius-lg);
    }

    .step-header {
        gap: 12px;
        margin-bottom: 20px;
    }

    .step-number {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .step-title {
        font-size: 22px;
    }

    .step-description {
        font-size: 13px;
    }

    .option-card {
        padding: 20px;
    }

    .option-icon {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }

    .option-title {
        font-size: 17px;
    }

    .option-description {
        font-size: 13px;
    }

    .option-check {
        font-size: 22px;
    }

    .art-style-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .art-preview-placeholder {
        font-size: 24px;
    }

    .art-info {
        padding: 10px;
    }

    .art-title {
        font-size: 12px;
    }

    .character-slot {
        padding: 12px;
    }

    .source-tabs {
        padding: 3px;
        gap: 4px;
    }

    .source-tab {
        padding: 8px 4px;
    }

    .source-tab i {
        font-size: 14px;
    }

    .source-tab span {
        font-size: 9px;
    }

    .empty-character-state {
        padding: 30px 15px;
    }

    .empty-character-state i {
        font-size: 40px;
    }

    .empty-character-state span {
        font-size: 13px;
    }

    .saved-character-card {
        padding: 8px;
        gap: 10px;
    }

    .saved-character-avatar {
        width: 44px;
        height: 44px;
    }

    .saved-character-name {
        font-size: 12px;
    }


    .character-placeholder {
        padding: 25px 12px;
    }

    .character-placeholder i {
        font-size: 28px;
    }

    .character-placeholder span {
        font-size: 13px;
    }

    .character-placeholder small {
        font-size: 10px;
    }

    .remove-character {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .character-note {
        padding: 14px 16px;
        font-size: 13px;
    }

    .form-label {
        font-size: 14px;
    }

    .story-textarea {
        padding: 12px;
        font-size: 14px;
    }

    .form-select,
    .form-input {
        padding: 12px 14px;
        font-size: 14px;
    }

    .character-name-field {
        padding: 9px 12px;
        font-size: 13px;
    }

    .input-hint {
        font-size: 12px;
    }

    .char-counter,
    .word-counter {
        font-size: 12px;
    }

    .spelling-toggle {
        padding: 14px 16px;
    }

    .toggle-icon {
        width: 34px;
        height: 34px;
    }

    .toggle-title {
        font-size: 14px;
    }

    .toggle-subtitle {
        font-size: 11px;
    }

    .recommended-badge {
        padding: 4px 10px;
        font-size: 10px;
    }

    .spelling-panel {
        padding: 0 16px 16px;
    }

    .spelling-benefits {
        padding: 14px;
    }

    .benefit-item {
        font-size: 13px;
    }

    .form-actions {
        padding: 24px 16px;
        border-radius: var(--border-radius-lg);
    }

    .generate-btn {
        padding: 15px 24px;
        font-size: 15px;
    }

    .btn-content i {
        font-size: 18px;
    }

    .form-note {
        font-size: 13px;
    }

    .loading-modal {
        padding: 28px 20px;
        max-width: calc(100vw - 24px);
    }

    .loading-icon {
        width: 64px;
        height: 64px;
        font-size: 28px;
        margin-bottom: 16px;
    }

    .loading-title {
        font-size: 20px;
    }

    .loading-subtitle {
        font-size: 13px;
    }

    .loading-header {
        margin-bottom: 32px;
    }

    .loading-stages {
        gap: 10px;
        margin-bottom: 28px;
    }

    .loading-stage {
        padding: 14px;
    }

    .stage-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .stage-text {
        gap: 2px;
    }

    .stage-title {
        font-size: 14px;
    }

    .stage-desc {
        font-size: 11px;
    }

    .stage-check {
        width: 26px;
        height: 26px;
        font-size: 13px;
    }

    .loading-progress {
        margin-top: 28px;
    }

    .progress-bar {
        height: 6px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* Selected Character Preview */
.selected-character-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-green-light);
    border: 3px solid var(--primary-green);
    border-radius: var(--border-radius-lg);
    margin-bottom: 16px;
    position: relative;
    width: 100%;
}

.selected-character-preview img {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: var(--border-radius-md);
    object-fit: contain;
    border: 2px solid var(--primary-green-light);
}

.preview-placeholder {
    width: 100%;
    max-width: 300px;
    aspect-ratio: 3/4;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-green-light), var(--bg-green-lighter));
    border-radius: var(--border-radius-md);
    border: 2px solid var(--primary-green-light);
    color: var(--primary-green-light);
    font-size: 48px;
}

.preview-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    text-align: center;
}

.preview-remove {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: var(--error-red);
    color: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.preview-remove:hover {
    background: #b71c1c;
    transform: scale(1.1);
}





/* ===================================
   UNLOCK RESTRICTIONS STYLES
   =================================== */

/* Unlock Banner */
.unlock-banner {
    background: linear-gradient(135deg, var(--primary-green-dark), var(--primary-green));
    border-radius: var(--border-radius-xl);
    padding: 24px 32px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-lg);
}

.unlock-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.unlock-icon {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 24px;
    flex-shrink: 0;
}

.unlock-text {
    flex: 1;
}

.unlock-text h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 6px;
}

.unlock-text p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.4;
}

.unlock-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
    color: var(--primary-green);
    padding: 12px 24px;
    border-radius: var(--border-radius-md);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    transition: all var(--transition-normal);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.unlock-btn:hover {
    background: var(--off-white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.unlock-btn i {
    font-size: 16px;
}

/* Locked Options */
.locked-option {
    position: relative;
    opacity: 0.6;
    cursor: not-allowed !important;
}

.locked-option:hover {
    transform: none !important;
    border-color: var(--border-light) !important;
    box-shadow: var(--shadow-sm) !important;
}

.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(2px);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    pointer-events: none;
}

.lock-overlay i {
    font-size: 32px;
    color: var(--text-light);
}

.lock-overlay span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Locked Art Styles */
.locked-style {
    opacity: 0.6;
    cursor: not-allowed !important;
}

.locked-style:hover {
    transform: none !important;
    border-color: var(--border-light) !important;
    box-shadow: none !important;
}

.art-lock {
    color: var(--text-light);
    font-size: 20px;
}

/* Locked Character Tabs */
.locked-tab {
    opacity: 0.6;
    cursor: not-allowed !important;
    position: relative;
}

.locked-tab:hover {
    background: transparent !important;
    color: var(--text-light) !important;
}

.tab-lock-icon {
    font-size: 10px;
    position: absolute;
    top: 6px;
    right: 6px;
}

/* Locked Toggle/Section */
.locked-toggle {
    cursor: not-allowed !important;
    opacity: 0.6;
}

.locked-toggle:hover {
    background: transparent !important;
}

.locked-section {
    opacity: 0.6;
}

.locked-badge {
    background: var(--text-light);
    color: var(--white);
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.locked-badge i {
    font-size: 11px;
}

/* Responsive - Unlock Banner */
@media (max-width: 768px) {
    .unlock-banner {
        padding: 20px 24px;
        margin-bottom: 24px;
    }

    .unlock-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .unlock-icon {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .unlock-text h3 {
        font-size: 18px;
    }

    .unlock-text p {
        font-size: 13px;
    }

    .unlock-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .unlock-banner {
        padding: 16px 20px;
    }

    .unlock-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .unlock-text h3 {
        font-size: 16px;
    }

    .unlock-text p {
        font-size: 12px;
    }

    .lock-overlay i {
        font-size: 28px;
    }

    .lock-overlay span {
        font-size: 12px;
    }
}






/* ===================================
   NEW LOADING SCREEN STYLES
   =================================== */

/* Loading Spinner */
.loading-spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 40px 0;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-light);
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading Tip */
.loading-tip {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 24px;
    background: var(--bg-green-light);
    border-left: 4px solid var(--primary-green);
    border-radius: var(--border-radius-md);
    margin-bottom: 32px;
}

.loading-tip i {
    color: var(--primary-green);
    font-size: 20px;
    margin-top: 2px;
    flex-shrink: 0;
}

.loading-tip p {
    font-size: 15px;
    color: var(--text-dark);
    line-height: 1.6;
    margin: 0;
    transition: opacity 0.3s ease;
}

/* Progress Section */
.loading-progress {
    margin-top: 32px;
}

.progress-text {
    text-align: center;
    font-size: 14px;
    color: var(--text-medium);
    font-weight: 600;
    margin-bottom: 12px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .loading-spinner {
        width: 50px;
        height: 50px;
        border-width: 3px;
    }
    
    .loading-tip {
        padding: 20px;
        gap: 12px;
    }
    
    .loading-tip i {
        font-size: 18px;
    }
    
    .loading-tip p {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .loading-spinner-container {
        margin: 32px 0;
    }
    
    .loading-spinner {
        width: 44px;
        height: 44px;
    }
    
    .loading-tip {
        padding: 16px;
        gap: 10px;
    }
    
    .loading-tip i {
        font-size: 16px;
    }
    
    .loading-tip p {
        font-size: 13px;
    }
    
    .progress-text {
        font-size: 13px;
    }
}



/* Messages */
.message-box {
    background: var(--white);
    border-radius: var(--border-radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.error-message {
    background: var(--error-bg);
    color: var(--error-red);
    border-left: 4px solid var(--error-red);
}

.success-message {
    background: var(--success-bg);
    color: var(--success-green);
    border-left: 4px solid var(--success-green);
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 500px;
    width: calc(100% - 32px);
}

.toast {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: 16px 20px;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 14px;
    pointer-events: auto;
    cursor: pointer;
    border-left: 4px solid var(--error-red);
    animation: toast-slide-in 0.3s ease-out;
    transition: all var(--transition-normal);
}

.toast:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

.toast.toast-success {
    border-left-color: var(--success-green);
}

.toast.toast-warning {
    border-left-color: #f59e0b;
}

.toast.toast-info {
    border-left-color: #3b82f6;
}

.toast-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.toast-icon.error {
    background: var(--error-bg);
    color: var(--error-red);
}

.toast-icon.success {
    background: var(--success-bg);
    color: var(--success-green);
}

.toast-icon.warning {
    background: #fef3c7;
    color: #f59e0b;
}

.toast-icon.info {
    background: #dbeafe;
    color: #3b82f6;
}

/* b56676 — locked-feature upsell: an invitation-framed toast (green, matching the
   unlock banner it scrolls to) instead of the red "Error" toast, plus a one-shot
   attention pulse on the banner so the eye lands on "Unlock Now". */
.toast.toast-unlock {
    border-left-color: var(--primary-green);
}
.toast-icon.unlock {
    background: #e6f4ea;
    color: var(--primary-green);
}
@keyframes unlockBannerPulse {
    0%   { box-shadow: var(--shadow-lg), 0 0 0 0 rgba(46, 125, 50, 0.5); }
    70%  { box-shadow: var(--shadow-lg), 0 0 0 16px rgba(46, 125, 50, 0); }
    100% { box-shadow: var(--shadow-lg), 0 0 0 0 rgba(46, 125, 50, 0); }
}
.unlock-banner--pulse {
    animation: unlockBannerPulse 1.5s ease-out;
}
@media (prefers-reduced-motion: reduce) {
    .unlock-banner--pulse { animation: none; }
}

.toast-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toast-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.toast-message {
    font-size: 13px;
    color: var(--text-medium);
    line-height: 1.4;
}

.toast-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--border-light);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-medium);
    font-size: 14px;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.toast-close:hover {
    background: var(--border-medium);
    color: var(--text-dark);
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast.toast-slide-out {
    animation: toast-slide-out 0.3s ease-in forwards;
}

@keyframes toast-slide-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Highlight invalid sections */
.form-step.invalid-section {
    animation: shake 0.5s ease-in-out;
    border: 2px solid var(--error-red);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}




.art-preview {
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--bg-green-light), var(--bg-green-lighter));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.art-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* 2026-09-22: no wash over the sample art. The old white/green gradients muddied every tile,
       worst on the selected one; the lifted card and the check badge carry the selection. */
    background: transparent;
    transition: all var(--transition-normal);
}

.art-style-card:hover .art-preview-overlay {
    background: transparent;
}

.art-style-card:has(input[type="radio"]:checked) .art-preview-overlay {
    background: transparent;
}

.art-preview-placeholder {
    color: var(--primary-green-light);
    font-size: 36px;
    opacity: 0.6;
    z-index: 1;
    position: relative;
}


/* ===================================
   DYNAMIC CHARACTER SLOTS STYLES
   =================================== */

/* Characters Header with Count */
.characters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.character-count-display {
    font-size: 14px;
    color: var(--text-medium);
    font-weight: 600;
}

.character-count-display span {
    color: var(--primary-green);
    font-weight: 700;
}

/* Updated Characters Grid for Dynamic Slots */
.characters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Character Slot Position for Remove Button */
.character-slot {
    position: relative;
}

/* Remove Slot Button */
.remove-slot-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    background: var(--error-red);
    color: var(--white);
    border: 2px solid var(--white);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
    z-index: 10;
    opacity: 0;
}

.character-slot:hover .remove-slot-btn {
    opacity: 1;
}

.remove-slot-btn:hover {
    background: #b71c1c;
    transform: scale(1.1);
}

/* Hide remove button for first slot */
.character-slot[data-slot="1"] .remove-slot-btn {
    display: none;
}

/* Add Character Button — lives inside .characters-grid as its own cell */
.add-character-btn {
    width: 100%;
    padding: 24px;
    background: var(--white);
    border: 2px dashed var(--border-medium);
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--primary-green);
    transition: all var(--transition-normal);
    font-family: inherit;
    /* Stretch to match the height of neighboring character slots */
    align-self: stretch;
    /* Always render visually after dynamically-appended slots (which default to order:0) */
    order: 100;
}

.add-character-btn:hover:not(:disabled) {
    background: var(--bg-green-light);
    border-color: var(--primary-green-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.add-character-btn:disabled,
.add-character-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--text-light);
    border-color: var(--border-light);
}

.add-character-btn:disabled:hover,
.add-character-btn.disabled:hover {
    background: var(--white);
    transform: none;
    box-shadow: none;
}

.add-character-btn i {
    font-size: 28px;
}

.add-character-btn span {
    font-size: 16px;
    font-weight: 600;
}

.add-character-btn small {
    font-size: 12px;
    color: var(--text-light);
}

.cap-hint-upgrade {
    color: #d97706;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px dotted #d97706;
    transition: color 0.15s ease, border-color 0.15s ease;
}

/* Subtle "(the people in your story)" qualifier next to the Characters heading */
.step-subnote {
    font-weight: 400;
    color: #94a3b8;
    font-size: 0.7em;
    margin-left: 6px;
}

/* Warning banner inside object-upload modal — disambiguates Objects vs Characters */
.objref-warning-banner {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 14px;
    margin-bottom: 14px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 10px;
    color: #78350f;
    font-size: 13px;
    line-height: 1.5;
}
.objref-warning-banner > i {
    color: #b45309;
    font-size: 14px;
    margin-top: 2px;
    flex-shrink: 0;
}
.objref-warning-banner strong {
    color: #78350f;
    font-weight: 700;
}

/* Inline name-collision hint shown right under the object name input */
.objref-name-hint {
    margin-top: 6px;
    padding: 8px 10px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    border-radius: 8px;
    color: #9a3412;
    font-size: 12px;
    line-height: 1.45;
}

/* "Improve" badge on saved-character cards that lack vision-extracted descriptions */
.char-enrich-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border: none;
    border-radius: 999px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.3);
    transition: transform 0.12s ease, box-shadow 0.15s ease, opacity 0.3s ease;
}
.char-enrich-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(217, 119, 6, 0.4);
}
.char-enrich-badge:disabled {
    opacity: 0.7;
    cursor: wait;
    transform: none;
}
.char-enrich-badge i { font-size: 10px; }
.char-enrich-badge-done {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.3);
}
.saved-character-sheet { position: relative; }

/* Highlight a character slot that failed required-field validation. */
.character-slot.slot-invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
    animation: slot-shake 0.35s ease;
}

@keyframes slot-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.cap-hint-upgrade:hover {
    color: #b45309;
    border-bottom-color: #b45309;
}

/* Inline upload error — sits at the top of the upload panel so the user sees it without scrolling */
.upload-error-inline {
    display: none;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fdecea;
    color: #b71c1c;
    border: 1px solid #f5c2c0;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    line-height: 1.35;
    animation: upload-error-pop 0.18s ease-out;
}

.upload-error-inline.visible {
    display: flex;
}

.upload-error-inline i {
    flex-shrink: 0;
    margin-top: 1px;
    font-size: 14px;
}

@keyframes upload-error-pop {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Slot Enter/Exit Animations */
.slot-enter {
    animation: slot-enter 0.3s ease-out;
}

@keyframes slot-enter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.slot-exit {
    animation: slot-exit 0.2s ease-in forwards;
}

@keyframes slot-exit {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Character Upgrade Card for Free Users */
.upgrade-card {
    display: none;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed var(--primary-green);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.upgrade-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(76, 175, 80, 0.03) 10px,
        rgba(76, 175, 80, 0.03) 20px
    );
    pointer-events: none;
}

.upgrade-card-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upgrade-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.upgrade-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.upgrade-text {
    font-size: 14px;
    color: var(--text-medium);
    line-height: 1.5;
    margin: 0;
    max-width: 280px;
}

.upgrade-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-dark) 100%);
    color: white;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--border-radius-md);
    transition: all var(--transition-normal);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
    margin-top: 4px;
}

.upgrade-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.4);
    color: white;
}

.upgrade-cta i {
    font-size: 16px;
}

/* Responsive adjustments for dynamic grid */
@media (min-width: 1200px) {
    .characters-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 900px) and (max-width: 1199px) {
    .characters-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 899px) {
    .characters-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .add-character-btn {
        padding: 20px;
    }

    .add-character-btn i {
        font-size: 24px;
    }

    .add-character-btn span {
        font-size: 14px;
    }

    .remove-slot-btn {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .characters-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .add-character-btn {
        padding: 16px;
    }

    .add-character-btn i {
        font-size: 22px;
    }

    .add-character-btn span {
        font-size: 13px;
    }

    .add-character-btn small {
        font-size: 11px;
    }
}

/* ============================================================================
   OBJECTS SECTION (paid-only feature on the create-story page)
   ============================================================================ */

.step-optional-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 11px;
    font-weight: 500;
    border-radius: 999px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.step-locked-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 8px;
    padding: 3px 9px;
    background: #fef3c7;
    color: #b45309;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.objects-section {
    background: var(--off-white);
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    padding: 20px;
}

/* Locked state for free users */
.objects-locked-overlay {
    text-align: center;
    padding: 28px 24px;
}

.objects-locked-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #b45309;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    font-size: 22px;
}

.objects-locked-title {
    font-size: 17px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 8px;
}

.objects-locked-copy {
    font-size: 14px;
    line-height: 1.55;
    color: #475569;
    margin: 0 auto 18px;
    max-width: 560px;
}

.btn-unlock-objects {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.25);
    transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.btn-unlock-objects:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.35);
    color: white;
}

/* Active picker for paid users */
.objects-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 14px;
}

.object-count-display {
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
}

#activeObjectCount {
    color: var(--primary-green);
    font-weight: 700;
}

.objects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.object-tile {
    position: relative;
    aspect-ratio: 1 / 1.15;
    border-radius: 12px;
    border: 1.5px solid #e5e7eb;
    background: white;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    font-family: inherit;
    text-align: left;
}

.object-tile:hover {
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.06);
}

.object-tile.selected {
    border-color: var(--primary-green);
    border-width: 2px;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.object-tile.selected::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary-green);
    color: white;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.object-tile img {
    width: 100%;
    flex: 1;
    object-fit: cover;
    background: #f8fafc;
    display: block;
    min-height: 0;
}

.object-tile-name {
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    text-align: center;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: white;
    border-top: 1px solid #f1f5f9;
}

.object-tile-delete {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: white;
    border: none;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 1;
}

.object-tile:hover .object-tile-delete {
    opacity: 1;
}

.object-tile-delete:hover {
    background: #ef4444;
}

.object-add-new {
    background: white;
    border: 1.5px dashed #cbd5e1;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #6366f1;
    text-align: center;
}

.object-add-new:hover {
    border-color: #6366f1;
    background: #f5f3ff;
}

.object-add-new.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: #f8fafc;
    color: #94a3b8;
    border-color: #e5e7eb;
}

.object-add-new.disabled:hover {
    background: #f8fafc;
    border-color: #e5e7eb;
}

.object-add-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f5f3ff;
    color: #6366f1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.object-add-new.disabled .object-add-icon {
    background: #f1f5f9;
    color: #94a3b8;
}

.object-add-label {
    font-size: 13px;
    font-weight: 600;
}

.object-add-cost {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

.objects-loading {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    padding: 16px;
    color: #94a3b8;
    font-size: 18px;
}

.object-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    color: #075985;
    font-size: 13px;
    line-height: 1.5;
}

.object-note i {
    color: #0284c7;
    margin-top: 2px;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .objects-section {
        padding: 16px;
    }
    .objects-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    .object-tile-delete {
        opacity: 1; /* always visible on touch */
    }
    .objects-locked-overlay {
        padding: 20px 12px;
    }
    .objects-locked-title {
        font-size: 15px;
    }
    .objects-locked-copy {
        font-size: 13px;
    }
}

/* Object upload modal — reuse styles from story.css if present, otherwise fall back */
.objref-upload-modal {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.objref-upload-modal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}
.objref-upload-content {
    position: relative;
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.objref-upload-state .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #f1f5f9;
}
.objref-upload-state .modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #0f172a;
}
.objref-upload-state .modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.15s ease, color 0.15s ease;
}
.objref-upload-state .modal-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}
.objref-upload-state .modal-body {
    padding: 18px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Cap body height so a tall preview image scrolls inside it instead of pushing the footer off-screen */
    max-height: calc(90vh - 140px);
}
.objref-upload-state .modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 20px;
    /* Respect iOS safe area (home indicator) so the action button is never under the chrome */
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid #f1f5f9;
    background: #fafafa;
    flex-shrink: 0;
}
.objref-hint {
    margin: 0 0 14px;
    font-size: 13px;
    color: #64748b;
    line-height: 1.5;
}
.objref-field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
    margin-top: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.objref-field-label:first-of-type {
    margin-top: 0;
}
.objref-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    color: #0f172a;
    background: #fafafa;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.objref-input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
    background: white;
}
.objref-file-row { display: flex; align-items: center; }
.objref-file-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    background: white;
    color: #374151;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.objref-file-btn:hover {
    border-color: #6366f1;
    background: #f5f3ff;
    color: #6366f1;
}
.objref-preview-wrap {
    margin-top: 12px;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    max-width: 100%;
    /* Constrain the preview tile so a tall portrait photo can't blow up the modal */
    max-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.objref-preview-wrap img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
    display: block;
}
.fix-credit-cost {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    padding: 8px 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #15803d;
}
.fix-credit-cost i { font-size: 12px; }

.objref-style-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding: 9px 12px;
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 8px;
    font-size: 13px;
    color: #4c1d95;
    line-height: 1.4;
}
.objref-style-notice i { color: #7c3aed; font-size: 13px; flex-shrink: 0; }
.objref-style-notice strong { color: #1e1b4b; font-weight: 600; }
.objref-upload-state .btn-cancel {
    padding: 9px 16px;
    background: #f1f5f9;
    color: #475569;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.objref-upload-state .btn-cancel:hover { background: #e2e8f0; }
.objref-upload-state .btn-fix {
    padding: 9px 18px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.objref-upload-state .btn-fix:hover { transform: translateY(-1px); }
.objref-upload-state .btn-fix:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #94a3b8;
    transform: none;
}

/* Photo / Text tab toggle inside upload modal */
.objref-mode-tabs {
    display: flex;
    gap: 6px;
    margin-top: 14px;
    margin-bottom: 4px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
}
.objref-mode-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: #64748b;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.objref-mode-tab i { font-size: 12px; }
.objref-mode-tab:hover { color: #1f2937; }
.objref-mode-tab.active {
    background: white;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.objref-mode-panel { margin-top: 6px; }
.objref-textarea {
    min-height: 90px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}
.objref-helper-text {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #64748b;
    line-height: 1.45;
}
.fix-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 12px auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.fix-processing-text {
    text-align: center;
    font-size: 15px;
    color: #1a1a1a;
    margin: 0 0 6px;
}
.fix-processing-subtext {
    text-align: center;
    font-size: 13px;
    color: #64748b;
    margin: 0;
}

@media (max-width: 640px) {
    .objref-upload-modal {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .objref-upload-content {
        max-width: 100%;
        /* Use dvh so the iOS URL bar doesn't push content off-screen; vh fallback for older browsers */
        height: 100vh;
        max-height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .objref-upload-state .modal-body {
        /* Body fills everything between header (~57px) and footer (~70px incl safe area) */
        max-height: calc(100vh - 140px);
        max-height: calc(100dvh - 140px);
    }
}
/* ==========================================================================
   Builder rework 2026-09-15 — PersonalizedComics' order and blocks in LoveToRead's system:
   tone chips, the Idea Generator pill, the title block (suggested or your own), "Your people"
   chips, and the words block. Tokens from tokens.css (loads last); no green anywhere here.
   ========================================================================== */
.prompt-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.prompt-footer .char-counter { margin: 0; font-variant-numeric: tabular-nums; }
.idea-row { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; min-width: 0; }
.idea-hint { flex: 1; min-width: 0; max-width: 300px; padding: 9px 14px; border: 1.5px solid var(--rule); border-radius: var(--pill); background: var(--card); font: 400 .9rem var(--body); color: var(--ink); outline: none; }
.idea-hint:focus { border-color: var(--lagoon); box-shadow: 0 0 0 3px var(--lagoon-tint); }
.idea-btn { flex: 0 0 auto; padding: 9px 16px; border: 2px solid var(--ink); border-radius: var(--pill); background: var(--paper); color: var(--ink); font: 700 .88rem/1 var(--body); cursor: pointer; white-space: nowrap; transition: background .12s ease, color .12s ease, transform .12s ease; }
.idea-btn:hover { background: var(--ink); color: var(--paper); transform: translateY(-1px); }
.idea-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.textlink { background: none; border: 0; padding: 0; font: 600 .9rem var(--body); color: var(--lagoon-deep); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); }
.textlink:hover { color: var(--lagoon); text-decoration-color: currentColor; }

/* tone (and prose / rhyme, which borrows the same chips) */
.tone-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tone-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 520px; }
.tone-option { cursor: pointer; margin: 0; }
.tone-option input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.tone-chip { display: block; padding: 12px 10px; border: 2px solid var(--rule); border-radius: 14px; background: var(--card); color: var(--ink); font: 700 .95rem/1.2 var(--body); text-align: center; transition: border-color .12s ease, background .12s ease, transform .12s ease; }
.tone-chip b { display: block; font-size: 1rem; }
.tone-chip small { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); margin-top: 3px; }
.tone-option:hover .tone-chip { border-color: var(--ink-soft); transform: translateY(-1px); }
.tone-option input:checked + .tone-chip { border-color: var(--lagoon); background: var(--lagoon-tint); color: var(--lagoon-deep); }
.tone-option input:checked + .tone-chip small { color: var(--lagoon-deep); }
.tone-option input:focus-visible + .tone-chip { box-shadow: 0 0 0 3px var(--lagoon-tint); }
@media (max-width: 640px) { .tone-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* title block */
.title-block { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--rule); }
.title-block [hidden] { display: none !important; }
.title-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.title-head .form-label { margin: 0; }
.title-opt { color: var(--muted); font-size: .86rem; }
.title-opt.is-set { color: var(--ink); }
.title-opt b { font-weight: 700; }
.title-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.title-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.title-option { text-align: left; background: var(--card); border: 2px solid var(--rule); border-radius: 14px; padding: 12px 14px; color: var(--ink); cursor: pointer; font: 400 1rem/1.3 var(--body); transition: border-color .12s ease, background .12s ease, transform .12s ease; }
.title-option b { display: block; font-family: var(--display); font-weight: 700; font-size: 1.08rem; }
.title-option small { display: block; color: var(--muted); font-size: .82rem; margin-top: 2px; }
.title-option:hover { border-color: var(--ink-soft); transform: translateY(-1px); }
.title-option.is-on { border-color: var(--lagoon); background: var(--lagoon-tint); }
.title-option.is-on b { color: var(--lagoon-deep); }
.title-skel { display: block; height: 3.2rem; border-radius: 14px; background: linear-gradient(90deg, var(--oat) 25%, var(--oat-deep) 50%, var(--oat) 75%); background-size: 200% 100%; animation: titleShimmer 1.1s linear infinite; }
@keyframes titleShimmer { to { background-position: -200% 0; } }
.title-more { margin-top: 10px; }
.title-own { margin-top: 14px; max-width: 520px; }
@media (max-width: 560px) { .title-options { grid-template-columns: 1fr; } }

/* "Your people" chips */
.people-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.people-row[hidden] { display: none !important; }
.people-label { font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.people-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.people-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border: 2px solid var(--rule); border-radius: var(--pill); background: var(--card); color: var(--ink); font: 700 .88rem var(--body); cursor: pointer; transition: border-color .12s ease, background .12s ease, transform .12s ease; }
.people-chip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; object-position: top; border: 1px solid var(--rule); background: var(--oat); }
.people-chip:hover { border-color: var(--ink-soft); transform: translateY(-1px); }
.people-chip.is-on, .people-chip:disabled { background: var(--lagoon-tint); border-color: var(--lagoon); color: var(--lagoon-deep); transform: none; cursor: default; }

/* the words block (LoveToRead only) */
.words-block { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--rule); }
.words-block .form-group + .form-group { margin-top: 18px; }
