/* —— 手机版布局：隐藏侧栏，预览铺满 —— */
body.mobile-mode {
  overflow: auto;
  -webkit-tap-highlight-color: transparent;
}

body.mobile-mode .app {
  display: flex;
  flex-direction: column;
  grid-template-columns: unset;
  height: auto;
  min-height: calc(100vh - 44px);
}

body.mobile-mode .editor-pane {
  display: none !important;
}

body.mobile-mode .preview-pane {
  flex: 1;
  min-height: 0;
}

body.mobile-mode .preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 8px 10px;
  gap: 8px;
  background: rgba(13, 15, 18, 0.94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

body.mobile-mode .preview-toolbar h1 {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.mobile-mode .toolbar-actions {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  width: 100%;
}

body.mobile-mode .toolbar-actions .btn,
body.mobile-mode .toolbar-actions .check {
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  white-space: nowrap;
  padding: 7px 4px;
  font-size: 11px;
}

body.mobile-mode .toolbar-actions .check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  color: #c4c7cc;
}

body.mobile-mode .phone-wrap {
  padding: 10px 10px 24px;
  align-items: center;
  justify-content: center;
}

body.mobile-mode .phone {
  width: min(390px, 100%);
  max-width: 390px;
  border-radius: 28px;
  padding: 8px;
  margin: 0 auto;
}

/* 仅在有手机外框时铺满；使用者页直接是 phone-screen，需限制宽度 */
body.mobile-mode .phone .phone-screen {
  width: 100%;
}

body.mobile-mode .phone-wrap > .phone-screen {
  width: min(390px, 100%);
  max-width: 390px;
  margin: 0 auto;
}

/* 可点击热区提示 */
body.mobile-mode #capture-root [data-field],
body.mobile-mode #capture-root [data-edit-target],
body.mobile-mode #capture-root .record[data-record-index],
body.mobile-mode #capture-root .tab[data-tab],
body.mobile-mode #capture-root .battery,
body.mobile-mode #capture-root .network-slot {
  cursor: pointer;
  border-radius: 4px;
  transition: outline-color 0.15s, background 0.15s;
}

body.mobile-mode #capture-root [data-field]:hover,
body.mobile-mode #capture-root [data-edit-target]:hover,
body.mobile-mode #capture-root .record[data-record-index]:hover,
body.mobile-mode #capture-root .tab[data-tab]:hover,
body.mobile-mode #capture-root .battery:hover,
body.mobile-mode #capture-root .network-slot:hover {
  outline: 1.5px dashed rgba(59, 130, 246, 0.85);
  outline-offset: 2px;
  background: rgba(59, 130, 246, 0.12);
}

body.mobile-mode #capture-root .slot[data-slot]:hover {
  outline: 1.5px dashed rgba(59, 130, 246, 0.85);
  outline-offset: 1px;
  background: rgba(59, 130, 246, 0.2) !important;
}

body.mobile-mode.edit-hint-off #capture-root [data-field]:hover,
body.mobile-mode.edit-hint-off #capture-root .record[data-record-index]:hover,
body.mobile-mode.edit-hint-off #capture-root .tab[data-tab]:hover,
body.mobile-mode.edit-hint-off #capture-root .battery:hover,
body.mobile-mode.edit-hint-off #capture-root .slot[data-slot]:hover {
  outline: none;
  background: transparent;
}

/* —— 底部弹窗 —— */
.me-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.me-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.me-sheet {
  width: min(420px, 100%);
  max-height: min(86vh, 640px);
  background: #1a1d24;
  color: #e8eaed;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  transform: translateY(24px);
  transition: transform 0.22s ease;
  font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
}

.me-overlay.is-open .me-sheet {
  transform: translateY(0);
}

.me-sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  margin: 10px auto 4px;
  flex-shrink: 0;
}

.me-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.me-sheet__title {
  font-size: 15px;
  font-weight: 600;
}

.me-sheet__close {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #e8eaed;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.me-sheet__body {
  padding: 14px 16px 8px;
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.me-field label {
  display: block;
  font-size: 12px;
  color: #9aa0a6;
  margin-bottom: 6px;
}

.me-field input,
.me-field textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #111318;
  color: #e8eaed;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

.me-field input:focus,
.me-field textarea:focus {
  border-color: #3b82f6;
}

.me-field textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.45;
}

.me-choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.me-choice {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #111318;
  color: #e8eaed;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.me-choice:active {
  background: rgba(255, 255, 255, 0.08);
}

.me-choice.is-active {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.18);
  color: #fff;
}

.me-sheet__foot {
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.me-sheet__foot .btn {
  flex: 1;
  justify-content: center;
  padding: 12px;
  font-size: 14px;
  border-radius: 10px;
}

.me-sheet__foot .btn-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.me-sheet__foot .btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
}

.me-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #c4c7cc;
}

.me-check input {
  width: 16px;
  height: 16px;
}

