:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6e9f0;
  --border-strong: #d3d8e3;
  --text: #1f2733;
  --text-muted: #6b7488;
  --text-faint: #98a0b3;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eef3ff;
  --success: #16a34a;
  --success-soft: #ecfdf3;
  --warning: #d97706;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, .06);
  --shadow: 0 6px 20px rgba(20, 30, 60, .08);
  --shadow-lg: 0 16px 48px rgba(20, 30, 60, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
}

* { box-sizing: border-box; }

/* 保证 hidden 属性始终生效（覆盖组件自身的 display 规则） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* ---------- 顶部状态条 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 60px;
  padding: 0 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-version { font-size: 12px; color: var(--text-faint); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; color: var(--text);
  background: var(--surface-2); transition: background .15s, border-color .15s, opacity .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; height: 42px; font-size: 14.5px; margin-top: 4px; }
.btn-icon { width: 36px; height: 36px; padding: 0; background: transparent; color: var(--text-muted); }
.btn-icon:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-close:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; color: #fff; animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { color: #fff; }
.btn-ghost.is-loading::after { color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* 产品一句话描述：顶部条下方居中，说明本工具能干什么 */
.tagline {
  margin: 0; padding: 12px 22px 0;
  text-align: center; font-size: 13px; line-height: 1.6;
  color: var(--text-muted);
}

/* ---------- 布局 ---------- */
/* minmax(0,1fr)：列最小宽度归零。否则任务卡内步骤条（6 步最小宽度约 420px）
   会沿 task-card → tasks-list → panel 一路把列撑得比手机屏幕还宽，整页随之溢出。
   过宽的内容交给元素自身的 overflow（步骤条横向滑动）处理。 */
.layout {
  display: grid;
  grid-template-columns: 408px minmax(0, 1fr);
  gap: 20px;
  padding: 20px 22px 28px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}
.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.panel-title { margin: 0 0 16px; font-size: 15.5px; font-weight: 700; }

/* ---------- 拖拽区 ---------- */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 26px 18px;
  text-align: center;
  transition: border-color .15s, background .15s, box-shadow .15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.is-drag { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 3px rgba(37,99,235,.12); }
