:root {
    --ink: var(--text-primary);
    --ink-soft: var(--text-secondary);
    --paper: var(--bg-primary);
    --panel: var(--anthropic-light);
    --line: var(--border-color);
    --line-strong: var(--anthropic-mid-gray);
    --green: var(--accent-orange);
    --green-deep: #b85f43;
    --green-pale: #f9e9e3;
    --warm: var(--accent-blue);
    --danger: #b34338;
    --mono: var(--font-heading);
    --sans: var(--font-heading);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { min-width: 320px; background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 14px; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: calc(100vh - 70px); margin-top: 70px; background: var(--paper); }
.workspace { width: 100%; min-height: calc(100vh - 70px); margin: 0; padding: 0; }
.workspace-intro { height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 22px; border-bottom: 1px solid var(--line); background: var(--panel); }
.intro-title-group { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.eyebrow { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--green-deep); font-family: var(--mono); font-size: 9px; letter-spacing: .08em; white-space: nowrap; }
.eyebrow span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-pale); }
h1 { max-width: 700px; margin: 0; color: var(--ink); font-size: 18px; font-weight: 800; letter-spacing: 0; line-height: 1.1; white-space: nowrap; }
h1 em { color: var(--green); font-style: normal; }
.intro-copy { margin: 0; color: var(--ink-soft); font-family: var(--font-body); font-size: 11px; line-height: 1.6; white-space: nowrap; }
.workspace-actions { display: inline-flex; align-items: center; gap: 8px; }
.balance-link, .quota-link, .intro-status { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-soft); background: transparent; font-family: var(--mono); font-size: 10px; text-decoration: none; }
.balance-link:hover, .quota-link:hover { border-color: var(--green); color: var(--green-deep); }
.quota-link.is-warn { border-color: var(--danger); color: var(--danger); }
.balance-link svg, .quota-link svg, .intro-status svg { width: 15px; color: var(--green); }
.quota-link.is-warn svg { color: var(--danger); }
.balance-value, .quota-value { color: var(--ink); font-weight: 600; }
.quota-link.is-warn .quota-value { color: var(--danger); }

