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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f4ff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #1e3a5f;
}

.container {
    width: 100%;
    max-width: 900px;
    height: 95vh;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(59, 130, 246, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #dbeafe;
}

header {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 1px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f8fbff;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    gap: 14px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    background: #dbeafe;
    border: 2px solid #bfdbfe;
}

.message.assistant .message-avatar {
    background: #3b82f6;
    border-color: #2563eb;
}

.message.user .message-avatar {
    background: #1e3a5f;
    border-color: #1e3a5f;
}

.message-content {
    max-width: 72%;
    padding: 14px 18px;
    border-radius: 16px;
    line-height: 1.7;
    font-size: 15px;
    background: #fff;
    border: 1px solid #e0e9ff;
    color: #1e3a5f;
}

.message.user .message-content {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff;
    border: none;
}

.message-content pre {
    background: #f0f4ff;
    color: #1e3a5f;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid #dbeafe;
}

.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 12px 0 8px;
    font-weight: 600;
    color: #1e3a5f;
}

.message-content h1 {
    font-size: 18px;
    border-bottom: 2px solid #3b82f6;
    padding-bottom: 4px;
}

.message-content h2 {
    font-size: 16px;
}

.message-content h3 {
    font-size: 15px;
}

.message-content code {
    background: #dbeafe;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    color: #1d4ed8;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: #1e3a5f;
}

.input-container {
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #dbeafe;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: #f8fbff;
    border: 2px solid #dbeafe;
    border-radius: 14px;
    padding: 12px 16px;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#userInput {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 15px;
    font-family: inherit;
    max-height: 120px;
    line-height: 1.5;
    background: transparent;
    color: #1e3a5f;
}

#userInput::placeholder {
    color: #93c5fd;
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #3b82f6;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f8fbff;
}

::-webkit-scrollbar-thumb {
    background: #bfdbfe;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #93c5fd;
}

.ai-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    padding: 24px 32px;
    border-radius: 16px;
    color: white;
    margin-bottom: 24px;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.header-left .subtitle {
    font-size: 14px;
    opacity: 0.85;
}

.balance-info {
    display: flex;
    align-items: center;
    gap: 24px;
    background: rgba(255, 255, 255, 0.15);
    padding: 16px 24px;
    border-radius: 12px;
}

.balance-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.balance-label {
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 4px;
}

.balance-value {
    font-size: 22px;
    font-weight: 700;
}

.balance-value.crab {
    color: #fbbf24;
}

.balance-unit {
    font-size: 12px;
    opacity: 0.7;
}

.balance-divider {
    width: 1px;
    height: 40px;
    background: rgba(255, 255, 255, 0.3);
}

.exchange-section {
    margin-bottom: 24px;
}

.exchange-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.1);
    border: 1px solid #dbeafe;
}

.exchange-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #1e3a5f;
}

.exchange-rates {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    padding: 16px;
    background: #f8fbff;
    border-radius: 12px;
}

.rate-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rate-label {
    font-size: 13px;
    color: #64748b;
}

.rate-value {
    font-size: 15px;
    font-weight: 600;
    color: #1e3a5f;
}

.exchange-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: #475569;
}

.form-group select {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    color: #1e3a5f;
    cursor: pointer;
    transition: border-color 0.2s;
}

.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
}

.exchange-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fef3c7;
    border-radius: 10px;
    font-size: 14px;
    color: #92400e;
}

.exchange-summary .crab {
    font-weight: 700;
    font-size: 18px;
    color: #d97706;
}

.exchange-btn {
    padding: 14px 24px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.exchange-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
}

.services-section {
    margin-bottom: 24px;
}

.services-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1e3a5f;
}

.services-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.service-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.1);
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.3s;
}

.service-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.2);
    transform: translateX(4px);
}

.card-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.card-content {
    flex: 1;
}

.card-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #1e3a5f;
}

.card-content p {
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
}

.card-tags {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.tag {
    padding: 4px 12px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.card-arrow {
    color: #94a3b8;
    transition: color 0.2s;
}

.service-card:hover .card-arrow {
    color: #3b82f6;
}

.pricing-section {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.1);
    border: 1px solid #dbeafe;
}

.pricing-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #1e3a5f;
}

.pricing-table {
    overflow-x: auto;
}

.pricing-table table {
    width: 100%;
    border-collapse: collapse;
}

.pricing-table th,
.pricing-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.pricing-table th {
    background: #f8fbff;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
}

.pricing-table td {
    font-size: 14px;
    color: #1e3a5f;
}

.pricing-table tr:hover td {
    background: #fafafa;
}

.pricing-note {
    margin-top: 16px;
    font-size: 13px;
    color: #94a3b8;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 8px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1e3a5f;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    font-size: 20px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #e2e8f0;
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    font-size: 15px;
    color: #475569;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
}

.modal-btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn.cancel {
    background: #f1f5f9;
    border: none;
    color: #64748b;
}

.modal-btn.cancel:hover {
    background: #e2e8f0;
}

.modal-btn.primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border: none;
    color: white;
}

.modal-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.chat-page header {
    justify-content: space-between;
}

.chat-page .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-page .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.chat-balance {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-size: 14px;
    margin-right: 12px;
}

.usage-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #fef3c7;
    border-radius: 8px;
    font-size: 13px;
    color: #92400e;
}

.usage-info #currentUsage {
    font-weight: 600;
    color: #d97706;
}
