:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-soft: #fafbfd;
  --border: #e6e8ef;
  --border-strong: #d5d9e4;
  --text: #131a2b;
  --text-2: #5b6479;
  --text-3: #8b93a7;
  --accent: #4f46e5;
  --accent-ink: #4238cf;
  --accent-soft: #eef0ff;
  --danger: #dc2f36;
  --danger-soft: #fdecec;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-2: 0 12px 28px -16px rgba(16, 24, 40, .28);
  --shadow-3: 0 24px 60px -24px rgba(16, 24, 40, .35);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ================ 共用组件（前后台都用） ================ */

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 15px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 550;
  box-shadow: 0 6px 16px -8px rgba(79, 70, 229, .9);
  transition: background .15s, transform .12s;
}

.primary-btn:hover { background: var(--accent-ink); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn[disabled] { opacity: .6; cursor: not-allowed; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  transition: all .15s;
}

.ghost-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-soft);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
}

.icon-btn:hover { background: var(--surface-soft); color: var(--text); }

/* 弹窗表单（后台编辑器） */

.dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-3);
}

.dialog::backdrop {
  background: rgba(19, 26, 43, .38);
  backdrop-filter: blur(2px);
}

.dialog form { padding: 20px 22px 18px; }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.dialog-head h3 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }

.field { display: block; margin-bottom: 14px; }

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
}

.field > span i { color: var(--danger); font-style: normal; }

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 13.5px;
  outline: 0;
  transition: border-color .15s, box-shadow .15s, background .15s;
  resize: vertical;
}

.field input[type="text"]:focus,
.field input[type="email"]:focus,
.field input[type="password"]:focus,
.field textarea:focus {
  background: #fff;
  border-color: #b9b7f4;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.field small {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--text-3);
}

.field small.is-error { color: var(--danger); }
.field small.is-ok { color: #15803d; }

.icon-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-row input { flex: 1; }

.icon-preview {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 22px;
}

.icon-preview img { width: 100%; height: 100%; object-fit: contain; }

.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  cursor: text;
}

.tag-input:focus-within {
  background: #fff;
  border-color: #b9b7f4;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.tag-chips { display: contents; }

.tag-chips .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 6px;
  padding: 2px 5px 2px 8px;
  font-size: 12px;
}

.tag-chips .chip button {
  border: 0;
  background: none;
  padding: 0;
  line-height: 1;
  color: inherit;
  opacity: .55;
  font-size: 13px;
}

.tag-chips .chip button:hover { opacity: 1; }

.tag-input input {
  flex: 1;
  min-width: 110px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13.5px;
  padding: 3px 2px;
}

.tag-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag-suggest:empty { display: none; }

.suggest-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  transition: filter .15s, transform .12s;
}

.suggest-chip span { opacity: .7; font-size: 11px; }
.suggest-chip:hover { filter: brightness(.94); }
.suggest-chip:active { transform: scale(.97); }

.switch-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0 18px;
  cursor: pointer;
  user-select: none;
}

.switch-row input { position: absolute; opacity: 0; pointer-events: none; }

.switch {
  width: 36px;
  height: 21px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background .18s;
  flex: none;
}

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

.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(15px); }
.switch-label { font-size: 13px; color: var(--text-2); }

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.tag-pill {
  font-size: 11px;
  border-radius: 6px;
  padding: 1px 6px;
  white-space: nowrap;
  border: 1px solid transparent;
}

/* 提示气泡 */

.toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 11px;
  background: #131a2b;
  color: #f4f5f8;
  font-size: 13px;
  box-shadow: var(--shadow-3);
  animation: toast-in .22s ease both;
  max-width: 320px;
}

.toast.is-error { background: #7f1d1d; }
.toast.is-out { animation: toast-out .2s ease both; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px) scale(.98); }
}

/* ================ 前台：分组导航（暗色） ================ */

