/* ===== 文档转换与解析 · 独立样式 v2（红色主题 · 参考图布局） ===== */

:root {
    --red: #c81623;
    --red-dark: #a9121d;
    --red-light: #fdecec;
    --red-border: #f3c2c7;
    --line: #ececef;
    --txt: #2b2f36;
    --txt2: #6b7280;
    --txt3: #9aa0a8;
}

.dococr { padding-bottom: 24px; }

/* ---------- 页面标题 ---------- */
.page-head {
    margin: 4px 0 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
}
.page-title {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    color: var(--txt);
    letter-spacing: .5px;
    text-align: center;
}
.page-desc {
    margin: 0;
    font-size: 13px;
    color: var(--txt2);
    line-height: 1.6;
    text-align: center;
}

/* ---------- 胶囊 Tabs ---------- */
.mode-tabs {
    display: flex;
    width: fit-content;
    margin: 2px auto 16px;
    gap: 4px;
    background: #f3f3f5;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px;
}
.mode-tab {
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 14px;
    padding: 8px 20px;
    border-radius: 999px;
    cursor: pointer;
    transition: all .18s ease;
    white-space: nowrap;
}
.mode-tab:hover { color: var(--red); }
.mode-tab.active {
    background: #ffffff;
    color: var(--red);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}

/* ---------- 工作台两栏（原文档 / 转化结果） ---------- */
.workbench {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    align-items: stretch;
}

/* 转换类型按钮（Tab 下方居中显示） */
.type-rail {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: -10px 0 16px;
}
.type-rail.hidden { display: none; }
.type-card {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: #595f6b;
    font-size: 13.5px;
    padding: 8px 18px;
    border-radius: 999px;
    cursor: pointer;
    transition: all .18s ease;
    white-space: nowrap;
}
.type-card svg { flex-shrink: 0; opacity: .75; }
.type-card:hover { border-color: #d8d8de; background: #fafafa; }
.type-card.active {
    background: var(--red-light);
    border-color: var(--red-border);
    color: var(--red);
    font-weight: 600;
}
.type-card.active svg { opacity: 1; }
.type-card.muted { opacity: .4; cursor: pointer; }
.type-card.muted:hover { opacity: .75; }

/* ---------- 面板通用 ---------- */
.panel {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(20, 30, 50, .04);
}
.panel-head {
    padding: 14px 20px;
    border-bottom: 1px solid #f2f2f4;
    flex-shrink: 0;
}
.panel-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--txt);
}

/* ---------- 原文档：内容区 ---------- */
.src-body {
    flex: 1;
    display: flex;
    min-height: 460px;
}

/* 缩略图列表 */
.thumb-rail {
    width: 106px;
    flex-shrink: 0;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    overflow-y: auto;
    border-right: 1px solid #f4f4f6;
}
.thumb-rail:empty { display: none; }
.thumb {
    width: 78px;
    height: 100px;
    flex-shrink: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    background: #f7f7f8;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: border-color .18s ease;
}
.thumb.active { border-color: var(--red); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-pdf {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 100%;
    background: #ffffff;
}
.thumb-pdf svg { color: #c2c7cf; }
.thumb-pdf span {
    font-size: 10px;
    font-weight: 700;
    color: #ffffff;
    background: #e2574c;
    border-radius: 3px;
    padding: 2px 7px;
    letter-spacing: .5px;
}

/* 大预览区 */
.preview-zone {
    flex: 1;
    min-width: 0;
    padding: 14px;
    display: flex;
    min-height: 0;
}
.preview-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1.5px dashed #dcdce0;
    border-radius: 10px;
    cursor: pointer;
    transition: all .18s ease;
    background: #fcfcfd;
}
.preview-empty:hover,
.preview-zone.dragover .preview-empty {
    border-color: var(--red);
    background: var(--red-light);
}
.upload-text { margin: 0; font-size: 13.5px; color: var(--txt3); }
.preview-img {
    margin: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 14px rgba(0, 0, 0, .12);
}
.preview-frame {
    flex: 1;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafafa;
}

/* ---------- 文件信息条 ---------- */
.file-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 16px 10px;
    background: #f7f7f8;
    border-radius: 8px;
    padding: 8px 12px;
    flex-shrink: 0;
}
.file-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--txt);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.file-size { font-size: 12px; color: var(--txt3); flex-shrink: 0; }
.btn-remove {
    margin-left: auto;
    border: none;
    background: transparent;
    color: var(--txt2);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all .18s;
}
.btn-remove:hover { background: #ececef; color: var(--red); }

/* ---------- 工具条：上传 / URL / 检测 ---------- */
.src-toolbar {
    display: flex;
    gap: 10px;
    padding: 0 16px 12px;
    flex-shrink: 0;
}
.btn-pick {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid #e2e2e6;
    background: #ffffff;
    color: var(--txt);
    font-size: 13.5px;
    padding: 9px 18px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .18s ease;
}
.btn-pick:hover { border-color: var(--red); color: var(--red); }

/* 格式说明 */
.src-hint {
    margin: 0;
    padding: 0 16px 12px;
    font-size: 12px;
    color: var(--txt3);
    flex-shrink: 0;
}

/* ---------- 页码范围 ---------- */
.adv-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 16px 16px;
}
.adv-label {
    font-size: 12.5px;
    color: var(--txt2);
    white-space: nowrap;
    flex-shrink: 0;
}
.adv-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #e2e2e6;
    border-radius: 7px;
    padding: 7px 11px;
    font-size: 12.5px;
    color: var(--txt);
    outline: none;
    transition: border-color .2s;
}
.adv-input:focus { border-color: var(--red); }

