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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: #0f172a;
    min-height: 100vh;
    padding: 15px;
    color: #e2e8f0;
    position: relative;
}

.code-section {
    position: absolute;
    top: 20px;
    right: 50px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 20px;
    max-width: 500px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.settings-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    color: #94a3b8;
}

.settings-icon:hover {
    background: #334155;
    color: #e2e8f0;
    transform: scale(1.05);
}

.settings-icon:active {
    transform: scale(0.95);
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 27px;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 400;
}

.usage-info {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    padding: 9px 18px;
    background: #1e293b;
    border-radius: 12px;
    border: 1px solid #334155;
    max-width: 750px;
    margin-left: auto;
    margin-right: auto;
}

.usage-text {
    font-size: 10.5px;
    color: #94a3b8;
}

.usage-text strong {
    color: #e2e8f0;
    font-weight: 600;
}

.mode-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 22.5px;
    padding: 12px 18px;
    background: #1e293b;
    border-radius: 12px;
    border: 1px solid #334155;
    max-width: 750px;
    margin-left: auto;
    margin-right: auto;
    flex-wrap: wrap;
    gap: 12px;
}

.mode-selector label {
    font-size: 13.5px;
    font-weight: 600;
    color: #94a3b8;
    white-space: nowrap;
}

.radio-group {
    display: flex;
    gap: 18px;
    align-items: center;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 7.5px;
    cursor: pointer;
    font-size: 12px;
    color: #e2e8f0;
}

.radio-option input[type="radio"] {
    width: 15px;
    height: 15px;
    accent-color: #3b82f6;
    cursor: pointer;
}

.radio-option span {
    cursor: pointer;
    transition: color 0.2s ease;
}

.radio-option:hover span {
    color: #3b82f6;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 36px;
    min-height: 450px;
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
}

.left-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

.upload-section {
    margin-bottom: 0;
}

.upload-area {
    border: 2px dashed #475569;
    border-radius: 16px;
    padding: 75px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #1e293b;
    min-height: 300px;
}

.upload-area:hover {
    border-color: #3b82f6;
    background: #334155;
}

.upload-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    color: #64748b;
}

.upload-text {
    font-size: 13.5px;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 10.5px;
    color: #94a3b8;
}

.image-preview {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 412.5px;
}

.image-preview h3,
.latex-result h3 {
    font-size: 13.5px;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 8px;
}

#preview-image {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 8px;
}

.latex-result {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 699px;
}

.latex-preview {
    min-height: 187.5px;
    padding: 18px;
    background: #0f172a;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.6;
    color: #e2e8f0;
    text-align: left;
}

/* MathJax暗色主题样式 */
.latex-preview mjx-container {
    color: #e2e8f0 !important;
}

.latex-preview mjx-container svg {
    fill: #e2e8f0 !important;
    stroke: #e2e8f0 !important;
}

.latex-preview mjx-container mjx-math {
    color: #e2e8f0 !important;
}

.latex-preview mjx-container mjx-mo {
    color: #e2e8f0 !important;
}

.latex-preview mjx-container mjx-mi {
    color: #e2e8f0 !important;
}

.latex-preview mjx-container mjx-mn {
    color: #e2e8f0 !important;
}

.latex-preview mjx-container mjx-mspace {
    color: #e2e8f0 !important;
}

.latex-preview.simple {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    text-align: center;
}

.latex-preview h1,
.latex-preview h2,
.latex-preview h3,
.latex-preview h4,
.latex-preview h5,
.latex-preview h6 {
    margin-top: 18px;
    margin-bottom: 12px;
    font-weight: 600;
    line-height: 1.25;
}

.latex-preview h1 {
    font-size: 1.5em;
    border-bottom: 1px solid #334155;
    padding-bottom: 0.3em;
}

.latex-preview h2 {
    font-size: 1.125em;
    border-bottom: 1px solid #334155;
    padding-bottom: 0.3em;
}

.latex-preview h3 {
    font-size: 0.9375em;
}

.latex-preview p {
    margin-top: 0;
    margin-bottom: 12px;
}

.latex-preview ul,
.latex-preview ol {
    padding-left: 1.5em;
    margin-top: 0;
    margin-bottom: 12px;
}

.latex-preview li {
    margin-top: 0.1875em;
}