.dz-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-muted); }
.dz-empty svg { color: var(--text-faint); margin-bottom: 4px; }
.dz-hint { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.dz-hint em { font-style: normal; color: var(--primary); text-decoration: underline; }
.dz-sub { margin: 0; font-size: 12px; color: var(--text-faint); }
.dz-img-btn {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--text-muted); font-size: 12.5px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.dz-img-btn:hover { border-color: var(--primary); color: var(--primary); }
.dz-file { display: flex; align-items: center; gap: 12px; text-align: left; }
.file-badge {
  flex: none; display: grid; place-items: center;
  min-width: 46px; height: 46px; padding: 0 8px;
  border-radius: 10px; background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 700; letter-spacing: .3px;
}
.file-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-name { font-weight: 600; font-size: 13.5px; white-space: normal; word-break: break-all; }
.file-size { font-size: 12px; color: var(--text-faint); }

/* ---------- 字段 ---------- */
.field { margin-top: 18px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 9px; }
.format-toggle { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.layout { overflow-x: clip; } /* 兜底：任何残余的横向溢出直接裁掉，不产生滚动条（clip 不影响顶栏 sticky） */
.format-btn {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 16px; border: 1.5px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text-muted); font-size: 14px; font-weight: 600;
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s;
}
.format-btn svg { color: var(--text-faint); transition: color .15s; }
.format-btn:hover { border-color: var(--primary); }
.format-btn.is-active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.format-btn.is-active svg { color: var(--primary); }

.collapse-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 13.5px; font-weight: 600;
}
.collapse-head .chev { transition: transform .2s; color: var(--text-faint); }
.collapse-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.collapse-body { padding: 14px; border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); display: flex; flex-direction: column; gap: 16px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.switch-desc { font-size: 12px; color: var(--text-faint); }
.switch { position: relative; flex: none; width: 42px; height: 24px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { display: block; width: 42px; height: 24px; border-radius: 999px; background: var(--border-strong); transition: background .18s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .18s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }

.text-row, .select-row { display: flex; flex-direction: column; gap: 7px; }
.text-input, .select-input, .text-area {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.text-area { resize: vertical; line-height: 1.45; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }
.text-input:focus, .select-input:focus, .text-area:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.select-input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #6b7488 50%), linear-gradient(135deg, #6b7488 50%, transparent 50%); background-position: calc(100% - 17px) calc(50% + 2px), calc(100% - 12px) calc(50% + 2px); background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.limits-hint { margin: 10px 2px 0; font-size: 12px; color: var(--text-faint); min-height: 1px; }

/* ---------- 任务列表 ---------- */
.tasks-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.tasks-head .panel-title { margin: 0; }
/* margin-right:auto 把「清除已完成任务」推到最右，计数紧贴标题 */
.tasks-count { font-size: 12.5px; color: var(--text-faint); margin-right: auto; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn svg { flex: none; }
.tasks-list { display: flex; flex-direction: column; gap: 14px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 20px; color: var(--text-faint); text-align: center; }
.empty-state p { margin: 0; font-size: 13.5px; }

.task-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); min-width: 0; }
.task-card.is-failed { border-color: var(--danger); }
.task-card.is-unlocked { border-color: var(--success); }
.task-top { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.task-badge { flex: none; display: grid; place-items: center; min-width: 44px; height: 44px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-size: 11.5px; font-weight: 700; }
.task-info { min-width: 0; flex: 1; }
.task-name { font-weight: 600; font-size: 13.5px; white-space: normal; word-break: break-all; }
.task-sub { font-size: 12px; color: var(--text-faint); }
.task-state-tag { flex: none; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); }
.task-state-tag.s-queued { background: #eef2f7; color: #475569; }
.task-state-tag.s-uploading, .task-state-tag.s-downloading, .task-state-tag.s-building { background: var(--primary-soft); color: var(--primary); }
.task-state-tag.s-parsing { background: #fff7ed; color: var(--warning); }
.task-state-tag.s-locked { background: #fef9c3; color: #a16207; }
.task-state-tag.s-failed { background: var(--danger-soft); color: var(--danger); }
.task-state-tag.s-unlocked { background: var(--success-soft); color: var(--success); }

/* 步骤条 */
.stepper { display: flex; padding: 16px 16px 4px; }
.step { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.step:not(:last-child)::before { content: ""; position: absolute; top: 11px; left: 50%; width: 100%; height: 2px; background: var(--border); }
.step.done:not(:last-child)::before, .step.active:not(:last-child)::before { background: var(--primary); }
.step-dot { position: relative; z-index: 1; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); display: grid; place-items: center; font-size: 11px; color: var(--text-faint); }
.step.done .step-dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.active .step-dot { border-color: var(--primary); color: var(--primary); }
.step.active .step-dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .4; } 50% { opacity: 1; } }
.step-label { margin-top: 6px; font-size: 11px; color: var(--text-faint); text-align: center; }
.step.done .step-label, .step.active .step-label { color: var(--text); }

/* 进度条 */
.progress-wrap { padding: 6px 16px 16px; }
.progress-line { font-size: 12px; color: var(--text-muted); margin-bottom: 7px; display: flex; justify-content: space-between; gap: 10px; }
.progress-line .pct { color: var(--text-faint); font-variant-numeric: tabular-nums; }
/* 进度条：阶段文案（中文无空格，min-content 是一整行）允许收缩省略，百分比固定不挪位 */
.progress-line > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-line .pct { flex: none; }
.progress-track { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--primary); width: 0; transition: width .4s ease; }
.progress-bar.indeterminate { width: 40% !important; background-image: linear-gradient(45deg, rgba(255,255,255,.35) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.35) 50%, rgba(255,255,255,.35) 75%, transparent 75%, transparent); background-size: 18px 18px; animation: stripes 1s linear infinite; }
@keyframes stripes { from { background-position: 0 0; } to { background-position: 18px 0; } }
.progress-bar.is-failed { background: var(--danger); }

/* 失败 */
.task-error { padding: 0 16px 16px; }
.task-error .err-msg { font-size: 13px; color: var(--danger); margin: 0 0 12px; display: flex; gap: 8px; align-items: flex-start; }
.task-error .err-msg svg { flex: none; margin-top: 1px; }
.task-error .err-detail { font-size: 12px; color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px; margin: -4px 0 12px; }

