/* ===== Local Reset =====
 * 这里原本通过 CDN @import 引入 Tailwind。但项目实际并未使用任何 Tailwind 工具类
 * （HTML 中出现的 42 个 class 全部由本文件定义），@import 只是借用了它的 preflight
 * 来重置浏览器默认样式。
 * 打包成 NSIS / MSIX 后应用可能运行在离线环境，CDN 请求会失败导致样式基线丢失；
 * 且商店应用依赖外部远程资源也存在合规风险。
 * 因此改为内联等价的精简 reset，保证离线与在线表现完全一致。
 */

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* 去掉浏览器对标题/段落的默认外边距（原先依赖 Tailwind preflight） */
h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* 表单控件继承页面字体与配色，避免各浏览器默认样式不一致 */
button, input, optgroup, select, textarea {
  font-family: inherit;
  font-size: 100%;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
}

button, select {
  text-transform: none;
}

button, [type="button"], [type="reset"], [type="submit"] {
  -webkit-appearance: button;
  background-color: transparent;
  background-image: none;
}

button, [role="button"] {
  cursor: pointer;
}

/* 媒体元素按块级渲染，避免行内基线产生额外间隙 */
img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  vertical-align: middle;
}

img, video {
  max-width: 100%;
  height: auto;
}

/* ===== Design Tokens ===== */
:root {
  --primary-1: #6366F1;
  --primary-2: #8B5CF6;
  --primary-3: #3B82F6;
  --bg-1: #F5F7FB;
  --bg-2: #FFFFFF;
  --bg-3: #EEF2FF;
  --text-1: #1F2937;
  --text-2: #6B7280;
  --text-3: #FFFFFF;
  --ok: #10B981;
  --err: #EF4444;
  --warn: #F59E0B;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px -12px rgba(99, 102, 241, 0.35);
  --shadow-soft: 0 4px 16px -6px rgba(31, 41, 55, 0.18);
  --gradient: linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #3B82F6 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-1);
  color: var(--text-1);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(139, 92, 246, 0.10), transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, rgba(59, 130, 246, 0.10), transparent 60%),
    var(--bg-1);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* 移动端地址栏会占用视口高度，100vh 会把状态栏顶出可视区；dvh 才是「当前可见高度」 */
  min-height: 100dvh;
}

/* ===== Top Navigation ===== */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  /* 窄屏放不下时换行（语言菜单 + 桌面版入口都在这一行） */
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 14px 28px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(99, 102, 241, 0.12);
  box-shadow: 0 4px 20px -12px rgba(99, 102, 241, 0.25);
}
.app-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.3px;
}
.app-logo .logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--gradient);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 20px;
  box-shadow: var(--shadow);
}
.nav-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-3);
  padding: 5px;
  border-radius: 12px;
}
.nav-tab {
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.25s ease;
}
.nav-tab.active {
  background: #fff;
  color: var(--primary-1);
  box-shadow: var(--shadow-soft);
}
.nav-tab:hover:not(.active) { color: var(--primary-1); }

/* 导航栏署名：低调但不缺席 */
.powered {
  padding-left: 12px;
  margin-left: 2px;
  border-left: 1px solid rgba(99, 102, 241, 0.18);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.nav-spacer { flex: 1; }

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.25s ease, opacity 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: var(--shadow);
}
.btn-primary:hover { box-shadow: 0 14px 34px -10px rgba(99, 102, 241, 0.55); transform: translateY(-1px); }
.btn-ghost {
  background: #fff;
  color: var(--primary-1);
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.btn-ghost:hover { background: var(--bg-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== Layout ===== */
.page { flex: 1; display: none; }
.page.active { display: flex; }

.workspace {
  display: grid;
  gap: 18px;
  padding: 18px 28px 28px;
  flex: 1;
  min-height: 0;
}

/* Editor layout: left params, center canvas, right export */
.editor-grid {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  gap: 18px;
  flex: 1;
  min-height: 0;
}
@media (max-width: 1200px) {
  .editor-grid { grid-template-columns: 260px 1fr; }
  .editor-grid .panel-export { grid-column: 1 / -1; }
}

/* ===== Card / Panel ===== */
.card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(99, 102, 241, 0.10);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.card:hover { box-shadow: 0 16px 40px -16px rgba(99, 102, 241, 0.3); }
.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-1);
}
.card-title .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gradient);
}

