/* ===== 壁纸样机生成器 App 样式（同款复刻） ===== */

/* ===== SF Pro 字体（Apple 专有字体，仅供个人学习演示，商用请替换为授权字体） ===== */
@font-face {
  font-family: 'SF Pro Rounded';
  src: url('../fonts/SF-Pro-Rounded-Regular.otf') format('opentype');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'SF Pro Rounded';
  src: url('../fonts/SF-Pro-Rounded-Bold.otf') format('opentype');
  font-weight: 600 700; font-display: swap;
}
@font-face {
  font-family: 'SF Pro Rounded';
  src: url('../fonts/SF-Pro-Rounded-Heavy.otf') format('opentype');
  font-weight: 800 900; font-display: swap;
}
@font-face {
  /* 细字重：借用 Display Ultralight 文件挂到同族，供 thin/ios26 风格使用 */
  font-family: 'SF Pro Rounded';
  src: url('../fonts/SF-Pro-Display-Ultralight.otf') format('opentype');
  font-weight: 100 200; font-display: swap;
}
@font-face {
  font-family: 'SF Pro Display';
  src: url('../fonts/SF-Pro-Display-Ultralight.otf') format('opentype');
  font-weight: 100 200; font-display: swap;
}
@font-face {
  font-family: 'SF Pro Display';
  src: url('../fonts/SF-Pro-Display-Bold.otf') format('opentype');
  font-weight: 700 900; font-display: swap;
}
/* 原站同款时间字体 */
@font-face {
  font-family: 'Baloo Thambi 2';
  src: url('../fonts/BalooThambi2-Regular.ttf') format('truetype');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Business2';
  src: url('../fonts/Business2.ttf') format('truetype');
  /* 可变字体：声明轴范围后 canvas 的 font-weight / fontStretch 才会映射到 wght / wdth 轴
     （原站默认实例：wght 420, wdth 40 —— 见 mjcn.club 前端实测） */
  font-weight: 100 900;
  font-stretch: 25% 200%;
  font-display: swap;
}
@font-face {
  /* iOS26 专用实例：fvar 已字节级钉死 wdth=40 / opsz=144 / XTRA=460 / YTFI=788 / wght 默认 420
     （原站 font-variation-settings 实测值，gvar 数据在钉死值下自然生效）。
     wght 轴保留 100-1000 可变：canvas font-weight 直接映射 */
  font-family: 'Business2-OS26';
  src: url('../fonts/Business2-OS26.ttf') format('truetype');
  font-weight: 100 1000;
  font-stretch: 40%;
  font-display: swap;
}
@font-face {
  font-family: 'Oswald Stencil';
  src: url('../fonts/Oswald-Stencil.ttf') format('truetype');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Monoton';
  src: url('../fonts/Monoton-Regular.ttf') format('truetype');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Alibaba PuHuiTi Date';
  src: url('../fonts/AlibabaPuHuiTi-Date.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}

/* 时间字体四选段 */
.seg4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.seg4 button {
  border: 1px solid var(--line); background: #fff; color: var(--ink2);
  border-radius: 7px; padding: 5px 0; font-size: 12px; cursor: pointer;
}
.seg4 button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.check.sm { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; cursor: pointer; }
.check.sm input { accent-color: var(--brand); }

:root {
  --brand: #00B96B;
  --brand-dark: #009a5b;
  --orange: #FF8C00;
  --ink: #111827;
  --ink2: #374151;
  --muted: #6B7280;
  --line: #E5E7EB;
  --stage: #F9FAFB;
  --radius: 8px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink); background: #fff; font-size: 14px;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; }

/* ===== 顶栏 ===== */
.topbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; border-bottom: 1px solid var(--line); background: #fff;
}
.topbar-left { display: flex; align-items: center; gap: 22px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; color: var(--ink); text-decoration: none; }
.topbar-link { color: var(--ink2); text-decoration: none; font-size: 14px; }
.topbar-link:hover { color: var(--brand); }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.topbar-item { color: var(--ink2); font-size: 13px; cursor: pointer; }
.topbar-item:hover { color: var(--brand); }
.btn-login { background: var(--brand); color: #fff; border-radius: 6px; padding: 6px 18px; font-size: 14px; }
.btn-login:hover { background: var(--brand-dark); }

/* ===== 工作区三栏 ===== */
.workspace { display: flex; height: calc(100vh - 64px); }

/* ---- 左栏 ---- */
.left-panel { width: 328px; min-width: 328px; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: #fff; }
.panel-tabs { display: flex; border-bottom: 1px solid var(--line); }
.ptab { flex: 1; padding: 11px 0; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.ptab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tab-page { display: none; overflow-y: auto; padding: 12px; height: 100%; }
.tab-page.active { display: block; }

.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cat-card {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 14px 6px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  color: var(--ink2); font-size: 13px; transition: all .15s; background: #fff;
}
.cat-card:hover { border-color: var(--brand); color: var(--brand); }
.cat-card.active { border-color: var(--brand); color: var(--brand); background: rgba(0,185,107,.06); font-weight: 600; }
.cat-ico { font-size: 24px; line-height: 1; }

.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tpl-card { position: relative; border-radius: 10px; overflow: hidden; cursor: pointer; border: 2px solid transparent; background: var(--stage); transition: border-color .15s; }
.tpl-card canvas { display: block; width: 100%; height: auto; }
.tpl-card.active { border-color: var(--brand); }
.tpl-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 0 4px; text-align: center; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.55)); }

.saved-tip { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.saved-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.saved-item { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.saved-item .ops { display: flex; gap: 8px; }
.saved-item .ops button { color: var(--brand); font-size: 12.5px; }
.saved-item .ops button.del { color: #ef4444; }
.saved-actions { display: flex; gap: 8px; margin-top: 14px; }
.saved-actions .btn-ghost { flex: 1; }

/* ---- 中间画布区 ---- */
.stage { flex: 1; background: var(--stage); display: flex; flex-direction: column; position: relative; min-width: 0; }
.view-tabs { display: flex; justify-content: center; gap: 4px; padding: 10px 0 0; }
.vtab { padding: 6px 16px; border-radius: 99px; font-size: 13px; color: var(--ink2); }
.vtab.active { background: var(--ink); color: #fff; }
.canvas-wrap { flex: 1; position: relative; min-height: 0; }
#cv {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; margin: auto;
  max-width: calc(100% - 28px); max-height: calc(100% - 12px);
  border-radius: 6px; box-shadow: 0 8px 40px -12px rgba(17,24,39,.25); background: #fff;
}
.stage-foot { text-align: center; font-size: 12px; color: #9CA3AF; padding: 8px 0 10px; }
.stage-foot a { color: var(--brand); text-decoration: none; }
.stage-foot .icp { margin-left: 14px; }

/* ---- 右栏 ---- */
.right-panel { width: 308px; min-width: 308px; border-left: 1px solid var(--line); overflow-y: auto; background: #fff; padding: 4px 0 0; }
.grp { padding: 14px 16px 16px; border-bottom: 1px solid #F3F4F6; }
.grp-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.grp-sub { font-size: 12.5px; color: var(--muted); margin: 10px 0 7px; }
.grp-note { font-size: 11.5px; color: #9CA3AF; font-weight: 400; }
.panel-pad { height: 90px; }

.ipt {
  width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
  font-size: 13px; color: var(--ink); outline: none; background: #fff; margin-top: 8px;
}
.ipt:focus { border-color: var(--brand); }
.ipt.color { padding: 3px; height: 36px; }
select.ipt { appearance: auto; }
.row2 { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.row2 > * { flex: 1; }
.row2 .seg { margin: 0; }

.seg { display: flex; background: #F3F4F6; border-radius: 8px; padding: 3px; gap: 2px; margin-top: 8px; }
.seg-btn { flex: 1; padding: 5px 4px; border-radius: 6px; font-size: 12.5px; color: var(--ink2); white-space: nowrap; }
.seg-btn.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 4px rgba(17,24,39,.12); }
.seg-row { display: flex; align-items: center; gap: 10px; }
.seg-row .seg { flex: 1; margin: 0; }
.seg-label { font-size: 12.5px; color: var(--muted); min-width: 48px; }

.slider-row { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--brand); }
.slider-row .val { font-size: 12px; color: var(--muted); min-width: 38px; text-align: right; }

.check { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink2); white-space: nowrap; }
.check input { accent-color: var(--brand); }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #D1D5DB; border-radius: 99px; transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { translate: 18px 0; }
.switch.sm { transform: scale(.85); }

.upload {
  margin-top: 10px; border: 1.5px dashed #C9CED6; border-radius: 10px;
  padding: 20px 10px; text-align: center; cursor: pointer; transition: all .15s; background: #FAFBFC;
}
.upload:hover, .upload.drag { border-color: var(--brand); background: rgba(0,185,107,.05); }
.upload.slim { padding: 12px 8px; }
.up-icon { font-size: 26px; }
.up-txt { font-size: 13px; color: var(--ink2); margin-top: 6px; }
.up-sub { font-size: 11.5px; color: #9CA3AF; margin-top: 3px; }
.mini-row { display: flex; gap: 8px; margin-top: 9px; }
.btn-ghost { border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; font-size: 12.5px; color: var(--ink2); background: #fff; }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost.sm { padding: 5px 10px; flex: 1; }
.btn-green { background: var(--brand); color: #fff; border-radius: 6px; padding: 9px 16px; font-size: 13.5px; font-weight: 600; }
.btn-green:hover { background: var(--brand-dark); }
.w-full { width: 100%; }
.tip-line { font-size: 12px; color: var(--muted); margin-top: 9px; }
.tip-line a { color: var(--brand); text-decoration: none; }
.tip-line.dim { color: #9CA3AF; }

.font-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 4px; }
.font-card { border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 4px 6px; text-align: center; font-size: 15px; color: var(--ink); background: #fff; }
.font-card small { display: block; font-size: 10.5px; color: #9CA3AF; margin-top: 2px; }
.font-card.active { border-color: var(--brand); color: var(--brand); background: rgba(0,185,107,.05); }

.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--brand); }

.chip-toggles { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-toggle { border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-size: 12.5px; color: var(--ink2); cursor: pointer; user-select: none; }
.chip-toggle.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ===== 导出条 ===== */
.export-bar { position: fixed; right: 332px; bottom: 18px; z-index: 50; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.quota { font-size: 12px; color: var(--muted); background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: 99px; padding: 3px 12px; }
.export-btns { display: flex; gap: 10px; }
.btn-export {
  width: 130px; height: 48px; border-radius: 8px; background: var(--brand); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.25;
  box-shadow: 0 8px 20px -8px rgba(0,185,107,.65);
}
.btn-export span { font-size: 14.5px; font-weight: 700; }
.btn-export em { font-style: normal; font-size: 11px; opacity: .9; }
.btn-export:hover { background: var(--brand-dark); }
.btn-batch {
  width: 128px; height: 48px; border-radius: 8px; background: var(--orange); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.25;
  box-shadow: 0 8px 20px -8px rgba(255,140,0,.6);
}
.btn-batch small { font-size: 10.5px; opacity: .92; transform: scale(.95); }
.btn-batch:hover { filter: brightness(.95); }

/* ===== 弹层 ===== */
.modal { position: fixed; inset: 0; z-index: 200; background: rgba(17,24,39,.45); display: grid; place-items: center; backdrop-filter: blur(2px); }
.modal[hidden] { display: none; }
.modal-card { position: relative; width: 400px; max-width: calc(100vw - 40px); max-height: calc(100vh - 60px); overflow-y: auto; background: #fff; border-radius: 14px; padding: 20px; box-shadow: 0 24px 70px -20px rgba(17,24,39,.5); }
.modal-card.wide { width: 720px; }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.modal-title small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.modal-x { position: absolute; top: 12px; right: 14px; color: #9CA3AF; font-size: 15px; }
.modal-x:hover { color: var(--ink); }
.modal-btns { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
.crop-stage { display: grid; place-items: center; background: var(--stage); border-radius: 10px; padding: 12px; }
#cropCv { max-width: 100%; border-radius: 6px; }
.batch-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.batch-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.batch-chk { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: 12px; cursor: pointer; user-select: none; }
.batch-chk.on { background: rgba(0,185,107,.09); border-color: var(--brand); color: var(--brand); }
.vip-cards { display: flex; gap: 10px; margin-top: 14px; }
.vip-card { flex: 1; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.vip-card b { color: var(--ink); font-size: 13.5px; }
.vip-card i { font-style: normal; font-size: 20px; font-weight: 800; color: var(--orange); }
.vip-card.hot { border-color: var(--orange); }

.toast { position: fixed; top: 76px; left: 50%; translate: -50% 0; z-index: 300; background: rgba(17,24,39,.88); color: #fff; font-size: 13px; padding: 9px 20px; border-radius: 99px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D8DCE2; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #C0C6CE; }

@media (max-width: 1100px) {
  .right-panel { width: 280px; min-width: 280px; }
  .left-panel { width: 280px; min-width: 280px; }
  .export-bar { right: 300px; }
}

/* 移动布局容器：桌面端一律隐藏 */
#mTop, #mResize, #mSet { display: none; }

/* ===================== 移动端适配（手机） ===================== */
@media (max-width: 900px) {
  /* 关键：解除整页滚动锁定（桌面版 body overflow:hidden 会划不动） */
  html, body { height: auto; min-height: 100%; overflow: visible !important; overflow-y: auto !important; }

  /* 顶栏精简 */
  .topbar { padding: 0 12px; }
  .topbar-link, .topbar-item { display: none; }

  /* 三栏 → 原站同款纵向结构：横滑模板条 → 预览（62vh 起，可拖调）→ 设置 */
  .workspace { flex-direction: column; height: auto; min-height: calc(100vh - 64px); }
  .stage { order: 0; flex: none; height: var(--stageH, 62vh); min-height: 30vh; }
  #cv { max-width: calc(100% - 16px); max-height: calc(100% - 8px); }
  .view-tabs { overflow-x: auto; justify-content: flex-start; padding: 8px 12px 0; -webkit-overflow-scrolling: touch; }
  .vtab { flex: none; padding: 7px 14px; }
  .stage-foot { padding: 6px 0 8px; }

  /* 原站同款结构：顶部横滑模板条 → 预览（可拖调大小）→ 具体设置 */
  #mTop { display: block; background: #fff; border-bottom: 1px solid var(--line); padding: 8px 0 6px; }
  .m-sec-label { font-size: 11.5px; color: #9CA3AF; padding: 0 14px 4px; }
  .m-cats, .m-tpls { display: flex; gap: 8px; overflow-x: auto; padding: 0 14px 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .m-cats::-webkit-scrollbar, .m-tpls::-webkit-scrollbar { display: none; }
  .m-cats .cat-grid { display: flex; gap: 4px; }        /* catGrid 本体是 grid 容器 → 横排化 */
  /* 原站同款：纯文字标签，无图标无边框盒 */
  .m-cats .cat-card { flex: none; display: inline; border: none; background: none; padding: 4px 10px; margin: 0; font-size: 15px; color: var(--ink2); border-radius: 0; }
  .m-cats .cat-card .cat-ico { display: none; }
  .m-cats .cat-card.active { background: none; color: var(--brand); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); }
  .m-tpls .tpl-grid { display: flex; gap: 10px; }
  .m-tpls .tpl-card { flex: none; width: 64px; }
  .m-tpls .tpl-card .tpl-name { font-size: 10.5px; padding: 2px 0 3px; }

  /* 设置分类标签条 */
  .m-settabs { position: sticky; top: 0; z-index: 20; display: flex; gap: 4px; overflow-x: auto; padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--line); -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .m-settabs::-webkit-scrollbar { display: none; }
  .m-stab { flex: none; padding: 5px 14px; border-radius: 99px; background: #F3F4F6; color: var(--ink2); font-size: 13.5px; }
  .m-stab.on { background: var(--ink); color: #fff; font-weight: 600; }
  .m-setpage { display: none; }
  .m-setpage.on { display: block; }

  /* 预览区调大小把手 */
  #mResize { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 2px; touch-action: none; cursor: row-resize; user-select: none; background: #fff; }
  .m-handle { width: 48px; height: 6px; border-radius: 99px; background: #E5E7EB; }
  .m-hint { font-size: 10.5px; color: #C0C6CE; }

  /* 具体设置区 */
  #mSet { display: block; background: #fff; border-top: 1px solid var(--line); }
  #mSet .right-panel { width: 100%; min-width: 0; border: none; overflow: visible; display: block; height: auto; }
  .left-panel[hidden] { display: none; }

  /* 导出操作条：移动端居中吸底（配额徽标在按钮上方，不遮挡内容） */
  .export-bar { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); flex-direction: column-reverse; align-items: center; gap: 6px; }
  .quota { font-size: 11px; padding: 2px 10px; }
  /* 面板尾部留白：滚动到底时内容不被吸底按钮遮挡 */
  .left-panel, .right-panel { padding-bottom: 140px; }

  /* 触控目标加大 */
  .seg-btn, .ptab { padding: 7px 6px; font-size: 13px; }
  .slider-row input[type="range"] { height: 34px; }
  .cat-grid, .tpl-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .topbar { height: 52px; }
  .brand span { font-size: 15px; }
  .btn-login { padding: 5px 14px; }
  .workspace { min-height: calc(100vh - 52px); }
  .stage { height: var(--stageH, 54vh); min-height: 30vh; }
  #cv { max-width: calc(100% - 12px); border-radius: 8px; }
  .grp { padding: 12px 14px 14px; }
  .modal-card { width: auto; max-width: calc(100vw - 24px); max-height: calc(100vh - 40px); padding: 16px; }
  .modal-btns { flex-wrap: wrap; }
  .modal-btns .btn-green, .modal-btns .btn-ghost { flex: 1; min-width: 120px; text-align: center; }
  .export-bar { left: 12px; justify-content: center; }
  .stage-foot { font-size: 11px; }
  .stage-foot .icp { display: block; margin: 2px 0 0; }
  .row2 { flex-wrap: wrap; }
  /* 触屏滚动流畅 */
  .canvas-wrap, .right-panel, .left-panel { -webkit-overflow-scrolling: touch; }
  input, select { font-size: 16px; }   /* iOS 聚焦不触发页面缩放 */
  .seg-label { font-size: 13px; }
}
