/* ========================================
   Word 一键排版工具 — 精致版 UI
   ======================================== */

:root {
    --red:       #c41230;
    --red-dark:  #a00e26;
    --red-light: #fef2f4;
    --ink:       #1a1a2e;
    --gray-900:  #1e1e24;
    --gray-700:  #4a4a55;
    --gray-500:  #8e8e9a;
    --gray-300:  #d4d4dc;
    --gray-200:  #e8e8ee;
    --gray-100:  #f6f6f9;
    --gray-50:   #fafafc;
    --white:     #ffffff;
    --green:     #168a4a;
    --green-bg:  #e6f4ec;
    --gold:      #c4862c;
    --gold-bg:   #fef9f0;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow:    0 4px 20px rgba(0,0,0,0.07);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.10);
    --radius-lg: 14px;
    --radius:    10px;
    --radius-sm: 7px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: #f1f2f5;
    color: var(--gray-900);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Top Bar ---- */
.topbar {
    background: var(--white);
    border-bottom: 1px solid transparent;
    box-shadow: 0 1px 0 var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px) saturate(180%);
    background: rgba(255,255,255,0.85);
}
.topbar-inner {
    max-width: 940px;
    margin: 0 auto;
    padding: 0 28px;
    height: 58px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--red), #d4384f);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(196,18,48,0.25);
}
.topbar-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.2px;
}
.topbar-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--red);
    background: var(--red-light);
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}
.topbar-user {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-700);
    margin-left: auto;
}

/* ---- Main ---- */
.main {
    max-width: 1340px;
    margin: 0 auto;
    padding: 24px 28px 100px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.main-col-left {
    flex: 0 0 420px;
    position: sticky;
    top: 80px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.main-col-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ---- Panel ---- */
.panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
    transition: box-shadow var(--transition);
}
.panel:hover {
    box-shadow: var(--shadow);
}
.panel-header {
    padding: 22px 30px 0;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}
.panel-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}
.panel-desc {
    font-size: 12px;
    color: var(--gray-500);
}
.panel-body {
    padding: 20px 30px 28px;
}

