/* ==========================================================================
   失乐园 · 内容管理
   --------------------------------------------------------------------------
   结构：顶栏 → 卡片 → 表单 → 模特列表/编辑 → 素材格子 → 移动端
   取向：一层结构、少按钮、去掉一切往返导出的中间态
   ========================================================================== */

:root {
  --paper: #fbfaf7;
  --paper-2: #f4f1ea;
  --paper-3: #efece4;
  --ink: #17140f;
  --ink-2: #4a443b;
  --muted: #8b8377;
  --line: #e5dfd3;
  --line-strong: #d4ccbb;
  --gold: #a07e4a;
  --gold-soft: #f0e8d9;
  --danger: #a4402f;
  --font-display: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.admin {
  margin: 0;
  background: #f6f3ec;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.admin img,
.admin video {
  display: block;
  max-width: 100%;
}

.admin button {
  font-family: inherit;
}

.shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 clamp(14px, 3vw, 32px) 64px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 0;
  margin-bottom: 18px;
  background: rgba(246, 243, 236, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex: none;
}

.brand a {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 0.18em;
  color: var(--ink);
}

.brand span {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
}

.tabs button {
  border: 0;
  background: none;
  padding: 7px 17px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.tabs button:hover {
  color: var(--ink);
}

.tabs button.is-on {
  background: var(--ink);
  color: var(--paper);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  flex: none;
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.save-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b9b2a4;
}

.save-state.is-dirty {
  color: var(--gold);
}

.save-state.is-dirty::before {
  background: var(--gold);
}

.save-state.is-ok::before {
  background: #5c8a5f;
}

.save-state i {
  font-style: normal;
}

.btn-save {
  height: 40px;
  padding: 0 22px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  border-radius: 2px;
  cursor: pointer;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.btn-save:disabled {
  opacity: 0.28;
  cursor: default;
}

.btn-save:not(:disabled):hover {
  transform: translateY(-1px);
}

.btn-save.is-busy {
  opacity: 0.6;
}

/* ---------- 卡片 ---------- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 22px 24px;
  margin-bottom: 14px;
}

.card > h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--ink);
}

.card > h2 em {
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.card-hint {
  margin: -8px 0 16px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

/* ---------- 表单 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px 18px;
}

.span-2 {
  grid-column: span 2;
}

.field {
  min-width: 0;
}

.field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fbfaf7;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.field textarea {
  min-height: 76px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--ink-2);
  background: #fff;
}

.field .tip {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

/* 开关（.field > label 会覆盖 display，这里提高一级选择器） */
.field > label.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  margin-bottom: 0;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--ink-2);
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch i {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #ddd6c8;
  transition: background 0.24s var(--ease);
  flex: none;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.24s var(--ease);
}

.switch input:checked + i {
  background: var(--gold);
}

.switch input:checked + i::after {
  transform: translateX(18px);
}

/* ---------- 通用按钮 ---------- */
.btn-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.btn-line:hover {
  border-color: var(--ink-2);
  background: #fbfaf7;
}

.btn-line.is-ghost {
  border-style: dashed;
  color: var(--muted);
}

.btn-line.is-danger {
  color: var(--danger);
  border-color: #e3cdc7;
}

.btn-line.is-danger:hover {
  background: #fdf5f3;
  border-color: var(--danger);
}

/* ---------- 表头（桌面用表头，手机用字段标签） ---------- */
.table-head {
  display: grid;
  gap: 10px;
  padding-bottom: 9px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.head-contact {
  grid-template-columns: 132px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr) 34px;
}

.head-region {
  grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr) 76px 34px;
}

@media (min-width: 861px) {
  .contact-row .field > label,
  .region-row .field > label {
    display: none;
  }

  .contact-row,
  .region-row {
    align-items: center;
  }

  .contact-row .field input,
  .contact-row .field select,
  .region-row .field input {
    background: #fff;
  }
}

/* ---------- 联系方式行 ---------- */
.contact-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr) 34px;
  gap: 10px;
  align-items: end;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.table-head + .contact-row {
  border-top: 0;
  padding-top: 4px;
}

.icon-btn {
  width: 34px;
  height: 40px;
  border: 1px solid transparent;
  background: none;
  border-radius: 2px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}

.icon-btn:hover {
  color: var(--danger);
  background: #fdf5f3;
}

.row-foot {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

/* ---------- 模特：列表 + 编辑 ---------- */
.models-wrap {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.mlist {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  position: sticky;
  top: 88px;
}

.mlist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.mlist-body {
  max-height: 62vh;
  overflow-y: auto;
}

.mrow {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid #f2eee5;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s var(--ease);
}

.mrow:hover {
  background: #fbfaf7;
}

.mrow.is-on {
  background: #f4efe4;
  box-shadow: inset 3px 0 0 var(--gold);
}

.mrow-thumb {
  width: 34px;
  height: 45px;
  flex: none;
  object-fit: cover;
  background: var(--paper-3);
  border-radius: 1px;
}

.mrow-txt {
  min-width: 0;
  flex: 1;
}

.mrow-name {
  display: block;
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mrow-meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag {
  flex: none;
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 2px;
  background: var(--gold-soft);
  color: #7a5c2c;
}

.tag.is-off {
  background: #eee9de;
  color: var(--muted);
}

/* 编辑区头部 */
.edit-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.edit-head .back {
  display: none;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px 0 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 2px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}

.edit-title {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.06em;
}

.edit-sub {
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------- 封面 ---------- */
.cover-wrap {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.cover-box {
  position: relative;
  width: 132px;
  flex: none;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  background: var(--paper-3);
  border-radius: 2px;
  overflow: hidden;
}

.cover-box img,
.cover-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-box .empty {
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 10px;
}

.cover-side {
  flex: 1;
  min-width: 0;
}

.cover-side .btn-line + .btn-line {
  margin-left: 8px;
}

.cover-side .card-hint {
  margin: 12px 0 0;
}

/* ---------- 相册 ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}

.tile {
  position: relative;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  background: var(--paper-3);
  border-radius: 2px;
  overflow: hidden;
}

.tile img,
.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile .kind {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 1px 6px;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 2px;
}

.tile .kill {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 17, 12, 0.62);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.tile:hover .kill,
.tile:focus-within .kill {
  opacity: 1;
}

.tile.is-busy {
  display: grid;
  place-items: center;
  border-style: dashed;
  color: var(--muted);
  font-size: 11px;
}

.tile-add {
  display: grid;
  place-items: center;
  gap: 6px;
  aspect-ratio: 3 / 4;
  border: 1px dashed var(--line-strong);
  border-radius: 2px;
  background: #fbfaf7;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s;
}

.tile-add:hover {
  border-color: var(--ink-2);
  color: var(--ink);
  background: #fff;
}

.tile-add b {
  font-size: 18px;
  font-weight: 300;
  line-height: 1;
}

.media-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.media-foot .link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 11.5px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.media-foot .link-btn:hover {
  color: var(--ink);
}

/* ---------- 折叠块 ---------- */
.acc {
  border-top: 1px dashed var(--line);
  margin-top: 4px;
  padding-top: 4px;
}

.acc > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 6px;
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ink-2);
}

.acc > summary::-webkit-details-marker {
  display: none;
}

.acc > summary::after {
  content: "展开";
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.acc[open] > summary::after {
  content: "收起";
}

.acc .acc-body {
  padding: 6px 0 4px;
}

/* ---------- 模特底部操作 ---------- */
.edit-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 24px;
}

.edit-foot .spacer {
  flex: 1;
}

/* ---------- 区域 ---------- */
.region-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr) 76px 34px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.table-head + .region-row {
  border-top: 0;
}

.row-count {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

.region-row .idx {
  display: grid;
  place-items: center;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fbfaf7;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- 提示 ---------- */
.loading {
  padding: 80px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #f6f3ec;
}

.boot-card {
  max-width: 520px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 32px;
  border-radius: 3px;
}

.boot-card h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.08em;
  margin: 0 0 12px;
}

.boot-card p,
.boot-card li {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.8;
}

.boot-card ol {
  padding-left: 18px;
}

.boot-card .boot-actions {
  margin: 20px 0 0;
}

.boot-card .boot-btn {
  display: inline-block;
  padding: 11px 22px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-decoration: none;
  border-radius: 2px;
  transition: opacity 0.2s var(--ease);
}

.boot-card .boot-btn:hover {
  opacity: 0.82;
}

.boot-card .boot-back {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.boot-card .boot-back a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line-2, #cfc9bd);
  padding-bottom: 1px;
}

.boot-card .boot-back a:hover {
  border-bottom-color: var(--ink);
}

.boot-card code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--paper-2);
  padding: 2px 6px;
  border-radius: 2px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  z-index: 95;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s var(--ease), transform 0.26s var(--ease);
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ==========================================================================
   移动端
   ========================================================================== */
@media (max-width: 860px) {
  .shell {
    padding: 0 14px 40px;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 11px 0 9px;
    margin-bottom: 12px;
  }

  .brand {
    order: 1;
  }

  .brand a {
    font-size: 15px;
  }

  .top-actions {
    order: 2;
    gap: 10px;
  }

  .save-state {
    font-size: 11px;
    white-space: nowrap;
  }

  .save-state i {
    display: none;
  }

  .btn-save {
    height: 36px;
    padding: 0 14px;
    font-size: 12px;
    letter-spacing: 0.04em;
  }

  .tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    border-radius: 2px;
    padding: 2px;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  /* 手机上不再用表头，各字段自带标签 */
  .table-head {
    display: none;
  }

  .tabs button {
    flex: 1;
    padding: 8px 6px;
    font-size: 12.5px;
    border-radius: 2px;
  }

  .card {
    padding: 15px 13px;
    margin-bottom: 10px;
  }

  .field > label {
    margin-bottom: 4px;
    font-size: 11px;
  }

  .card > h2 {
    margin-bottom: 14px;
    font-size: 14px;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px 10px;
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px 10px;
  }

  .span-2 {
    grid-column: span 2;
  }

  .field input,
  .field textarea,
  .field select {
    min-height: 42px;
    font-size: 15px; /* 避免 iOS 聚焦时自动放大 */
  }

  /* 联系方式：改成两行紧凑布局 */
  .contact-row {
    grid-template-columns: minmax(0, 1fr) 34px;
    grid-template-areas:
      "type kill"
      "label label"
      "value value"
      "link link";
    gap: 8px;
    padding: 14px 0;
  }

  .contact-row > .f-type {
    grid-area: type;
  }

  .contact-row > .f-label {
    grid-area: label;
  }

  .contact-row > .f-value {
    grid-area: value;
  }

  .contact-row > .f-link {
    grid-area: link;
  }

  .contact-row > .f-kill {
    grid-area: kill;
  }

  /* 模特：列表与编辑同一屏切换，避免超长页面 */
  .models-wrap {
    display: block;
  }

  .mlist {
    position: static;
  }

  .mlist-body {
    max-height: none;
  }

  .models-wrap .editor {
    display: none;
  }

  .models-wrap.mode-edit .mlist {
    display: none;
  }

  .models-wrap.mode-edit .editor {
    display: block;
  }

  .edit-head .back {
    display: inline-flex;
  }

  .edit-title {
    font-size: 16px;
  }

  .cover-wrap {
    gap: 14px;
  }

  .cover-box {
    width: 104px;
  }

  .cover-side .btn-line {
    height: 36px;
    padding: 0 12px;
    font-size: 12px;
  }

  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .tile .kill {
    opacity: 1;
    width: 20px;
    height: 20px;
    font-size: 11px;
    background: rgba(20, 17, 12, 0.45);
  }

  /* 开关不需要标签，去掉空行 */
  .field-toggle > label:first-child {
    display: none;
  }

  .field-toggle {
    align-self: end;
  }

  .region-row {
    grid-template-columns: 44px minmax(0, 1fr) 34px;
    grid-template-areas:
      "idx name kill"
      "idx nameEn nameEn";
    gap: 8px;
    padding: 12px 0;
  }

  .region-row .row-count {
    display: none;
  }

  .row-count {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

.region-row .idx {
    grid-area: idx;
    height: 42px;
  }

  .region-row > .f-name {
    grid-area: name;
  }

  .region-row > .f-nameEn {
    grid-area: nameEn;
  }

  .region-row > .f-kill {
    grid-area: kill;
  }
}