@media (min-width: 720px) {
  .me-overlay {
    align-items: center;
    padding: 24px;
  }

  .me-sheet {
    border-radius: 16px;
    max-height: 80vh;
  }

  .me-sheet__handle {
    display: none;
  }
}

/* —— iPhone 导出保存弹层 —— */
.export-save-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.export-save-modal[hidden] {
  display: none !important;
}

.export-save-modal__sheet {
  width: min(440px, 100%);
  max-height: 92dvh;
  background: #1a1d24;
  color: #e8eaed;
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
}

.export-save-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.export-save-modal__title {
  font-size: 16px;
  font-weight: 600;
}

.export-save-modal__close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #e8eaed;
  font-size: 18px;
  cursor: pointer;
}

.export-save-modal__hint {
  font-size: 12px;
  color: #9aa0a6;
  line-height: 1.4;
}

.export-save-modal__preview {
  overflow: auto;
  max-height: 58dvh;
  border-radius: 12px;
  background: #0b0d10;
  text-align: center;
}

.export-save-modal__preview img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-touch-callout: default;
  user-select: auto;
  -webkit-user-select: auto;
}

.export-save-modal__actions {
  display: flex;
  gap: 8px;
}

.export-save-modal__actions .btn {
  flex: 1;
  justify-content: center;
  padding: 12px;
  font-size: 14px;
  border-radius: 10px;
}

@media (min-width: 720px) {
  .export-save-modal {
    align-items: center;
    padding: 24px;
  }

  .export-save-modal__sheet {
    border-radius: 16px;
  }
}

/* —— 全屏预览（按当前手机屏幕铺满） —— */
body.is-fullscreen-preview {
  overflow: hidden !important;
  background: #000 !important;
}

/* 全屏时隐藏地址栏下方的站点 UI（导航/工具栏/菜单/编辑栏） */
body.is-fullscreen-preview .site-nav,
body.is-fullscreen-preview .site-nav-menu,
body.is-fullscreen-preview .preview-toolbar,
body.is-fullscreen-preview .editor-pane,
body.is-fullscreen-preview .toast {
  display: none !important;
}

body.is-fullscreen-preview .app,
body.is-fullscreen-preview .preview-pane {
  position: static !important;
  min-height: 0 !important;
  height: auto !important;
  background: #000 !important;
}

body.is-fullscreen-preview .phone-wrap {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1200 !important;
  width: 100% !important;
  height: var(--fs-vh, 100dvh) !important;
  max-height: var(--fs-vh, 100dvh) !important;
  padding: 0 !important;
  margin: 0 !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  overflow: hidden !important;
  background: #000 !important;
}

body.is-fullscreen-preview .phone {
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

body.is-fullscreen-preview .phone-screen,
body.is-fullscreen-preview #capture-root {
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: auto !important;
  -webkit-overflow-scrolling: touch;
}

body.is-fullscreen-preview .phone-screen .base {
  width: 100% !important;
  height: auto !important;
}

body.is-fullscreen-preview .tabbar-img {
  margin-top: auto;
}

body.is-fullscreen-preview .home-indicator {
  margin-top: auto;
}

/* 右上角透明热区：鼠标移入 / 手指点到才显示退出按钮 */
.fullscreen-exit-zone {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1290;
  width: 120px;
  height: calc(56px + env(safe-area-inset-top, 0px));
  background: transparent;
  touch-action: manipulation;
}

.fullscreen-exit-zone[hidden] {
  display: none !important;
}

.fullscreen-exit-btn {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 12px;
  z-index: 1300;
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.fullscreen-exit-btn.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.fullscreen-exit-btn[hidden] {
  display: none !important;
}

/* 导出 PNG：强制直角，避免 PC html2canvas 带上预览圆角 */
body.is-exporting-png #capture-root,
body.is-exporting-png .phone-screen,
#capture-root.is-exporting,
.phone-screen.is-exporting {
  border-radius: 0 !important;
  -webkit-border-radius: 0 !important;
  box-shadow: none !important;
}

body.is-exporting-png #capture-root [data-field],
body.is-exporting-png #capture-root [data-edit-target],
body.is-exporting-png #capture-root .record[data-record-index],
body.is-exporting-png #capture-root .tab[data-tab],
body.is-exporting-png #capture-root .battery,
body.is-exporting-png #capture-root .network-slot,
body.is-exporting-png #capture-root .slot[data-slot] {
  outline: none !important;
}

body.is-fullscreen-preview #capture-root [data-field]:hover,
body.is-fullscreen-preview #capture-root .record[data-record-index]:hover,
body.is-fullscreen-preview #capture-root .tab[data-tab]:hover,
body.is-fullscreen-preview #capture-root .battery:hover,
body.is-fullscreen-preview #capture-root .slot[data-slot]:hover {
  outline: none !important;
  background: transparent !important;
}
