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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #f0f2f8 0%, #e8ecf4 100%);
    color: #2c2c2c;
}

/* ========== Header ========== */
.header {
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,.06);
    padding: 14px 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    letter-spacing: -.5px;
}
.header-nav {
    display: flex;
    gap: 4px;
}
.header-nav a {
    padding: 6px 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: #6b7280;
    text-decoration: none;
    border-radius: 7px;
    transition: all .2s;
}
.header-nav a:hover {
    color: #6366f1;
    background: #f5f3ff;
}

/* ========== Hero ========== */
.hero {
    text-align: center;
    padding: 44px 20px 28px;
}
.hero-title {
    font-size: 32px;
    font-weight: 800;
    color: #1a1a2e;
    margin-bottom: 12px;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #1a1a2e 20%, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-subtitle {
    font-size: 15px;
    color: #8895a7;
    max-width: 1200px;
    margin: 0 auto;
    line-height: 1.7;
}
.hero-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 700;
    color: #6366f1;
    background: #fff;
    border: 2px solid #6366f1;
    border-radius: 10px;
    text-decoration: none;
    transition: all .2s;
    box-shadow: 0 2px 10px rgba(99,102,241,.15);
}
.hero-btn:hover {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
    box-shadow: 0 4px 18px rgba(99,102,241,.35);
    transform: translateY(-1px);
}

/* ========== Main Layout ========== */
.main {
    display: flex;
    gap: 0;
    min-height: 460px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 20px rgba(0,0,0,.04), 0 4px 30px rgba(99,102,241,.06);
}

.panel {
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.panel-left {
    width: 400px;
    min-width: 360px;
    padding: 32px 28px;
    gap: 18px;
    border-right: 1px solid #f0f1f5;
}
.panel-right {
    flex: 1;
    min-width: 0;
    background: #fafbfc;
}

/* ========== 左侧 - 上传区域 ========== */
.upload-area {
    border: 2px dashed #dce0e8;
    border-radius: 14px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .25s ease;
    background: #fafbfd;
}
.upload-area:hover {
    border-color: #a5b4fc;
    background: #f5f3ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99,102,241,.08);
}
.upload-area.drag-over {
    border-color: #6366f1;
    background: #ede9fe;
    border-style: solid;
    box-shadow: 0 4px 20px rgba(99,102,241,.12);
    transform: translateY(-2px);
}
.upload-content { pointer-events: none; }
.upload-icon {
    margin-bottom: 12px;
    opacity: .55;
    transition: opacity .25s;
}
.upload-area:hover .upload-icon { opacity: .8; }
.upload-text { font-size: 14.5px; font-weight: 500; color: #4b5563; margin-bottom: 6px; }
.upload-hint { font-size: 12px; color: #b0b8c4; }

.preview-area {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e8ecf0;
}
.preview-area img {
    width: 100%;
    max-height: 260px;
    object-fit: contain;
    display: block;
    background: #fafbfc;
}
.btn-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 14px;
    font-size: 12px;
    color: #fff;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(8px);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background .2s;
}
.btn-remove:hover { background: rgba(0,0,0,.65); }

/* 模型行 */
.model-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fc;
    padding: 10px 14px;
    border-radius: 10px;
}
.model-label {
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    white-space: nowrap;
}
.model-select {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid #e0e4ea;
    border-radius: 8px;
    color: #2c2c2c;
    background: #fff;
    outline: none;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.model-select:hover { border-color: #c4b5fd; }
.model-select:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.1); }

.model-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    border: 1px solid #e0e4ea;
    border-radius: 8px;
    color: #2c2c2c;
    background: #fff;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.model-input::placeholder { color: #b0b8c4; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
.model-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.1); }

.btn-toggle-key {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #e0e4ea;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
    padding: 0;
}
.btn-toggle-key:hover { border-color: #c4b5fd; background: #f5f3ff; }

.btn-recognize {
    width: 100%;
    padding: 12px 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all .25s ease;
    box-shadow: 0 2px 10px rgba(99,102,241,.25);
    letter-spacing: .5px;
}
.btn-recognize:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99,102,241,.35);
}
.btn-recognize:active:not(:disabled) { transform: translateY(0); }
.btn-recognize:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }

