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

/*
 * GB/T 9704 公文标准字体声明
 * macOS 字体查找优先级：英文 PostScript/家族名 → 中文名 → 系统回退
 * Windows 字体查找优先级：中文名 → 英文名 → 系统回退
 */
@font-face {
    font-family: 'GovTitle';
    src: local('FZXiaoBiaoSong-B05S'),  /* macOS PostScript 名 */
         local('方正小标宋简体'),        /* Windows 家族名 */
         local('STSong'),                /* macOS 华文宋体 */
         local('Songti SC'),             /* macOS 宋体-简 */
         local('SimSun'),                /* Windows 宋体 */
         local('serif');
    font-weight: 400;
}
@font-face {
    font-family: 'GovHeading1';
    src: local('Heiti SC'),              /* macOS 黑体-简 */
         local('STHeiti'),               /* macOS 华文黑体 */
         local('黑体'),                   /* Windows 家族名 */
         local('SimHei'),                /* Windows 黑体 */
         local('PingFang SC'),           /* macOS 苹方 */
         local('sans-serif');
    font-weight: 400;
}
@font-face {
    font-family: 'GovHeading2';
    src: local('STKaiti'),               /* macOS 华文楷体 */
         local('Kaiti SC'),              /* macOS 楷体-简 */
         local('楷体_GB2312'),           /* Windows 家族名 */
         local('楷体'),                   /* Windows */
         local('KaiTi'),                 /* Windows 英文 */
         local('BiauKai'),               /* macOS 標楷體 */
         local('serif');
    font-weight: 700;
}
@font-face {
    font-family: 'GovBody';
    src: local('FangSong_GB2312'),       /* macOS 家族名 */
         local('仿宋_GB2312'),           /* Windows 家族名 */
         local('STFangsong'),            /* macOS 华文仿宋 */
         local('FangSong'),              /* 通用英文字体名 */
         local('仿宋'),                   /* 通用中文字体名 */
         local('Songti SC'),             /* macOS 宋体-简 */
         local('serif');
    font-weight: 400;
}

: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; }

/* ---- Text Input ---- */
.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 {
    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;
    justify-content: 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;
    /* 模拟 A4 页面边距：上3.7cm 下3.5cm 左2.8cm 右2.6cm (按屏幕比例压缩) */
    padding: 40px 44px 38px 48px;
    /* GB/T 9704: 固定行距 28 磅 */
    line-height: 28pt;
    min-height: 500px;
    font-family: 'GovBody', 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: 36px 40px 34px 44px;
    border: 1px dashed #e8e8f0;
    pointer-events: none;
    border-radius: 1px;
}

/* 大标题 — 方正小标宋简体 二号(22pt) 居中，段前段后 28pt */
.doc-title {
    text-align: center;
    font-size: 22pt;
    font-family: 'GovTitle', serif;
    font-weight: 400;
    line-height: 28pt;
    padding-top: 28pt;
    padding-bottom: 28pt;
}

/* 发文字号 — 仿宋 三号(16pt) 居中 */
.doc-doc_number {
    text-align: center;
    font-family: inherit;
    font-size: inherit;
    line-height: 28pt;
}

/* 主送机关 — 仿宋 三号(16pt) 左对齐，顶格 */
.doc-addressee {
    text-align: left;
    font-family: inherit;
    font-size: inherit;
    line-height: 28pt;
}

/* 一级标题 — 黑体 三号(16pt) 左对齐 首行缩进2字符 */
.doc-heading1 {
    font-family: 'GovHeading1', sans-serif;
    font-weight: 400;
    font-size: inherit;
    text-align: left;
    text-indent: 2em;
    line-height: 28pt;
}

/* 二级标题 — 楷体 三号(16pt) 加粗 左对齐 首行缩进2字符 */
.doc-heading2 {
    font-family: 'GovHeading2', serif;
    font-weight: 700;
    font-size: inherit;
    text-align: left;
    text-indent: 2em;
    line-height: 28pt;
}

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

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

/* 附件 — 黑体 三号(16pt) 左对齐 顶格 */
.doc-attachment {
    font-family: 'GovHeading1', sans-serif;
    font-weight: 400;
    font-size: inherit;
    text-align: left;
    line-height: 28pt;
}

/* 正文 — 仿宋 三号(16pt) 两端对齐 首行缩进2字符 */
.doc-body {
    font-family: inherit;
    font-size: inherit;
    text-align: justify;
    text-indent: 2em;
    line-height: 28pt;
    margin: 0;
}

/* 印发机关 — 仿宋 三号(16pt) 居中 */
.doc-print_issuer {
    font-family: inherit;
    font-size: inherit;
    text-align: center;
    line-height: 28pt;
}