/* ===== Form controls ===== */
.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}
.input, .select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  color: var(--text-1);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.input:focus, .select:focus {
  border-color: var(--primary-1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg {
  display: flex;
  background: var(--bg-3);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 6px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.seg button.active {
  background: #fff;
  color: var(--primary-1);
  box-shadow: var(--shadow-soft);
}

.checkbox {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--text-1);
  cursor: pointer; user-select: none;
  padding: 6px 0;
}
.checkbox input { width: 17px; height: 17px; accent-color: var(--primary-1); }

.chip-group { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid rgba(99, 102, 241, 0.25);
  background: #fff;
  color: var(--text-2);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.chip.active {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-soft);
}

/* ===== Canvas Stage ===== */
.stage-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.stage-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.tool-btn {
  border: 1px solid rgba(99, 102, 241, 0.2);
  background: #fff;
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-1);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.tool-btn:hover { background: var(--bg-3); color: var(--primary-1); }
.zoom-label {
  font-size: 13px; color: var(--text-2);
  background: var(--bg-3); padding: 7px 12px; border-radius: 9px;
  min-width: 64px; text-align: center;
}
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background:
    linear-gradient(45deg, #eceef4 25%, transparent 25%),
    linear-gradient(-45deg, #eceef4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eceef4 75%),
    linear-gradient(-45deg, transparent 75%, #eceef4 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  border-radius: var(--radius);
  border: 1px solid rgba(99, 102, 241, 0.12);
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage-canvas-host {
  position: relative;
  transform-origin: top left;
}
.stage-canvas-host canvas { display: block; border-radius: 4px; }
/* OCR 文字块叠加框：只读展示，位置由 JS 按 0~1 相对坐标换算后写入 */
.ocr-box {
  position: absolute;
  z-index: 6;
  border: 1.5px solid rgba(99, 102, 241, 0.9);
  border-radius: 3px;
  background: rgba(99, 102, 241, 0.10);
  pointer-events: none;
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.35);
  animation: boxIn 0.32s cubic-bezier(.22,1,.36,1) both;
}
.ocr-box:hover {
  border-color: var(--primary-2);
  background: rgba(139, 92, 246, 0.18);
}
@keyframes boxIn {
  from { opacity: 0; transform: scale(1.04); }
  to { opacity: 1; transform: scale(1); }
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-2);
  text-align: center;
  pointer-events: none;
}
.empty-hint .big {
  width: 76px; height: 76px; border-radius: 22px;
  background: var(--bg-3);
  display: grid; place-items: center;
  font-size: 38px;
}

/* ===== Status bar ===== */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  padding: 10px 28px;
  /* 全面屏底部有 Home 手势条，留出安全区否则文字被盖 */
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  font-size: 12.5px;
  color: var(--text-2);
  background: rgba(255,255,255,0.7);
  border-top: 1px solid rgba(99,102,241,0.10);
  backdrop-filter: blur(8px);
}
.status-bar b { color: var(--text-1); font-weight: 600; }
/* 状态栏右侧的滚动提示：窄屏换行后不再强制顶到最右 */
.status-msg { margin-left: auto; color: var(--primary-1); }

/* ===== Toast ===== */
.toast-wrap {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: #fff;
  border-left: 4px solid var(--primary-1);
  border-radius: 12px;
  padding: 13px 18px;
  box-shadow: 0 14px 34px -10px rgba(31,41,55,0.35);
  font-size: 13.5px;
  color: var(--text-1);
  min-width: 240px;
  animation: toastIn 0.35s cubic-bezier(.22,1,.36,1);
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast.out { opacity: 0; transform: translateX(40px); transition: all .3s; }

/* ===== Modal ===== */
.modal-mask {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(31,41,55,0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
}
.modal-mask.show { display: flex; animation: fadeIn .25s ease; }
@keyframes fadeIn { from {opacity:0} to {opacity:1} }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 380px;
  box-shadow: 0 30px 60px -20px rgba(31,41,55,0.5);
  animation: modalIn .3s cubic-bezier(.22,1,.36,1);
}
@keyframes modalIn { from {opacity:0; transform: translateY(20px) scale(.97)} to {opacity:1} }
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ===== Batch page ===== */
.batch-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  flex: 1;
  min-height: 0;
}
.file-list { overflow: auto; min-height: 0; }
.view-toggle { display: flex; gap: 6px; }
.thumb-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.thumb-card {
  background: #fff;
  border: 1px solid rgba(99,102,241,0.12);
  border-radius: 14px;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  cursor: default;
}
.thumb-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-soft); }
.thumb-card img { width: 100%; height: 110px; object-fit: cover; background: #f0f1f6; }
.thumb-card .meta { padding: 9px 11px; font-size: 12px; color: var(--text-2); }
.thumb-card .meta b { color: var(--text-1); display: block; font-size: 12.5px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-row {
  display: grid;
  grid-template-columns: 40px 1fr 90px 80px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(99,102,241,0.08);
  font-size: 13px;
}
.detail-row .ficon { font-size: 20px; }
.detail-row .fname { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-row .fstat { color: var(--text-2); font-size: 12px; text-align: right; }
.detail-row .badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg-3); color: var(--primary-1); text-align: center; }

.progress-track { height: 8px; background: var(--bg-3); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: var(--gradient); width: 0%; transition: width .25s; border-radius: 999px; }

.hint-text { font-size: 12px; color: var(--text-2); line-height: 1.6; }
.divider { height: 1px; background: rgba(99,102,241,0.10); margin: 14px 0; }
.scroll-y { overflow-y: auto; }

/* ===== OCR: 拖拽导入 ===== */
.drop-zone { position: relative; }
.drop-zone.dragging {
  border-color: var(--primary-1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18), var(--shadow-soft);
}
.drop-mask {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: rgba(99, 102, 241, 0.10);
  color: var(--primary-1);
  font-weight: 600;
  font-size: 14px;
  pointer-events: none;
}
.drop-zone.dragging .drop-mask { display: flex; }

/* ===== OCR: 选项面板 ===== */
/* 引擎名较长，窄栏里横向排会挤成两行，改为纵向堆叠 */
.seg-col { flex-direction: column; }
.seg-col button { text-align: left; padding: 9px 12px; }
.seg button:disabled { opacity: 0.45; cursor: not-allowed; }
.field.is-disabled { opacity: 0.55; }
.field.is-disabled .select { pointer-events: none; }
.lang-note { margin-top: 6px; color: var(--warn); }

/* ===== OCR: 结果面板 ===== */
.result-head { display: flex; align-items: center; margin-bottom: 12px; }
.stat-pill {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--primary-1);
  margin-left: 6px;
  white-space: nowrap;
}
.result-box {
  flex: 1;
  min-height: 180px;
  width: 100%;
  resize: none;
  padding: 12px 14px;
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 12px;
  background: #fff;
  color: var(--text-1);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.7;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.result-box:focus { border-color: var(--primary-1); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-actions .btn { justify-content: center; }
.result-actions .btn:last-child { grid-column: 1 / -1; }

/* ===== OCR: 队列状态徽标 ===== */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--primary-1);
  white-space: nowrap;
}
.badge.done { background: rgba(16, 185, 129, 0.14); color: var(--ok); }
.badge.running { background: rgba(99, 102, 241, 0.14); color: var(--primary-1); }
.badge.fail { background: rgba(239, 68, 68, 0.14); color: var(--err); }
.thumb-card .meta .badge { margin-top: 5px; }

