/* ============================================================
   ATHChat 网页端样式 —— 白 80% / 黑 15% / 蓝 5% + 绿点缀
   前台（顶部导航）/ 用户控制台（侧边栏）/ 后台（深色侧边栏）三套布局共用
   ============================================================ */
:root {
  --ink:        #1e2129;
  --ink-2:      #343845;
  --ink-3:      #6a7080;
  --ink-soft:   #eef0f4;
  --bg:         #f7f8fa;
  --card:       #ffffff;
  --accent:        #3d5af1;
  --accent-strong: #2c46d4;
  --accent-soft:   #edf0fe;
  --border:     #e3e6ee;
  --grass:      #58b53c;
  --grass-dark: #3f8f28;
  --grass-soft: #ebf7e6;
  --danger:       #d64545;
  --danger-soft:  #fdecec;
  --warn-soft:    #fff7e6;
  --shadow-pixel: 4px 4px 0 rgba(30, 33, 41, .13);
  --shadow-pixel-sm: 3px 3px 0 rgba(30, 33, 41, .12);
  --font: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
/* 注意：body 不能用 overflow-x:hidden（会让 sticky 侧边栏失效），
   用 clip 既裁掉横向溢出又不会创建滚动容器 */
html { overflow-x: hidden; }
body { overflow-x: clip; font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.65; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.icon { vertical-align: -3px; flex-shrink: 0; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--ink-soft); color: var(--ink); border-radius: 4px; padding: 1px 6px; border: 1px solid var(--border); word-break: break-all; }
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ==================== 卡片 / 提示 / 按钮 / 表单 ==================== */
.card { background: var(--card); border: 2px solid var(--ink); border-radius: 8px; padding: 24px 26px; margin-bottom: 22px; box-shadow: var(--shadow-pixel); }
.card-title { margin: 0 0 6px; font-size: 17px; display: flex; align-items: center; gap: 9px; }
.card-title .icon { color: var(--accent); }
.card-sub { margin: 0 0 18px; font-size: 13px; color: var(--ink-3); }
.section-title { margin: 24px 0 12px; font-size: 15px; font-weight: 700; }
.muted { color: var(--ink-3); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
  .hero h1 { font-size: 24px; }
  .hero { padding: 30px 0 10px; }
  .chat-head { padding: 10px 12px; }
  .chat-me { width: 100%; justify-content: space-between; }
  .name-pick .name-card { width: 100%; justify-content: center; }
}

.alert { padding: 11px 15px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; line-height: 1.7; border: 2px solid var(--ink); overflow-wrap: break-word; }
.alert .icon { margin-right: 4px; }
.alert-error   { background: var(--danger-soft); color: #a32626; }
.alert-success { background: var(--grass-soft);  color: var(--grass-dark); }
.alert-info    { background: var(--accent-soft); color: #2740b8; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 18px; border: 2px solid var(--ink); border-radius: 6px; background: #e8eaf0; color: var(--ink); font-size: 14px; font-weight: 600; font-family: var(--font); cursor: pointer; text-decoration: none; box-shadow: inset 2px 2px 0 rgba(255,255,255,.85), inset -2px -3px 0 rgba(0,0,0,.14); transition: background .12s, transform .1s; }
.btn:hover { background: #f2f4f8; color: var(--ink); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost-danger { background: #fff; color: var(--danger); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 5px; }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 12px 26px; font-size: 15px; }

.form-row { margin-bottom: 16px; }
.form-row label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.form-row input, .form-row select, .form-row textarea { width: 100%; padding: 10px 13px; border: 2px solid var(--ink); border-radius: 6px; font-size: 14px; background: #fff; color: var(--ink); outline: none; font-family: var(--font); }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { box-shadow: var(--shadow-pixel-sm); }
.form-row input[readonly] { background: var(--ink-soft); color: var(--ink-2); }
.form-hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 9px; border-radius: 4px; border: 1.5px solid var(--ink); background: #fff; color: var(--ink); font-weight: 700; }
.badge-web { background: var(--accent-soft); color: var(--accent-strong); }
.badge-game { background: var(--grass-soft); color: var(--grass-dark); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; border-bottom: 2px solid var(--ink-soft); text-align: left; white-space: nowrap; }
.table th { color: var(--ink); font-weight: 700; background: var(--ink-soft); font-size: 12.5px; border-bottom: 2px solid var(--ink); }

/* ==================== 前台顶部导航 ==================== */
.topnav-bar { background: #fff; border-bottom: 2px solid var(--ink); position: sticky; top: 0; z-index: 50; }
.topnav-inner { display: flex; align-items: center; justify-content: space-between; gap: 14px; height: 60px; }
.topnav-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); min-width: 0; }
.topnav-brand:hover { text-decoration: none; }
.topnav-links { display: flex; align-items: center; gap: 4px; }
.topnav-side { display: flex; align-items: center; gap: 8px; }
.topnav-link { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border: 2px solid transparent; border-radius: 6px; color: var(--ink-2); font-size: 14px; font-weight: 500; white-space: nowrap; }
.topnav-link:hover { background: var(--ink-soft); color: var(--ink); text-decoration: none; }
.topnav-link.active { background: var(--accent); border-color: var(--ink); color: #fff; font-weight: 600; }
.topnav-link-primary { background: var(--accent); border-color: var(--ink); color: #fff; font-weight: 600; }
.topnav-link-primary:hover { background: var(--accent-strong); color: #fff; }
.nav-user { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 4px 10px; }
.nav-avatar { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; object-fit: cover; }
.nav-avatar-fb { display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); }
.topnav-burger { display: none; width: 40px; height: 40px; flex-shrink: 0; border: 2px solid var(--ink); border-radius: 6px; background: var(--card); color: var(--ink); cursor: pointer; align-items: center; justify-content: center; }
.topnav-drawer { display: none; }
@media (max-width: 860px) {
  .topnav-links, .topnav-side { display: none; }
  .topnav-burger { display: inline-flex; }
  body.front-menu-open .topnav-drawer { display: block; border-top: 2px dashed var(--border); background: #fff; padding: 8px 14px 12px; }
  .topnav-drawer .topnav-link { display: flex; width: 100%; padding: 12px 14px; border-radius: 6px; }
}
.front-main { flex: 1; padding: 26px 0 34px; min-height: calc(100vh - 200px); }
.site-footer { padding: 20px 0; text-align: center; color: var(--ink-3); font-size: 12.5px; }
.site-footer .icon { color: var(--grass-dark); }

/* ==================== 首页 Hero ==================== */
.hero { text-align: center; padding: 46px 0 20px; }
.hero h1 { font-size: 30px; margin: 10px 0; letter-spacing: 1px; }
.hero p { color: var(--ink-2); margin: 0 auto 24px; font-size: 15px; max-width: 640px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 10px; }
.feat-card { background: var(--card); border: 2px solid var(--ink); border-radius: 8px; padding: 20px; box-shadow: var(--shadow-pixel); }
.feat-card h3 { margin: 8px 0 6px; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.feat-card h3 .icon { color: var(--grass-dark); }
.feat-card p { margin: 0; font-size: 13.5px; color: var(--ink-2); }

/* ==================== 安装页 ==================== */
.page { flex: 1; display: flex; align-items: flex-start; padding: 30px 18px; }
.install-card { max-width: 560px; margin: 20px auto; width: 100%; }

/* ==================== 侧边栏框架（用户控制台 + 后台） ====================
   侧边栏用 fixed 常驻固定（不用 sticky——兼容性零顾虑，滚动时绝不跟随），
   主内容区用 margin-left 让出宽度；移动端侧边栏变抽屉。 */
.shell { display: block; min-height: 100vh; }
.side-overlay { display: none; position: fixed; inset: 0; z-index: 90; background: rgba(20, 22, 30, .45); }
body.side-open .side-overlay { display: block; }
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 232px; background: var(--card); border-right: 2px solid var(--ink); display: flex; flex-direction: column; overflow-y: auto; z-index: 100; }
.sidebar-dark { background: var(--ink); }
.side-head { padding: 20px 18px 14px; border-bottom: 2px solid var(--ink); }
.sidebar-dark .side-head { border-bottom-color: #2e323e; }
.side-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); }
.sidebar-dark .side-brand { color: #fff; }
.side-tag { font-size: 11px; color: var(--ink-3); margin-top: 5px; padding-left: 44px; letter-spacing: 1px; }
.sidebar-dark .side-tag { color: #7c828f; }
.side-nav { flex: 1; padding: 12px 12px 20px; }
.side-label { font-size: 11px; color: var(--ink-3); padding: 14px 8px 6px; letter-spacing: 1.5px; }
.sidebar-dark .side-label { color: #6f7585; }
.side-link { display: flex; align-items: center; gap: 10px; margin: 2px 0; padding: 9px 12px; border: 2px solid transparent; border-radius: 6px; color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.side-link:hover { background: var(--ink-soft); color: var(--ink); text-decoration: none; }
.sidebar-dark .side-link { color: #c3c8d4; }
.sidebar-dark .side-link:hover { background: #2a2e3a; color: #fff; }
.side-link.active { background: var(--accent); border-color: var(--ink); color: #fff; font-weight: 600; }
.side-link-quit:hover { background: var(--danger-soft); color: var(--danger); }
.side-foot { padding: 12px; border-top: 2px solid var(--ink); }
.sidebar-dark .side-foot { border-top-color: #2e323e; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px 6px; margin-top: 6px; }
.side-user-info { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.side-user-info strong { font-size: 13.5px; }
.side-user-info span { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; object-fit: cover; flex-shrink: 0; }
.side-chip { display: flex; align-items: center; gap: 8px; margin: 2px 4px; padding: 8px 12px; border: 2px solid var(--border); border-radius: 6px; background: var(--grass-soft); color: var(--grass-dark); font-size: 13px; font-weight: 600; }
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: 232px; min-height: 100vh; }
.content-area { flex: 1; padding: 28px; max-width: 1020px; width: 100%; margin: 0 auto; }
.mobile-bar { display: none; align-items: center; gap: 12px; height: 56px; padding: 0 16px; background: var(--card); border-bottom: 2px solid var(--ink); position: sticky; top: 0; z-index: 50; }
.mobile-bar-title { font-weight: 700; font-size: 15px; }
.side-toggle { width: 40px; height: 40px; border: 2px solid var(--ink); border-radius: 6px; background: var(--card); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 900px) {
  .mobile-bar { display: flex; }
  .main-area { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .24s cubic-bezier(.22,.9,.3,1.08); }
  body.side-open .sidebar { transform: translateX(0); box-shadow: 6px 0 0 rgba(30,33,41,.15); }
  body.side-open { overflow: hidden; }
  .content-area { padding: 18px; }
}

/* ==================== 聊天室 ==================== */
.chat-shell { border: 2px solid var(--ink); border-radius: 8px; background: var(--card); box-shadow: var(--shadow-pixel); display: flex; flex-direction: column; height: calc(100vh - 250px); min-height: 440px; overflow: hidden; }
@media (max-width: 700px) {
  .chat-shell { height: calc(100vh - 210px); min-height: 360px; border-radius: 6px; }
  .chat-input-bar { padding: 10px; gap: 8px; position: sticky; bottom: 0; }
  .chat-input-bar input { font-size: 16px; }   /* 16px 防 iOS 聚焦自动放大 */
}
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 2px solid var(--ink); background: var(--ink-soft); flex-wrap: wrap; }
.chat-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; }
.chat-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); display: inline-block; }
.chat-dot.on { background: var(--grass); box-shadow: 0 0 0 3px var(--grass-soft); }
.chat-dot.off { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.chat-me { font-size: 12.5px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chat-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: repeating-linear-gradient(0deg, #fbfcfe, #fbfcfe 26px, #f6f8fc 26px, #f6f8fc 27px); }
.msg { display: flex; flex-direction: column; max-width: 78%; }
.msg .who { font-size: 12px; color: var(--ink-3); margin-bottom: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.msg .who b { color: var(--ink-2); font-size: 12.5px; }
.msg .bubble { padding: 9px 13px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font-size: 14px; word-break: break-word; box-shadow: 2px 2px 0 rgba(30,33,41,.10); }
.msg .mention { color: var(--accent-strong); font-weight: 700; }
.msg-self { align-self: flex-end; }
.msg-self .who { justify-content: flex-end; }
.msg-self .bubble { background: var(--accent-soft); }
.msg-web .bubble { border-style: dashed; }
.msg .time { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.chat-empty { margin: auto; text-align: center; color: var(--ink-3); font-size: 13.5px; }
.chat-input-bar { display: flex; gap: 10px; padding: 12px 14px; border-top: 2px solid var(--ink); background: #fff; }
.chat-input-bar input { flex: 1; padding: 11px 14px; border: 2px solid var(--ink); border-radius: 6px; font-size: 14px; font-family: var(--font); outline: none; }
.chat-input-bar input:focus { box-shadow: var(--shadow-pixel-sm); }
.chat-note { font-size: 12px; color: var(--ink-3); padding: 0 16px 10px; background: #fff; }
@media (max-width: 700px) { .msg { max-width: 92%; } }

/* 名字选择 */
.name-pick { display: flex; gap: 12px; flex-wrap: wrap; }
.name-card { display: inline-flex; align-items: center; gap: 10px; padding: 14px 20px; border: 2px solid var(--ink); border-radius: 8px; background: #fff; font-weight: 700; cursor: pointer; box-shadow: var(--shadow-pixel-sm); }
.name-card:hover { background: var(--accent-soft); }
.name-card .icon { color: var(--grass-dark); }

/* ==================== 后台 ==================== */
.admin-content { max-width: 1000px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 2px solid var(--ink); border-radius: 8px; padding: 18px 20px; box-shadow: var(--shadow-pixel); display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 46px; height: 46px; border-radius: 8px; flex-shrink: 0; background: var(--accent-soft); color: var(--accent-strong); border: 2px solid var(--ink); display: flex; align-items: center; justify-content: center; }
.stat-num { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--ink-3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.reveal { animation: rise .45s ease both; }