/* 加载 & 错误 */
.loading-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 0;
    font-size: 13px;
    color: #8895a7;
}
.loading-spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid #e8eaed;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-inline {
    padding: 14px;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 10px;
    font-size: 12.5px;
    color: #e53e3e;
    line-height: 1.6;
    word-break: break-all;
}
.btn-retry {
    margin-top: 10px;
    padding: 6px 18px;
    font-size: 12.5px;
    font-weight: 500;
    color: #6366f1;
    background: #fff;
    border: 1px solid #c4b5fd;
    border-radius: 7px;
    cursor: pointer;
    transition: all .2s;
}
.btn-retry:hover { background: #6366f1; color: #fff; border-color: #6366f1; }

/* ========== 右侧 - 结果面板 ========== */
.result-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #c0c8d4;
    font-size: 14px;
}

.result-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.result-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid #eef0f5;
    flex-shrink: 0;
    background: #fff;
}

.code-tabs { display: flex; gap: 4px; }
.code-tab {
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 500;
    color: #8895a7;
    background: #f5f6fa;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s ease;
}
.code-tab.active {
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    box-shadow: 0 1px 4px rgba(99,102,241,.2);
}
.code-tab:hover:not(.active) { color: #4b5563; background: #ede9fe; }

.result-actions { display: flex; gap: 8px; }
.btn-action {
    padding: 6px 16px;
    font-size: 12.5px;
    font-weight: 500;
    color: #6366f1;
    background: #fff;
    border: 1px solid #e0e4ea;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
}
.btn-action:hover { border-color: #6366f1; background: #f5f3ff; box-shadow: 0 1px 4px rgba(99,102,241,.08); }

.code-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
    margin: 0;
}
.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    font-size: 11.5px;
    font-weight: 600;
    color: #8895a7;
    background: #fafbfc;
    border-bottom: 1px solid #eef0f5;
    flex-shrink: 0;
}
.btn-copy-code {
    padding: 4px 12px;
    font-size: 11.5px;
    font-weight: 500;
    color: #6366f1;
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 6px;
    cursor: pointer;
    transition: all .2s;
}
.btn-copy-code:hover { background: #6366f1; color: #fff; border-color: #6366f1; }

.code-body {
    flex: 1;
    padding: 20px 24px;
    margin: 0;
    font-family: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", "Menlo", monospace;
    font-size: 13px;
    line-height: 1.7;
    color: #2c2c2c;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-y: auto;
    background: #fff;
    tab-size: 2;
}

/* ========== Tips ========== */
.tips {
    max-width: 1200px;
    margin: 32px auto 0;
    padding: 20px 36px;
    background: rgba(255,255,255,.7);
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,.06);
}
.tips-title {
    font-size: 15px;
    font-weight: 700;
    color: #4b5563;
    margin-bottom: 14px;
    position: relative;
    padding-left: 14px;
}
.tips-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 3px;
    bottom: 3px;
    width: 3px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 2px;
}
.tips-text p {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.85;
    margin-bottom: 10px;
}
.tips-text p:last-child { margin-bottom: 0; }
.tips-text a {
    color: #6366f1;
    text-decoration: none;
    font-weight: 500;
}
.tips-text a:hover { text-decoration: underline; }

/* ========== Footer ========== */
.footer {
    text-align: center;
    padding: 14px;
    font-size: 11.5px;
    color: #b0b8c4;
    border-top: 1px solid rgba(0,0,0,.04);
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    font-size: 13.5px;
    font-weight: 500;
    color: #fff;
    background: #2c2c2c;
    border-radius: 8px;
    z-index: 9999;
    animation: toastIn .3s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.toast.success { background: #059669; }
.toast.error   { background: #dc2626; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    html, body { height: auto; }
    .hero { padding: 32px 20px 20px; }
    .hero-title { font-size: 24px; }
    .main {
        flex-direction: column;
        border-radius: 0;
        margin: 0;
    }
    .panel-left { width: 100%; min-width: 0; padding: 20px 16px; border-right: none; border-bottom: 1px solid #f0f1f5; }
    .panel-right { min-height: 460px; }
    .result-toolbar { flex-direction: column; gap: 12px; align-items: flex-start; }
    .result-actions { width: 100%; }
    .btn-action { flex: 1; text-align: center; }
}
