:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1f2329;
  --muted: #8a909a;
  --line: #e6e8eb;
  --brand: #009a2c;
  --brand-d: #007a22;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 820px; margin: 0 auto; padding: 0 18px; }

/* header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.nav-row { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { font-weight: 700; font-size: 19px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.nav a { margin-left: 16px; color: #444; font-size: 14px; }
.nav a:hover { color: var(--brand); text-decoration: none; }

.main { padding: 28px 18px 60px; min-height: 60vh; }
.subtitle { color: var(--muted); margin: 0 0 22px; font-size: 15px; }
.page-title { margin: 0 0 18px; }

/* post cards */
.post-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.post-card h2 { margin: 0 0 6px; font-size: 20px; }
.post-card h2 a { color: var(--ink); }
.post-card h2 a:hover { color: var(--brand); text-decoration: none; }
.meta { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.summary { color: #444; margin: 0 0 10px; }
.read-more { font-size: 14px; }
.cover { width: 100%; max-height: 280px; object-fit: cover; border-radius: 8px; margin-bottom: 12px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* post detail */
.post h1 { font-size: 28px; margin: 0 0 8px; }
.content { margin-top: 16px; }
.content img { max-width: 100%; border-radius: 8px; }
.content pre { background: #0f1115; color: #e6e6e6; padding: 14px; border-radius: 8px; overflow: auto; }
.content code { background: #eef0f3; padding: 2px 5px; border-radius: 4px; font-size: 13px; }
.content pre code { background: none; padding: 0; }
.content blockquote { border-left: 4px solid var(--brand); margin: 12px 0; padding: 4px 14px; color: #555; background: #f0f4ff; }
.back { display: inline-block; margin-top: 22px; }

/* pager */
.pager { display: flex; justify-content: space-between; margin-top: 24px; }

/* footer */
.site-footer { border-top: 1px solid var(--line); background: var(--card); padding: 18px 0; color: var(--muted); font-size: 13px; text-align: center; }

/* flash */
.flash { background: #fff7e6; border: 1px solid #ffd591; color: #9c6b00; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }

/* forms */
.form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; max-width: 640px; }
.form label { display: block; font-size: 14px; margin: 14px 0 6px; color: #333; }
.form label:first-child { margin-top: 0; }
.form input[type=text], .form input[type=password], .form input[type=number], .form input[name=title],
.form input[name=site_title], .form input[name=site_subtitle], .form input[name=slug], .form input[name=name],
.form select, .form textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
.form textarea { resize: vertical; }
.form .mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 13px; }
.form .check { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.form .check input { width: auto; }
.form .actions { margin-top: 20px; display: flex; gap: 10px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

/* buttons */
.btn { display: inline-block; background: var(--brand); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.btn:hover { background: var(--brand-d); text-decoration: none; color: #fff; }
.btn.ghost { background: #eef0f3; color: #444; }
.btn.ghost:hover { background: #e2e5ea; }

/* admin */
body.admin { background: #eef1f5; }
.admin-bar { background: #1f2329; color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 18px; height: 52px; flex-wrap: wrap; }
.admin-bar a { color: #c7ccd4; font-size: 14px; }
.admin-bar a:hover { color: #fff; text-decoration: none; }
.ab-brand { font-weight: 700; }
.ab-right { margin-left: auto; }
.admin-main { padding-top: 26px; }
.head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* grid table */
.grid { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.grid th, .grid td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.grid th { background: #fafbfc; color: #555; font-weight: 600; }
.grid tr:last-child td { border-bottom: none; }
.grid .ops a { margin-right: 12px; }
.muted { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-align: center; }
.stat-card .num { font-size: 28px; font-weight: 700; color: var(--brand); }
.stat-card .label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.quick a { margin-right: 10px; }

/* upload inline + file library */
.upload-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.upload-inline input[type=file] { flex: 1; min-width: 200px; }
.link-danger { background: none; border: none; color: #e5484d; cursor: pointer; font-size: 14px; padding: 0; }
.link-danger:hover { text-decoration: underline; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

/* insert-image modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: #fff; border-radius: 12px; width: 620px; max-width: 92vw; max-height: 86vh; overflow: auto; box-shadow: 0 16px 50px rgba(0,0,0,.2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; }
.modal-x { background: none; border: none; font-size: 24px; line-height: 1; cursor: pointer; color: #888; }
.modal-body { padding: 16px 18px; }
.img-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 14px; }
.img-cell img { width: 100%; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; transition: transform .08s; }
.img-cell img:hover { transform: scale(1.04); border-color: var(--brand); }
.upload-row { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding-top: 14px; }
.upload-row input[type=file] { flex: 1; }
.btn.mini { padding: 4px 10px; font-size: 13px; margin-left: 8px; vertical-align: middle; }
@media (max-width: 600px) { .img-grid { grid-template-columns: repeat(3, 1fr); } }

/* login */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 34px; width: 320px; box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.login-box h1 { margin: 0 0 18px; font-size: 20px; text-align: center; }
.login-box input { width: 100%; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.login-box button { width: 100%; padding: 10px; background: var(--brand); color: #fff; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; }
.login-box button:hover { background: var(--brand-d); }
.login-box .hint { color: var(--muted); font-size: 12px; text-align: center; margin: 14px 0 0; }

@media (max-width: 600px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .nav a { margin-left: 10px; font-size: 13px; }
}

/* ===== 旧站框架整合：覆盖 legacy/comm.css 的破坏性绝对定位等规则 ===== */
body { height: auto; }

/* 全屏背景轮播：固定铺满视口，随窗口缩放；内容层浮于其上 */
.banner { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 0; overflow: hidden; background: #000; }
.banner .slider,
.banner .jquery-slider-wrapper,
.banner .jquery-slider-slide { width: 100% !important; height: 100% !important; }
.banner .jquery-slider-slide img { width: 100%; height: 100%; object-fit: cover; }
/* 隐藏背景轮播的导航箭头/圆点，保持纯背景观感 */
.banner .jquery-slider-selectors,
.banner .jquery-slider-navigation,
.banner .jquery-slider-control { display: none !important; }

/* 内容层抬到背景之上并加半透明背景，使背景透出 */
.headtopnb,
.container.main,
.dblist { position: relative; z-index: 1; }
.headtopnb { background: rgba(0, 154, 44, .92); box-shadow: 0 1px 6px rgba(0,0,0,.18); }
.container.main {
  background: rgba(255, 255, 255, .93);
  border-radius: 12px;
  margin-top: 12px;
  padding: 30px 40px 60px;
  box-shadow: 0 4px 22px rgba(0, 0, 0, .10);
  max-width: 1140px;
}
/* 首页无文章时隐藏空白白色内容框 */
.container.main.is-empty { display: none; }
.dblist { background: rgba(0, 0, 0, .72); }

.menuw { width: 100%; max-width: 1140px; padding: 0 20px; }
.menulist { width: auto; margin-left: 0; }
.menulist a { width: auto; padding: 0 16px; }
.logo { display: flex; align-items: center; }
.logo-link { font-weight: 700; font-size: 18px; color: #1c1c1c; }
.logo-link:hover { text-decoration: none; }

.main { max-width: 1080px; padding-top: 24px; }

.dblist { position: static; height: auto; opacity: 1; color: #98c4da; line-height: 34px; margin-top: auto; text-align: center; }
.dblist .opty { width: 100%; max-width: 1140px; padding: 0 20px; text-align: center; }
.dblist a.bah { color: #86AA9F; }
.dblist a.bah:hover { color: #fc6e6e; text-decoration: none; }

/* 游戏页容器：避免与 .container 通用类冲突时仍居中显示 */
.game-page { max-width: 1000px; margin: 0 auto; }

/* ---------- 文件库展示 ---------- */
.file-lib { margin-top: 34px; }
.file-lib-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.file-lib-head h2 { font-size: 20px; margin: 0; color: var(--ink); }
.file-lib-head .more { color: var(--brand); font-size: 14px; }
.file-grid, .file-page-list {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
}
@media (max-width: 900px) { .file-grid, .file-page-list { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .file-grid, .file-page-list { grid-template-columns: repeat(2, 1fr); } }
.file-card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; color: var(--ink);
  transition: box-shadow .15s, transform .15s;
}
.file-card:hover {
  text-decoration: none; box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-2px);
}
.file-thumb-link { display: block; }
.file-thumb {
  height: 96px; display: flex; align-items: center; justify-content: center;
  background: #f0f2f5; overflow: hidden;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-ext {
  font-size: 18px; font-weight: 700; color: var(--brand); letter-spacing: 1px;
  background: #e8f7ec; padding: 6px 10px; border-radius: 6px;
}
.file-meta { padding: 8px 10px; }
.file-name {
  font-size: 13px; line-height: 1.4; height: 2.8em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.file-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.file-ops { margin-top: 6px; font-size: 13px; }
.file-ops a { margin-right: 12px; }
.file-empty { color: var(--muted); padding: 14px 0; }

/* ===================== 响应式适配（随窗口/设备动态变化） ===================== */

/* 背景用 100% 而非 100vw：避免竖向滚动条出现时产生横向溢出/白边 */
.banner { width: 100%; right: 0; }

/* 平板及以下：绿色导航条内项目可换行，避免窄屏水平溢出被截断 */
@media (max-width: 900px) {
  .menuw {
    display: flex; align-items: center; flex-wrap: wrap;
    height: auto; min-height: 62px; padding: 8px 14px;
  }
  .logo { float: none; }
  .logo-link { font-size: 16px; }
  .menulist { float: none; display: flex; flex-wrap: wrap; align-items: center; }
  .menulist a {
    float: none; width: auto; padding: 6px 12px; line-height: 1.5;
    font-size: 14px; border-radius: 6px;
  }
  .clear { display: none; }            /* flex 布局下不再需要清除浮动 */
  .headtopnb { position: relative; }
}

/* 内容白框在不同屏宽自适应内边距，避免手机端左右过挤 */
@media (max-width: 900px) {
  .container.main { padding: 24px 22px 44px; margin-top: 10px; border-radius: 10px; }
}
@media (max-width: 560px) {
  .container.main { padding: 18px 14px 34px; }
  .post-card { padding: 14px; }
  .post-card h2 { font-size: 18px; }
  .post h1 { font-size: 23px; }
  .dblist { line-height: 1.7; font-size: 13px; padding: 10px 0; }
  .file-lib-head h2 { font-size: 18px; }
}

/* 文章详情：长代码/表格在窄屏内部横向滚动，不撑破布局 */
.content pre { max-width: 100%; }
.content table { display: block; width: 100%; overflow-x: auto; white-space: nowrap; }
.content img, .content iframe, .content video { max-width: 100%; height: auto; }

/* 游戏页窄屏留边 */
@media (max-width: 900px) {
  .game-page { padding: 0 12px; }
}

/* 登录框在超小屏不至于贴边/溢出 */
@media (max-width: 360px) {
  .login-box { width: 92vw; padding: 24px 16px; }
}