/* 结果（锁 / 解锁） */
.result { padding: 4px 16px 16px; }
.result-locked { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid #fde68a; background: #fffbeb; border-radius: var(--radius); }
.lock-icon { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: #fef3c7; color: #b45309; }
.result-locked .rl-text { flex: 1; min-width: 0; }
.result-locked .rl-title { font-weight: 600; font-size: 13.5px; word-break: break-all; }
.result-locked .rl-sub { font-size: 12px; color: #a16207; }
.result-unlocked { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid #bbf7d0; background: var(--success-soft); border-radius: var(--radius); }
.unlock-icon { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: #dcfce7; color: var(--success); }
.result-unlocked .ru-text { flex: 1; min-width: 0; }
.result-unlocked .ru-title { font-weight: 600; font-size: 13.5px; color: var(--success); word-break: break-all; }
.result-unlocked .ru-path { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-actions { display: flex; gap: 10px; margin-top: 12px; }
.result-actions .btn { flex: 1; }

/* ---------- 模态 / 抽屉 ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 28, 48, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 440px; max-width: calc(100vw - 40px); background: var(--surface);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 22px;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-sub { font-size: 13px; color: var(--text-muted); margin: 6px 0 16px; }
.modal-sub code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }

.code-input {
  width: 100%; padding: 14px 14px; border: 2px solid var(--border-strong); border-radius: var(--radius);
  font-size: 20px; font-weight: 700; letter-spacing: 3px; text-align: center;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--text);
  text-transform: uppercase;
}
.code-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
.code-input.is-invalid { border-color: var(--danger); }
.code-error { margin: 12px 0 0; font-size: 13px; color: var(--danger); background: var(--danger-soft); border: 1px solid #fecaca; padding: 10px 12px; border-radius: var(--radius-sm); }
.code-error .ce-detail { display: block; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
/* 授权码弹框内的购买引导：微信二维码 + 价格 */
.code-buy {
  display: flex; align-items: center; gap: 14px;
  margin-top: 16px; padding: 12px 14px;
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.code-qr { width: 116px; height: 116px; border-radius: 8px; border: 1px solid var(--border); flex: none; }
.code-buy-text { min-width: 0; }
.cb-title { margin: 0 0 4px; font-size: 13.5px; font-weight: 700; color: var(--text); }
.cb-sub { margin: 0; font-size: 12.5px; color: var(--text-muted); line-height: 1.6; }
.cb-sub b { color: var(--primary); font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-actions .btn { min-width: 96px; }

.form-row { display: flex; flex-direction: column; gap: 7px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text); }

/* ---------- 文档预览 ---------- */
/* 安全模型：内容经服务端「转PDF + 截前3页 + 烧水印」后以 Blob 一次性下发，
   OFV(pdf.js) 渲染；原始文件与下载地址全程不出现。 */
.preview-overlay { position: fixed; inset: 0; z-index: 40; background: #525659; display: flex; flex-direction: column; }
.preview-topbar { height: 48px; background: #323639; color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 14px; flex: none; }
.pv-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-count { font-size: 12px; color: #babcbe; flex: none; }
.pv-close { margin-left: auto; color: #fff; }
.preview-scroll { flex: 1; overflow: hidden; position: relative; min-height: 0; }
.pv-loading, .pv-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #e8e8e8; font-size: 14px; }
.pv-error { color: #ffb4b4; }
.pv-hint { flex: none; background: rgba(255, 193, 7, .16); color: #ffd54f; font-size: 13px; text-align: center; padding: 9px 14px; }
.preview-bottombar { height: 56px; background: #323639; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; gap: 12px; flex: none; }
.pv-tip { color: #babcbe; font-size: 12.5px; }
/* 桌面版（exe）没有服务端预览，按钮整体隐藏 */
body:not(.is-web) [data-action="preview"] { display: none; }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast {
  min-width: 240px; max-width: 380px; padding: 12px 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 13px; display: flex; align-items: flex-start; gap: 10px;
  animation: toastin .2s ease; border-left: 4px solid var(--text-faint);
}
.toast.out { animation: toastout .25s ease forwards; }
@keyframes toastin { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastout { to { transform: translateY(8px); opacity: 0; } }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--primary); }
.toast .t-icon { flex: none; margin-top: 1px; }
.toast.success .t-icon { color: var(--success); }
.toast.error .t-icon { color: var(--danger); }
.toast.info .t-icon { color: var(--primary); }
.toast .t-msg { color: var(--text); }

@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   响应式：平板 / 手机
   桌面版是 408px 表单 + 列表的双列，窄屏必须退成单列，
   并把点击目标放大到手指够得着的尺寸。
   ============================================================ */
@media (max-width: 820px) {
  .topbar {
    height: auto; flex-wrap: wrap; gap: 10px 12px;
    padding: 10px 14px;
  }
  .topbar-actions { margin-left: auto; }
  .tagline { padding: 10px 14px 0; text-align: left; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 14px 14px 24px; }
  .panel { padding: 14px; }
  .dropzone { padding: 26px 14px; }
  .btn { min-height: 40px; }
  /* 6 步进度条在窄屏放不下，允许横向滑动而不是挤成一团 */
  .stepper { overflow-x: auto; padding-bottom: 6px; }
  .step-label { font-size: 11px; white-space: nowrap; }
  .code-input { font-size: 17px; letter-spacing: 1px; }
  .toast-wrap { left: 12px; right: 12px; }
  .toast { max-width: none; }
  /* 待授权卡片：文件名独占一行，两个按钮折行均分，不再撑破屏幕 */
  .result-locked { flex-wrap: wrap; }
  .result-locked .rl-text { flex: 1 1 100%; }
  .result-locked .btn { flex: 1; justify-content: center; }
  /* 已解锁卡片的操作按钮同样允许折行 */
  .result-actions { flex-wrap: wrap; }
  .result-actions .btn { flex: 1 1 46%; }
  /* 任务列表头：计数与按钮折行 */
  .tasks-head { flex-wrap: wrap; }
  /* 预览底栏：长提示文字（中文无空格，min-content 是一整行）允许收缩换行，
     底栏整体可折行增高，不再横向溢出 */
  .preview-bottombar { flex-wrap: wrap; height: auto; min-height: 56px; padding: 8px 16px; row-gap: 6px; }
  .pv-tip { min-width: 0; flex: 1 1 100%; }
  /* 授权码弹框的购买引导：窄屏改上下布局，二维码居中 */
  .code-buy { flex-direction: column; align-items: center; text-align: center; gap: 10px; }
}

@media (max-width: 480px) {
  /* 品牌区与用户区整体收紧，目标：一行放下 品牌+用户名+退出登录 */
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand { gap: 6px; }
  .brand-logo { width: 24px; height: 24px; }
  .brand-name { font-size: 13.5px; }
  .brand-version { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn { height: 32px; padding: 0 10px; font-size: 12.5px; }
  .user-chip, .web-user { font-size: 12px; padding: 3px 8px; gap: 4px; }
  /* 用户名胶囊过长时截断，不挤掉退出按钮 */
  .web-user { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; }
  .tagline { font-size: 12.5px; }
  .format-toggle { gap: 8px; }
  .format-btn { flex: 1; padding: 10px 6px; }
  .tasks-head { flex-wrap: wrap; }
  .tasks-count { margin-right: 0; }
  .btn-sm { padding: 7px 12px; }
  .modal { padding: 18px; }
  .login-card { padding: 22px 18px; }
}

/* ============================================================
   Web 版专属
   ============================================================ */
/* 「打开所在文件夹」在 Web 版没意义：文件在服务器上，不在访问者电脑里 */
body.is-web [data-action="open"] { display: none; }

.web-user {
  font-size: 13px; color: var(--text-muted);
  padding: 4px 10px; border-radius: 999px; background: var(--surface-2);
  white-space: nowrap;
}

/* 登录弹框：未登录时可随时关闭，只在用户发起需要会话的操作时弹出 */
.login-mask {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(20, 28, 48, .45);
  animation: fade .15s ease;
}
.login-mask[hidden] { display: none; }
.login-card {
  position: relative;
  width: 100%; max-width: min(380px, calc(100vw - 40px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 28px 24px;
  animation: pop .18s ease;
}
.login-card .modal-close { position: absolute; top: 10px; right: 10px; }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand img { border-radius: 14px; }
.login-brand h2 { margin: 12px 0 4px; font-size: 17px; font-weight: 700; }
.login-sub { margin: 0; font-size: 13px; color: var(--text-muted); }
.login-err {
  margin: 10px 0 0; padding: 9px 12px; font-size: 13px;
  color: var(--danger); background: var(--danger-soft);
  border-radius: var(--radius-sm);
}
.btn-block { width: 100%; justify-content: center; margin-top: 18px; }