/* ===== 无障碍：视觉隐藏但仍可被读屏与爬虫读到 =====
 * 用 1×1px + clip 而不是 display:none —— 后者会连同内容一起从无障碍树里摘掉。
 * H1 就是靠这个类挂在页面顶部，不参与布局也不影响观感。
 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ===== 子页面承载（iframe 填满可用高度） ===== */
.page { min-height: 0; }
.page > iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ===== 语言菜单（构建期写入的真实 <a> 链接） ===== */
.lang-menu { position: relative; }
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--primary-1);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}
.lang-toggle:hover { background: var(--bg-3); }
.caret { font-size: 11px; transition: transform 0.2s ease; }
.lang-menu.open .caret { transform: rotate(180deg); }

.lang-list {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 176px;
  /* 13 种语言排下来约 545px：桌面端一屏放下（560px 上限），
   * 小屏则被 70vh 压住并允许内部滚动，保证菜单位置始终收敛在视口内 */
  max-height: min(70vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  background: #fff;
  border: 1px solid rgba(99, 102, 241, 0.14);
  border-radius: 12px;
  box-shadow: 0 18px 40px -16px rgba(31, 41, 55, 0.35);
  z-index: 60;
}
/* 桌面端靠 hover 更顺手，触屏端没有 hover，必须靠点击加上的 .open。
 * 只写 :hover 的话，触屏点一下反而会把菜单关掉，等于完全不可用。 */
.lang-menu:hover .lang-list,
.lang-menu.open .lang-list { display: block; }
.lang-list a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-1);
  font-size: 13.5px;
  text-decoration: none;
  touch-action: manipulation;
}
.lang-list a:hover { background: var(--bg-3); color: var(--primary-1); }
.lang-list a.active { background: var(--bg-3); color: var(--primary-1); font-weight: 600; }
/* 选中标记：用 visibility 隐藏而不是不渲染，保证各语言名称左边缘对齐 */
.lang-check { width: 1.1em; flex: none; color: var(--primary-1); font-size: 12px; }
.lang-check.is-off { visibility: hidden; }

