/*
 * 手机版布局。
 * 只在 html.is-mobile 下生效（由 index.html 的启动脚本按设备判定，
 * 横屏也不会掉回电脑三栏）。桌面样式仍然完全由 styles.css 负责。
 */

/* 手机专用元素在桌面上必须彻底隐藏 */
.mobile-tools,
.mobile-add-page,
.mobile-empty-add,
.mobile-crop-bar,
.mobile-only,
.language-chip { display: none; }

html.is-mobile {
  --mobile-header: 54px;
  --mobile-film: 78px;
  --mobile-toolbar: 58px;
  --mobile-gutter: 12px;
  height: 100%;
  overflow: hidden;
  background: #efebe2;
  -webkit-text-size-adjust: 100%;
}

html.is-mobile,
html.is-mobile * {
  -webkit-tap-highlight-color: transparent;
}

html.is-mobile button {
  touch-action: manipulation;
}

html.is-mobile .site-header,
html.is-mobile .pages,
html.is-mobile .controls,
html.is-mobile .mobile-tools {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html.is-mobile ::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

html.is-mobile * { scrollbar-width: none; }

html.is-mobile,
html.is-mobile body {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

html.is-mobile body {
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #efebe2;
  overscroll-behavior: none;
}

/* ---------- 顶栏 ---------- */

html.is-mobile .site-header {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  padding-top: env(safe-area-inset-top);
  background: #fff;
  border-bottom: 1px solid var(--line);
}

html.is-mobile .topbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  height: var(--mobile-header);
  padding: 0 10px;
}

html.is-mobile .brand {
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

html.is-mobile .logo {
  width: 24px;
  height: 24px;
  margin: 0;
}

html.is-mobile .brand-copy { min-width: 0; }

html.is-mobile h1 {
  font-size: 17px;
  line-height: 1.1;
  gap: 0;
}

html.is-mobile #brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

html.is-mobile #brand-en {
  display: none;
  font-size: 17px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* 中文只显示「叶文净」，其他语言只显示 PuriDoc，避免两个品牌名挤在一起 */
html.is-mobile #brand-name[hidden] + #brand-en { display: inline; }

html.is-mobile .brand-copy p { display: none; }

html.is-mobile .action-bar {
  flex: 0 0 auto;
  gap: 6px;
  margin-left: 0;
}

html.is-mobile #add-button,
html.is-mobile #export-button {
  height: 38px;
  min-height: 38px;
  padding: 0 11px;
  border-radius: 11px;
  font-size: 14px;
  white-space: nowrap;
}

html.is-mobile #export-button { padding-inline: 10px; }
html.is-mobile #export-button:disabled {
  background: #eceae4;
  color: #9aa19c;
}

html.is-mobile .language-label {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--quiet-line);
  border-radius: 12px;
  background: #fff;
}

html.is-mobile .language-chip {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}

html.is-mobile #language {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  opacity: 0;
  font-size: 16px;
  background: transparent;
  border: 0;
}

/* ---------- 工作区骨架 ---------- */

html.is-mobile .workspace {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  gap: 0;
  overflow: hidden;
}

html.is-mobile .stage {
  order: 1;
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 0;
  gap: 0;
  overflow: hidden;
}

html.is-mobile .empty,
html.is-mobile .compare,
html.is-mobile .text-preview { grid-row: auto; }

/* ---------- 空状态 / 介绍 ---------- */

html.is-mobile .empty {
  flex: 1 1 auto;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  justify-content: safe center;
  gap: 16px;
  width: 100%;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 22px 18px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(120% 60% at 50% 0%, #fffdf8 0%, #f7f4ec 58%, #f1eee6 100%);
  box-shadow: none;
  text-align: start;
}

html.is-mobile .empty[hidden] { display: none; }

html.is-mobile .hero-copy {
  display: grid;
  gap: 10px;
}

html.is-mobile .empty strong {
  font-size: clamp(25px, 7.3vw, 30px);
  line-height: 1.2;
  letter-spacing: -0.035em;
}

html.is-mobile .hero-copy > span {
  font-size: 15px;
  line-height: 1.62;
  color: var(--muted);
  max-width: 34rem;
}

html.is-mobile .mobile-empty-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: stretch;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 15px;
  background: var(--sage);
  color: #f4fff8;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 24px rgba(22, 130, 74, 0.22);
}

