/* 星布谷地 Wiki —— 星空主题（沿用原站风格） */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: #f0e6c8; background: #0b1030; overflow-x: hidden; min-height: 100vh;
  padding-top: var(--header-h, 76px);
}
a { color: inherit; }

.bg { position: fixed; inset: 0; z-index: -2; background: url("assets/背景.jpg") center / cover no-repeat, #0b1030; }
.bg-mask {
  position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(10,15,45,0.82) 0%, rgba(15,20,55,0.78) 50%, rgba(10,15,45,0.88) 100%);
}

/* ---------- 顶栏 ---------- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: rgba(12,18,48,0.86);
  backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255,217,122,0.18);
  position: fixed; top: 0; left: 0; right: 0; z-index: 30; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; cursor: pointer; }
.brand .logo { height: 48px; width: auto; display: block; }
.brand .sub { font-size: 13px; color: #a8b3d9; letter-spacing: 2px; border-left: 1px solid rgba(255,217,122,0.3); padding-left: 14px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,217,122,0.25);
  border-radius: 20px; padding: 6px 14px; width: 240px;
}
.search-box input { background: transparent; border: none; outline: none; color: #f0e6c8; font-size: 14px; width: 100%; }
.search-box input::placeholder { color: #8a94b8; }

.btn {
  padding: 6px 16px; border-radius: 18px; cursor: pointer; font-size: 13px;
  background: rgba(255,217,122,0.15); color: #ffd97a;
  border: 1px solid rgba(255,217,122,0.5); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: rgba(255,217,122,0.25); }
.btn-solid { background: #ffd97a; color: #1a2250; font-weight: 600; border: none; }
.btn-ghost { background: rgba(255,255,255,0.08); color: #d8d4c0; border-color: transparent; }
.btn-danger { background: rgba(255,110,110,0.15); color: #ff9c9c; border-color: rgba(255,110,110,0.4); }
.user-chip { font-size: 13px; color: #9cd6ff; display: flex; align-items: center; gap: 8px; }

/* ---------- 布局 ---------- */
.layout {
  display: grid; grid-template-columns: var(--aside-w, 260px) 1fr; gap: 20px;
  max-width: 1400px; margin: 20px auto; padding: 0 20px 40px;
}
.layout.no-aside { grid-template-columns: 1fr; }
aside { display: flex; flex-direction: column; gap: 16px; align-self: start; position: sticky; top: 90px; }
.aside-card {
  background: rgba(20,28,65,0.7); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,217,122,0.18); border-radius: 12px; padding: 18px;
}
.aside-card h2 {
  font-size: 15px; color: #ffd97a; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px dashed rgba(255,217,122,0.25);
  display: flex; align-items: center; gap: 8px;
}
.aside-card h2::before { content: ""; width: 4px; height: 14px; background: #ffd97a; border-radius: 2px; }
.about-box { font-size: 12px; line-height: 1.7; color: #c8c4b0; }

main {
  background: rgba(20,28,65,0.6); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,217,122,0.18); border-radius: 12px; padding: 24px;
}
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.page-title { display: flex; align-items: center; gap: 12px; font-size: 22px; color: #ffd97a; }
.page-title img:not(.cat-head-icon) { width: 40px; height: 40px; object-fit: contain; }
.cat-head-icon { object-fit: contain; max-height: 96px; }
.breadcrumb { font-size: 12px; color: #8a94b8; margin-bottom: 14px; }
.breadcrumb a { color: #ffd97a; text-decoration: none; cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }

/* 主页分类网格 */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.cat-entry {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 18px 10px; text-decoration: none; color: #f0e6c8;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; transition: all .2s; cursor: pointer;
}
.cat-entry:hover { transform: translateY(-3px); border-color: rgba(255,217,122,0.6); background: rgba(255,217,122,0.1); }
.cat-entry .icon { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; }
.cat-entry img { max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 3px 8px rgba(0,0,0,0.3)); }
.cat-entry .label { font-size: 14px; font-weight: 600; letter-spacing: 1px; }
.fallback { font-size: 26px; color: #ffd97a; font-weight: bold; }

/* 物品网格（分类页） */
.tag-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.tag-btn { padding: 5px 14px; border-radius: 14px; cursor: pointer; background: rgba(255,255,255,0.06); color: #d8d4c0; border: 1px solid transparent; font-size: 13px; }
.tag-btn:hover { background: rgba(255,217,122,0.12); }
.tag-btn.active { background: rgba(255,217,122,0.22); color: #ffd97a; border-color: rgba(255,217,122,0.5); }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.item-card {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 14px 10px; text-align: center; cursor: pointer; transition: all .15s;
}
.item-card:hover { transform: translateY(-2px); border-color: rgba(255,217,122,0.5); background: rgba(255,217,122,0.08); }
.item-card .icon { width: 64px; max-width: 100%; height: auto; margin: 0 auto 8px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.06); border-radius: 10px; }
.item-card .icon img { width: 100%; height: auto; object-fit: contain; display: block; }
.item-card .name { font-size: 14px; color: #f0e6c8; }
.item-card .tags { font-size: 11px; color: #8a94b8; margin-top: 3px; }

/* 文章页（物品详情） */
.article-layout { display: grid; grid-template-columns: var(--left-w, 260px) 1fr; gap: 20px; }
.left-card {
  background: rgba(20,28,65,0.7); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,217,122,0.18); border-radius: 12px; padding: 24px;
  text-align: center; align-self: start; position: sticky; top: 90px;
}
.left-card .icon-box { max-width: 100%; margin: 0 auto 16px; background: rgba(255,255,255,0.06); border-radius: 16px; display: flex; align-items: center; justify-content: center; }
.left-card .icon-box img { width: 100%; height: auto; object-fit: contain; display: block; }
.left-card h1 { font-size: 20px; color: #ffd97a; }
.article-body h2 { font-size: 17px; color: #ffd97a; margin: 16px 0 8px; padding-left: 8px; border-left: 3px solid #ffd97a; }
.article-body h3 { font-size: 15px; color: #ffd97a; margin: 12px 0 6px; }
.article-body p, .article-body li { margin: 6px 0; line-height: 1.8; font-size: 14px; }
.article-body ul, .article-body ol { margin-left: 24px; }
.article-body strong { color: #ffd97a; }
.article-body a { color: #9cd6ff; }
.article-body hr { border: none; border-top: 1px dashed rgba(255,217,122,0.3); margin: 14px 0; }
.wiki-img img { max-width: 100%; border-radius: 8px; margin: 6px 0; }
.wiki-img figcaption { font-size: 12px; color: #8a94b8; text-align: center; }

/* 公告列表 */
.ann-row { padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 13px; line-height: 1.6; color: #d8d4c0; }
.ann-row:last-child { border-bottom: none; }
.ann-meta .date { font-size: 11px; color: #8a94b8; }
.ann-list .tag, .ann-row .tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 8px; margin-right: 6px; vertical-align: 1px; }
.tag-update { background: rgba(255,217,122,0.18); color: #ffd97a; }
.tag-event  { background: rgba(120,200,255,0.18); color: #9cd6ff; }
.tag-notice { background: rgba(255,150,150,0.18); color: #ffb0b0; }
a.ann-title { color: #f0e6c8; text-decoration: none; border-bottom: 1px dotted rgba(255,217,122,0.4); }
a.ann-title:hover { color: #ffd97a; border-color: #ffd97a; }

.empty { text-align: center; padding: 40px 0; color: #8a94b8; font-size: 14px; }

/* ---------- 弹窗 / 编辑面板 ---------- */
.mask { position: fixed; inset: 0; background: rgba(5,8,25,0.7); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 150; padding: 20px; }
.mask.show { display: flex; }
.form-box { background: #1a2250; border: 1px solid rgba(255,217,122,0.4); border-radius: 12px; padding: 24px 28px; width: 420px; max-width: 92vw; max-height: 88vh; overflow-y: auto; }
.form-box h3 { color: #ffd97a; font-size: 16px; margin-bottom: 16px; }
.form-box label { display: block; font-size: 12px; color: #a8b3d9; margin: 10px 0 4px; }
.form-box input, .form-box textarea, .form-box select {
  width: 100%; padding: 8px 10px; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,217,122,0.25); border-radius: 6px;
  color: #f0e6c8; font-size: 14px; outline: none; font-family: inherit;
}
.form-box input:focus, .form-box textarea:focus { border-color: #ffd97a; }
.form-box textarea { min-height: 120px; resize: vertical; font-family: Consolas, monospace; font-size: 12px; line-height: 1.5; }
.form-box .foot { margin-top: 18px; display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.form-box .status { margin-right: auto; font-size: 12px; color: #9cd6ff; }

.edit-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  width: 640px; max-width: 94vw; max-height: 82vh; display: none; flex-direction: column;
  background: #1a2250; border: 1px solid rgba(255,217,122,0.5);
  border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); overflow: hidden;
}
body.editing .edit-panel { display: flex; }
.edit-panel .ep-head { padding: 10px 16px; background: rgba(255,217,122,0.15); color: #ffd97a; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.edit-panel .ep-head .hint { font-size: 11px; color: #a8b3d9; }
.edit-panel textarea {
  flex: 1; min-height: 360px; border: none; outline: none;
  background: #121838; color: #d8d4c0; padding: 14px;
  font-family: Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.6;
  resize: vertical; white-space: pre;
}
.edit-panel .ep-foot { padding: 10px 16px; display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.edit-panel .ep-foot .status { margin-right: auto; font-size: 12px; color: #9cd6ff; }
#epSummary { flex: 1; min-width: 120px; padding: 6px 10px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,217,122,0.25); border-radius: 6px; color: #f0e6c8; font-size: 13px; outline: none; }
#epSummary:focus { border-color: #ffd97a; }

.ep-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; background: rgba(255,255,255,0.04); border-bottom: 1px solid rgba(255,217,122,0.15); }
.ep-toolbar button { padding: 4px 10px; border-radius: 6px; cursor: pointer; background: rgba(255,217,122,0.12); color: #ffd97a; border: 1px solid rgba(255,217,122,0.3); font-size: 12px; }
.ep-toolbar button:hover { background: rgba(255,217,122,0.28); }

/* 历史列表 */
.history-item { padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 13px; color: #d8d4c0; }
.history-item .rev-no { color: #ffd97a; font-weight: 600; margin-right: 10px; }
.history-item .date { font-size: 12px; color: #8a94b8; margin-right: 10px; }
.history-item .summary { font-size: 12px; color: #c8c4b0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1a2250; border: 1px solid rgba(255,217,122,0.5); color: #f0e6c8; padding: 10px 20px; border-radius: 8px; z-index: 300; font-size: 14px; opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.error { border-color: rgba(255,110,110,0.6); }

/* 工具类（替代内联样式，配合严格 CSP） */
.page-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.user-row { display: flex; align-items: center; gap: 10px; }
.flex-1 { flex: 1; }
.ml10 { margin-left: 10px; }
.fs20 { font-size: 20px; }
.btn-sm { padding: 2px 10px; margin-left: 8px; }
.rev-view { margin-top: 16px; border-top: 1px dashed rgba(255,217,122,0.3); padding-top: 12px; }
.logo-text { font-size: 22px; color: #ffd97a; font-weight: 700; letter-spacing: 2px; }
.hidden { display: none !important; }
.form-box.wide { width: 520px; }
.divider { border-top: 1px dashed rgba(255,217,122,0.3); margin: 14px 0; padding-top: 14px; }
.section-title { font-size: 16px; color: #ffd97a; margin-bottom: 10px; }
.mb14 { margin-bottom: 14px; }
.module-card { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,217,122,0.14); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.module-card:last-child { margin-bottom: 0; }
.link-like { color: #ffd97a; cursor: pointer; }
.gold { color: #ffd97a; }

/* 修改历史模块（列表容器，外层由 module-card / aside-card 提供卡片样式） */
.recent-box { padding-top: 8px; }
.recent-title { font-size: 16px; color: #ffd97a; margin-bottom: 12px; padding-left: 8px; border-left: 3px solid #ffd97a; }
.recent-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 13px; color: #d8d4c0; }
.recent-item:last-child { border-bottom: none; }
.recent-item .date { font-size: 12px; color: #8a94b8; }
.recent-item .summary { font-size: 12px; color: #c8c4b0; }
.recent-more { cursor: pointer; text-align: center; color: #ffd97a; font-size: 15px; letter-spacing: 3px; padding: 8px 0; margin-top: 4px; border-top: 1px dashed rgba(255,217,122,0.25); user-select: none; }
.recent-more:hover { background: rgba(255,217,122,0.08); }

/* 图片ID列表（{{图片项}}）：文件名 + 可点击ID + 删除 */
.media-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 13px; }
.media-row:last-child { border-bottom: none; }
.media-name { color: #d8d4c0; }
.media-id { color: #9cd6ff; font-family: Consolas, "Courier New", monospace; font-size: 12px; word-break: break-all; text-decoration: none; }
.media-id:hover { color: #ffd97a; text-decoration: underline; }
.media-del { margin-left: auto; padding: 2px 10px; border-radius: 6px; cursor: pointer; background: rgba(255,110,110,0.15); color: #ff9c9c; border: 1px solid rgba(255,110,110,0.4); font-size: 12px; }
.media-del:hover { background: rgba(255,110,110,0.3); }
.media-replace { margin-left: auto; padding: 2px 10px; border-radius: 6px; cursor: pointer; background: rgba(255,217,122,0.12); color: #ffd97a; border: 1px solid rgba(255,217,122,0.4); font-size: 12px; }
.media-replace:hover { background: rgba(255,217,122,0.28); }
.media-replace + .media-del { margin-left: 6px; }

/* 小图标（{{图标}}）：紧贴图片的外边框，不显示名称；可带上下文字 */
.wiki-icon { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 4px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,217,122,0.25); border-radius: 6px; flex-shrink: 0; max-width: 100%; }
.wiki-icon img { display: block; max-width: 100%; height: auto; }
.wiki-icon-cap { font-size: 11px; color: #c8c4b0; line-height: 1.3; text-align: center; max-width: 140px; word-break: break-word; }

/* 图标列表模式（{{图标|...|列表=是}}）：图标在左、文字在右，一项一行 */
.wiki-icon-list { display: flex; align-items: center; gap: 8px; padding: 5px 0; max-width: 100%; }
.wiki-icon-list img { display: block; max-width: 100%; height: auto; flex-shrink: 0; }
.wiki-icon-list .wiki-icon-cap { text-align: left; max-width: none; }

/* 图标行（连续图标分组排列，默认换行） */
.icon-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin: 8px 0; }
.icon-row.nowrap { flex-wrap: nowrap; }
.icon-row.wrap { flex-wrap: wrap; }
.icon-row.left { justify-content: flex-start; }
.icon-row.center { justify-content: center; }
.icon-row.right { justify-content: flex-end; }

/* 分类页顶部介绍（wikitext 描述文字） */
.category-intro { margin-bottom: 16px; }
.category-intro h2 { font-size: 16px; color: #ffd97a; margin: 10px 0 6px; padding-left: 8px; border-left: 3px solid #ffd97a; }
.category-intro p, .category-intro li { line-height: 1.8; font-size: 14px; }

@media (max-width: 900px) {
  .layout, .layout.no-aside { grid-template-columns: 1fr; }
  aside { position: static; }
  .article-layout { grid-template-columns: 1fr; }
  .left-card { position: static; }
  .brand .sub { display: none; }
  .search-box { width: 160px; }
  header { padding: 10px 14px; gap: 8px; }
  .header-right { gap: 6px; }
}