/* ===== 品牌位：桌面版入口（外链） ===== */
.store-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 5px 12px;
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-1);
  text-decoration: none;
  touch-action: manipulation;
}
.store-badge:hover { background: var(--bg-3); }
.store-badge-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--gradient);
  color: #fff;
  flex: none;
}
.store-badge-text { display: flex; flex-direction: column; line-height: 1.25; }
.store-badge-text b { font-size: 12.5px; font-weight: 600; }
.store-badge-text span { font-size: 11px; color: var(--text-2); }
.store-badge-arrow { color: var(--primary-1); font-size: 13px; }

/* ===== 模板里被内联样式顶掉的布局（挪进 CSS，便于媒体查询覆盖） ===== */
.drop-zone {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 18px;
}
.toolbar-card {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 18px;
}
.card-head { display: flex; align-items: center; margin-bottom: 12px; }
.card-title-flat { margin: 0; }
.stat-row { display: flex; flex-wrap: wrap; margin-bottom: 10px; }
.panel-stage { padding: 14px; }
.static-hint { position: static; }

/* ===== 触屏：加大触控目标，去掉 300ms 点击延迟 ===== */
.btn, .nav-tab, .tool-btn, .seg button, .chip, .checkbox, .lang-toggle, .lang-list a, .store-badge {
  touch-action: manipulation;
}
.btn { min-height: 40px; }
.tool-btn { min-height: 38px; }
.nav-tab { min-height: 38px; }
.seg button { min-height: 36px; }

/* ===== 移动端适配 ===== */
/* ≤860px：菜单栏/工具栏换行；工作区由左右两栏改为上下堆叠 */
@media (max-width: 860px) {
  .app-nav { padding: 10px 14px; gap: 10px 12px; }
  .nav-tabs { order: 3; width: 100%; overflow-x: auto; }
  .nav-tab { white-space: nowrap; }
  .workspace { padding: 14px 14px 18px; gap: 14px; }
  .editor-grid,
  .batch-grid { grid-template-columns: 1fr; }
  .editor-grid .panel-stage { min-height: 240px; }
  .editor-grid .panel-export { grid-column: auto; }
  .drop-zone { flex-direction: column; align-items: flex-start; }
  .status-bar { gap: 6px 14px; padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); }
  .status-msg { margin-left: 0; width: 100%; }
}

/* ≤640px：隐藏次要提示文案，缩小徽章，收紧内边距 */
@media (max-width: 640px) {
  .import-hint { display: none; }
  /* 徽章只留主标语，避免在 320px 宽的屏幕上把导航挤成三行 */
  .store-badge-text span { display: none; }
  .store-badge { padding: 5px 9px; gap: 7px; }
  .card { padding: 14px; }
  .detail-row { grid-template-columns: 28px 1fr auto auto; gap: 8px; }
  .checkbox { padding: 10px 0; }
  .checkbox input { width: 20px; height: 20px; }
}

/* 横屏且很矮：恢复左右两栏，保证主视图（画布/队列）还有高度 */
@media (max-height: 480px) and (orientation: landscape) {
  .app-nav { position: static; }
  .editor-grid { grid-template-columns: 260px minmax(0, 1fr); }
  .batch-grid { grid-template-columns: minmax(0, 1fr) 260px; }
}

/* ===== 防止窄屏横向溢出 =====
 * 栅格轨道默认是 minmax(auto, 1fr)，而栅格项默认 min-width:auto：
 * 只要里面有一个「内容偏宽」的元素（画布、长语种名、文件行），整条轨道就会被撑得
 * 比容器还宽，页面于是横向溢出——320px 屏上实测会多出 26px。
 * 这里把轨道下限压到 0、并给栅格项 min-width:0，让内部 overflow 容器去承担滚动。
 */
.workspace { grid-template-columns: minmax(0, 1fr); }
.workspace > *,
.editor-grid > *,
.batch-grid > * { min-width: 0; }
.editor-grid { grid-template-columns: 300px minmax(0, 1fr) 320px; }
.batch-grid { grid-template-columns: minmax(0, 1fr) 320px; }
@media (max-width: 1200px) {
  .editor-grid { grid-template-columns: 260px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .editor-grid,
  .batch-grid { grid-template-columns: minmax(0, 1fr); }
}
