/* ============================================================
   后台外壳（2026-10-31 照 docs\后台首页装修-原型.html 重做）
   顶栏（两个模式） + 页签 + 工作区 + 右边手机预览
   内容样式仍在 style.css（日常管理）和 decorate.css（装修页）
   ============================================================ */

html, body { height: 100%; }
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 1180px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-name { font-weight: 600; font-size: 15px; }
.topbar .tag {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 2px 9px;
  white-space: nowrap;
}
.mode-tabs { display: flex; gap: 4px; margin-left: 6px; }
.mode-tab {
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.mode-tab:hover { background: #ecece6; color: var(--ink); }
.mode-tab.on { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.top-actions .status {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.deco-actions { display: flex; align-items: center; gap: 8px; }
.btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.btn:hover { border-color: #bdbdb4; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #333; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.save-state { color: var(--faint); font-size: 11.5px; margin-right: 2px; white-space: nowrap; }
/* 装修模版（2026-11-10） */
.deco-template {
  height: 32px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  max-width: 170px;
}
.deco-template:disabled { opacity: .5; }
.tpl-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #eee; }
.tpl-row:last-child { border-bottom: 0; }
.tpl-name { flex: 1; font-weight: 600; }
.tpl-tag { font-size: 12px; color: #2f7d32; }
.pub-choices { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- 页签 ---------- */
.sub-tabs {
  height: 45px;
  flex: none;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
}
.sub-inner {
  width: 100%;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}
.sub-label {
  color: var(--faint);
  font-size: 11px;
  letter-spacing: .06em;
  margin-right: 6px;
  white-space: nowrap;
}
.sub-sep { width: 1px; height: 18px; background: var(--line); margin: 0 8px; flex: none; }
.page-tab {
  height: 30px;
  padding: 0 13px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.page-tab:hover { background: #ecece6; color: var(--ink); }
.page-tab.on { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }

/* ---------- 主区域 ---------- */
.app-main { flex: 1; min-height: 0; padding: 0; width: 100%; margin: 0; }
/* 装修和日常管理都有右边这一栏手机预览（2026-10-31 照原型） */
.app-main.builder-mode,
.app-main.manage-mode { display: grid; grid-template-columns: minmax(0, 1fr) 440px; }
/* 页面装修：最左边多一列「页面管理」（2026-11-13） */
.app-main.builder-mode { grid-template-columns: 188px minmax(0, 1fr) 440px; }
/* 总控不需要手机预览：整宽给开关 */
.app-main.builder-mode.master-mode { grid-template-columns: 188px minmax(0, 1fr); }
.app-main.builder-mode.master-mode .preview-panel { display: none; }
/* 商品页是四栏全宽，塞不下手机 —— 它的预览改成弹窗 */
.app-main.manage-mode.wide-products { grid-template-columns: minmax(0, 1fr); overflow: hidden; }
.app-main.manage-mode.wide-products .preview-panel { display: none; }

#builderTabs { grid-column: 1; grid-row: 1; }
#builderView, #builderEmpty, #pageBuilderView, #inviteBuilderView, #navBuilderView { grid-column: 2; grid-row: 1; }
#manageView { grid-column: 1; grid-row: 1; }
.preview-panel { grid-column: 2; grid-row: 1; }
.app-main.builder-mode .preview-panel { grid-column: 3; }

/* ---------- 左侧页面管理（2026-11-13：顶上横向页签挪到左栏） ---------- */
.page-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.rail-head {
  flex: none;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-head b { font-size: 13.5px; font-weight: 600; }
.rail-head span { font-size: 11px; color: var(--faint); }
.rail-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 10px 10px; }
.rail-group { margin-bottom: 10px; }
.rail-group + .rail-group { padding-top: 10px; border-top: 1px solid #efefe9; }
.rail-group:last-child { margin-bottom: 4px; }
/* 分组标题：各组样式一致 */
.rail-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--ink);
}
.rail-label::before {
  content: "";
  flex: none;
  width: 3px;
  height: 11px;
  border-radius: 2px;
  background: var(--ink);
}
.rail-count {
  margin-left: auto;
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
/* 页面行：各组样式一致 */
.page-rail .page-tab {
  display: flex;
  width: 100%;
  height: 34px;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12.8px;
  color: var(--ink);
}
.page-rail .page-tab + .page-tab { margin-top: 2px; }
.page-rail .page-tab:hover { background: #f0f0ea; color: var(--ink); }
.page-rail .page-tab.on {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-weight: 600;
}
.rail-foot {
  flex: none;
  padding: 10px 14px;
  border-top: 1px dashed var(--line);
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.6;
}
#manageView { padding: 24px 0 60px; height: 100%; min-height: 0; overflow-y: auto; }
#manageView .wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }

/* ---------- 工作区：左库 / 中列表 / 右设置 ---------- */
.workspace {
  height: 100%;
  display: grid;
  grid-template-columns: 230px 220px minmax(320px, 1fr);
  min-height: 0;
  overflow: hidden;
}
.ws-col {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.ws-col:last-child { border-right: 0; border-left: 1px solid var(--line); }
.ws-col.library { background: #f7f7f2; }
.ws-head {
  height: 46px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
}
.ws-head .count { color: var(--faint); font-weight: 400; font-size: 11.5px; }
.lib-body { flex: 1; overflow-y: auto; padding: 12px; }
.lib-title { font-size: 11.5px; color: var(--faint); letter-spacing: .06em; margin: 2px 0 8px; }
.module-list { flex: 1; overflow-y: auto; padding: 6px 10px 10px; }
.settings-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
.module-note, .lib-note {
  padding: 10px 12px;
  border-top: 1px dashed var(--line);
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.6;
}

/* ---------- 右边：手机预览 ---------- */
.preview-panel {
  border-left: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.preview-head {
  height: 46px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.preview-head b { font-size: 13px; white-space: nowrap; }
.preview-head .hint { margin: 0; color: var(--faint); font-size: 11px; }
.preview-head .hint:last-child { margin-left: auto; }
.preview-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden; /* 竖向滚动条会吃掉宽度，不挡住手机 */
  padding: 16px 8px 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.phone-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.phone-caption { color: var(--faint); font-size: 11px; }

.phone {
  width: 375px;
  height: 812px;
  box-sizing: content-box;
  border: 10px solid #0f1720;
  border-radius: 48px;
  background: #0f1720;
  box-shadow: 0 24px 60px rgba(10, 22, 40, .28);
  overflow: hidden;
  position: relative;
}
.phone-screen {
  width: 375px;
  height: 812px;
  border-radius: 38px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.statusbar {
  height: 44px;
  flex: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 22px 6px;
  font-size: 12px;
  font-weight: 600;
  color: #111;
  background: #fff;
}
.status-right { display: flex; align-items: center; gap: 6px; }
.signal { letter-spacing: 1px; font-size: 10px; }
.battery { width: 20px; height: 10px; border: 1px solid #111; border-radius: 3px; padding: 1px; display: inline-block; }
.battery i { display: block; width: 70%; height: 100%; background: #111; border-radius: 1px; }
.navbar {
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .02em;
  position: relative;
}
.phone-back {
  position: absolute;
  left: 10px;
  top: 0;
  height: 44px;
  width: 34px;
  border: 0;
  background: none;
  font-size: 28px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #111;
  padding-bottom: 4px;
  font-family: inherit;
}
.screen-body { flex: 1; min-height: 0; overflow-y: auto; position: relative; background: #fff; }
.tabbar { height: 50px; flex: none; display: flex; border-top: 1px solid #eee; background: #fff; }
.tab {
  flex: 1;
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 10px;
  color: #8a8a8a;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
}
.tab img { width: 22px; height: 22px; display: block; }
.tab.on { color: #000; font-weight: 600; }

/* ---------- 装修里第一版不做的页 ---------- */
.builder-empty { padding: 24px; display: flex; justify-content: center; align-items: flex-start; }
.builder-empty-inner {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
}
.builder-empty-inner h2 { margin: 0 0 6px; }
.builder-empty-inner .hint { margin: 0; line-height: 1.8; }
.builder-empty-phone {
  padding: 120px 20px;
  text-align: center;
  color: #a9a9a0;
  font-size: 12px;
  line-height: 1.9;
}
.builder-empty-phone b { display: block; color: #666; font-size: 13px; margin-bottom: 4px; }

/* ---------- 窄屏：照原型把手机缩到 .86 ---------- */
@media (max-width: 1400px) {
  .app-main.builder-mode,
  .app-main.manage-mode { grid-template-columns: minmax(0, 1fr) 400px; }
  .app-main.manage-mode.wide-products { grid-template-columns: minmax(0, 1fr); }
  .workspace { grid-template-columns: 210px 190px minmax(280px, 1fr); }
  .phone { transform: scale(.86); transform-origin: top center; margin-bottom: -110px; }
}

/* ---------- RONIN 后台（/ronin）：只留 装修-首页 / 装修-邀请码页 / 邀请码 ----------
   2026-11-05 他定的：两个后台分开，RONIN 后台其它页一律不要。 */
body.admin-ronin [data-builder-key="catalog"],
body.admin-ronin [data-builder-key="favorites"],
body.admin-ronin [data-builder-key="mine"],
body.admin-ronin [data-builder-key="products"],
body.admin-ronin [data-builder-key="feed"],
body.admin-ronin [data-builder-key="moment"],
body.admin-ronin [data-view="overview"],
body.admin-ronin [data-view="personal"],
body.admin-ronin [data-view="products"],
body.admin-ronin [data-view="sync"],
body.admin-ronin [data-view="api"],
body.admin-ronin [data-view="database"],
body.admin-ronin #builderSubLabelSub {
  display: none !important;
}
