:root {
    --doc-ink: #242a2f;
    --doc-muted: #7c7d78;
    --doc-paper: #fbfaf6;
    --doc-line: #e8e3d9;
    --doc-accent: #c34a28;
    --doc-accent-dark: #a8391d;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body { margin: 0; color: var(--doc-ink); background: #efefec; font-family: "Microsoft YaHei", "PingFang SC", sans-serif; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }

.docformat-shell { min-height: 100vh; background: #efefec; }
.docformat-page { width: min(980px, calc(100% - 36px)); margin: 16px auto 64px; }
.assistant-heading { padding: 14px 18px 18px; text-align: center; }
.assistant-kicker { margin: 0 0 4px; color: var(--doc-accent); font: 700 10px/1.35 Arial, sans-serif; letter-spacing: .22em; }
.assistant-heading h1 { margin: 0; font-family: STSong, SimSun, serif; font-size: clamp(32px, 4vw, 44px); font-weight: 700; line-height: 1.2; letter-spacing: .05em; }
.assistant-heading > p:last-child { margin: 6px auto 0; color: #777771; font: 14px/1.55 STSong, SimSun, serif; }

.workbench { position: relative; padding: 34px 38px 38px; border: 1px solid #dedbd3; background:
    linear-gradient(rgba(255,255,255,.74), rgba(255,255,255,.74)),
    repeating-linear-gradient(0deg, transparent 0 30px, rgba(111,94,64,.025) 30px 31px), var(--doc-paper);
    box-shadow: 0 18px 55px rgba(38, 36, 31, .08); }
.workbench::before { content: ""; position: absolute; inset: 8px; pointer-events: none; border: 1px solid rgba(95,75,43,.035); }
.file-row { position: relative; display: grid; grid-template-columns: 52px 1fr; gap: 0; align-items: stretch; min-height: 52px; margin-bottom: 8px; }
.row-label { display: grid; place-items: center start; color: #777872; font: 16px STSong, SimSun, serif; }
.file-field { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; padding: 0 20px; border: 1px solid #ebe7de; background: rgba(244,242,235,.72); cursor: pointer; text-align: left; transition: border-color .18s, background .18s; }
.file-field:hover, .file-field.dragging { border-color: var(--doc-accent); background: #fff9f4; }
.file-field span { min-width: 0; overflow: hidden; color: #aaa9a4; text-overflow: ellipsis; white-space: nowrap; }
.file-field strong { flex: 0 0 auto; color: var(--doc-accent); font-size: 13px; font-weight: 500; }
.file-field.is-static { cursor: default; }
.file-field.is-static:hover { border-color: #ebe7de; background: rgba(244,242,235,.72); }
.input-actions { display: flex; gap: 28px; padding: 0 0 24px 52px; }
.text-action { padding: 0; border: 0; color: #6d6b65; background: transparent; cursor: pointer; font-family: STSong, SimSun, serif; }
.text-action:hover { color: var(--doc-accent); }
.text-action span { margin-right: 7px; }
.output-row { margin-bottom: 0; }
.section-rule { height: 1px; margin: 34px 0 26px; background: linear-gradient(90deg, transparent, #e9e5dc 8%, #e9e5dc 92%, transparent); }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card { display: flex; align-items: center; gap: 20px; min-height: 116px; padding: 22px 28px; border: 1px solid #e6e2da; background: rgba(255,255,255,.62); cursor: pointer; text-align: left; transition: border-color .18s, transform .18s, background .18s; }
.mode-card:hover { transform: translateY(-1px); border-color: #d2b6a9; background: white; }
.mode-card.primary { grid-column: 1 / -1; min-height: 128px; }
.mode-card.selected { border-color: var(--doc-accent); box-shadow: inset 0 0 0 1px rgba(195,74,40,.08); }
.mode-icon { display: grid; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; color: #202429; font: 22px/1 Georgia, serif; }
.mode-card strong { display: block; font: 700 19px/1.4 STSong, SimSun, serif; }
.mode-card strong em { display: inline-block; margin-left: 8px; padding: 3px 8px; color: #fff; background: var(--doc-accent); font: normal 11px/1.4 "Microsoft YaHei", sans-serif; vertical-align: 3px; }
.mode-card small { display: block; margin-top: 7px; color: #92918b; font: 14px/1.55 STSong, SimSun, serif; }

.preset-section { margin-top: 28px; }
.preset-section h2 { margin: 0 0 12px; color: #777872; font: 16px/1.4 STSong, SimSun, serif; }
.preset-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.preset-card { min-height: 62px; padding: 10px 12px; border: 1px solid #e7e3dc; background: rgba(255,255,255,.7); cursor: pointer; font: 16px STSong, SimSun, serif; }
.preset-card:hover { border-color: #d2b6a9; }
.preset-card.selected { border-color: var(--doc-accent); color: #222; background: #fffaf6; }
.option-stack { display: grid; gap: 14px; margin: 28px 0; }
.option-line { display: flex; align-items: center; gap: 11px; color: #686861; font: 14px STSong, SimSun, serif; }
.option-line input { width: 22px; height: 22px; margin: 0; accent-color: var(--doc-accent); }
.option-line button { display: grid; width: 17px; height: 17px; padding: 0; place-items: center; border: 1px solid #bbb; border-radius: 50%; color: #888; background: transparent; cursor: help; font: 11px serif; }
.process-button { position: relative; width: 100%; height: 70px; border: 0; color: #fff; background: var(--doc-accent); cursor: pointer; font: 700 21px STSong, SimSun, serif; letter-spacing: .08em; transition: background .18s, transform .18s; }
.process-button:hover { background: var(--doc-accent-dark); }
.process-button:active { transform: translateY(1px); }
.process-button:disabled { cursor: wait; opacity: .65; }

.progress-panel, .result-panel { margin-top: 20px; padding: 20px 22px; border: 1px solid #e4dfd5; background: rgba(255,255,255,.78); }
.progress-panel > div:first-child { display: flex; justify-content: space-between; gap: 20px; }
.progress-panel strong { font-family: STSong, SimSun, serif; }
.progress-panel span, .progress-panel p { color: #85837d; font-size: 13px; }
.progress-track { height: 5px; margin-top: 14px; overflow: hidden; background: #eee9e0; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--doc-accent); transition: width .3s ease; }
.progress-panel p { margin: 9px 0 0; }
.result-panel h2 { margin: 0 0 12px; font: 700 20px STSong, SimSun, serif; }
.result-panel > p { margin: 0; color: #6f6e68; line-height: 1.7; }
.result-panel.success { border-color: #aecdb6; background: #f7fff8; }
.result-panel.error { border-color: #dfb4aa; background: #fff8f6; }
.diagnosis-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 15px 0; }
.diagnosis-summary div { padding: 13px; background: #f5f2eb; text-align: center; }
.diagnosis-summary strong { display: block; color: var(--doc-accent); font-size: 22px; }
.diagnosis-summary span { color: #85837d; font-size: 12px; }
.diagnosis-list { margin: 12px 0 0; padding: 0; list-style: none; }
.diagnosis-list li { padding: 9px 0; border-top: 1px dashed #e3dfd7; color: #61605b; font-size: 14px; }
.privacy-note { display: flex; justify-content: center; gap: 10px; margin: 20px auto; color: #8b8a84; font-size: 12px; }
.privacy-note strong { color: #66655f; }

.modal { position: fixed; z-index: 1000; inset: 0; display: grid; padding: 24px; place-items: center; background: rgba(26,27,27,.55); backdrop-filter: blur(3px); }
.modal-card { display: flex; flex-direction: column; width: min(760px, 100%); max-height: min(860px, calc(100vh - 48px)); overflow: hidden; border: 1px solid #dad5ca; background: #fbfaf6; box-shadow: 0 28px 80px rgba(0,0,0,.25); }
.modal-card > header { display: flex; align-items: center; justify-content: space-between; padding: 22px 28px; border-bottom: 1px solid #e5e0d7; }
.modal-card > header small { color: var(--doc-accent); font: 700 9px Arial, sans-serif; letter-spacing: .2em; }
.modal-card > header h2 { margin: 3px 0 0; font: 700 23px STSong, SimSun, serif; }
.modal-card > header > button { padding: 0; border: 0; color: #777; background: transparent; cursor: pointer; font: 30px/1 Arial; }
.modal-body { padding: 24px 28px; overflow: auto; }
.modal-card > footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 28px; border-top: 1px solid #e5e0d7; background: #f7f5ef; }
.field-label { display: grid; gap: 8px; margin-bottom: 18px; color: #65645f; font-size: 13px; }
.field-label input, .field-label textarea, .preset-toolbar input, .settings-grid input, .settings-grid select, .element-table input, .element-table select { width: 100%; border: 1px solid #dcd7cd; border-radius: 0; outline: none; background: #fff; }
.field-label input { height: 42px; padding: 0 12px; }
.field-label textarea { min-height: 280px; padding: 12px; resize: vertical; line-height: 1.7; }
input:focus, textarea:focus, select:focus { border-color: var(--doc-accent) !important; box-shadow: 0 0 0 2px rgba(195,74,40,.08); }
.paste-meta { display: flex; justify-content: space-between; color: #8a8983; font-size: 12px; }
.primary-button, .secondary-button, .preset-toolbar button { min-height: 40px; padding: 0 18px; border: 1px solid var(--doc-accent); cursor: pointer; }
.primary-button { color: #fff; background: var(--doc-accent); }
.secondary-button, .preset-toolbar button { color: #666; border-color: #d5d0c6; background: #fff; }

.settings-modal { width: min(1120px, 100%); }
.preset-toolbar { display: flex; gap: 8px; padding: 12px 28px; border-bottom: 1px solid #e5e0d7; background: #f7f5ef; }
.preset-toolbar input { min-width: 180px; height: 40px; padding: 0 12px; margin-right: auto; }
.settings-body { display: grid; gap: 12px; }
.settings-body details { border: 1px solid #e4dfd5; background: rgba(255,255,255,.68); }
.settings-body summary { padding: 15px 18px; cursor: pointer; font: 700 16px STSong, SimSun, serif; }
.settings-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 4px 18px 18px; }
.settings-grid label { display: grid; gap: 6px; color: #74726c; font-size: 12px; }
.settings-grid input, .settings-grid select { height: 38px; padding: 0 9px; }
.settings-checks { display: flex; flex-wrap: wrap; gap: 18px; padding: 0 18px 18px; color: #64635e; font-size: 13px; }
.settings-checks input { accent-color: var(--doc-accent); }
.element-table-wrap { padding: 4px 18px 18px; overflow-x: auto; }
.element-table { width: 100%; min-width: 1080px; border-collapse: collapse; }
.element-table th { padding: 8px 5px; color: #7b7973; background: #f3f0e9; font-size: 11px; font-weight: 500; }
.element-table td { padding: 5px; border-bottom: 1px solid #eeeae2; }
.element-table td:first-child { color: #55544f; white-space: nowrap; font-size: 12px; }
.element-table input, .element-table select { height: 33px; padding: 0 6px; font-size: 12px; }
.element-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--doc-accent); }
.docformat-toast { position: fixed; z-index: 1200; right: 24px; bottom: 24px; max-width: min(420px, calc(100% - 48px)); padding: 13px 18px; color: #fff; background: #333; box-shadow: 0 8px 30px rgba(0,0,0,.2); font-size: 13px; }

@media (max-width: 860px) {
    .docformat-page { width: min(100% - 20px, 760px); margin-top: 14px; }
    .workbench { padding: 26px 22px; }
    .mode-grid { grid-template-columns: 1fr; }
    .mode-card.primary { grid-column: auto; }
    .preset-row { grid-template-columns: 1fr 1fr; }
    .settings-grid { grid-template-columns: 1fr 1fr; }
    .diagnosis-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
    .assistant-heading { padding: 12px 8px 14px; }
    .assistant-heading h1 { font-size: 31px; }
    .workbench { padding: 20px 14px; }
    .file-row { grid-template-columns: 42px 1fr; }
    .file-field { display: grid; gap: 4px; min-height: 66px; padding: 11px 13px; }
    .file-field strong { white-space: normal; }
    .input-actions { display: grid; gap: 14px; padding-left: 42px; }
    .mode-card { min-height: 104px; padding: 17px 16px; }
    .mode-icon { flex-basis: 32px; width: 32px; }
    .preset-row, .settings-grid { grid-template-columns: 1fr; }
    .option-line { align-items: flex-start; }
    .process-button { height: 60px; }
    .privacy-note { display: grid; text-align: center; }
    .modal { padding: 0; place-items: stretch; }
    .modal-card { width: 100%; max-height: 100vh; min-height: 100vh; }
    .modal-card > header, .modal-body, .modal-card > footer { padding-left: 18px; padding-right: 18px; }
    .preset-toolbar { flex-wrap: wrap; padding: 10px 18px; }
    .preset-toolbar input { flex-basis: 100%; margin: 0; }
}