/* ---- Upload ---- */
.upload-area {
    position: relative;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: linear-gradient(180deg, var(--gray-50) 0%, var(--white) 100%);
}
.upload-area:hover {
    border-color: var(--red);
    background: linear-gradient(180deg, var(--red-light) 0%, var(--white) 100%);
    box-shadow: 0 0 0 4px rgba(196,18,48,0.05);
}
.upload-area.dragover {
    border-color: var(--red);
    border-style: solid;
    background: var(--red-light);
    box-shadow: 0 0 0 8px rgba(196,18,48,0.06);
}
.upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.upload-visual { pointer-events: none; }
.upload-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    background: var(--red-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.upload-area:hover .upload-icon {
    background: #fde0e4;
    transform: translateY(-2px);
}
.upload-text strong {
    display: block;
    font-size: 15px;
    color: var(--gray-900);
    margin-bottom: 4px;
}
.upload-text span {
    font-size: 12px;
    color: var(--gray-500);
}
.upload-area.has-file {
    border-style: solid;
    border-color: var(--green);
    background: var(--green-bg);
}
.upload-area.has-file .upload-icon {
    background: #d4ede0;
}

/* ---- Divider ---- */
.divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--gray-500);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gray-300), transparent);
}
.divider span { padding: 0 18px; }
.btn-reset{
    background: linear-gradient(135deg, #39bdf1, #20a0e7);
    color: #fff;
    padding: 12px 30px;
    font-size: 15px;
    box-shadow: 0 2px 10px rgb(116 200 253 / 25%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: inherit;
    letter-spacing: 0.2px;
}
/* ---- Text Input ---- */
.text-input {
    width: 100%;
    min-height: 180px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 16px 18px;
    font-size: 15px;
    font-family: "FangSong", "仿宋_GB2312", "STFangsong", "Songti SC", serif;
    line-height: 2;
    resize: vertical;
    outline: none;
    transition: all var(--transition);
    background: var(--gray-50);
    color: var(--gray-900);
}
.text-input:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(196,18,48,0.06);
    background: var(--white);
}
/* ---- Paste indicator ---- */
.paste-indicator {
    margin-top: 8px;
    padding: 8px 14px;
    background: #e6f4ec;
    border: 1px solid #b7dcc4;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: #168a4a;
    font-weight: 500;
    animation: pasteFadeIn 0.25s ease;
    letter-spacing: 0.2px;
}
@keyframes pasteFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.text-input::placeholder {
    color: var(--gray-500);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    line-height: 1.8;
}

/* ---- Format Selector ---- */
.format-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-top: 22px;
    flex-wrap: wrap;
}
.format-selector { flex: 1; min-width: 260px; }
.fs-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 8px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.fs-options {
    display: flex;
    gap: 8px;
}
.fs-option {
    flex: 1;
    position: relative;
    cursor: pointer;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 12px 14px 12px 40px;
    transition: all var(--transition);
    background: var(--white);
}
.fs-option:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
}
.fs-option.active {
    border-color: var(--red);
    background: var(--red-light);
    box-shadow: 0 0 0 3px rgba(196,18,48,0.05);
}
.fs-option input { display: none; }
.fs-radio {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray-300);
    border-radius: 50%;
    transition: all var(--transition);
}
.fs-option.active .fs-radio {
    border-color: var(--red);
    border-width: 6px;
    box-shadow: 0 0 0 3px rgba(196,18,48,0.12);
}
.fs-content strong {
    display: block;
    font-size: 13px;
    color: var(--gray-900);
    margin-bottom: 1px;
}
.fs-content small {
    font-size: 11px;
    color: var(--gray-500);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 26px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: inherit;
    letter-spacing: 0.2px;
}
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.3);
}
.btn-analyze {
    background: linear-gradient(135deg, var(--red), #d4384f);
    color: #fff;
    padding: 12px 30px;
    font-size: 15px;
    box-shadow: 0 2px 10px rgba(196,18,48,0.25);
}
.btn-analyze:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(196,18,48,0.35);
    transform: translateY(-1px);
}
.btn-analyze:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(196,18,48,0.2);
}
.btn-download {
    background: linear-gradient(135deg, var(--green), #1c9e58);
    color: #fff;
    padding: 10px 24px;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(22,138,74,0.25);
}
.btn-download:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(22,138,74,0.35);
    transform: translateY(-1px);
}
.btn-back {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    padding: 10px 22px;
}
.btn-back:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-500);
}

/* ---- Structure List (左侧结构分析) ---- */
.structure-list {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}
.structure-list .preview-item {
    border-bottom: 1px solid var(--gray-100);
}
.structure-list .preview-item:last-child {
    border-bottom: none;
}

/* ---- Document Preview (右侧排版预览) ---- */
.doc-preview {
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: 2px;
    padding: 56px 60px;
    line-height: 28pt;           /* GB/T 9704: 固定行距28磅 */
    min-height: 800px;
    font-family: "FangSong_GB2312", "仿宋_GB2312", "STFangsong", "FangSong", serif;
    font-size: 16pt;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.03);
    position: relative;
    overflow-y: auto;
}
.doc-preview::before {
    content: '';
    position: absolute;
    inset: 52px 56px;
    border: 1px dashed #e0e0e8;
    pointer-events: none;
    border-radius: 1px;
}

/* 大标题 — 方正小标宋简体 22pt 居中 */
.doc-title {
    text-align: center;
    font-size: 22pt;
    font-family: "方正小标宋简体", "Songti SC", "STSong", "SimSun", serif;
    font-weight: 400;
    margin-bottom: 0.8em;
}

/* 发文字号 — 仿宋 16pt 居中 */
.doc-doc_number {
    text-align: center;
}

