/*
 * 手机版（h5.html）：单列布局 + 底部三键切换
 * 只覆盖布局，不与 app.css 的业务样式冲突；桌面版不加载本文件。
 */
body.h5 {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  /* 禁止双指/双击缩放页面；画布自身已设置 touch-action: none */
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
}

body.h5 .app-header {
  position: relative;
  z-index: 2;
  height: auto;
  flex-wrap: wrap;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px))
    calc(14px + env(safe-area-inset-right, 0px))
    10px
    calc(14px + env(safe-area-inset-left, 0px));
  border-bottom: 0;
  background: var(--panel);
  box-shadow: 0 1px 0 var(--line), 0 8px 20px rgba(15, 23, 42, .04);
}

body.h5 .brand { order: 1; font-size: 15px; font-weight: 600; }

body.h5 .brand-dot {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  box-shadow: 0 2px 6px rgba(217, 134, 26, .35);
}

body.h5 .name-input {
  order: 2;
  flex: 1 1 0;
  min-width: 80px;
  height: 34px;
  padding: 0 10px;
  border-color: transparent;
  border-radius: 9px;
  background: var(--panel-2);
  font-size: 14px;
  font-weight: 500;
}

body.h5 .header-actions {
  order: 3;
  flex: 1 1 100%;
  margin-left: 0;
  display: flex;
  gap: 8px;
}

body.h5 .header-actions .btn {
  flex: 1 1 0;
  height: 34px;
  padding: 0 4px;
  border-color: transparent;
  border-radius: 9px;
  background: var(--panel-2);
  font-size: 12px;
  font-weight: 500;
}

body.h5 .header-actions .btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 10px rgba(217, 134, 26, .26);
}

body.h5 .header-actions .btn-theme {
  flex: 0 0 52px;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

/* 三块面板同一时刻只显示一块 */
body.h5 .app-main {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

body.h5 .h5-view { display: none; height: 100%; }

body.h5[data-view="params"] .panel-left,
body.h5[data-view="legend"] .panel-right {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  border: 0;
  padding: 12px calc(14px + env(safe-area-inset-right, 0px)) 18px calc(14px + env(safe-area-inset-left, 0px));
}

body.h5[data-view="params"] .panel-left {
  background: var(--bg);
}

body.h5 .param-card {
  flex: 0 0 auto;
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}

body.h5 .param-card .panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}

body.h5 .step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 7px;
  background: rgba(217, 134, 26, .14);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

body.h5 .dropzone {
  padding: 18px 12px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px dashed var(--line);
}

body.h5 .upload-icon {
  display: block;
  width: 26px;
  height: 26px;
  margin: 0 auto 6px;
  color: var(--accent);
}

body.h5 .dropzone .btn {
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

body.h5 .dropzone .hint { margin-top: 5px; }

body.h5 .preview-wrap { display: none; margin-top: 12px; }
body.h5 .preview-wrap.has-image {
  display: block;
  width: min(100%, 240px);
  aspect-ratio: 1 / 1;
  height: auto;
  margin: 12px auto 0;
}
body.h5 .preview-actions { display: none; padding: 8px 0 0; }
body.h5 .preview-wrap.has-image + .preview-actions { display: block; }
body.h5 .preview-actions .btn { height: 32px; }

body.h5 .advanced.param-card {
  margin-top: 0;
  padding: 12px;
  border: 1px solid var(--line);
}

body.h5 .tip-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 0 4px;
  padding: 14px;
  border: 1px solid rgba(217, 134, 26, .18);
  border-radius: 14px;
  background: rgba(217, 134, 26, .07);
}

body.h5 .tip-card svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  color: var(--accent);
}

body.h5 .tip-card strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 13px;
}

body.h5 .tip-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

body.h5 #btnGenerate {
  height: 44px;
  margin-top: 6px;
  border-radius: 10px;
  font-size: 15px;
  box-shadow: 0 6px 16px rgba(217, 134, 26, .22);
}

body.h5[data-view="canvas"] .workspace {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 0;
}

body.h5 .panel-right .tab-panel { flex: 1 1 auto; min-height: 0; }

