/* ================= 后台 ================= */
body.admin {
  background: #e8e6e1;
  overflow: hidden;
  height: 100vh;
}

/* 顶栏 */
.topbar {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
  position: relative;
  z-index: 10;
}

.tb-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tb-mark {
  width: 26px;
}

.topbar h1 {
  margin: 0;
  font-family: var(--px);
  font-size: 20px;
  line-height: 1.2;
}

.topbar p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status {
  font-family: var(--en);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 10px;
  border: 1.5px solid rgba(13, 13, 13, 0.2);
  margin-right: 6px;
}

.status.dirty {
  color: #b3007a;
  border-color: var(--pink);
  background: rgba(255, 87, 228, 0.12);
}

.status.ok {
  color: #1e7a00;
  border-color: var(--green-deep);
  background: rgba(118, 245, 20, 0.16);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1.5px solid var(--ink);
  background: var(--white);
  font-family: var(--px);
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
}

.btn:hover { background: var(--yellow); }
.btn:active { transform: translate(1px, 1px); }
.btn.primary { background: var(--pink); border-width: 2px; }
.btn.primary:hover { background: var(--pink-deep); color: #fff; }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 4px 9px; font-size: 11px; }
.btn.danger { background: #fff2f2; border-color: #d40000; color: #c00; }

/* 布局 */
.layout {
  display: grid;
  grid-template-columns: 210px minmax(400px, 1fr) 540px;
  height: calc(100vh - 66px);
}

/* 左：页面列表 */
.rail {
  border-right: 2px solid var(--ink);
  background: #f7f6f3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rail-head {
  padding: 12px 16px;
  font-family: var(--en);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1.5px solid rgba(13, 13, 13, 0.14);
}

.rail-head b { color: var(--ink); }

.rail-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.rail-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  margin-bottom: 4px;
  border: 1.5px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  color: #3b3833;
  border-radius: 2px;
}

.rail-item:hover { background: #eeecE7; }

.rail-item.on {
  background: var(--white);
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.rail-item .n {
  font-family: var(--en);
  font-size: 10px;
  color: var(--pink-deep);
  min-width: 18px;
}

.rail-item .t {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-item .warn {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow-deep);
  flex: 0 0 auto;
}

/* 中：编辑器 */
.editor {
  overflow-y: auto;
  padding: 26px 30px 80px;
  background: #e8e6e1;
}

.empty {
  color: #9a958e;
  font-family: var(--px);
  font-size: 16px;
  padding: 60px 0;
  text-align: center;
}

.ed-head {
  margin-bottom: 22px;
}

.ed-head .tag {
  display: inline-block;
  padding: 3px 9px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--en);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ed-head h2 {
  margin: 12px 0 6px;
  font-family: var(--px);
  font-size: 26px;
  line-height: 1.3;
}

.ed-head .slotnote {
  margin: 10px 0 0;
  padding: 10px 14px;
  background: rgba(230, 242, 0, 0.35);
  border-left: 4px solid var(--yellow-deep);
  font-size: 13px;
  line-height: 1.6;
  color: #4a463f;
}

.field {
  margin-bottom: 18px;
}

.field > label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: #7c7770;
}

.field > label .key {
  color: var(--pink-deep);
}

.field input[type='text'],
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #b9b4ac;
  background: var(--white);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  border-radius: 2px;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.field textarea {
  resize: vertical;
  min-height: 62px;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(255, 87, 228, 0.25);
}

/* 图片字段 */
.imgfield {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px;
  border: 1.5px solid #c9c4bc;
  background: #f3f1ec;
  border-radius: 2px;
}

.imgfield .thumb {
  width: 128px;
  height: 88px;
  flex: 0 0 auto;
  border: 1.5px solid var(--ink);
  background: #fff;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.imgfield .thumb img,
.imgfield .thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.imgfield .thumb .none {
  font-family: var(--en);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: #b3aea6;
  text-transform: uppercase;
}

.imgfield .ops {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.imgfield .path {
  font-family: var(--mono);
  font-size: 11px;
  color: #6d6861;
  word-break: break-all;
  background: #fff;
  border: 1px solid #d5d0c8;
  padding: 5px 8px;
}

.imgfield .row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.imgfield input[type='file'] { display: none; }

.msg {
  font-size: 11.5px;
  color: #8a857e;
}

.msg.err { color: #c00; }
.msg.ok { color: #1e7a00; }

/* 分组 */
.group {
  border: 1.5px solid #cfcac2;
  background: #f3f1ec;
  margin-bottom: 16px;
}

.group > .ghead {
  padding: 8px 14px;
  border-bottom: 1.5px solid #cfcac2;
  background: #eae7e1;
  font-family: var(--en);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.group > .gbody {
  padding: 14px;
}

.group .del {
  border: none;
  background: none;
  color: #c46;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--mono);
}

.addrow {
  width: 100%;
  padding: 8px;
  border: 1.5px dashed #b9b4ac;
  background: transparent;
  color: #7c7770;
  font-family: var(--px);
  font-size: 12px;
  cursor: pointer;
}

.addrow:hover { border-color: var(--ink); color: var(--ink); background: #fff; }

/* 右：预览 */
.preview {
  border-left: 2px solid var(--ink);
  background: #f7f6f3;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0 0 20px;
}

.pv-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1.5px solid rgba(13, 13, 13, 0.14);
  font-family: var(--en);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  position: sticky;
  top: 0;
  background: #f7f6f3;
  z-index: 3;
}

.pv-frame {
  padding: 14px;
}

.pv-stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 rgba(13, 13, 13, 0.25);
}

#pv-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1600px;
  height: 900px;
  transform-origin: top left;
  background-color: var(--paper);
  background-image: linear-gradient(rgba(13, 13, 13, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 13, 13, 0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

#pv-stage .slide {
  position: absolute;
  inset: 0;
  opacity: 1 !important;
  visibility: visible !important;
}

#pv-stage .rise {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

.pv-hint,
.lib-hint {
  margin: 0 14px 14px;
  font-size: 11px;
  color: #948f88;
  line-height: 1.6;
}

/* 素材库 */
.lib {
  border-top: 1.5px solid rgba(13, 13, 13, 0.14);
  padding-top: 12px;
}

.lib-head {
  padding: 0 14px 8px;
  font-family: var(--en);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 0 14px;
  max-height: 260px;
  overflow-y: auto;
}

.lib-item {
  position: relative;
  aspect-ratio: 1;
  border: 1.5px solid #c9c4bc;
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
}

.lib-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lib-item:hover { border-color: var(--pink); }

.lib-item .vs {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--en);
  font-size: 9px;
  background: #1d1c20;
  color: var(--yellow);
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  padding: 11px 22px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--px);
  font-size: 13px;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.22s;
  z-index: 100;
}

.toast.on {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.toast.err { background: #b00020; }

@media (max-width: 1240px) {
  .layout { grid-template-columns: 190px 1fr; }
  .preview { display: none; }
}