html.is-mobile .hero-scenes {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0;
}

html.is-mobile .hero-card {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  grid-template-areas:
    "art title"
    "art body";
  align-items: center;
  justify-items: start;
  gap: 1px 12px;
  padding: 10px 13px;
  min-height: 76px;
  border-radius: 16px;
  background: #f7f4ed;
  border: 1px solid rgba(28, 36, 48, 0.05);
  text-align: start;
}

html.is-mobile .hero-card:nth-child(2) {
  background: #eef8f2;
  border-color: #d7efe4;
}

html.is-mobile .hero-art {
  grid-area: art;
  justify-self: center;
  display: grid;
  place-items: center;
  width: 66px;
  height: 54px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  overflow: hidden;
}

html.is-mobile .hero-art svg {
  width: 62px;
  height: auto;
  max-width: none;
}

html.is-mobile .hero-card strong {
  grid-area: title;
  font-size: 15px;
  letter-spacing: -0.01em;
}

html.is-mobile .hero-card span {
  grid-area: body;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

html.is-mobile .hero-foot {
  margin: 0;
  padding: 0;
  text-align: center;
}

html.is-mobile .hero-drop {
  display: block;
  font-size: 12px;
  line-height: 1.5;
  color: #7d857f;
}

html.is-mobile .hero-drop-key { display: none; }
html.is-mobile .hero-drop-touch { display: inline; }

/* ---------- 预览 ---------- */

html.is-mobile .compare {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  height: auto;
  min-height: 0;
  gap: 0;
}

html.is-mobile .compare[hidden] { display: none; }

html.is-mobile .compare .pane,
html.is-mobile .compare .pane-original,
html.is-mobile .compare .pane-result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

html.is-mobile .compare .pane-original { display: none; z-index: 2; }
html.is-mobile .compare.show-original .pane-result { display: none; }
html.is-mobile .compare.show-original .pane-original { display: flex; }
html.is-mobile .compare.is-crop .pane-original { display: flex; }
html.is-mobile .compare.is-crop .pane-result { display: none; }

html.is-mobile .compare .view-switch {
  position: absolute;
  z-index: 7;
  top: 8px;
  left: 8px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px;
  width: auto;
  padding: 2px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 16px rgba(28, 36, 48, 0.12);
}

html.is-mobile .view-switch button {
  min-width: 52px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
}

html.is-mobile .view-switch button.is-on {
  background: var(--mint);
  color: var(--sage-deep);
  border-color: rgba(22, 130, 74, 0.35);
}

html.is-mobile .compare .pane-title {
  position: absolute;
  z-index: 7;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 2px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 16px rgba(28, 36, 48, 0.12);
}

html.is-mobile .pane-title h3 { display: none; }

html.is-mobile .zoom-controls {
  display: flex;
  align-items: center;
  gap: 1px;
  direction: ltr;
}

html.is-mobile .zoom-controls button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
  font-size: 18px;
}

html.is-mobile .zoom-readout {
  min-width: 42px;
  font-size: 11px;
}

html.is-mobile .pane-original .zoom-controls { display: none; }
html.is-mobile .compare.show-original:not(.is-crop) .pane-original .zoom-controls { display: flex; }
html.is-mobile .compare.show-original .pane-result .zoom-controls { display: none; }

html.is-mobile .compare .pane-view,
html.is-mobile #result-view.pane-view,
html.is-mobile #original-view.pane-view {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: #e7e3da;
  overflow: hidden;
}