/* 附注 — 仿宋 三号(16pt) 左对齐 首行缩进2字符 */
.doc-annotation {
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    text-indent: 2em;
    line-height: 28pt;
}

/* 联系方式 — 仿宋 三号(16pt) 左对齐 首行缩进2字符 */
.doc-contact_info {
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    text-indent: 2em;
    line-height: 28pt;
}

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

/* 落款 — 仿宋 三号(16pt) 右对齐 */
.doc-signature {
    font-family: inherit;
    font-size: inherit;
    text-align: right;
    line-height: 28pt;
}

/* 日期 — 仿宋 三号(16pt) 右对齐 */
.doc-date {
    font-family: inherit;
    font-size: inherit;
    text-align: right;
    line-height: 28pt;
}

/* 列表项 — 仿宋 三号(16pt) 两端对齐 首行缩进2字符 */
.doc-list_item {
    font-family: inherit;
    font-size: inherit;
    text-align: justify;
    text-indent: 2em;
    line-height: 28pt;
}

.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;
}
.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);
}

/* ---- Style Selector Row ---- */
.style-selector-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.style-select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--white);
    color: var(--gray-900);
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition);
}
.style-select:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(196,18,48,0.06);
}
.btn-icon {
    width: 34px;
    height: 34px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--gray-700);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.btn-icon:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-light);
}

/* ---- Modal System ---- */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}
.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    max-height: 88vh;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    animation: modalIn 0.25s ease;
}
@keyframes modalIn {
    from { transform: translateY(16px) scale(0.97); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 {
    font-size: 16px;
    color: var(--ink);
    font-weight: 700;
}
.modal-close {
    background: transparent;
    border: 0;
    font-size: 22px;
    color: var(--gray-500);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.modal-close:hover { color: var(--red); background: var(--red-light); }
.modal-body {
    padding: 18px 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-body p {
    margin: 6px 0;
    line-height: 1.6;
    color: var(--gray-900);
    font-size: 14px;
}
.modal-footer {
    padding: 14px 24px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ---- Button Variants ---- */
.btn-primary {
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: #fff;
    border: 0;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: var(--gray-50);
    color: var(--gray-900);
    border: 1px solid var(--gray-300);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-secondary:hover { background: var(--gray-100); border-color: var(--gray-500); }

.btn-danger {
    color: #dc2626 !important;
    border-color: #fca5a5 !important;
}
.btn-danger:hover {
    background: #fef2f2 !important;
    border-color: #dc2626 !important;
}

/* ---- Style Editor ---- */
.modal-style-editor {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
}
.style-editor-body {
    padding: 16px 24px !important;
    overflow-y: auto;
    max-height: 65vh;
}

.se-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}
.se-preset-select {
    padding: 7px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--white);
    color: var(--gray-900);
    outline: none;
    cursor: pointer;
}
.se-preset-select:focus { border-color: var(--red); }
.se-btn {
    padding: 6px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.se-btn:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-light);
}
.se-toolbar-spacer { flex: 1; }

.se-name-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.se-name-row label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    white-space: nowrap;
}
.se-name-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}
.se-name-input:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(196,18,48,0.06);
}

.se-section { margin-bottom: 16px; }
.se-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.se-page-grid {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.se-page-grid label {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 6px;
}
.se-page-option { margin-top: 10px; }
.se-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--gray-700);
    cursor: pointer;
}
.se-checkbox-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--red);
}
.se-num {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
    outline: none;
    font-family: inherit;
}
.se-num:focus { border-color: var(--red); }

.se-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
}
.se-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    white-space: nowrap;
}
.se-table th {
    background: var(--gray-50);
    padding: 8px 8px;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-300);
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 11px;
}
.se-th-role { text-align: left !important; min-width: 80px; }
.se-table td {
    padding: 5px 5px;
    border-bottom: 1px solid var(--gray-100);
    text-align: center;
    vertical-align: middle;
}
.se-table tr:last-child td { border-bottom: none; }
.se-table tr:hover td { background: var(--gray-50); }

.se-table select,
.se-table input[type="number"] {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    background: var(--white);
    color: var(--gray-900);
    outline: none;
    text-align: center;
}
.se-table select { min-width: 86px; cursor: pointer; }
.se-table input[type="number"] { min-width: 50px; }
.se-table input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--red);
}
.se-table select:focus,
.se-table input[type="number"]:focus { border-color: var(--red); }

.se-role-name {
    font-weight: 600;
    color: var(--gray-900);
    text-align: left !important;
    padding-left: 10px !important;
}

/* ---- 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; }
    .doc-preview::before {inset: 20px 10px;}
    .btn-analyze {width: 100%;}
    .btn-batch{width: 100%}
}
@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: 100px; padding: 12px 22px; font-size: 14px; }
}