body.front {
  min-height: 100vh;
  color: #eef2fa;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(120, 170, 255, .35), transparent 60%),
    radial-gradient(900px 600px at -10% 100%, rgba(37, 64, 130, .55), transparent 55%),
    linear-gradient(158deg, #3d6ab5 0%, #2a4c8f 40%, #17284c 78%, #101d3a 100%);
  background-attachment: fixed;
}

/* 自定义背景图：叠一层可调深浅的遮罩，保证文字可读 */
body.front.has-bg {
  background-image:
    linear-gradient(
      rgba(16, 29, 58, var(--bg-dim, .72)),
      rgba(10, 19, 38, calc(var(--bg-dim, .72) + .1))
    ),
    var(--bg-url);
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed, fixed;
}

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1060px;
  margin: 0 auto;
  padding: 26px 24px 6px;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.site-logo {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  font-size: 19px;
  backdrop-filter: blur(4px);
}

.site-logo img { width: 100%; height: 100%; object-fit: contain; }

.site-brand h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 750;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 12px rgba(9, 20, 45, .35);
}

.head-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 240px;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .22);
  color: rgba(255, 255, 255, .6);
  backdrop-filter: blur(6px);
  transition: background .15s, border-color .15s;
}

.search:focus-within { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .4); }

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13.5px;
  color: #fff;
}

.search input::placeholder { color: rgba(255, 255, 255, .55); }
.search input::-webkit-search-cancel-button { display: none; }

.admin-entry {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: rgba(255, 255, 255, .75);
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .18);
  transition: all .15s;
}

.admin-entry:hover { color: #fff; background: rgba(255, 255, 255, .2); }

.sections {
  max-width: 1060px;
  margin: 0 auto;
  padding: 10px 24px 64px;
}

.group { margin-top: 26px; }

.group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: .01em;
  color: #fff;
  text-shadow: 0 2px 12px rgba(9, 20, 45, .35);
}

.group-glyph {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .2);
  color: rgba(255, 255, 255, .85);
  flex: none;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 14px;
}

.nav-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .16);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background .16s, transform .16s, box-shadow .16s;
}

.nav-card:hover {
  background: rgba(255, 255, 255, .17);
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -14px rgba(6, 15, 35, .55);
}

.nav-card:focus-visible { outline: 2px solid rgba(255, 255, 255, .6); outline-offset: 2px; }

.nav-card-body { min-width: 0; flex: 1; }

.nav-card-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

.nav-card-desc {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, .62);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nav-card-icon {
  position: relative;
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 11px;
  font-size: 25px;
  line-height: 1;
}

.nav-card-icon > span { position: relative; z-index: 1; }

.nav-card-icon img {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
}

.nav-card-icon.has-letter img { background: transparent; }

.front-empty {
  max-width: 560px;
  margin: 60px auto;
  padding: 40px 24px;
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, .3);
  border-radius: 16px;
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .75);
}

.front-empty h3 { margin: 10px 0 4px; font-size: 16px; color: #fff; }
.front-empty p { margin: 0; font-size: 13px; }

.skeleton-card {
  height: 72px;
  border-radius: 13px;
  background: linear-gradient(100deg, rgba(255,255,255,.08) 30%, rgba(255,255,255,.16) 45%, rgba(255,255,255,.08) 60%);
  background-size: 240% 100%;
  animation: shimmer 1.4s infinite linear;
  border: 1px solid rgba(255, 255, 255, .12);
}

@keyframes shimmer {
  from { background-position: 130% 0; }
  to { background-position: -30% 0; }
}

@media (max-width: 640px) {
  .site-head { flex-wrap: wrap; padding-top: 18px; }
  .search { width: 100%; order: 3; }
  .head-right { order: 2; margin-left: auto; }
  .site-brand { order: 1; flex: 1; }
  .sections { padding: 6px 16px 48px; }
  .group-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .nav-card { padding: 12px 13px; }
  .nav-card-desc { -webkit-line-clamp: 1; }
  .toasts { left: 14px; right: 14px; bottom: 14px; }
  .toast { max-width: none; }
}