html.is-mobile .result-stage {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 48px 0 20px;
  overflow: auto;
  border-radius: 0;
  background: transparent;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: none;
}

html.is-mobile .result-frame {
  min-width: 100%;
  min-height: 100%;
  width: max-content;
  height: max-content;
}

html.is-mobile #result-canvas,
html.is-mobile #original-canvas {
  max-width: none;
  max-height: none;
  touch-action: none;
  box-shadow: 0 10px 28px rgba(28, 36, 48, 0.14);
}

html.is-mobile .compare.is-crop .view-switch,
html.is-mobile .compare.is-crop .pane-title { display: none; }

html.is-mobile .compare.is-crop #original-view.pane-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 52px 30px 34px;
  overflow: hidden;
}

html.is-mobile .compare.is-crop #original-stage { display: none; }

html.is-mobile .compare.is-crop #crop-layer {
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  touch-action: none;
}

html.is-mobile .corner-handle {
  width: 36px;
  height: 36px;
}

/* 状态条：浮在预览底部，不参与布局 */
html.is-mobile .status {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 10px;
  z-index: 9;
  width: max-content;
  max-width: calc(100% - 24px);
  transform: translateX(-50%);
  min-height: 0;
  margin: 0;
  padding: 5px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 3px 12px rgba(28, 36, 48, 0.08);
  pointer-events: none;
}

html.is-mobile .status:empty { display: none; }
html.is-mobile .status { transition: opacity 0.2s ease; }

/* 选角是模态操作：只剩预览和顶部的确认 / 取消 */
html.is-mobile .workspace.is-cropping .pages,
html.is-mobile .workspace.is-cropping .controls,
html.is-mobile .workspace.is-cropping .mobile-tools { display: none !important; }

/* 裁切时的悬浮操作条 */
html.is-mobile .mobile-crop-bar {
  position: absolute;
  z-index: 14;
  top: 10px;
  left: 10px;
  right: 10px;
  display: none;
  grid-template-columns: 1fr 1.35fr;
  gap: 8px;
  padding: 6px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 8px 26px rgba(28, 36, 48, 0.16);
}

html.is-mobile .mobile-crop-bar:not([hidden]) { display: grid; }
html.is-mobile .mobile-crop-bar button {
  min-height: 44px;
  border-radius: 11px;
  font-size: 14px;
}

/* ---------- 底部缩略图条 ---------- */

html.is-mobile .pages {
  order: 2;
  display: none;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  height: var(--mobile-film);
  padding: 6px 8px;
  border-radius: 0;
  border-top: 1px solid var(--line);
  background: #fff;
  box-shadow: none;
  overflow: hidden;
}

html.is-mobile .workspace.has-pages .pages { display: flex; }

html.is-mobile .pages h2,
html.is-mobile .pages > .insert-actions { display: none; }

html.is-mobile .page-list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

html.is-mobile .page-list::-webkit-scrollbar { display: none; }

html.is-mobile .page-row {
  display: block;
  flex: 0 0 46px;
  width: 46px;
  gap: 0;
  scroll-snap-align: start;
}

html.is-mobile .page-button {
  position: relative;
  display: block;
  width: 46px;
  height: 62px;
  min-height: 0;
  padding: 2px;
  border-radius: 8px;
  background: #f3f0e9;
  font-size: 0;
  text-align: center;
  overflow: hidden;
}

html.is-mobile .page-button canvas {
  display: block;
  width: 42px;
  height: 58px;
  object-fit: contain;
  border-radius: 5px;
  background: #fff;
}

html.is-mobile .page-button > span { display: none; }

html.is-mobile .page-button::after {
  content: attr(data-page);
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: rgba(28, 36, 48, 0.62);
  color: #fff;
  font-size: 9px;
  line-height: 15px;
  font-weight: 600;
  text-align: center;
}

html.is-mobile .page-button.is-selected {
  outline: 2px solid var(--sage);
  outline-offset: 0;
  background: #fff;
}

