/* =========================================================
   腾云 — 后台面板
   与前台同一套暖纸编辑风：米白纸底 / 墨黑 / 深藏蓝 / 花黄
   自包含，不依赖任何第三方 UI 框架
   ========================================================= */

@font-face {
  font-family: "Inter Variable";
  src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/instrument-serif-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper:   #e9e5da;
  --paper-2: #f1ede3;
  --paper-3: #f7f4ec;
  --paper-4: #fcfaf5;

  --ink:     #14161a;
  --ink-soft:#33373e;
  --muted:   #6e6c64;
  --line:    rgba(20, 22, 26, 0.15);
  --line-2:  rgba(20, 22, 26, 0.32);

  --blue:    #2e4bdb;
  --blue-deep:#1a2c8c;
  --saffron: #e9a227;
  --clay:    #c4643c;
  --pine:    #1e3a38;

  --sans:  "Inter Variable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
           "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Instrument Serif", Georgia, "Songti SC", "SimSun", serif;
  --ease:  cubic-bezier(0.22, 1, 0.36, 1);

  --topbar-h: 60px;
  --r: 12px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 500; letter-spacing: -0.04em; line-height: 1.2; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }

.serif-num { font-family: var(--serif); font-weight: 400; letter-spacing: -0.02em; }

/* ---------------- 登录闸门 ---------------- */

.gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
.gate[hidden] { display: none; }

.gate-card {
  width: min(400px, 100%);
  padding: 30px 28px 26px;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--paper-4);
  box-shadow: 0 24px 60px rgba(20, 22, 26, 0.14);
}
.gate-kicker {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.gate-title { margin-bottom: 8px; font-size: 26px; }
.gate-sub { margin-bottom: 22px; color: var(--muted); font-size: 13px; line-height: 1.6; }

.gate-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border: 1px solid rgba(196, 100, 60, 0.4);
  border-radius: 8px;
  background: rgba(196, 100, 60, 0.08);
  color: #8e4526;
  font-size: 12.5px;
}
.gate-error[hidden] { display: none; }

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  height: var(--topbar-h);
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(233, 229, 218, 0.9);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
.brand { display: flex; align-items: baseline; gap: 9px; text-decoration: none; }
.brand__name { font-family: var(--serif); font-size: 19px; }
.brand__role {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tabs { display: flex; gap: 2px; margin-left: 8px; }
.tab {
  position: relative;
  min-height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease;
}
.tab:hover { background: var(--paper-2); color: var(--ink); }
.tab.is-active { background: var(--ink); color: var(--paper-4); }
.tab__badge {
  display: inline-block;
  min-width: 17px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--clay);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 17px;
  text-align: center;
  vertical-align: 1px;
}
.tab.is-active .tab__badge { background: var(--saffron); color: var(--ink); }
.tab__badge[hidden] { display: none; }

.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.topbar-user { color: var(--muted); font-size: 12px; }
.topbar-link { color: var(--muted); font-size: 12.5px; text-decoration: none; transition: color 180ms ease; }
.topbar-link:hover { color: var(--ink); }

/* ---------------- 画布 ---------------- */

.canvas { max-width: 1180px; margin: 0 auto; padding: 30px 20px 90px; }
.view[hidden] { display: none; }

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.view-head h1 { font-size: 25px; }
.view-head p { margin-top: 6px; color: var(--muted); font-size: 13px; }

