:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --border: #333333;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.app {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 30px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 8px;
}

.lang-selector {
    position: absolute;
    right: 0;
}

.lang-selector select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
}

.lang-selector select:focus {
    outline: none;
    border-color: var(--accent);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2.5rem;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Level Navigation */
.level-nav {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.level-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.level-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.level-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.level-btn.completed {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

/* Level Info */
.level-info {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.level-badge {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.level-info h2 {
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.level-info p {
    color: var(--text-secondary);
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    min-height: 400px;
    max-height: 500px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

.message.assistant, .message.system {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.95rem;
}

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

.message.assistant .message-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message.system .message-content {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-secondary);
    font-style: italic;
}

.message.blocked .message-content {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.message.success .message-content {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

/* Chat Input */
.chat-input-form {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.chat-input-form textarea {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    margin-bottom: 10px;
}

.chat-input-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.clear-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: var(--bg-tertiary);
    color: var(--error);
    border-color: var(--error);
}

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

.chat-input-form button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.chat-input-form button:hover {
    background: var(--accent-hover);
}

.chat-input-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Password Submit */
.password-submit {
    margin-top: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
}

.password-submit h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.password-form {
    display: flex;
    gap: 10px;
}

.password-form input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

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

.password-form button {
    background: var(--success);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.password-form button:hover {
    opacity: 0.9;
}

.password-hint {
    margin-top: 10px;
    font-size: 0.9rem;
}

.password-hint.error {
    color: var(--error);
}

.password-hint.success {
    color: var(--success);
}

/* Footer */
.footer {
    margin-top: 30px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.provider-info {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.provider-info select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    color: var(--text-primary);
    cursor: pointer;
}

.version-info {
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.85rem;
}

#versionNumber {
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}

.changelog-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.changelog-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
    border-color: var(--accent);
}

.changelog-content {
    max-width: 500px;
    max-height: 70vh;
    overflow-y: auto;
    text-align: left;
}

.changelog-content h2 {
    text-align: center;
    margin-bottom: 20px;
}

.changelog-content h3 {
    color: var(--accent);
    font-size: 1rem;
    margin: 15px 0 10px 0;
}

.changelog-content ul {
    margin-left: 20px;
    color: var(--text-secondary);
}

.changelog-content li {
    margin: 5px 0;
    font-size: 0.9rem;
}

.close-btn {
    margin-top: 20px;
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--accent);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    max-width: 400px;
    border: 1px solid var(--border);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.modal-content h2 {
    margin-bottom: 10px;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal-content button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-content button:hover {
    background: var(--accent-hover);
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

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

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 600px) {
    .app {
        padding: 10px;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .password-form {
        flex-direction: column;
    }

    .message {
        max-width: 95%;
    }
}