/* ---------- 转化结果 ---------- */
.res-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    min-height: 0;
}
.result-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
}

/* 大文件图标 */
.res-bigicon {
    width: 104px;
    height: 104px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 36px;
    font-weight: 800;
    position: relative;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .16);
    user-select: none;
}
.res-bigicon::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    border-style: solid;
    border-width: 0 22px 22px 0;
    border-color: transparent rgba(255, 255, 255, .35) transparent transparent;
    border-radius: 0 22px 0 8px;
}
.res-bigicon span { line-height: 1; }
.res-bigicon.word { background: linear-gradient(145deg, #4aa3eb, #2470c9); }
.res-bigicon.pdf  { background: linear-gradient(145deg, #ff7364, #d93025); font-size: 26px; letter-spacing: 1px; }
.res-bigicon.md   { background: linear-gradient(145deg, #97a3ba, #5b6b84); font-size: 26px; letter-spacing: 1px; }

/* 红色主按钮（开始转化 / 下载文件） */
.btn-convert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    background: var(--red);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    padding: 13px 46px;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(200, 22, 35, .28);
    transition: all .18s ease;
}
.btn-convert:hover:not(:disabled) {
    background: var(--red-dark);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(200, 22, 35, .34);
}
.btn-convert:disabled {
    background: #eebcc1;
    box-shadow: none;
    cursor: not-allowed;
}

/* 进行中 */
.result-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
}
.loading-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid #f7d9dc;
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-status {
    font-size: 15px;
    font-weight: 600;
    color: var(--txt);
    margin: 0;
}
.loading-tip { font-size: 12px; color: var(--txt3); margin: 0; }

/* 成功：下载 */
.result-download {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
}
.dl-sub {
    margin: 0;
    font-size: 13px;
    color: var(--txt2);
    background: #f7f7f8;
    padding: 5px 16px;
    border-radius: 20px;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dl-note { font-size: 12px; color: var(--txt3); margin: 0; }

/* 成功：解析预览 */
.result-parse {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.parse-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f2f2f4;
    margin-bottom: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.parse-title { font-size: 14px; font-weight: 600; color: var(--txt); }
.parse-actions { display: flex; gap: 8px; }
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #e2e2e6;
    background: #ffffff;
    color: var(--txt2);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 7px;
    cursor: pointer;
    text-decoration: none;
    transition: all .18s;
}
.btn-action:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-light);
}
.md-preview {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 18px 20px;
    background: #fafafa;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.8;
    color: var(--txt);
    word-break: break-word;
    overflow-y: auto;
    overflow-x: auto;
}
.md-preview .md-loading { margin: 0; color: var(--txt3); }
.md-preview > :first-child { margin-top: 0; }
.md-preview > :last-child { margin-bottom: 0; }
.md-preview h1, .md-preview h2, .md-preview h3,
.md-preview h4, .md-preview h5, .md-preview h6 {
    margin: 1.2em 0 .5em;
    line-height: 1.4;
    color: var(--txt);
}
.md-preview h1 { font-size: 20px; border-bottom: 2px solid var(--red-border); padding-bottom: 6px; }
.md-preview h2 { font-size: 17px; border-bottom: 1px solid var(--line); padding-bottom: 5px; }
.md-preview h3 { font-size: 15px; }
.md-preview h4 { font-size: 14px; }
.md-preview p { margin: .6em 0; }
.md-preview strong { color: #b91c1c; }
.md-preview a { color: var(--red); }
.md-preview blockquote {
    margin: .8em 0;
    padding: 6px 14px;
    border-left: 3px solid var(--red-border);
    background: var(--red-light);
    border-radius: 0 6px 6px 0;
    color: var(--txt2);
}
.md-preview ul, .md-preview ol { margin: .6em 0; padding-left: 1.6em; }
.md-preview code {
    background: #f0f0f2;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12.5px;
    font-family: Consolas, "Microsoft YaHei", monospace;
}
.md-preview pre {
    background: #f0f0f2;
    border-radius: 8px;
    padding: 12px 14px;
    overflow-x: auto;
}
.md-preview pre code { background: transparent; padding: 0; }
/* 表格渲染 */
.md-preview table {
    border-collapse: collapse;
    margin: 1em 0;
    width: 100%;
    font-size: 12.5px;
}
.md-preview th, .md-preview td {
    border: 1px solid #dcdce0;
    padding: 7px 11px;
    text-align: left;
    vertical-align: top;
}
.md-preview th {
    background: var(--red-light);
    color: var(--txt);
    font-weight: 600;
    white-space: nowrap;
}
.md-preview tr:nth-child(even) td { background: #f5f5f7; }
/* 图片渲染（base64 / URL） */
.md-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid var(--line);
    margin: .6em 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}
/* 分隔线 */
.md-preview hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 1.2em 0;
}
/* 公式（KaTeX） */
.md-preview .katex { font-size: 1.08em; }
.md-preview .katex-display {
    margin: .9em 0;
    padding: 4px 2px;
    overflow-x: auto;
    overflow-y: hidden;
}
.md-preview .formula-raw {
    margin: .8em 0;
    padding: 8px 12px;
    background: #f0f0f2;
    border-radius: 6px;
    font-family: Consolas, monospace;
    font-size: 12.5px;
    overflow-x: auto;
}
.md-preview .katex-error {
    color: #b91c1c;
    background: var(--red-light);
    border-radius: 4px;
    padding: 1px 5px;
}

/* ---------- 错误浮层 ---------- */
.error-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 14px;
    background: #ffffff;
    border: 1px solid var(--red-border);
    border-radius: 10px;
    padding: 12px 18px;
    box-shadow: 0 8px 28px rgba(120, 20, 30, .14);
    max-width: min(620px, 86vw);
}
.error-toast p {
    margin: 0;
    font-size: 13px;
    color: #b91c1c;
    line-height: 1.5;
    word-break: break-all;
}
.btn-retry {
    border: none;
    background: var(--red);
    color: #ffffff;
    font-size: 12px;
    padding: 6px 16px;
    border-radius: 7px;
    cursor: pointer;
    flex-shrink: 0;
}
.btn-retry:hover { background: var(--red-dark); }

/* ---------- 响应式 ---------- */
@media (max-width: 1200px) {
    .workbench { grid-template-columns: 1fr; }
    .type-rail {
        overflow-x: auto;
        padding: 2px 0;
    }
    .type-card { flex-shrink: 0; }
    .res-body { min-height: 420px; }
    .src-body { min-height: 380px; }
}
@media (max-width: 640px) {
    .mode-tab { padding: 7px 14px; font-size: 13px; }
    .panel-src, .panel-res { border-radius: 10px; }
    .src-toolbar { flex-wrap: wrap; }
    .thumb-rail {
        flex-direction: row;
        width: auto;
        align-items: flex-start;
        border-right: none;
        border-bottom: 1px solid #f4f4f6;
        overflow-x: auto;
    }
    .src-body { flex-direction: column; }
    .btn-convert { padding: 12px 34px; }
}