.section-title {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 15px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--paper-4);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 200ms var(--ease), background-color 180ms ease,
              border-color 180ms ease, color 180ms ease;
}
.btn:hover { border-color: var(--ink); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: progress; transform: none; }
.btn--primary { background: var(--ink); border-color: var(--ink); color: var(--paper-4); }
.btn--primary:hover { background: var(--blue); border-color: var(--blue); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn--ghost:hover { color: var(--ink); }
.btn--danger { color: #8e4526; border-color: rgba(196, 100, 60, 0.4); background: rgba(196, 100, 60, 0.06); }
.btn--danger:hover { background: var(--clay); border-color: var(--clay); color: #fff; }
.btn--tiny { min-height: 30px; padding: 0 10px; border-radius: 7px; font-size: 12px; }
.btn--block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------------- 表单 ---------------- */

.field { display: grid; gap: 6px; }
.field > label,
.field > .field-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.input, .textarea, .select {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--paper-4);
  font-size: 13.5px;
  line-height: 1.5;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.textarea { min-height: 84px; resize: vertical; font-family: inherit; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(46, 75, 219, 0.13);
}
.input--mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------------- 卡片 ---------------- */

.card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--paper-4);
}
.card + .card { margin-top: 14px; }

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

.stat {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--paper-4);
}
.stat__label { color: var(--muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.stat__value { margin-top: 8px; font-family: var(--serif); font-size: 34px; line-height: 1; letter-spacing: -0.02em; }
.stat__foot { margin-top: 7px; color: var(--muted); font-size: 11.5px; }
.stat--accent { background: var(--ink); border-color: var(--ink); color: var(--paper-4); }
.stat--accent .stat__label, .stat--accent .stat__foot { color: rgba(240, 238, 229, 0.66); }

/* ---------------- 列表 ---------------- */

.list { display: grid; }
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-row__main { flex: 1 1 auto; min-width: 0; }
.list-row__title { font-size: 13.5px; font-weight: 500; letter-spacing: -0.015em; }
.list-row__meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
  word-break: break-word;
}
.list-row__actions { display: flex; flex: 0 0 auto; gap: 6px; }
.list-empty { padding: 26px 0; color: var(--muted); font-size: 13px; text-align: center; }

.tag {
  display: inline-block;
  flex: 0 0 auto;
  padding: 2px 8px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.tag--pending { border-color: var(--saffron); color: #8a5f08; background: rgba(233, 162, 39, 0.12); }
.tag--approved { border-color: var(--pine); color: var(--pine); background: rgba(30, 58, 56, 0.08); }
.tag--spam { border-color: var(--clay); color: #8e4526; background: rgba(196, 100, 60, 0.1); }
.tag--active { border-color: var(--pine); color: var(--pine); }
.tag--blocked { border-color: var(--clay); color: #8e4526; }
.tag--admin { border-color: var(--blue); color: var(--blue); background: rgba(46, 75, 219, 0.08); }

.filter-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.filter {
  min-height: 32px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease;
}
.filter:hover { color: var(--ink); border-color: var(--line-2); }
.filter.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper-4); }

/* ---------------- 图表 ---------------- */

.chart { width: 100%; height: auto; }
.chart-wrap { padding: 8px 0 0; }
.chart-legend { display: flex; gap: 18px; margin-top: 12px; color: var(--muted); font-size: 11.5px; }
.chart-legend i { display: inline-block; width: 14px; height: 2px; margin-right: 6px; vertical-align:3px; }

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.bar-row:last-child { border-bottom: 0; }
.bar-row__name { font-size: 12.5px; word-break: break-all; }
.bar-row__num { color: var(--muted); font-size: 12px; }
.bar-row__track { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.bar-row__fill { height: 100%; border-radius: 3px; background: var(--blue); }
.bar-row__fill.is-alt { background: var(--saffron); }

/* ---------------- 可重复条目编辑器 ---------------- */

.rep { display: grid; gap: 10px; }
.rep-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-3);
}
.rep-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 9px;
  border-bottom: 1px dashed var(--line-2);
}
.rep-head__label { flex: 1 1 auto; font-size: 12px; font-weight: 500; }
.rep-num {
  display: inline-grid;
  width: 22px; height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper-4);
  font-family: var(--serif);
  font-size: 12px;
}
.icon-btn {
  display: grid;
  width: 26px; height: 26px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-4);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
.icon-btn--danger:hover { color: #8e4526; border-color: var(--clay); }

.content-block { margin-bottom: 16px; }
.content-block__head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.content-block__key { font-family: var(--serif); font-size: 17px; }
.content-block__desc { color: var(--muted); font-size: 11.5px; }

/* ---------------- 图片上传 ---------------- */

.img-picker { display: flex; gap: 12px; align-items: flex-start; }
.img-preview {
  display: grid;
  flex: 0 0 auto;
  width: 132px;
  height: 92px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background:
    linear-gradient(45deg, var(--paper-2) 25%, transparent 25%, transparent 75%, var(--paper-2) 75%) 0 0 / 12px 12px,
    var(--paper-3);
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-side { display: grid; flex: 1 1 auto; gap: 8px; }
.img-hint { color: var(--muted); font-size: 11.5px; line-height: 1.5; }

.gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.gallery-item {
  position: relative;
  width: 62px;
  height: 46px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper-3);
  cursor: pointer;
  transition: border-color 160ms ease;
}
.gallery-item:hover { border-color: var(--blue); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------- 弹层 ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 22, 26, 0.42);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fade-in 180ms var(--ease) both;
}
.modal[hidden] { display: none; }
.modal__panel {
  width: min(880px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--paper-4);
  box-shadow: 0 30px 70px rgba(20, 22, 26, 0.3);
  animation: pop-in 260ms var(--ease) both;
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.modal__head h2 { font-size: 20px; }
.modal__foot {
  position: sticky;
  bottom: -22px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 20px -22px -22px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--paper-4);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

/* ---------------- 提示条 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper-4);
  font-size: 13px;
  box-shadow: 0 16px 40px rgba(20, 22, 26, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="error"] { background: #8e4526; }

.loading { padding: 40px 0; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
}
@media (max-width: 720px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand__role, .topbar-user { display: none; }
  .canvas { padding: 20px 14px 80px; }
  .view-head { flex-direction: column; align-items: flex-start; }
  .modal__panel { padding: 16px; }
  .modal__foot { margin: 18px -16px -16px; padding: 12px 16px; }
  .img-picker { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .modal, .modal__panel, .toast { animation: none; transition: none; }
}