.latex-preview code {
    background: #334155;
    padding: 0.15em 0.3em;
    border-radius: 0.225em;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.65625em;
}

.latex-preview pre {
    background: #334155;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin-top: 0;
    margin-bottom: 12px;
}

.latex-preview pre code {
    background: none;
    padding: 0;
}

.latex-preview blockquote {
    border-left: 4px solid #334155;
    padding-left: 12px;
    color: #94a3b8;
    margin-top: 0;
    margin-bottom: 12px;
}

#latex-input {
    width: 100%;
    min-height: 262.5px;
    padding: 15px;
    border: 1px solid #475569;
    border-radius: 8px;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 13.5px;
    line-height: 1.6;
    resize: vertical;
    background: #0f172a;
    color: #e2e8f0;
    transition: border-color 0.2s;
}

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

.format-selector {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 18px;
}

.format-selector label {
    font-size: 10.5px;
    font-weight: 600;
    color: #94a3b8;
    white-space: nowrap;
}

.format-selector select {
    flex: 1;
    width: 100%;
    min-width: 375px;
    padding: 9px 12px;
    padding-right: 30px;
    border: 1px solid #475569;
    border-radius: 8px;
    font-size: 10.5px;
    background: #0f172a;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 9L1 5l5 5 5 5-5-5-5-5 5 5 5 5 5 5-5 5-5-5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.format-selector select:hover {
    border-color: #3b82f6;
}

.format-selector select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.format-selector select option {
    padding: 7.5px 12px;
    white-space: nowrap;
    overflow: visible;
    text-overflow: visible;
    max-width: none;
    width: auto;
    min-width: 100%;
    background: #0f172a;
    color: #e2e8f0;
}

.format-selector select option:hover {
    background-color: #334155;
}

.format-selector select option:checked {
    background-color: #3b82f6;
    color: white;
    font-weight: 600;
}

.button-group {
    display: flex;
    gap: 9px;
}

.btn {
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

#get-code-btn {
    padding: 9px 24px;
    background: #f97316;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#get-code-btn:hover {
    background: #ea580c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.btn-secondary {
    background: #334155;
    color: #94a3b8;
    border: 1px solid #475569;
}

.btn-secondary:hover {
    background: #475569;
    border-color: #64748b;
}

.copy-message {
    text-align: center;
    padding: 9px;
    margin-top: 12px;
    border-radius: 8px;
    font-size: 10.5px;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: #e2e8f0;
}

.copy-message.show {
    opacity: 1;
}

.code-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 9px;
}

.arrow-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    color: #94a3b8;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.arrow-btn:hover {
    background: #334155;
    color: #e2e8f0;
}

.code-header h3 {
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
    margin: 0;
}

.code-input-group {
    display: flex;
    gap: 9px;
    margin-left: 0px;
    max-width: 450px;
}

#code-input {
    flex: 1;
    min-width: 225px;
    padding: 9px 12px;
    border: 1px solid #475569;
    border-radius: 8px;
    font-size: 10.5px;
    background: #0f172a;
    color: #e2e8f0;
    transition: border-color 0.2s;
}

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

#verify-btn {
    padding: 9px 24px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#verify-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.code-message {
    text-align: center;
    padding: 9px;
    margin-top: 9px;
    border-radius: 8px;
    font-size: 10.5px;
}

.code-message.success {
    color: #34d399;
    background: #064e3b;
}

.code-message.error {
    color: #f87171;
    background: #7f1d1d;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #334155;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    margin-top: 16px;
    font-size: 16px;
    color: #94a3b8;
}

@media (max-width: 768px) {
    body {
        padding: 7.5px;
    }
    
    .code-section {
        position: relative;
        top: 0;
        right: 0;
        max-width: 100%;
        margin-bottom: 15px;
    }
    
    .settings-icon {
        position: relative;
        top: 0;
        right: 0;
        margin-bottom: 15px;
    }
    
    .mode-selector {
        flex-direction: column;
        align-items: stretch;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 18px;
    }
    
    header h1 {
        font-size: 21px;
    }
    
    .format-selector {
        flex-direction: column;
        align-items: stretch;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .code-input-group {
        flex-direction: column;
        margin-left: 0;
        max-width: 100%;
    }

    #code-input {
        min-width: 100%;
    }

    #verify-btn,
    #get-code-btn {
        width: 100%;
    }
}