html.is-mobile .page-button.is-selected::after {
  background: var(--sage);
}

html.is-mobile .page-order { display: none; }

html.is-mobile .mobile-add-page {
  flex: 0 0 46px;
  width: 46px;
  height: 62px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(28, 36, 48, 0.22);
  border-radius: 9px;
  background: #faf8f3;
  color: var(--sage);
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
}

/* ---------- 工具面板 ---------- */

html.is-mobile .controls {
  order: 3;
  display: none;
  flex: 0 0 auto;
  max-height: 32dvh;
  padding: 6px 12px;
  border-radius: 0;
  border-top: 1px solid var(--line);
  background: #fff;
  box-shadow: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html.is-mobile .workspace.has-pages[data-mobile-panel] .controls { display: block; }

/* 打开工具面板时收起缩略图条，把高度留给当前页 */
html.is-mobile .workspace.has-pages[data-mobile-panel] .pages { display: none; }

html.is-mobile .tool-drawer,
html.is-mobile .tool-drawer[open] { display: block; }
html.is-mobile .tool-drawer > summary { display: none; }

html.is-mobile .tool-drawer .controls-stack,
html.is-mobile .controls-stack {
  display: block;
  max-height: none;
  padding: 0;
  overflow: visible;
}

html.is-mobile .controls-stack > .tool-group,
html.is-mobile .controls-stack > #delete-page,
html.is-mobile .controls-stack > .insert-actions,
html.is-mobile .controls-stack > .mobile-page-move { display: none; }

html.is-mobile .workspace[data-mobile-panel="straighten"] .controls-stack > [data-tool-panel="straighten"],
html.is-mobile .workspace[data-mobile-panel="erase"] .controls-stack > [data-tool-panel="erase"],
html.is-mobile .workspace[data-mobile-panel="handwriting"] .controls-stack > [data-tool-panel="handwriting"],
html.is-mobile .workspace[data-mobile-panel="more"] .controls-stack > .insert-actions,
html.is-mobile .workspace[data-mobile-panel="more"] .controls-stack > .mobile-page-move,
html.is-mobile .workspace[data-mobile-panel="more"] .controls-stack > #delete-page {
  display: grid;
}

html.is-mobile .workspace[data-mobile-panel="more"] .controls-stack > #delete-page { display: block; }

html.is-mobile .mobile-page-move {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

html.is-mobile .mobile-page-move button {
  min-height: 38px;
  font-size: 12.5px;
}

html.is-mobile .tool-group {
  gap: 6px;
  padding: 0;
  border: 0;
}

html.is-mobile .tool-group h2 { display: none; }

html.is-mobile .rotate-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

html.is-mobile .tool-group[data-tool-panel="straighten"] .rotate-row:first-of-type {
  display: flex;
}

html.is-mobile .tool-group[data-tool-panel="straighten"] .rotate-row:first-of-type > button {
  flex: 1 1 0;
}

html.is-mobile .rotate-row > button,
html.is-mobile .controls button {
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 13px;
}

html.is-mobile .controls label {
  display: grid;
  gap: 2px;
}

html.is-mobile .controls label span {
  font-size: 11px;
}

html.is-mobile #fine,
html.is-mobile #eraser-size {
  height: 26px;
  touch-action: none;
}

html.is-mobile input[type="range"]::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -9px;
}

html.is-mobile .eraser-options {
  padding: 6px;
  border-radius: 11px;
  gap: 4px;
}

html.is-mobile .eraser-options[hidden] { display: none; }

html.is-mobile [data-tool-panel="erase"] { gap: 6px; }

html.is-mobile [data-tool-panel="erase"] .rotate-row > button {
  min-height: 36px;
  font-size: 12.5px;
}

html.is-mobile [data-tool-panel="erase"] .eraser-options .rotate-row > button {
  min-height: 34px;
}

html.is-mobile [data-tool-panel="erase"] label span { font-size: 10.5px; }

