:root {
  --bg-0: #12100e;
  --bg-1: #1b1713;
  --bg-2: #242018;
  --bg-3: #2e281f;
  --border: #3d3429;
  --text: #f6f0e6;
  --text-dim: #b3a894;
  --text-mute: #7a7164;
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --rose: #fb7185;
  --emerald: #34d399;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
body { padding-bottom: calc(64px + var(--safe-b)); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, video { max-width: 100%; display: block; }
.hidden { display: none !important; }

.m-top {
  position: sticky; top: 0; z-index: 20;
  padding: calc(10px + var(--safe-t)) 14px 10px;
  background: rgba(18, 16, 14, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.m-top h1 { font-size: 17px; font-weight: 700; flex: 1; min-width: 0; }
.m-top .sub { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.m-back {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
}
.m-points {
  font-size: 12px; color: var(--amber);
  background: var(--amber-soft);
  border-radius: 999px; padding: 4px 10px; white-space: nowrap;
}

.m-page { padding: 14px 14px 24px; }
.m-search {
  width: 100%; border: 1px solid var(--border); background: var(--bg-1);
  border-radius: 12px; padding: 11px 12px; margin-bottom: 12px; outline: none;
}
.m-cats {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.m-cats::-webkit-scrollbar { display: none; }
.m-cat {
  flex: 0 0 auto; border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text-dim); border-radius: 999px; padding: 6px 12px; font-size: 13px;
}
.m-cat.on { background: var(--amber); color: #1a1408; border-color: var(--amber); font-weight: 700; }

.m-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.m-card {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; text-align: left; color: inherit;
}
.m-card-cover {
  height: 92px; background:
    linear-gradient(135deg, var(--accent, #c4a574) 0%, #2a241c 80%);
  position: relative;
}
.m-card-cover img, .m-card-cover video { width: 100%; height: 100%; object-fit: cover; }
.m-card-body { padding: 10px; }
.m-card-title { font-size: 14px; font-weight: 700; }
.m-card-desc { font-size: 12px; color: var(--text-dim); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.m-tag { font-size: 10px; color: var(--text-mute); background: var(--bg-3); border-radius: 6px; padding: 2px 6px; }

.m-empty, .m-loading { text-align: center; color: var(--text-dim); padding: 40px 16px; font-size: 13px; }
.m-howto {
  font-size: 13px; color: var(--text-dim); background: var(--bg-1);
  border: 1px dashed var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px;
  white-space: pre-wrap;
}

.m-field { margin-bottom: 14px; }
.m-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.m-label em { font-style: normal; color: var(--rose); font-weight: 500; font-size: 12px; }
.m-hint { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.m-input, .m-select, .m-area {
  width: 100%; border: 1px solid var(--border); background: var(--bg-1);
  border-radius: 12px; padding: 10px 12px; outline: none;
}
.m-area { min-height: 110px; resize: vertical; }
.m-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.m-upload {
  border: 1px dashed var(--border); background: var(--bg-1); border-radius: 14px;
  min-height: 120px; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px; color: var(--text-dim); position: relative; overflow: hidden;
}
.m-upload input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }
.m-upload.has-file { border-style: solid; padding: 0; }
.m-upload img, .m-upload video { width: 100%; max-height: 220px; object-fit: cover; }
.m-upload audio { width: 92%; margin: 16px auto; }
.m-upload .clear {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
}

.m-gen {
  position: sticky; bottom: calc(56px + var(--safe-b)); z-index: 15;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: linear-gradient(180deg, transparent, var(--bg-0) 28%);
}
.m-btn {
  width: 100%; border: 0; border-radius: 14px; padding: 13px 16px;
  background: var(--amber); color: #1a1408; font-weight: 800; font-size: 16px;
}
.m-btn[disabled] { opacity: .55; }
.m-btn.ghost { background: var(--bg-2); color: var(--text); border: 1px solid var(--border); }

.m-progress { font-size: 13px; color: var(--text-dim); text-align: center; margin: 8px 0 0; }
.m-results { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.m-result {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
}
.m-result-hd { padding: 10px 12px 0; font-size: 13px; font-weight: 700; }
.m-result img, .m-result video { width: 100%; background: #000; }
.m-result-actions { display: flex; gap: 8px; padding: 10px; }
.m-result-actions a, .m-result-actions button {
  flex: 1; text-align: center; text-decoration: none; color: var(--text);
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px; padding: 8px;
  font-size: 13px;
}

.m-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr;
  padding: 6px 8px calc(6px + var(--safe-b));
  background: rgba(27, 23, 19, 0.96);
  border-top: 1px solid var(--border);
}
.m-tab {
  border: 0; background: transparent; color: var(--text-mute); padding: 8px 4px; font-size: 12px;
}
.m-tab.on { color: var(--amber); font-weight: 700; }

.m-points { border: 0; cursor: pointer; }
.m-notice { background: var(--bg-1); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.m-notice-body { margin-top: 10px; font-size: 14px; color: var(--text-dim); line-height: 1.65; }
.m-notice-body p { margin: 0 0 12px; }
.m-me { background: var(--bg-1); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.m-me strong { display: block; font-size: 18px; }
.m-me p { color: var(--text-dim); font-size: 13px; margin: 6px 0 14px; }
.m-vip-tag { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--amber); background: var(--amber-soft); border-radius: 999px; padding: 2px 8px; }

.m-sub-hero { background: var(--bg-1); border: 1px solid var(--border); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.m-sub-hero p { color: var(--text-dim); font-size: 13px; margin-top: 6px; }
.m-status { background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.m-status.is-vip { border-color: rgba(245,158,11,.35); background: var(--amber-soft); }
.m-status strong { display: block; font-size: 15px; }
.m-status span { display: block; font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.m-period { display: flex; gap: 6px; margin: 0 0 10px; }
.m-period button { flex: 1; border: 1px solid var(--border); background: var(--bg-2); color: var(--text-dim); border-radius: 999px; padding: 7px 8px; font-size: 13px; }
.m-period button.on { background: var(--amber); color: #1a1408; border-color: var(--amber); font-weight: 700; }
.m-plan { background: var(--bg-1); border: 1px solid var(--border); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.m-plan-name { font-weight: 700; }
.m-plan-price { color: var(--amber); font-size: 18px; margin: 4px 0; }
.m-plan-meta { font-size: 12px; color: var(--text-dim); }
.m-plan-desc { font-size: 12px; color: var(--text-mute); margin: 6px 0 10px; }
.m-plan ul { margin: 8px 0 0; padding-left: 18px; font-size: 12px; color: var(--text-dim); }
.m-cs-sheet { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; padding: 16px 16px calc(16px + var(--safe-b)); }
/* 支付扫码盖过订阅页其它浮层 */
#mPaySheet.m-cs-sheet { z-index: 15500; }
.m-cs-sheet .inner { width: 100%; max-width: 420px; background: var(--bg-1); border: 1px solid var(--border); border-radius: 16px; padding: 16px; text-align: center; }
.m-cs-sheet img { width: 180px; height: 180px; object-fit: cover; margin: 10px auto; border-radius: 8px; background: #fff; }
.m-ledger { font-size: 12px; }
.m-ledger-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.m-ledger-row span { color: var(--text-mute); }

.toast-wrap { position: fixed; left: 12px; right: 12px; bottom: calc(78px + var(--safe-b)); z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 14px; font-size: 13px; border-left: 3px solid var(--emerald);
}
.toast.err { border-left-color: var(--rose); }
.app-confirm-bg { display: none; position: fixed; inset: 0; z-index: 16000; place-items: center; background: rgba(0,0,0,.55); padding: 20px; }
.app-confirm-bg.show { display: grid; }
.app-confirm-panel { width: min(420px, 92vw); background: var(--bg-1); border: 1px solid var(--border); border-radius: 16px; padding: 18px; }
.app-confirm-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.app-confirm-body { font-size: 14px; color: var(--text-dim); }
.app-confirm-actions { display: flex; gap: 8px; margin-top: 16px; }
.app-confirm-actions .btn { flex: 1; border-radius: 12px; padding: 10px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); }
.app-confirm-actions .btn.primary { background: var(--amber); color: #1a1408; border: 0; }
.app-confirm-actions .btn.danger { background: var(--rose); color: #fff; border: 0; }
.app-confirm-input { width: 100%; margin-top: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-2); padding: 10px; }

/* —— 桌面模块在手机壳内复用：按钮 / 弹窗 / view —— */
.view { display: none; }
.view.active { display: block; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.btn.primary { background: var(--amber); color: #1a1408; border-color: var(--amber); font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.modal-bg {
  display: none; position: fixed; inset: 0; z-index: 500;
  place-items: center; background: rgba(0,0,0,.55); padding: 16px;
}
.modal-bg.show { display: grid; }
.modal {
  width: min(560px, 96vw); max-height: min(86vh, 820px);
  overflow: auto; background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px;
}

/* 创作工具入口 */
.m-tools-grid { display: flex; flex-direction: column; gap: 10px; }
.m-tool-card {
  display: flex; align-items: center; gap: 12px; text-align: left;
  width: 100%; border: 1px solid var(--border); background: var(--bg-1);
  border-radius: 14px; padding: 14px; color: inherit;
}
.m-tool-card:active { background: var(--bg-2); }
.m-tool-ico {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 22px;
  background: var(--amber-soft); color: var(--amber);
}
.m-tool-card strong { display: block; font-size: 15px; }
.m-tool-card span { display: block; font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.m-section-title {
  font-size: 13px; font-weight: 700; color: var(--text-dim);
  margin: 4px 0 10px;
}

/* 工具全屏宿主：盖住场景页，顶栏仍可见 */
.m-tool-host {
  position: fixed;
  left: 0; right: 0;
  top: calc(52px + var(--safe-t));
  bottom: 0;
  z-index: 25;
  background: var(--bg-0);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.m-tool-host[hidden] { display: none !important; }
body.m-tool-open #mApp { display: none; }
body.m-tool-open .m-tabbar { display: none; }
body.m-tool-open { padding-bottom: 0; }
body.m-tool-open .m-tool-host {
  bottom: 0;
}

#mToolHost .view {
  min-height: 100%;
  padding: 0;
}
#mToolHost #view-quick-image.active {
  display: block;
  padding-bottom: calc(16px + var(--safe-b));
}
#mToolHost #view-quick-video.active {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: auto;
}

/* 快捷视频：手机强制单列滚动 */
body.m-shell.quick-video-open .qv-page {
  grid-template-columns: 1fr !important;
  grid-template-rows: none !important;
  height: auto !important;
  min-height: 100%;
  overflow: visible !important;
  padding: 10px 10px 24px !important;
  gap: 10px !important;
}
body.m-shell.quick-video-open .qv-split { display: none !important; }
body.m-shell.quick-video-open .qv-col-left,
body.m-shell.quick-video-open .qv-col-center,
body.m-shell.quick-video-open .qv-col-right {
  height: auto !important;
  min-height: 0 !important;
}

/* 快捷图片：收窄双栏 */
body.m-shell #view-quick-image .qi-detail-body {
  grid-template-columns: 1fr !important;
}
body.m-shell #view-quick-image .qi-grid {
  grid-template-columns: 1fr 1fr !important;
}