.workbench-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 0; align-items: stretch; height: calc(100vh - 118px); min-height: 620px; }
.control-panel, .result-container { background: var(--panel); border: 0; border-radius: 0; box-shadow: none; }
.control-panel { height: 100%; min-height: 0; padding: 16px; overflow-y: auto; border-right: 1px solid var(--line); }
.panel-heading { display: flex; align-items: center; gap: 9px; }
.panel-heading p { margin: 0 0 1px; color: var(--green); font-family: var(--mono); font-size: 9px; letter-spacing: .1em; }
.panel-heading h2 { margin: 0; color: var(--ink); font-size: 15px; letter-spacing: 0; }
.step-number { width: 26px; height: 26px; flex: 0 0 26px; display: grid; place-items: center; color: var(--green-deep); background: var(--green-pale); border-radius: 4px; font-family: var(--mono); font-size: 10px; font-weight: 500; }
.control-section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.upload-section { padding-top: 18px; }
.section-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; color: var(--ink); font-size: 13px; font-weight: 700; }
.section-label small { color: var(--ink-soft); font-family: var(--mono); font-size: 10px; font-weight: 400; }
.upload-dropzone { position: relative; overflow: hidden; min-height: 108px; padding: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1px dashed var(--line-strong); border-radius: 6px; background: #f8faf6; color: var(--ink-soft); cursor: pointer; text-align: center; transition: border-color .2s ease, background .2s ease, transform .2s ease; }
.upload-dropzone:hover, .upload-dropzone:focus-within { border-color: var(--green); background: var(--green-pale); transform: translateY(-1px); }
.upload-dropzone input { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-dropzone.is-full input { pointer-events: none; cursor: not-allowed; }
.upload-symbol { width: 30px; height: 30px; display: grid; place-items: center; margin-bottom: 4px; border-radius: 5px; color: var(--green); background: var(--green-pale); }
.upload-symbol svg { width: 17px; height: 17px; }
.upload-primary { color: var(--ink); font-size: 13px; font-weight: 700; }
.upload-secondary { font-size: 11px; }
.file-list { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.file-list:empty { display: none; }
.file-list li { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 30px; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: var(--ink); font-size: 11px; line-height: 1.45; animation: file-enter .26s ease-out; }
.file-list li > div { display: none; }
.file-list li > input { grid-column: 1 / 2; width: 100%; height: 31px; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px; outline: none; color: var(--ink); background: #f8faf6; font-family: var(--mono); font-size: 11px; }
.file-list li > input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-pale); }
.remove-file { grid-column: 2; grid-row: 1 / span 2; width: 30px; height: 30px; padding: 0; place-self: center; display: grid; place-items: center; border: 0; border-radius: 4px; color: var(--danger); background: #fbedeb; cursor: pointer; font-size: 0; transition: background .18s ease, transform .18s ease; }
.remove-file::before { content: "×"; font-size: 21px; font-weight: 400; line-height: 1; }
.remove-file:hover { background: #f4d8d4; transform: scale(1.04); }

.format-options { display: flex; flex-wrap: wrap; gap: 7px; }
.format-option { position: relative; cursor: pointer; }
.format-option input { position: absolute; opacity: 0; pointer-events: none; }
.format-option span { min-height: 31px; display: grid; place-items: center; padding: 0 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-soft); background: #f8faf6; font-family: var(--mono); font-size: 10px; transition: background .18s ease, color .18s ease, border-color .18s ease; }
.format-option input:checked + span, .format-option.active span { border-color: var(--green); color: var(--green-deep); background: var(--green-pale); }
.processing-control { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 0; }
.stream-copy { display: grid; gap: 3px; color: var(--ink); font-weight: 700; font-size: 13px; }
.stream-copy small { color: var(--ink-soft); font-weight: 400; font-size: 11px; }
.switch { width: 42px; height: 25px; position: relative; flex: 0 0 42px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: #c7d0c8; transition: background .2s ease; }
.switch-track::after { content: ""; position: absolute; top: 4px; left: 4px; width: 17px; height: 17px; border-radius: 50%; background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.16); transition: transform .2s ease; }
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--green-pale); outline-offset: 2px; }
.analysis-action { padding-top: 6px; }
.analyze-btn { width: 100%; min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 5px; color: var(--panel); background: var(--green); cursor: pointer; font-weight: 800; transition: transform .18s ease, background .18s ease, box-shadow .18s ease; }
.analyze-btn:hover:not(:disabled) { background: var(--green-deep); transform: translateY(-1px); box-shadow: 0 9px 17px rgba(23, 119, 75, .18); }
.analyze-btn:focus-visible { outline: 3px solid var(--green-pale); outline-offset: 3px; }
.analyze-btn:disabled { color: #78847b; background: #d9dfd8; cursor: not-allowed; }
.button-icon { width: 18px; height: 18px; display: grid; place-items: center; }
.button-icon svg { width: 17px; height: 17px; }
.button-spinner { display: none; width: 15px; height: 15px; border: 2px solid rgba(252,252,248,.45); border-top-color: var(--panel); border-radius: 50%; animation: spin .8s linear infinite; }
.analyze-btn.is-loading .button-spinner { display: block; }
.analyze-btn.is-loading .button-icon { display: none; }
.action-hint { margin: 9px 0 0; color: var(--ink-soft); font-size: 11px; text-align: center; }
.analysis-progress { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 9px; margin-top: 18px; color: var(--ink-soft); font-family: var(--mono); font-size: 10px; }
.progress-copy { display: flex; min-width: 0; justify-content: space-between; grid-column: 1 / -1; gap: 8px; }
.progress-stage { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-elapsed { grid-column: 2; grid-row: 2; align-self: center; }
.progress-bar { height: 4px; margin: 0; overflow: hidden; border-radius: 999px; background: #e5e9e3; }
.progress { width: 0; height: 100%; background: var(--green); transition: width .35s ease; }
.analysis-progress.is-running .progress { background: linear-gradient(90deg, var(--green), var(--warm), var(--green)); background-size: 200% 100%; animation: progress-shimmer 1.5s linear infinite; }

.result-container { min-width: 0; height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.result-toolbar { min-height: 54px; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.toolbar-actions { display: inline-flex; align-items: center; gap: 10px; }
.publish-blog-btn { min-height: 31px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-soft); background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; }
.publish-blog-btn:hover { color: var(--green-deep); border-color: var(--green); }
.publish-blog-btn svg { width: 14px; height: 14px; }
.workspace-fullscreen { width: 31px; height: 31px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-soft); background: transparent; cursor: pointer; }
.workspace-fullscreen:hover { color: var(--green-deep); border-color: var(--green); }
.workspace-fullscreen svg { width: 16px; height: 16px; }
.analysis-indicator { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-soft); font-family: var(--mono); font-size: 10px; }
.analysis-indicator > span:first-child { width: 7px; height: 7px; border-radius: 50%; background: #b4beb5; }
.analysis-indicator.is-running > span:first-child { background: var(--warm); animation: pulse 1.35s ease-out infinite; }
.analysis-indicator.is-complete > span:first-child { background: var(--green); }
.tab-header { display: flex; gap: 2px; padding: 4px 12px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab-item { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 0 11px; border: 0; border-bottom: 2px solid transparent; color: var(--ink-soft); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; white-space: nowrap; transition: color .18s ease, border-color .18s ease, background .18s ease; }
.tab-item svg { width: 15px; height: 15px; }
.tab-item:hover { color: var(--green-deep); background: #f4f7f1; }
.tab-item.active { border-bottom-color: var(--green); color: var(--green-deep); }
.tab-item:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.tab-content { min-height: 0; flex: 1 1 0; padding: 8px; background: #f7f9f5; overflow: hidden; }
.tab-pane { display: none; height: 100%; min-height: 0; }
.tab-pane.active { display: block; animation: pane-enter .22s ease-out; }
#report-panel.active, #recent-panel.active { min-height: 0; overflow-x: auto; overflow-y: scroll; overscroll-behavior: contain; }
#report-panel.active { scrollbar-gutter: stable; }
.app-shell.workspace-maximized { position: fixed; z-index: 1100; inset: 0; margin: 0; min-height: 100vh; background: var(--paper); }
.workspace-maximized .workspace { min-height: 100vh; }
.workspace-maximized .workspace-intro, .workspace-maximized .control-panel, .workspace-maximized .tab-header, .workspace-maximized .editor-note { display: none; }
.workspace-maximized .workbench-grid { display: block; height: 100vh; min-height: 0; }
.workspace-maximized .result-container { height: 100vh; }
.workspace-maximized .result-toolbar { min-height: 52px; }
.workspace-maximized #markdown-panel { height: 100%; }
.workspace-maximized #md-editor-frame { height: 100%; }
.workspace-maximized .workspace-fullscreen { color: var(--green-deep); border-color: var(--green); }
#md-editor-frame { width: 100%; height: calc(100% - 24px); min-height: 0; display: block; border: 1px solid var(--line); border-radius: 0; background: var(--panel); }
.editor-note { margin: 9px 2px 0; color: var(--ink-soft); font-size: 11px; }
.empty-report { min-height: 100%; display: grid; place-content: center; justify-items: center; max-width: 380px; margin: 0 auto; color: var(--ink-soft); text-align: center; }
.empty-report-icon { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 50%; color: var(--green); background: var(--green-pale); }
.empty-report-icon svg { width: 23px; height: 23px; }
.empty-report h3 { margin: 0; color: var(--ink); font-size: 16px; }
.empty-report p { margin: 9px 0 0; font-size: 13px; line-height: 1.7; }
.info-box, .success-box, .error-box { max-width: 100%; padding: clamp(18px, 3vw, 32px); border-radius: 5px; line-height: 1.7; }
.info-box { border: 1px solid #cddfcf; background: #f1f8f1; }
.success-box { border: 1px solid #c8dec9; background: #f1f8f1; }
.error-box { border: 1px solid #ecc9c5; background: #fff3f2; color: #7d312a; }
.info-box h3, .success-box h3, .error-box h3 { margin-top: 0; color: inherit; }
.success-box { max-width: none; min-height: 100%; overflow: visible; white-space: normal; }
#streaming-content, .report-markdown { overflow-wrap: anywhere; font-family: var(--font-body); font-size: 14px; line-height: 1.78; }
.report-markdown { padding-bottom: 32px; }
.report-markdown > :first-child { margin-top: 0; }
.report-markdown h1, .report-markdown h2, .report-markdown h3, .report-markdown h4 { color: var(--ink); font-family: var(--font-heading); letter-spacing: 0; }
.report-markdown h1 { margin: 32px 0 16px; padding-bottom: 12px; border-bottom: 2px solid var(--green); font-size: 26px; }
.report-markdown h2 { margin: 28px 0 14px; padding-left: 12px; border-left: 3px solid var(--green); font-size: 21px; }
.report-markdown h3 { margin: 22px 0 10px; font-size: 17px; }
.report-markdown h4 { margin: 18px 0 8px; font-size: 15px; }
.report-markdown p { margin: 0 0 14px; }
.report-markdown ul, .report-markdown ol { margin: 0 0 16px; padding-left: 24px; }
.report-markdown li + li { margin-top: 5px; }
.report-markdown blockquote { margin: 16px 0; padding: 10px 15px; border-left: 3px solid var(--warm); color: var(--ink-soft); background: #f6f7f3; }
.report-markdown hr { margin: 24px 0; border: 0; border-top: 1px solid var(--line); }
.report-markdown table, #streaming-content table, .history-table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 16px 0 22px; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; }
.report-markdown th, .report-markdown td, #streaming-content th, #streaming-content td, .history-table th, .history-table td { min-width: 105px; padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.report-markdown th:last-child, .report-markdown td:last-child, #streaming-content th:last-child, #streaming-content td:last-child, .history-table th:last-child, .history-table td:last-child { border-right: 0; }
.report-markdown tr:last-child td, #streaming-content tr:last-child td, .history-table tr:last-child td { border-bottom: 0; }
.report-markdown th, #streaming-content th, .history-table th { color: var(--ink); background: var(--green-pale); font-family: var(--font-heading); font-size: 12px; font-weight: 700; }
.report-markdown tr:nth-child(even) td { background: #fafaf7; }
.report-markdown code, #streaming-content code { padding: 2px 4px; border-radius: 3px; background: #e9eee7; font-family: var(--mono); font-size: .88em; }
.report-markdown pre, #streaming-content pre { padding: 14px; overflow: auto; border-radius: 4px; background: #202a22; color: #e8eee9; }
.report-markdown pre code { padding: 0; background: transparent; color: inherit; }
.report-markdown img { max-width: 100%; height: auto; }
.history-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); }
.history-table { min-width: 930px; font-size: 12px; }
.history-table tbody tr:hover { background: #f4f8f2; }
.history-table td { color: var(--ink-soft); }
.history-table td:first-child, .history-table td:nth-child(2), .history-table td:nth-child(3) { color: var(--ink); font-family: var(--mono); }
.history-status-ok, .history-status-fail { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.history-status-ok { color: var(--green-deep); background: var(--green-pale); }
.history-status-fail { color: #8e3931; background: #fbe9e7; }
.history-dl { display: inline-flex; gap: 8px; white-space: nowrap; }
.history-dl a { color: var(--green-deep); font-size: 11px; font-weight: 700; text-decoration: none; }
.history-dl a:hover { text-decoration: underline; }

@keyframes spin { to { transform: rotate(360deg); } }@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(217, 152, 61, .32); } 70% { box-shadow: 0 0 0 7px rgba(217, 152, 61, 0); } 100% { box-shadow: 0 0 0 0 rgba(217, 152, 61, 0); } }
@keyframes progress-shimmer { to { background-position: -200% 0; } }
@keyframes pane-enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes file-enter { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
    .workspace { padding: 0; }
    .workspace-intro { height: auto; min-height: 58px; align-items: flex-start; padding: 10px 18px; }
    .intro-title-group { display: block; }
    .eyebrow { margin-bottom: 8px; }
    .intro-copy { margin-top: 8px; white-space: normal; }
    .workbench-grid { grid-template-columns: 1fr; height: auto; min-height: auto; }
    .control-panel { height: auto; min-height: 0; display: grid; border-right: 0; border-bottom: 1px solid var(--line); grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
    .control-panel > .panel-heading, .control-panel > .analysis-action, .control-panel > .progress-bar { grid-column: 1 / -1; }
    .upload-section { padding-top: 20px; }
    .analysis-action { padding-top: 20px; }
}
@media (max-width: 640px) {
    .app-shell { min-height: calc(100vh - 64px); margin-top: 64px; }
    .workspace { min-height: calc(100vh - 64px); padding: 0; }
    .workspace-intro { display: block; margin-bottom: 0; padding: 11px 14px; }
    h1 { margin-top: 5px; font-size: 22px; white-space: normal; }
    .intro-copy { margin-top: 5px; font-size: 11px; }
    .workspace-actions { margin-top: 10px; }
    .intro-status { display: none; }
    .balance-text, .quota-text { display: none; }
    .control-panel { display: block; padding: 17px; }
    .workbench-grid { gap: 0; }
    .control-section { padding: 17px 0; }
    .tab-header { padding: 7px 8px 0; }
    .tab-item { min-height: 38px; padding: 0 9px; }
    .tab-item svg { display: none; }
    .result-toolbar { min-height: 70px; padding: 16px; }
    .analysis-indicator { font-size: 9px; }
    .workspace-fullscreen { width: 30px; height: 30px; }
    .result-container { height: auto; min-height: 580px; }
    .tab-content { min-height: 595px; flex: none; padding: 8px; }
    #md-editor-frame { height: 540px; min-height: 540px; }
    .empty-report { min-height: 480px; padding: 24px; }
    .editor-note { padding: 0 4px; line-height: 1.5; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }

/* 发布到博客弹窗 */
.blog-publish-dialog[hidden] { display: none; }
.blog-publish-dialog { position: fixed; z-index: 1400; inset: 0; display: grid; place-items: center; padding: 16px; }
.blog-publish-backdrop { position: absolute; inset: 0; background: rgba(20, 20, 19, .45); }
.blog-publish-panel { position: relative; width: min(520px, 100%); max-height: 90vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 18px 50px rgba(20,20,19,.18); }
.blog-publish-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.blog-publish-header h3 { margin: 0; font-size: 16px; }
.blog-publish-close { width: 30px; height: 30px; border: 0; border-radius: 4px; color: var(--ink-soft); background: transparent; cursor: pointer; font-size: 22px; line-height: 1; }
.blog-publish-close:hover { color: var(--danger); background: #fbedeb; }
.blog-publish-body { display: grid; gap: 12px; padding: 16px 18px; }
.blog-publish-field { display: grid; gap: 6px; }
.blog-publish-field > span { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.blog-publish-field input, .blog-publish-field textarea, .blog-publish-field select { width: 100%; min-height: 34px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: #fafaf7; font: inherit; font-size: 13px; }
.blog-publish-field input:focus, .blog-publish-field textarea:focus, .blog-publish-field select:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px var(--green-pale); }
.blog-publish-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.blog-publish-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.blog-publish-cancel, .blog-publish-submit { min-height: 34px; padding: 0 16px; border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 700; }
.blog-publish-cancel { border: 1px solid var(--line); color: var(--ink-soft); background: transparent; }
.blog-publish-submit { border: 0; color: #fff; background: var(--green); }
.blog-publish-submit:disabled { opacity: .6; cursor: not-allowed; }
.blog-publish-status { margin: 0; padding: 0 18px 14px; color: var(--green-deep); font-size: 12px; }
@media (max-width: 640px) { .blog-publish-row { grid-template-columns: 1fr; } }