body.h5 .toolbar {
  flex: 0 0 auto;
  gap: 8px;
  margin: 10px calc(14px + env(safe-area-inset-right, 0px)) 8px calc(14px + env(safe-area-inset-left, 0px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 4px 16px rgba(15, 23, 42, .05);
  overflow: visible;
}

body.h5 .toolbar .tool,
body.h5 .toolbar .tool-group button {
  height: 32px;
  padding: 0 12px;
  border-color: transparent;
  border-radius: 8px;
}

body.h5 .toolbar .tool.active {
  border-color: transparent;
  background: rgba(217, 134, 26, .14);
  color: var(--accent);
}

body.h5 #btnMode {
  border-radius: 9px;
  box-shadow: 0 4px 10px rgba(217, 134, 26, .24);
}

body.h5 .mode-hint { line-height: 32px; }

body.h5 .current-color { font-size: 12px; }
body.h5 .toolbar .check { font-size: 12px; }

body.h5 .zoom { flex: 1 1 100%; margin-left: 0; }
body.h5 .zoom input[type="range"] { flex: 1 1 auto; width: auto; }

body.h5 .canvas-wrap {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  margin: 0 14px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

body.h5 .empty-state { font-size: 13px; }

body.h5[data-view="legend"] .panel-right { background: var(--bg); }

body.h5 .legend-head { display: none; }

body.h5 .legend-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 0 8px;
}

body.h5 .legend-row {
  grid-template-columns: 26px 1fr 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

body.h5 .legend-row:hover { background: var(--panel); }

body.h5 .legend-row .swatch {
  width: 24px;
  height: 24px;
  border-radius: 7px;
}

body.h5 .legend-count { font-size: 13px; font-weight: 600; }

body.h5 .legend-actions {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 4px 16px rgba(15, 23, 42, .05);
}

body.h5 .legend-actions .btn {
  height: 38px;
  border-radius: 9px;
  font-size: 13px;
}

body.h5 .panel-right .muted.pad { padding: 14px 4px; }

body.h5 .advanced > summary {
  font-size: 14px;
}

body.h5 .panel-title { margin-top: 14px; }

body.h5 .field input,
body.h5 .field select {
  font-size: 14px; /* ≥16px 才不触发 iOS 缩放，这里折中并把输入框加高 */
  height: 36px;
  border-color: transparent;
  border-radius: 8px;
  background: var(--panel-2);
}

body.h5 .field > span { font-size: 14px; }
body.h5 .field select { width: min(58%, 240px); }
body.h5 .field input[type="number"] { width: 96px; }
body.h5 .hint { font-size: 12px; }

body.h5 .export-menu button { padding: 9px 10px; font-size: 14px; }

/* 底部导航 */
.h5-nav { display: none; }

body.h5 .h5-nav {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  margin: 0 calc(14px + env(safe-area-inset-right, 0px))
    calc(8px + env(safe-area-inset-bottom, 0px))
    calc(14px + env(safe-area-inset-left, 0px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}

body.h5 .h5-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 52px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

body.h5 .h5-nav button svg { width: 20px; height: 20px; }

body.h5 .h5-nav button.active {
  color: var(--accent);
  font-weight: 600;
  background: rgba(217, 134, 26, .12);
  box-shadow: none;
}

body.h5 .statusbar {
  flex: 0 0 auto;
  display: block;
  height: auto;
  margin: 0 calc(14px + env(safe-area-inset-right, 0px)) 8px calc(14px + env(safe-area-inset-left, 0px));
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: normal;
  overflow: visible;
}

body.h5 .statusbar #statusText {
  display: block;
  color: var(--text);
}

body.h5 .statusbar #statusText::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--ok);
  vertical-align: 1px;
}

body.h5 .statusbar .stats {
  display: block;
  margin: 2px 0 0;
  white-space: normal;
  overflow: visible;
}

/* 手机端不显示拖拽提示 */
@media (hover: none) {
  body.h5 .dropzone .hint { display: none; }
}

/* 顶部提示条避开两行头部 */
body.h5 .toast {
  top: 96px;
  font-size: 14px;
}
