/* 熊出没社群资源配置平台 - 腾讯蓝 / 梦幻紫双主题 + 完整移动适配 */
:root, [data-theme="blue"] {
  --brand: #0052d9;
  --brand-2: #2b7fff;
  --brand-deep: #003ba6;
  --brand-soft: #e8f0ff;
  --brand-soft2: #d6e4ff;
  --brand-ink: #0b3f9e;
  --accent: #00c2d7;
  --grad: linear-gradient(135deg, #0052d9 0%, #2b7fff 55%, #5aa0ff 100%);
  --grad-soft: linear-gradient(135deg, #eef4ff 0%, #e3edff 100%);
  --shadow: 0 6px 22px rgba(0, 82, 217, .10);
  --shadow-lg: 0 14px 44px rgba(0, 82, 217, .18);
}
[data-theme="purple"] {
  --brand: #7c4dff;
  --brand-2: #a178ff;
  --brand-deep: #5b2fd6;
  --brand-soft: #f2ecff;
  --brand-soft2: #e6dbff;
  --brand-ink: #5b2fd6;
  --accent: #ff8ac4;
  --grad: linear-gradient(135deg, #7c4dff 0%, #a178ff 50%, #d3a8ff 100%);
  --grad-soft: linear-gradient(135deg, #f7f2ff 0%, #efe6ff 100%);
  --shadow: 0 6px 22px rgba(124, 77, 255, .12);
  --shadow-lg: 0 14px 44px rgba(124, 77, 255, .20);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f7fb; color: #1f2733; font-size: 14px; line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
:root { --bg: #f5f7fb; --surface: #ffffff; --surface-2: #fafbfe; --line: #e5eaf3; --text: #1f2733; --muted: #7a879c; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
button { cursor: pointer; }
input, select, textarea { outline: none; }

/* ---------- 布局 ---------- */
#app { min-height: 100vh; }
.layout { display: flex; min-height: 100vh; width: 100%; }
.sidebar {
  width: 224px; flex: 0 0 224px; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.brand { padding: 20px 18px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px;
  box-shadow: var(--shadow); flex: 0 0 auto;
}
.brand-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.3; min-width: 0; word-break: break-all; }
.brand-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.nav { flex: 1; overflow-y: auto; padding: 12px 10px; min-width: 0; }
.nav-label { font-size: 11px; color: var(--muted); padding: 10px 10px 6px; letter-spacing: .5px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: #4a566b; margin-bottom: 3px; cursor: pointer; min-width: 0; user-select: none;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--brand-soft); color: var(--brand-ink); }
.nav-item.active { background: var(--grad); color: #fff; font-weight: 600; box-shadow: var(--shadow); }
.nav-dot { width: 7px; height: 7px; border-radius: 3px; background: currentColor; opacity: .65; flex: 0 0 auto; }
.nav-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; flex: 0 0 58px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.content { padding: 22px; max-width: 1180px; width: 100%; margin: 0 auto; min-width: 0; }

/* ---------- 通用组件 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 2px 8px rgba(20,40,80,.03); min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; min-width: 0; }
.card-head h2 { font-size: 16px; margin: 0; font-weight: 700; min-width: 0; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.spacer { flex: 1; min-width: 0; }
.btn {
  border: 1px solid var(--line); background: var(--surface); color: #39445a; padding: 9px 15px;
  border-radius: 9px; font-weight: 600; min-height: 38px; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--brand-2); color: var(--brand); }
.btn-primary { background: var(--grad); color: #fff; border: none; box-shadow: var(--shadow); }
.btn-primary:hover { color: #fff; filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: #d13b3b; border-color: #f3d3d3; }
.btn-sm { padding: 6px 11px; min-height: 32px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.input, .select {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 10px 12px; border-radius: 9px; min-height: 40px; max-width: 100%;
}
.input:focus, .select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.field { min-width: 0; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.row > .field { flex: 1; min-width: 160px; }
.grid { display: grid; gap: 14px; min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--grad-soft); border: 1px solid var(--brand-soft2); border-radius: 12px; padding: 14px; min-width: 0; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 20px; font-weight: 800; color: var(--brand-ink); margin-top: 4px; word-break: break-all; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-blue { background: var(--brand-soft); color: var(--brand-ink); }
.badge-green { background: #e6f7ee; color: #178a53; }
.badge-red { background: #fdeaea; color: #c53a3a; }
.badge-gray { background: #eef1f6; color: #7a879c; }
.hint { color: var(--muted); font-size: 12px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; font-size: 13px; }

/* 表格：外层横滚，避免手机端撑破布局 */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; min-width: 0; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.wrap { word-break: break-word; min-width: 160px; }

/* 资源项目卡片 */
.res-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; min-width: 0;
}
.res-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--brand-2); }
.res-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; flex: 0 0 auto; }
.res-name { font-weight: 700; font-size: 15px; margin-top: 12px; word-break: break-word; }
.res-meta { color: var(--muted); font-size: 12px; margin-top: 6px; word-break: break-word; }

/* 频道信息条 */
.guild-bar {
  background: var(--grad); color: #fff; border-radius: 14px; padding: 18px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; box-shadow: var(--shadow-lg); min-width: 0;
}
.guild-bar .g-icon { width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; flex: 0 0 auto; }
.guild-bar .g-main { min-width: 0; flex: 1; }
.guild-bar .g-name { font-size: 17px; font-weight: 800; word-break: break-word; }
.guild-bar .g-sub { font-size: 12px; opacity: .9; margin-top: 3px; word-break: break-word; }
.guild-bar .g-tag { background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.35); padding: 5px 11px; border-radius: 20px; font-size: 12px; white-space: nowrap; }

/* 搜索结果条目 */
.feed-row {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 12px; border: 1px solid var(--line);
  border-radius: 11px; margin-bottom: 9px; background: var(--surface); min-width: 0;
}
.feed-row:hover { border-color: var(--brand-2); background: var(--surface-2); }
.feed-main { flex: 1; min-width: 0; }
.feed-title { font-weight: 650; font-size: 14px; word-break: break-word; line-height: 1.45; }
.feed-meta { color: var(--muted); font-size: 12px; margin-top: 5px; display: flex; gap: 10px; flex-wrap: wrap; min-width: 0; }
.feed-meta span { white-space: nowrap; }
.feed-act { flex: 0 0 auto; }

/* 帖子确认卡片 */
.feed-card {
  border: 1px solid var(--brand-soft2); background: var(--grad-soft); border-radius: 13px; padding: 16px; min-width: 0;
}
.feed-card .fc-title { font-size: 16px; font-weight: 750; word-break: break-word; line-height: 1.5; }
.feed-card .fc-meta { color: var(--brand-ink); font-size: 12px; margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.feed-card .fc-body { margin-top: 12px; background: rgba(255,255,255,.75); border-radius: 9px; padding: 12px; max-height: 190px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; font-size: 13px; color: #3a465c; }
.confirm-note { margin-top: 14px; background: #fff8e8; border: 1px solid #f3dfae; color: #8a6417; padding: 10px 12px; border-radius: 9px; font-size: 12px; }

/* 弹窗 / toast */
.mask { position: fixed; inset: 0; background: rgba(18, 28, 48, .48); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; width: 520px; max-width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); min-width: 0; }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 18px; min-width: 0; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
#toasts { position: fixed; top: 14px; right: 14px; z-index: 300; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 28px); }
.toast { background: var(--surface); border-left: 4px solid var(--brand); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 11px 14px; font-size: 13px; min-width: 220px; max-width: 100%; word-break: break-word; }
.toast.ok { border-left-color: #22a06b; } .toast.err { border-left-color: #d94a4a; } .toast.warn { border-left-color: #e0a020; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--grad-soft); }
.login-box { width: 400px; max-width: 100%; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 30px 26px; }
.login-box .brand-row { margin-bottom: 22px; }
.login-box h2 { margin: 0 0 4px; font-size: 19px; }
.login-box .hint { margin-bottom: 20px; }

/* 主题切换按钮 */
.theme-switch { display: flex; background: var(--brand-soft); border-radius: 9px; padding: 3px; gap: 2px; }
.theme-switch button { border: none; background: transparent; color: var(--brand-ink); font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 7px; white-space: nowrap; }
.theme-switch button.on { background: var(--surface); box-shadow: 0 1px 5px rgba(0,0,0,.08); }
.btn-menu { display: none; border: none; background: transparent; color: var(--text); padding: 8px; line-height: 1; align-items: center; justify-content: center; }
.hamburger { display: block; width: 18px; height: 2px; background: currentColor; position: relative; }
.hamburger::before, .hamburger::after { content: ''; position: absolute; left: 0; width: 18px; height: 2px; background: currentColor; }
.hamburger::before { top: -6px; }
.hamburger::after { top: 6px; }
#nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(18,28,48,.45); z-index: 39; }
.pill-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pill-tabs button { border: 1px solid var(--line); background: var(--surface); padding: 7px 13px; border-radius: 20px; font-size: 12px; font-weight: 650; color: #4a566b; }
.pill-tabs button.on { background: var(--grad); color: #fff; border-color: transparent; }

/* ---------- 手机端：抽屉导航 + 单列 + 全屏弹窗 ---------- */
@media (max-width: 768px) {
  .content { padding: 14px 12px 28px; }
  .topbar { height: 54px; flex-basis: 54px; padding: 0 12px; gap: 8px; }
  .topbar h1 { font-size: 15px; }
  .btn-menu { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px; flex-basis: 260px;
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); z-index: 40;
  }
  .sidebar.open { transform: translateX(0); }
  #nav-backdrop.show { display: block; }
  .grid-2, .grid-3, .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row > .field { min-width: 100%; }
  .card { padding: 14px; border-radius: 12px; }
  .guild-bar { padding: 14px; gap: 12px; }
  .guild-bar .g-icon { width: 40px; height: 40px; font-size: 17px; }
  .guild-bar .g-name { font-size: 15px; }
  .theme-switch button { padding: 5px 8px; font-size: 11px; }
  .btn { min-height: 42px; padding: 10px 14px; }
  .btn-sm { min-height: 36px; }
  .modal { width: 100% !important; max-width: 100% !important; border-radius: 0; height: 100%; max-height: 100%; }
  .mask { padding: 0; align-items: stretch; }
  .modal-foot { justify-content: stretch; }
  .modal-foot .btn { flex: 1; }
  .feed-row { flex-direction: column; gap: 10px; }
  .feed-act { width: 100%; }
  .feed-act .btn { width: 100%; }
  table { min-width: 600px; }
  .login-box { padding: 24px 18px; }
  #toasts { top: 8px; right: 8px; left: 8px; max-width: none; }
  .toast { min-width: 0; width: 100%; }
}
@media (max-width: 420px) {
  .grid-2, .grid-3, .stat-grid { grid-template-columns: 1fr; }
  .top-actions .user-chip { display: none; }
}
