/* H5 移动版样式：与桌面工作台完全独立，移动优先 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  background: #f2f3f7; color: #1c1f24; font-size: 15px; line-height: 1.55;
  overscroll-behavior: none;
}
button { font-family: inherit; }
.flex1 { flex: 1; }

/* ===== 框架布局 ===== */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.top {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: calc(6px + env(safe-area-inset-top)) 14px 6px;
  background: linear-gradient(135deg, #2b6cff, #6a3df5); color: #fff;
}
.top-title { font-weight: 700; font-size: 16px; }
.top-link { color: rgba(255,255,255,.92); text-decoration: none; font-size: 13px; border: 1px solid rgba(255,255,255,.5); border-radius: 999px; padding: 2px 10px; }

.views { flex: 1 1 auto; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: none; }
.view.active { display: flex; flex-direction: column; }
#view-image.active, #view-video.active, #view-gal.active { display: block; }

.pad { padding: 12px 12px calc(20px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; width: 100%; }

/* ===== 底部标签栏 ===== */
.tabbar {
  flex: 0 0 auto; display: flex; background: #fff; border-top: 1px solid #e8eaee;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center;
  padding: 6px 0 5px; color: #8a90a0; font-size: 11px; position: relative; cursor: pointer;
}
.tab .t-ico { font-size: 20px; line-height: 1.15; filter: grayscale(1) opacity(.6); }
.tab.active { color: #2b6cff; }
.tab.active .t-ico { filter: none; }
.tab.active .t-txt { font-weight: 600; }
.dot { position: absolute; top: 6px; right: 22%; width: 8px; height: 8px; border-radius: 50%; background: #ff4d4f; display: none; }
.dot.on { display: block; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ===== 通用控件 ===== */
.card { background: #fff; border-radius: 14px; padding: 12px; box-shadow: 0 1px 4px rgba(20,30,60,.05); margin-bottom: 12px; }
.ctop { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.ta {
  width: 100%; border: 0; outline: none; resize: none; font-size: 16px; line-height: 1.5;
  font-family: inherit; color: #1c1f24; min-height: 72px;
}
.sel {
  appearance: none; -webkit-appearance: none; border: 1px solid #dfe3ea; background: #f7f8fb;
  border-radius: 9px; padding: 8px 26px 8px 10px; font-size: 16px; color: #1c1f24;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239aa' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; max-width: 100%;
}
.frow { display: flex; gap: 8px; margin: 10px 0; }
.fitem { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #8a90a0; min-width: 0; }
.fitem .sel { width: 100%; }

/* 开关 */
.switch { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: #444; margin: 8px 0; user-select: none; }
.switch input { display: none; }
.switch i {
  width: 40px; height: 22px; border-radius: 999px; background: #d6dae2; position: relative; transition: background .2s; flex: 0 0 auto;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + i { background: #2b6cff; }
.switch input:checked + i::after { left: 20px; }

/* 风格/参数 chips（横向滚动） */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid #dfe3ea; background: #fff; color: #4a5060;
  border-radius: 999px; padding: 6px 14px; font-size: 13.5px; cursor: pointer;
}
.chip.active { background: #eaf0ff; border-color: #2b6cff; color: #2b6cff; font-weight: 600; }

/* 分段选择 */
.seg { display: flex; background: #eef0f5; border-radius: 10px; padding: 3px; margin: 10px 0; }
.seg-btn {
  flex: 1; border: 0; background: none; border-radius: 8px; padding: 8px 0; font-size: 14px; color: #666; cursor: pointer;
}
.seg-btn.active { background: #fff; color: #2b6cff; font-weight: 600; box-shadow: 0 1px 4px rgba(20,30,60,.08); }

/* 上传区 */
.upzone { border: 1.5px dashed #c9cfda; border-radius: 12px; padding: 12px; text-align: center; margin: 6px 0 10px; }
.upzone input[type=file] { width: 100%; font-size: 13px; }
.upprev { display: block; max-width: 60%; max-height: 140px; margin: 8px auto 2px; border-radius: 10px; }
.refs-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; justify-content: center; }
.refs-strip img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid #e5e8ee; }
.sel:disabled { opacity: .55; }

.adv { margin: 6px 0; font-size: 13.5px; color: #666; }
.adv summary { cursor: pointer; padding: 4px 0; }
.adv .fitem { margin-top: 8px; }

.go {
  display: block; width: 100%; border: 0; border-radius: 12px; margin-top: 10px;
  background: linear-gradient(135deg, #2b6cff, #6a3df5); color: #fff; font-size: 16.5px; font-weight: 700;
  padding: 13px 0; cursor: pointer; box-shadow: 0 4px 14px rgba(43,108,255,.3);
}
.go:disabled { opacity: .55; box-shadow: none; }
.hint { font-size: 12px; color: #9aa0ae; margin-top: 6px; }
.hint.center { text-align: center; }
.center { text-align: center; }

.mini, .ibtn {
  border: 1px solid #dfe3ea; background: #fff; color: #555; border-radius: 8px;
  font-size: 12.5px; padding: 5px 12px; cursor: pointer;
}
.ibtn { font-size: 16px; padding: 4px 9px; }

/* ===== 任务卡（生成中） ===== */
.task {
  background: #fff; border-radius: 14px; padding: 12px; margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(20,30,60,.05); font-size: 13.5px;
}
.task-t { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-weight: 600; }
.task-t .st { color: #2b6cff; font-size: 12.5px; font-weight: 400; }
.task-p { color: #7a8090; font-size: 12.5px; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prog { height: 6px; border-radius: 999px; background: #edf0f5; overflow: hidden; }
.prog i { display: block; height: 100%; width: 5%; border-radius: 999px; background: linear-gradient(90deg, #2b6cff, #6a3df5); transition: width 1s linear; }

/* ===== 结果区 ===== */
.media-result { margin-bottom: 14px; }
.empty {
  border: 1.5px dashed #d9dde5; border-radius: 14px; padding: 26px 12px; text-align: center;
  color: #a2a8b6; font-size: 13px; background: rgba(255,255,255,.6);
}
.media-result .err { color: #d54941; border-color: #f3c1bd; background: #fdf4f3; }
.mgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mgrid.n1 { grid-template-columns: 1fr; }
.mgrid a { display: block; border-radius: 12px; overflow: hidden; background: #fff; }
.mgrid img, .mgrid video { display: block; width: 100%; height: auto; }
.macts { display: flex; gap: 8px; margin-top: 8px; }
.macts .mini { flex: 1; padding: 9px 0; font-size: 13.5px; }
.vwrap video { width: 100%; border-radius: 12px; background: #000; }

/* ===== 最近作品横滑条 ===== */
.ghead { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 8px; font-size: 14px; font-weight: 600; }
.gstrip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.gstrip::-webkit-scrollbar { display: none; }
.gstrip .th { flex: 0 0 auto; width: 86px; height: 86px; border-radius: 10px; overflow: hidden; background: #fff; border: 0; padding: 0; cursor: pointer; position: relative; }
.gstrip .th img, .gstrip .th video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gstrip .th .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; text-shadow: 0 1px 6px rgba(0,0,0,.6); background: rgba(0,0,0,.18); }
.gstrip .none { color: #a2a8b6; font-size: 12.5px; padding: 8px 2px; }

/* ===== 作品集网格 ===== */
.gal-tabs { margin-bottom: 12px; }
.ggrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ggrid .gi { border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: #fff; aspect-ratio: 1; cursor: pointer; position: relative; }
.ggrid .gi img, .ggrid .gi video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ggrid .gi .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; background: rgba(0,0,0,.18); }
.ggrid .none { grid-column: 1 / -1; }

/* ===== 对话 ===== */
.chat-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: #fff; border-bottom: 1px solid #eceef2; overflow-x: auto; scrollbar-width: none;
}
.chat-bar::-webkit-scrollbar { display: none; }
.chat-bar .sel { flex: 0 0 auto; max-width: 46%; padding: 6px 24px 6px 9px; font-size: 14px; }
.chat-bar .switch { margin: 0; white-space: nowrap; font-size: 13px; }
.chat-bar .switch i { width: 34px; height: 19px; }
.chat-bar .switch i::after { width: 15px; height: 15px; }
.chat-bar .switch input:checked + i::after { left: 16px; }
.chat-bar .ibtn { flex: 0 0 auto; }

.chat-msgs { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px 6px; }
.cmsg { margin-bottom: 12px; display: flex; }
.cmsg.user { justify-content: flex-end; }
.cmsg .bub {
  max-width: 84%; border-radius: 14px; padding: 9px 12px; font-size: 15px; word-break: break-word; overflow-wrap: anywhere;
}
.cmsg.user .bub { background: linear-gradient(135deg, #2b6cff, #5a4df5); color: #fff; border-bottom-right-radius: 4px; }
.cmsg.ai .bub { background: #fff; border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(20,30,60,.06); }
.cmsg .bub p { margin: 0 0 8px; } .cmsg .bub p:last-child { margin-bottom: 0; }
.cmsg .bub ul, .cmsg .bub ol { padding-left: 20px; margin: 4px 0 8px; }
.cmsg .bub h1, .cmsg .bub h2, .cmsg .bub h3, .cmsg .bub h4 { font-size: 15.5px; margin: 8px 0 6px; }
.cmsg .bub pre { background: #f4f6fa; border-radius: 8px; padding: 9px; overflow-x: auto; font-size: 12.5px; margin: 6px 0; }
.cmsg .bub code { font-family: ui-monospace, Consolas, monospace; font-size: .92em; background: rgba(43,108,255,.08); border-radius: 4px; padding: 1px 4px; }
.cmsg .bub pre code { background: none; padding: 0; }
.cmsg .bub blockquote { border-left: 3px solid #cdd6ea; padding-left: 9px; color: #667; margin: 6px 0; }
.think { background: #f4f6fa; border-radius: 9px; margin-bottom: 7px; font-size: 12.5px; color: #789; overflow: hidden; }
.think-tag { padding: 6px 9px; cursor: pointer; user-select: none; }
.think-body { padding: 0 9px 8px; white-space: pre-wrap; max-height: 200px; overflow-y: auto; }
.macts-in { margin-top: 6px; }
.macts-in .mini { padding: 3px 10px; font-size: 12px; }
.chat-welcome { text-align: center; color: #98a0b0; font-size: 13.5px; padding: 40px 20px; line-height: 2; }
.typing::after { content: "▍"; animation: blink 1s infinite; color: #2b6cff; }
@keyframes blink { 50% { opacity: 0; } }

.composer {
  flex: 0 0 auto; display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #eceef2;
}
.composer textarea {
  flex: 1; border: 1px solid #dfe3ea; background: #f7f8fb; border-radius: 12px; padding: 9px 12px;
  font-size: 16px; line-height: 1.4; font-family: inherit; outline: none; resize: none;
  max-height: 110px; min-height: 40px;
}
.composer .send {
  flex: 0 0 auto; border: 0; border-radius: 12px; background: #2b6cff; color: #fff;
  font-size: 15px; font-weight: 600; padding: 10px 16px; cursor: pointer;
}
.composer .send:disabled { opacity: .5; }

/* ===== 弹层 ===== */
.mask { position: fixed; inset: 0; background: rgba(10,14,25,.45); z-index: 60; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; background: #fff;
  border-radius: 16px 16px 0 0; max-height: 72vh; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid #f0f1f4; font-size: 15px; }
.lib-tabs { display: flex; gap: 6px; margin-left: auto; }
.lib-tab { border: 0; background: #f2f3f7; border-radius: 999px; padding: 5px 13px; font-size: 13px; color: #667; cursor: pointer; }
.lib-tab.active { background: #eaf0ff; color: #2b6cff; font-weight: 600; }
.sheet-b { overflow-y: auto; padding: 12px 14px calc(16px + env(safe-area-inset-bottom)); }
.lib-item {
  display: block; width: 100%; text-align: left; border: 1px solid #eef0f4; background: #fbfcfe;
  border-radius: 11px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
}
.lib-item strong { display: block; font-size: 14px; margin-bottom: 2px; }
.lib-item span { font-size: 12.5px; color: #8a90a0; }

.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(8,10,18,.92); display: flex; flex-direction: column; }
.lb-body { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 16px; }
.lb-body img, .lb-body video { max-width: 100%; max-height: 100%; border-radius: 6px; }
.lb-acts { display: flex; gap: 10px; padding: 0 16px 8px; }
.lb-btn { flex: 1; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12); color: #fff; border-radius: 10px; padding: 11px 0; font-size: 14.5px; cursor: pointer; }
.lb-hint { text-align: center; color: rgba(255,255,255,.55); font-size: 11.5px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: rgba(20,24,34,.88); color: #fff; border-radius: 999px; padding: 9px 18px;
  font-size: 13.5px; z-index: 99; opacity: 0; pointer-events: none; transition: all .25s; max-width: 80vw; text-align: center;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 桌面窄窗口也能正常预览 H5 */
@media (min-width: 600px) { .app { max-width: 480px; margin: 0 auto; border-left: 1px solid #e6e8ee; border-right: 1px solid #e6e8ee; } }

/* ===== 拼多多电商预置 ===== */
.pdd-card { border: 1px solid #ffd9a8; background: #fffaf2; }
.pdd-row { display: flex; gap: 8px; margin: 6px 0 4px; }
.pdd-row input[type="text"] { flex: 1; min-width: 0; }
.pdd-row select { width: 104px; flex: none; }
.chip.pdd { border-color: #ffb45c; color: #b25e00; }