html.is-mobile [data-tool-panel="erase"] #eraser-size { height: 22px; }

html.is-mobile #run-handwriting {
  min-height: 42px;
}

html.is-mobile #delete-page {
  width: 100%;
  min-height: 42px;
  margin-top: 6px;
  border: 0;
  border-radius: 11px;
  background: #fff3ef;
  color: #a33b2d;
  font-size: 13px;
}

html.is-mobile .insert-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

html.is-mobile .insert-actions button {
  min-height: 40px;
  border-radius: 10px;
  font-size: 12.5px;
  white-space: nowrap;
}

/* ---------- 底部工具栏 ---------- */

html.is-mobile .mobile-tools {
  order: 4;
  flex: 0 0 auto;
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  padding: 3px 6px calc(3px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
  z-index: 25;
}

html.is-mobile .workspace.has-pages .mobile-tools { display: grid; }

html.is-mobile .mobile-tools button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  height: 46px;
  padding: 0 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #626b66;
  font-size: 10px;
  line-height: 1.1;
  box-shadow: none;
}

html.is-mobile .mobile-tools button svg {
  width: 20px;
  height: 20px;
  flex: none;
}

html.is-mobile .mobile-tools button.is-on {
  background: var(--mint);
  color: var(--sage-deep);
}

html.is-mobile .mobile-tools button:disabled {
  opacity: 0.45;
}

/* 没有页面时，底部 chrome 全部让位给介绍 */
html.is-mobile .workspace:not(.has-pages) .pages,
html.is-mobile .workspace:not(.has-pages) .controls,
html.is-mobile .workspace:not(.has-pages) .mobile-tools { display: none; }

/* ---------- 添加菜单 ---------- */

html.is-mobile .add-panel {
  position: fixed;
  left: 0;
  right: 0;
  top: auto;
  bottom: 0;
  z-index: 70;
  width: auto;
  max-height: min(88dvh, 600px);
  padding: 6px 12px calc(10px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 22px 22px 0 0;
  background: #fff;
  box-shadow: 0 -22px 54px rgba(28, 36, 48, 0.22);
}

html.is-mobile .add-panel::before {
  content: "";
  display: block;
  width: 38px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 999px;
  background: #e0ddd6;
}

html.is-mobile .add-title {
  display: block;
  margin: 0 6px 3px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

html.is-mobile .add-label {
  margin: 6px 6px 2px;
  font-size: 10.5px;
  font-weight: 600;
  color: #8a938e;
}

html.is-mobile .add-panel button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 12px;
  border: 0;
  border-radius: 11px;
  background: #f7f5f0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  text-align: start;
}

html.is-mobile .add-panel button::after {
  content: "›";
  flex: none;
  color: #a8b0aa;
  font-size: 18px;
  line-height: 1;
}

html.is-mobile .add-panel button:disabled { opacity: 0.45; }

/* ---------- 粘贴对话框 ---------- */

html.is-mobile #paste-dialog {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  right: 8px;
  bottom: auto;
  width: auto;
  max-width: none;
  max-height: calc(100dvh - max(16px, env(safe-area-inset-top)));
  margin: 0;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  transform: none;
  border-radius: 22px;
  overflow-y: auto;
}

html.is-mobile #paste-dialog strong { font-size: 19px; }

html.is-mobile .paste-hint {
  font-size: 14px;
  margin-top: 8px;
}

html.is-mobile .paste-hint-key { display: none; }
html.is-mobile .paste-hint-touch { display: flex; }

html.is-mobile #paste-catcher {
  min-height: 30dvh;
  max-height: 42dvh;
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  font-size: 16px;
  line-height: 1.55;
}

html.is-mobile .paste-close {
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  font-size: 24px;
}

/* ---------- 相机 ---------- */

html.is-mobile #camera-dialog {
  position: fixed;
  inset: max(8px, env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom));
  width: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 12px;
  border-radius: 20px;
  background: #10241c;
  overflow: hidden;
}