/* 主送机关 — 仿宋 16pt 左对齐 */
.doc-addressee {
    text-align: left;
}

/* 一级标题 — 黑体 16pt 左对齐 首行缩进2字符 */
.doc-heading1 {
    font-family: "SimHei", "黑体", "STHeiti", "Heiti SC", sans-serif;
    font-weight: 400;
    text-align: left;
    text-indent: 2em;
}

/* 二级标题 — 楷体 16pt 加粗 左对齐 首行缩进2字符 */
.doc-heading2 {
    font-family: "KaiTi_GB2312", "楷体_GB2312", "Kaiti SC", "STKaiti", serif;
    font-weight: 700;
    text-align: left;
    text-indent: 2em;
}

/* 三级标题 — 仿宋 16pt 加粗 左对齐 首行缩进2字符 */
.doc-heading3 {
    font-weight: 700;
    text-align: left;
    text-indent: 2em;
}

/* 四级标题 — 仿宋 16pt 不加粗 左对齐 首行缩进2字符 */
.doc-heading4 {
    font-weight: 400;
    text-align: left;
    text-indent: 2em;
}

/* 附件 — 黑体 16pt 左对齐 */
.doc-attachment {
    font-family: "SimHei", "黑体", "STHeiti", "Heiti SC", sans-serif;
    font-weight: 400;
    text-align: left;
}

/* 正文 — 仿宋 16pt 两端对齐 首行缩进2字符 */
.doc-body {
    text-align: justify;
    text-indent: 2em;
    margin: 0;
}

/* 印发机关 — 仿宋 16pt 居中 */
.doc-print_issuer {
    text-align: center;
}

/* 附注 — 仿宋 16pt 左对齐 首行缩进2字符 */
.doc-annotation {
    text-align: left;
    text-indent: 2em;
}

/* 联系方式 — 仿宋 16pt 左对齐 首行缩进2字符 */
.doc-contact_info {
    text-align: left;
    text-indent: 2em;
}

/* 抄送 — 仿宋 16pt 左对齐 */
.doc-cc {
    text-align: left;
    margin-top: 0.5em;
    padding-top: 0.5em;
    border-top: 1px solid var(--gray-300);
}

/* 落款 — 仿宋 16pt 右对齐 */
.doc-signature {
    text-align: right;
}

/* 日期 — 仿宋 16pt 右对齐 */
.doc-date {
    text-align: right;
}

/* 列表项 — 仿宋 16pt 两端对齐 首行缩进2字符 */
.doc-list_item {
    text-align: justify;
    text-indent: 2em;
}

.doc-placeholder {
    text-align: center;
    padding: 44px 20px;
    color: var(--gray-500);
}
.doc-placeholder p {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    margin-top: 10px;
}

/* ---- Preview ---- */
.panel-preview {
    position: sticky;
    top: 80px;
}

/* Format issues / inspection */
.issues-box {
    margin-top: 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}
