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

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    font-family: 'Space Mono', monospace;
    background: #f8f9fa;
    min-height: 100vh;
    color: #333;
    width: 100vw;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.navbar {
    background: white;
    border-bottom: 1px solid #e9ecef;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.nav-btn {
    padding: 8px 16px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: white;
    color: #333;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

.create-btn {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.create-btn:hover {
    background: #0056b3;
    border-color: #0056b3;
}

.main-content {
    position: relative;
    width: 100%;
    min-height: calc(100vh - 60px);
}

.page {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100%;
    padding: 20px;
    opacity: 0;
    transform: none;
    transition: opacity 0.2s ease;
    pointer-events: none;
    visibility: hidden;
    display: none;
}

.page.active {
    opacity: 1;
    transform: none;
    pointer-events: all;
    visibility: visible;
    display: block;
    position: relative;
}

.character-gallery {
    max-width: 1200px;
    margin: 0 auto;
}

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

.character-gallery h2 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 0;
}

.filter-container {
    position: relative;
}

.language-filter {
    padding: 12px 16px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: white;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
}

.language-filter:hover {
    border-color: #007bff;
}

.language-filter:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.character-card {
    background: white;
    padding: 24px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.2s ease;
}

.character-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #007bff;
}

.character-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #333;
}

.character-description {
    font-size: 0.9rem;
    color: #6c757d;
    line-height: 1.5;
    margin-bottom: 8px;
}

.character-author {
    font-size: 0.8rem;
    color: #adb5bd;
    font-style: italic;
}

.remixed-badge {
    font-size: 0.7em;
    color: #007bff;
    margin-left: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.create-container {
    max-width: 600px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
}

.page-header h2 {
    font-size: 1.8rem;
    color: #333;
}

.back-btn {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: white;
    color: #333;
    font-family: 'Space Mono', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

.character-form {
    background: white;
    padding: 30px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 700;
    color: #333;
    font-size: 0.9rem;
}

.form-group input, .form-group textarea {
    padding: 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-family: 'Space Mono', monospace;
    transition: border-color 0.2s ease;
    font-size: 0.9rem;
}

.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

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

.submit-btn {
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: flex-start;
}

.submit-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.refresh-btn {
    display: block;
    margin: 20px auto;
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.chat-container {
    max-width: none;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 0;
    border: none;
    overflow: hidden;
    width: 100%;
}

.chat-header {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.chat-info h3 {
    font-size: 1.2rem;
    margin-bottom: 4px;
    color: #333;
}

.chat-info p {
    font-size: 0.9rem;
    color: #6c757d;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    padding-bottom: 100px;
}

.message {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 0.9rem;
    line-height: 1.4;
}

.message.user {
    background: #007bff;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.chat-input {
    display: flex;
    padding: 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    gap: 12px;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px;
    z-index: 10;
}

.chat-input input {
    flex: 1;
    padding: 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
}

.chat-input input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.chat-input button {
    padding: 12px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    transition: all 0.2s ease;
}

.chat-input button:hover {
    background: #0056b3;
}

.loading {
    display: none; /* Hide loading message */
}

/* Success message styles */
.success-message {
    position: fixed;
    top: 80px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 16px 24px;
    border-radius: 6px;
    font-weight: 700;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease;
}

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

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

/* Toggle switch styles */
.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    font-weight: 400 !important;
    gap: 12px;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 24px;
    background: #ccc;
    border-radius: 12px;
    transition: background 0.3s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider {
    background: #007bff;
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider::after {
    transform: translateX(26px);
}

.toggle-text {
    font-size: 0.9rem;
    color: #333;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    min-height: 200px;
}

.progress-bar {
    width: 100%;
    max-width: 400px;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff 0%, #0056b3 100%);
    animation: loading 2s ease-in-out infinite;
    width: 30%;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(400%);
    }
}

.loading-message {
    font-size: 0.9rem;
    color: #6c757d;
    text-align: center;
    margin-top: 12px;
}

/* Selection prevention */
body {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Context menu */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 200px;
    padding: 8px 0;
}

.context-menu-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    font-family: 'Space Mono', monospace;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease;
}

.context-menu-item:hover,
.context-menu-item:focus {
    background: #f8f9fa;
    outline: none;
}

.context-menu-item:first-child:focus {
    background: #f8f9fa;
}

.search-input {
    padding: 12px 16px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    min-width: 250px;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

@media (max-width: 768px) {
    .page {
        padding: 10px;
    }
    
    .character-grid {
        grid-template-columns: 1fr;
    }
    
    .nav-title {
        font-size: 1.2rem;
    }
    
    .chat-container {
        height: 100vh;
        max-width: 100%;
    }
    
    .chat-input {
        max-width: 100%;
    }
    
    .gallery-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .character-gallery h2 {
        margin-bottom: 10px;
    }
    
    .language-filter {
        width: 100%;
    }
    
    .toggle-label {
        flex-wrap: wrap;
    }
}

.recents-container {
    max-width: 800px;
    margin: 0 auto;
}

.recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.recent-card {
    background: white;
    padding: 24px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.2s ease;
}

.recent-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #007bff;
}

.recent-card .character-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.recent-card .slots-info {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 12px;
}

.recent-card .last-interaction {
    font-size: 0.8rem;
    color: #adb5bd;
}

.beta-footer {
    text-align: center;
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 40px;
    padding-bottom: 20px;
}

.slots-settings {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 20px;
}