html.is-mobile #camera-video {
  width: 100%;
  max-height: calc(100dvh - 190px);
  border-radius: 14px;
}

html.is-mobile #camera-dialog .dialog-actions {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

html.is-mobile #camera-dialog .dialog-actions button {
  min-height: 46px;
  border-radius: 12px;
  font-size: 16px;
}

html.is-mobile #camera-error { color: #ffe4dc; }

/* ---------- 浮层 ---------- */

html.is-mobile .busy { z-index: 90; }
html.is-mobile .busy-card { width: min(340px, calc(100vw - 2rem)); }

/* 放大手势时禁用文本选择 */
html.is-mobile .result-stage,
html.is-mobile .result-stage canvas {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- 横屏 ---------- */

@media (max-height: 520px) {
  html.is-mobile {
    --mobile-header: 46px;
    --mobile-film: 64px;
    --mobile-toolbar: 48px;
  }

  html.is-mobile .topbar { height: var(--mobile-header); }
  html.is-mobile #add-button,
  html.is-mobile #export-button { height: 34px; min-height: 34px; font-size: 14px; }
  html.is-mobile .language-label { height: 34px; }
  html.is-mobile .pages { height: var(--mobile-film); padding-block: 3px; }
  html.is-mobile .page-button,
  html.is-mobile .mobile-add-page { height: 54px; }
  html.is-mobile .page-button canvas { height: 50px; }
  html.is-mobile .mobile-tools button { height: 42px; font-size: 10px; }
  html.is-mobile .mobile-tools button svg { width: 20px; height: 20px; }
  html.is-mobile .controls { max-height: 44dvh; }
  html.is-mobile .empty {
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 18px;
  }
  html.is-mobile .empty strong { font-size: 24px; }
  html.is-mobile .hero-copy { gap: 4px; }
  html.is-mobile .hero-copy > span { font-size: 13px; line-height: 1.45; }
  html.is-mobile .mobile-empty-add { min-height: 44px; }
  html.is-mobile .hero-scenes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  html.is-mobile .hero-card {
    display: block;
    min-height: 0;
    padding: 8px 10px;
  }
  html.is-mobile .hero-art { display: none; }
  html.is-mobile .hero-card strong { display: block; font-size: 14px; }
  html.is-mobile .hero-card span { display: block; font-size: 12px; line-height: 1.4; }
  html.is-mobile .hero-card:nth-child(3) { display: block; }
}

@media (max-width: 350px) {
  html.is-mobile #add-button,
  html.is-mobile #export-button { padding-inline: 9px; font-size: 14px; }
  html.is-mobile .language-label { width: 38px; }
  html.is-mobile .empty { padding-inline: 14px; }
  html.is-mobile .hero-card { grid-template-columns: 58px minmax(0, 1fr); }
  html.is-mobile .hero-art { width: 58px; height: 48px; }
  html.is-mobile .hero-art svg { width: 54px; }
}


html.is-mobile[dir="rtl"] .add-panel button::after {
  float: left;
  transform: scaleX(-1);
}


/* 小屏（320/360）把导出收成图标，给品牌和「添加」留出宽度。
   按钮仍有 data-i18n-aria，读屏名称不变。 */
@media (max-width: 360px) {
  html.is-mobile #export-button {
    display: grid;
    place-items: center;
    width: 40px;
    min-width: 40px;
    padding: 0;
    font-size: 0;
    overflow: hidden;
  }

  html.is-mobile #export-button::before {
    content: "";
    width: 19px;
    height: 19px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M7 10l5 5 5-5M5 21h14'/%3E%3C/svg%3E") center / 19px 19px no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M7 10l5 5 5-5M5 21h14'/%3E%3C/svg%3E") center / 19px 19px no-repeat;
  }

  html.is-mobile #add-button { padding-inline: 9px; font-size: 14px; }
  html.is-mobile .language-label { width: 38px; }
}