.issues-title {
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 700;
    color: var(--gray-700);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
    letter-spacing: 0.5px;
}
.issues-list { padding: 6px 12px; }
.issue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 4px;
    font-size: 12px;
    color: var(--gray-700);
    border-bottom: 1px solid #f5f5f7;
}
.issue-item:last-child { border-bottom: none; }
.issue-ok { color: #168a4a; font-weight: 500; justify-content: center; padding: 12px; }
.issue-badge {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}
.badge-error { background: #fde0e4; color: #c41230; }
.badge-warn  { background: #fef9f0; color: #c4862c; }
.badge-info  { background: #e8f0fe; color: #3b6fc0; }
.issue-locate {
    margin-left: auto;
    font-size: 11px;
    background: none;
    border: 1px solid var(--gray-300);
    color: var(--gray-500);
    padding: 2px 10px;
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}
.issue-locate:hover { border-color: var(--red); color: var(--red); }

/* Document stats */
.doc-stats {
    display: flex;
    gap: 20px;
    padding: 12px 16px;
    margin-top: 14px;
    background: linear-gradient(135deg, var(--gray-50), #f0f4ff);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--gray-700);
    flex-wrap: wrap;
    animation: fadeIn 0.3s ease;
}
.doc-stats strong {
    color: var(--ink);
    font-weight: 700;
    margin-left: 4px;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Type popover */
.type-popover {
    position: absolute;
    z-index: 200;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    min-width: 100px;
    animation: popIn 0.15s ease;
}
@keyframes popIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.type-opt {
    display: block;
    width: 100%;
    padding: 7px 14px;
    border: none;
    background: none;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    border-radius: 4px;
    text-align: left;
    transition: all 0.1s ease;
}
.type-opt:hover {
    background: var(--red-light);
    color: var(--red);
}
.type-opt.active {
    background: var(--red-light);
    color: var(--red);
    font-weight: 700;
}

/* Clickable preview tag */
.preview-tag[role="button"] {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.preview-tag[role="button"]:hover {
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Legend */
.legend {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--gray-700);
    font-weight: 500;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.legend-compact {
    gap: 8px;
    font-size: 10px;
    margin-bottom: 8px;
}
.legend-hint {
    color: var(--gray-500);
    font-weight: 400;
    font-size: 10px;
    padding-left: 6px;
    border-left: 1px solid var(--gray-300);
}
.dot {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    display: inline-block;
    margin-right: 3px;
    vertical-align: middle;
}
.dot-title { background: #c41230; }
.dot-docnum    { background: #e74c3c; }
.dot-addressee { background: #2ecc71; }
.dot-attach    { background: #e67e22; }
.dot-h3        { background: #d4a017; }
.dot-h4        { background: #b8860b; }
.dot-list      { background: #1abc9c; }
.dot-cc        { background: #9b59b6; }
.dot-h1        { background: #e67e22; }
.dot-h2    { background: #d4a017; }
.dot-body  { background: #6c757d; }
.dot-end   { background: #3498db; }

.preview-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 6px;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    letter-spacing: 0.4px;
    min-width: 52px;
    text-align: center;
}
.preview-text {
    flex: 1;
    word-break: break-all;
    padding-top: 4px;
}
.tag-title     { background: #c41230; color: #fff; }
.tag-heading1  { background: #e67e22; color: #fff; }
.tag-heading2  { background: #d4a017; color: #fff; }
.tag-body      { background: #6c757d; color: #fff; }
.tag-doc_number { background: #e74c3c; color: #fff; }
.tag-addressee  { background: #2ecc71; color: #fff; }
.tag-heading3    { background: #d4a017; color: #fff; }
.tag-heading4    { background: #b8860b; color: #fff; }
.tag-attachment { background: #e67e22; color: #fff; }
.tag-list_item  { background: #1abc9c; color: #fff; }
.tag-cc          { background: #9b59b6; color: #fff; }
.tag-annotation  { background: #607d8b; color: #fff; }
.tag-contact_info { background: #00bcd4; color: #fff; }
.tag-print_issuer { background: #795548; color: #fff; }
.tag-signature  { background: #3498db; color: #fff; }
.tag-date       { background: #8e44ad; color: #fff; }

/* ---- Reference ---- */
.reference {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: box-shadow var(--transition);
}
.reference:hover { box-shadow: var(--shadow); }
.reference summary {
    padding: 16px 30px;
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-700);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.reference summary::-webkit-details-marker { display: none; }
.reference summary::before {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--gray-500);
    border-bottom: 2px solid var(--gray-500);
    transform: rotate(45deg);
    transition: transform var(--transition);
}
.reference[open] summary::before { transform: rotate(-135deg); }
.reference summary::after {
    content: '参考标准';
    margin-left: auto;
    font-size: 11px;
    color: var(--gray-500);
    font-weight: 400;
}
.reference[open] summary::after { content: '收起'; }
.ref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1px;
    background: var(--gray-100);
    border-top: 1px solid var(--gray-100);
}
.ref-item {
    padding: 12px 30px;
    font-size: 12px;
    color: var(--gray-700);
    background: var(--white);
    display: flex;
    align-items: center;
    gap: 10px;
}
.ref-label {
    display: inline-block;
    font-weight: 700;
    color: var(--gray-900);
    min-width: 60px;
    font-size: 11px;
}

/* ---- Floating Buttons ---- */
.fab-download {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: 48px;
    cursor: pointer;
    background: linear-gradient(135deg, var(--green), #1c9e58);
    color: #fff;
    box-shadow: 0 4px 24px rgba(22,138,74,0.35), 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.3px;
    animation: fabIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fab-download:hover:not(:disabled) {
    transform: translateX(-50%) translateY(-3px);
    box-shadow: 0 8px 32px rgba(22,138,74,0.4), 0 4px 12px rgba(0,0,0,0.1);
}
.fab-download:active:not(:disabled) {
    transform: translateX(-50%) translateY(-1px);
    box-shadow: 0 2px 12px rgba(22,138,74,0.3);
}
.fab-download:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.3);
}

@keyframes fabIn {
    from { opacity: 0; transform: translateY(20px) scale(0.85); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Batch toggle ---- */
.batch-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.batch-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}
.batch-hint {
    font-size: 11px;
    color: var(--gray-500);
    margin-left: auto;
}
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}
.switch input { display: none; }
.switch-slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 24px;
    cursor: pointer;
    transition: background var(--transition);
}
.switch-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.switch input:checked + .switch-slider { background: var(--red); }
.switch input:checked + .switch-slider::after { transform: translateX(18px); }

/* ---- File list ---- */
.file-list {
    margin-top: 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}
.file-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}
.file-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}
.btn-clear {
    font-size: 12px;
    color: var(--red);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background var(--transition);
}
.btn-clear:hover { background: var(--red-light); }
.file-items {
    max-height: 240px;
    overflow-y: auto;
}
.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
    transition: background var(--transition);
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--gray-50); }
.file-name {
    flex: 1;
    color: var(--gray-900);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
        width: 200px;
}
.file-size {
    color: var(--gray-500);
    font-size: 11px;
    white-space: nowrap;
}
.file-remove {
    width: 22px;
    height: 22px;
    border: none;
    background: var(--gray-100);
    color: var(--gray-500);
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.file-remove:hover { background: var(--red); color: #fff; }

/* ---- Batch progress ---- */
.batch-progress {
    margin-top: 14px;
    padding: 14px 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 14px;
}
.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--red), #d4384f);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}
.progress-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    white-space: nowrap;
}

/* ---- Batch button ---- */
.btn-batch {
    background: linear-gradient(135deg, #8e44ad, #a569bd);
    color: #fff;
    padding: 12px 28px;
    font-size: 15px;
    box-shadow: 0 2px 10px rgba(142,68,173,0.25);
    white-space: nowrap;
}
.btn-batch:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(142,68,173,0.35);
    transform: translateY(-1px);
}

/* ---- Responsive ---- */
@media (max-width: 960px) {
    .main {
        flex-direction: column;
        padding: 20px 16px 100px;
    }
    .main-col-left { flex: none; position: static; width: 100%; }
    .main-col-right { width: 100%; }
    .panel-preview { position: static; }
    .doc-preview { padding: 32px 24px; min-height: 300px; }
}
@media (max-width: 640px) {
    .topbar-inner { padding: 0 16px; }
    .panel-header, .panel-body { padding-left: 18px; padding-right: 18px; }
    .format-bar { flex-direction: column; align-items: stretch; }
    .ref-grid { grid-template-columns: 1fr; }
    .fab-download { bottom: 18px; padding: 12px 22px; font-size: 14px; }
}
