:root {
  --bg: #121214;
  --bg-2: #1b1b1f;
  --card: #202026;
  --line: rgba(255, 255, 255, .08);
  --text: #f4f4f6;
  --muted: #9a9aa6;
  --accent: #7c5cfc;
  --accent-2: #a78bfa;
  --ok: #34c77b;
  --warn: #ff9a4d;
  --danger: #ff5c6c;
  --radius: 18px;
  --nav-h: 62px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }

/* ---------- 布局 ---------- */
.shell { max-width: 880px; margin: 0 auto; padding: 0 18px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; min-height: 56px; }
.topbar .title { font-weight: 600; font-size: 17px; }
.back { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-2); font-size: 20px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: linear-gradient(135deg, #5b3fd6, #8f6bff); font-size: 13px; font-weight: 600; }
.pill small { font-weight: 400; opacity: .85; }

.hero { padding: 8px 0 22px; }
.eyebrow { font-size: 11px; letter-spacing: .16em; color: var(--muted); }
.hero h1 { font-size: 30px; margin: 6px 0 8px; letter-spacing: .02em; }
.hero p { color: var(--muted); font-size: 14px; }

.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 14px; }
.section-head h2 { font-size: 19px; }
.section-head span { font-size: 12px; color: var(--accent-2); }

/* ---------- 模板卡片 ---------- */
.tpl-list { display: grid; gap: 14px; }
@media (min-width: 640px) { .tpl-list { grid-template-columns: 1fr 1fr; } }
.tpl-card {
  position: relative; overflow: hidden; text-align: left; width: 100%; min-height: 104px;
  border-radius: var(--radius); padding: 18px 96px 18px 18px; color: #fff;
  border: 1px solid var(--line); transition: transform .15s, border-color .15s;
}
.tpl-card:hover { transform: translateY(-2px); border-color: rgba(167, 139, 250, .5); }
.tpl-card.t1 { background: linear-gradient(120deg, #17141f 30%, #4b3a6d 100%); }
.tpl-card.t2 { background: linear-gradient(120deg, #17161a 30%, #6b4a3a 100%); }
.tpl-card.t3 { background: linear-gradient(120deg, #141a19 30%, #35625a 100%); }
.tpl-card.t4 { background: linear-gradient(120deg, #15181f 30%, #3a4d78 100%); }
.tpl-card h3 { font-size: 17px; margin-bottom: 4px; }
.tpl-card p { font-size: 12.5px; color: rgba(255, 255, 255, .72); }
.tpl-card .meta { margin-top: 8px; font-size: 11.5px; color: rgba(255, 255, 255, .55); }
.tpl-card .go { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 8px; }
.tpl-card .go b { width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #111; display: grid; place-items: center; font-size: 16px; }
.tpl-card .go i { font-style: normal; font-size: 11px; color: rgba(255, 255, 255, .6); position: absolute; right: 0; bottom: -18px; width: 100%; text-align: center; }

/* ---------- 首页动态 ---------- */
.feed { padding: 4px 16px 8px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); }
.feed-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.feed-row:last-child { border-bottom: 0; }
.feed-row .who { color: var(--text); font-weight: 600; }
.feed-row b { color: var(--accent-2); }
.feed-row small { margin-left: auto; font-size: 11.5px; }
.pill.guest { padding: 6px 14px; }

.guide { margin: 22px 0 0; padding: 16px 18px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.guide b { color: var(--accent-2); display: block; margin-bottom: 6px; font-size: 14px; }

/* ---------- 表单 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.card .sub { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.step { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); font-size: 12px; display: inline-grid; place-items: center; flex: none; }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.slot-grid.single { grid-template-columns: minmax(0, 260px); }
.upload-box {
  position: relative; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden;
  border: 1.5px dashed rgba(255, 255, 255, .22); background: var(--bg-2); display: grid; place-items: center;
  color: var(--muted); font-size: 12.5px; text-align: center; cursor: pointer;
}
.upload-box:hover, .upload-box.drag { border-color: var(--accent-2); color: var(--accent-2); }
.upload-box .plus { font-size: 28px; line-height: 1; display: block; margin-bottom: 4px; }
.upload-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.upload-box .rm { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0, 0, 0, .65); color: #fff; font-size: 14px; }
.upload-box.busy::after { content: "上传中…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .6); color: #fff; }
.upload-box input { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); font-size: 13.5px; color: #d6d6de; }
.chip.on { background: rgba(124, 92, 252, .22); border-color: var(--accent); color: #fff; }
.ratio-hint { margin-top: 10px; font-size: 12.5px; color: var(--muted); }

/* ---------- 输入补全建议 ---------- */
.suggest {
  margin-bottom: 10px; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  background: rgba(124, 92, 252, .12); border: 1px solid rgba(124, 92, 252, .35);
  transition: border-color .15s, background .15s;
}
.suggest:hover { background: rgba(124, 92, 252, .18); border-color: var(--accent); }
.suggest .meta { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--accent-2); margin-bottom: 6px; }
.suggest .act { padding: 2px 8px; border-radius: 999px; background: rgba(124, 92, 252, .25); }
.suggest .text { font-size: 13px; line-height: 1.6; color: #e9e9f2; word-break: break-word; }
.suggest.loading { cursor: default; }
.suggest.loading .text { color: var(--muted); }

textarea.input, input.input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none;
}
textarea.input { min-height: 74px; resize: vertical; }
.input:focus { border-color: var(--accent); }

.tips { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.checklist div { padding: 10px 12px; border-radius: 12px; background: var(--bg-2); font-size: 12.5px; color: var(--muted); }
.checklist b { display: block; color: var(--text); font-size: 13px; }
details.card summary { cursor: pointer; font-weight: 600; font-size: 14px; }

.footbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 20;
  background: rgba(18, 18, 20, .92); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.footbar .in { max-width: 880px; margin: 0 auto; padding: 10px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.footbar .cost { font-size: 13px; color: var(--muted); }
.footbar .cost b { color: #fff; font-size: 16px; }

.btn { padding: 12px 22px; border-radius: 999px; font-weight: 600; background: linear-gradient(135deg, #6a4af0, #9b78ff); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--bg-2); border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: rgba(255, 92, 108, .15); color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 14px; font-size: 13px; }

/* ---------- 结果 ---------- */
.result-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.result-grid.one { grid-template-columns: minmax(0, 560px); }
.shot { border-radius: 14px; overflow: hidden; background: var(--card); border: 1px solid var(--line); }
.shot .ph { position: relative; background: var(--bg-2); display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.shot .ph img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.shot .ph.loading { background: linear-gradient(110deg, #202026 30%, #2c2c35 50%, #202026 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.shot .cap { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; font-size: 13px; }
.shot .cap a { color: var(--accent-2); text-decoration: none; font-size: 12.5px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.status-line { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; color: var(--muted); font-size: 13.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); animation: pulse 1.2s infinite; }
.dot.ok { background: var(--ok); animation: none; }
.dot.err { background: var(--danger); animation: none; }
@keyframes pulse { 50% { opacity: .3; } }
.err-text { color: var(--danger); font-size: 13px; margin-top: 8px; }

.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .92); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---------- 作品 / 我的 ---------- */
.work { display: flex; gap: 12px; padding: 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); margin-bottom: 10px; align-items: center; text-align: left; width: 100%; }
.work .thumb { width: 72px; height: 72px; border-radius: 10px; background: var(--bg-2); overflow: hidden; flex: none; display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.work .thumb img { width: 100%; height: 100%; object-fit: cover; }
.work .info { flex: 1; min-width: 0; }
.work .info b { display: block; font-size: 14.5px; }
.work .info span { font-size: 12px; color: var(--muted); }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--bg-2); }
.tag.ok { color: var(--ok); } .tag.err { color: var(--danger); } .tag.run { color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat b { font-size: 24px; display: block; }
.stat span { font-size: 12.5px; color: var(--muted); }
.profile { display: flex; align-items: center; gap: 14px; margin: 8px 0 18px; }
.avatar { width: 54px; height: 54px; border-radius: 50%; background: linear-gradient(135deg, #5b3fd6, #b194ff); display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.ledger-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.ledger-row small { color: var(--muted); display: block; font-size: 11.5px; }
.pos { color: var(--ok); } .neg { color: var(--text); }
.row { display: flex; gap: 8px; }

/* ---------- 底部导航 ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #fff; display: flex; }
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #666; font-size: 11.5px; }
.nav button span { font-size: 19px; line-height: 1; }
.nav button.on { color: #5b3fd6; font-weight: 600; }

/* ---------- 登录 ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0%, #3a2a66 0%, transparent 50%), radial-gradient(circle at 90% 100%, #5b3a5a 0%, transparent 45%), var(--bg); }
.auth .box { width: 100%; max-width: 380px; }
.auth h1 { font-size: 32px; margin: 6px 0 6px; }
.auth .lead { color: var(--muted); font-size: 14px; margin-bottom: 26px; }
.auth form { display: grid; gap: 12px; }
.auth label { font-size: 12.5px; color: var(--muted); display: grid; gap: 6px; }
.auth .switch { margin-top: 16px; text-align: center; font-size: 13.5px; color: var(--muted); }
.auth .switch button { color: var(--accent-2); }
.form-err { color: var(--danger); font-size: 13px; min-height: 18px; }
.auth .bonus { margin-top: 18px; padding: 10px 14px; border-radius: 12px; background: rgba(124, 92, 252, .14); color: var(--accent-2); font-size: 12.5px; text-align: center; }

.toast { position: fixed; left: 50%; top: 22px; transform: translate(-50%, -80px); background: #fff; color: #111; padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 100; transition: transform .25s; max-width: 90vw; box-shadow: 0 8px 28px rgba(0, 0, 0, .4); }
.toast.show { transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- 桌面端:统一以 H5(手机)方式呈现 ---------- */
:root { --h5-w: 414px; --h5-h: 896px; --h5-r: 42px; }
@media (min-width: 720px) {
  html, body { height: 100%; }
  body {
    display: flex; align-items: center; justify-content: center; padding: 20px; overflow: hidden;
    background:
      radial-gradient(circle at 28% 10%, #262040 0%, transparent 55%),
      radial-gradient(circle at 78% 92%, #2c1f30 0%, transparent 50%),
      #08080a;
  }
  #app {
    flex: none; position: relative;
    width: var(--h5-w); height: min(var(--h5-h), calc(100vh - 40px));
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--bg);
    border-radius: var(--h5-r);
    box-shadow: 0 0 0 10px #17171b, 0 28px 80px rgba(0, 0, 0, .6);
    transform: translateZ(0); /* 让内部 position:fixed 元素以手机框为定位基准 */
  }
  #app > .shell { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  #app > .auth { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  #app > .shell::-webkit-scrollbar { width: 6px; }
  #app > .shell::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 3px; }
  /* 内容区不裁切,底部导航贴合圆角 */
  .nav { border-radius: 0 0 var(--h5-r) var(--h5-r); }
  .footbar { max-width: var(--h5-w); }
}
