/* ========== 数学公式识别 · 对齐模板设计语言 ========== */
:root {
    --brand: #2f6bff;
    --brand-dark: #1f56e0;
    --brand-light: #eef4ff;
    --card: #ffffff;
    --text: #1c2433;
    --text-2: #5c6678;
    --text-3: #97a0b3;
    --border: #e6ebf4;
    --shadow-card: 0 8px 30px rgba(31, 66, 138, 0.08);
    --radius: 18px;
}

/* ---------- 顶部横幅 ---------- */
.hero {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 28px 26px;
    text-align: center;
    margin-bottom: 18px;
}
.hero-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: .5px;
}
.hero-subtitle {
    margin-top: 10px;
    font-size: 13.5px;
    color: var(--text-2);
    line-height: 1.7;
}
.hero-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 16px;
    padding: 9px 20px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(47, 107, 255, .3);
    transition: filter .2s, transform .15s;
}
.hero-btn:hover {
    color: #fff;
    filter: brightness(1.08);
    transform: translateY(-1px);
}

/* ---------- 工作台 ---------- */
.workbench {
    display: grid;
    grid-template-columns: minmax(320px, 430px) 1fr;
    gap: 18px;
    align-items: stretch;
    margin-bottom: 18px;
}
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 22px;
}

/* ---------- 上传区 ---------- */
.upload-area {
    border: 2px dashed rgba(47, 107, 255, .4);
    background: var(--brand-light);
    border-radius: 14px;
    padding: 32px 18px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s, transform .2s;
}
.upload-area:hover {
    border-color: var(--brand);
    background: #e3ecff;
}
.upload-area.drag-over {
    border-color: var(--brand);
    background: #dbe7ff;
    transform: scale(1.01);
}
.upload-text {
    margin-top: 12px;
    font-size: 14.5px;
    font-weight: 700;
}
.upload-hint {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--text-3);
}

/* ---------- 图片预览（display:block 由 script.js 内联设置） ---------- */
.preview-area {
    margin-top: 14px;
    text-align: center;
}
.preview-area img {
    max-width: 100%;
    max-height: 260px;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.btn-remove {
    display: inline-block;
    margin-top: 12px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 7px 18px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--text-2);
    cursor: pointer;
    transition: all .15s;
}
.btn-remove:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-light);
}

/* ---------- 模型与 API Key ---------- */
.model-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}
.model-label {
    width: 62px;
    flex-shrink: 0;
    font-size: 13.5px;
    font-weight: 600;
}
.model-select,
.model-input {
    flex: 1;
    min-width: 0;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: #fff;
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.model-select:focus,
.model-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(47, 107, 255, .1);
}
.btn-toggle-key {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    border: none;
    background: none;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
}
.btn-toggle-key:hover { background: #f1f4fb; }

/* ---------- 识别按钮 ---------- */
.btn-recognize {
    width: 100%;
    margin-top: 18px;
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-size: 14.5px;
    font-weight: 700;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(47, 107, 255, .3);
    transition: filter .2s, transform .15s, box-shadow .2s;
}
.btn-recognize:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
}
.btn-recognize:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
}

/* ---------- 加载与错误 ---------- */
.loading-inline {
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-2);
}
.loading-inline .loading-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid var(--brand-light);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-inline {
    margin-top: 14px;
    background: #fff5f5;
    border: 1px solid #ffdfdf;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
    color: #d64545;
}
.error-inline p { line-height: 1.6; }
.btn-retry {
    margin-top: 10px;
    border: 1px solid #ffc9c9;
    background: #fff;
    border-radius: 999px;
    padding: 6px 16px;
    font-size: 12.5px;
    font-family: inherit;
    color: #d64545;
    cursor: pointer;
    transition: background .15s;
}
.btn-retry:hover { background: #ffecec; }

/* ---------- 右侧结果面板（display:flex 由 script.js 内联设置） ---------- */
.result-empty {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 340px;
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
}
.result-empty svg { margin-bottom: 14px; }
.result-content {
    flex-direction: column;
}
.result-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.code-tabs {
    display: inline-flex;
    gap: 4px;
    background: #f1f4fb;
    border-radius: 10px;
    padding: 4px;
}
.code-tab {
    border: none;
    background: transparent;
    border-radius: 8px;
    padding: 7px 18px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-2);
    cursor: pointer;
    transition: all .15s;
}
.code-tab:hover { color: var(--brand); }
.code-tab.active {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    font-weight: 600;
    box-shadow: 0 3px 8px rgba(47, 107, 255, .3);
}
.result-actions {
    display: flex;
    gap: 8px;
}
.btn-action {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 9px;
    padding: 7px 14px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--text-2);
    cursor: pointer;
    transition: all .15s;
}
.btn-action:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-light);
}

/* ---------- 代码框 ---------- */
.code-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    background: #f7f9fd;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
}
.btn-copy-code {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 12px;
    font-family: inherit;
    color: var(--text-2);
    cursor: pointer;
    transition: all .15s;
}
.btn-copy-code:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-light);
}
.code-body {
    margin: 0;
    padding: 16px;
    background: #fff;
    max-height: 430px;
    overflow: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---------- 使用提示 ---------- */
.tips {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 22px 26px;
}
.tips-title {
    font-size: 15.5px;
    font-weight: 700;
    padding-left: 10px;
    border-left: 3px solid var(--brand);
    line-height: 1.3;
    margin-bottom: 14px;
}
.tips-text p {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.8;
    margin-bottom: 6px;
}
.tips-text p:last-child { margin-bottom: 0; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 13px;
    z-index: 1200;
    box-shadow: 0 8px 24px rgba(23, 32, 55, .25);
    animation: toastIn .25s ease;
    transition: opacity .3s, transform .3s;
}
.toast.success { background: var(--brand); }
.toast.error { background: #e5484d; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .workbench { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .hero { padding: 22px 16px; }
    .hero-title { font-size: 19px; }
    .panel { padding: 16px; }
    .result-empty { min-height: 240px; }
    .tips { padding: 18px 16px; }
    .code-tab { padding: 6px 12px; }
}
