/* layout.css — 应用框架：登录页 / 侧边栏(含收起) / 顶栏 / 内容区 / 用户卡 */

  /* ============================================================
     登录页
     ============================================================ */
  #login-view {
    position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
    background: var(--bg-page); overflow: hidden;
  }
  #particle-canvas { position: absolute; inset: 0; display: block; z-index: 1; }
  .grid-overlay {
    position: absolute; inset: 0; z-index: 0;
    background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
    background-size: 24px 24px;
    -webkit-mask-image: radial-gradient(ellipse 65% 55% at 50% 45%, #000 25%, transparent 72%);
    mask-image: radial-gradient(ellipse 65% 55% at 50% 45%, #000 25%, transparent 72%);
    /* 默认可见 + backwards 补间：系统关闭动画时元素也不会消失 */
    animation: fadeIn 1.2s ease .2s backwards;
  }
  @keyframes fadeIn { from { opacity: 0; } }
  .login-card {
    position: relative; z-index: 2; width: 400px; max-width: calc(100vw - 40px);
    background: var(--bg-surface); border: 1px solid var(--border-2);
    border-radius: 20px; padding: 42px 40px 34px; box-shadow: var(--shadow-3);
    animation: cardIn .5s cubic-bezier(.22, 1, .36, 1) .08s backwards;
  }
  @keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
  .login-logo {
    width: 58px; height: 58px; margin: 0 auto 16px; border-radius: 15px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-subtle); border: 1px solid var(--border-2); box-shadow: var(--shadow-1);
    animation: floaty 4.5s ease-in-out infinite;
  }
  .login-logo img { width: 40px; height: 40px; image-rendering: pixelated; }
  @keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
  /* 登录页主题强调色条（随 data-skin 的 --accent 变化） */
  .login-card::before {
    content: ""; position: absolute; left: 24px; right: 24px; top: 0; height: 3px;
    border-radius: 0 0 3px 3px; background: var(--accent); opacity: .9;
  }
  /* 登录页主题装饰：当前主题的三件代表素材（由 applySkinIcons 填充） */
  #login-deco { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
  .login-deco-img {
    position: absolute; image-rendering: pixelated; opacity: .5;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .35));
    animation: floaty 6.5s ease-in-out infinite;
  }
  .login-deco-img.d1 { width: 42px; height: 42px; left: 9%; bottom: 17%; animation-delay: -1s; }
  .login-deco-img.d2 { width: 30px; height: 30px; right: 11%; top: 19%; animation-delay: -2.6s; }
  .login-deco-img.d3 { width: 24px; height: 24px; right: 17%; bottom: 13%; animation-delay: -4.2s; }
  /* 「14 天内免登录」 */
  .login-remember {
    display: flex; align-items: center; gap: 8px; margin: -4px 0 16px;
    font-size: 13px; color: var(--text-secondary); cursor: pointer; user-select: none;
    animation: fadeUp .4s cubic-bezier(.22, 1, .36, 1) .3s backwards;
  }
  .login-remember input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
  .login-remember .lr-hint { color: var(--text-caption); font-size: 12px; }
  .login-card h1 { font-size: 21px; font-weight: 600; text-align: center; margin-bottom: 6px; }
  .login-card .sub { text-align: center; color: var(--text-tertiary); font-size: 13px; margin-bottom: 28px; }
  .field { margin-bottom: 18px; animation: fadeUp .4s cubic-bezier(.22, 1, .36, 1) backwards; }
  .field:nth-of-type(1) { animation-delay: .16s; }
  .field:nth-of-type(2) { animation-delay: .22s; }
  .login-card .btn-primary { animation: fadeUp .4s cubic-bezier(.22, 1, .36, 1) .3s backwards; }
  .login-card .error-msg { animation: fadeUp .4s cubic-bezier(.22, 1, .36, 1) .34s backwards; }
  @keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
  .field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 7px; }
  .field input {
    width: 100%; height: 42px; padding: 0 14px; font-size: 14px; color: var(--text-primary);
    border: 1px solid var(--border-2); border-radius: var(--radius-s); background: var(--bg-surface);
    outline: none; transition: border-color .18s ease, box-shadow .18s ease;
  }
  .field input::placeholder { color: var(--text-caption); }
  .field input:focus { border-color: var(--text-tertiary); box-shadow: 0 0 0 3px var(--focus-ring); }
  .pw-wrap { position: relative; }
  .pw-wrap input { padding-right: 42px; }
  .pw-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: var(--text-caption); cursor: pointer;
    border-radius: 7px; transition: color .15s ease, background .15s ease;
  }
  .pw-toggle:hover { color: var(--text-secondary); background: var(--bg-hover); }
  .login-card .btn-primary { width: 100%; height: 44px; font-size: 15px; letter-spacing: 2px; }
  .login-tip {
    margin-top: 20px; padding: 12px 14px; border-radius: var(--radius-s);
    background: var(--bg-subtle); border: 1px solid var(--border-1);
    font-size: 12px; color: var(--text-tertiary); line-height: 1.7;
    animation: fadeUp .4s cubic-bezier(.22, 1, .36, 1) .38s backwards;
  }
  .login-tip-title { font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; cursor: pointer; user-select: none; }
  .login-tip-title .lr-caret { float: right; color: var(--text-caption); }
  .login-tip-body b { color: var(--text-secondary); }
  /* 首次登录 / 忘记密码：自助区默认折叠，点标题展开 */
  .login-tip-body { display: none; }
  .login-tip-body.open { display: block; }
  .login-help-list { margin: 2px 0 10px 18px; padding: 0; }
  .login-help-list li { margin-bottom: 2px; }
  .login-reset { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
  .login-reset input {
    width: 100%; height: 34px; padding: 0 10px; font-size: 13px;
    background: var(--bg-surface); color: var(--text-primary);
    border: 1px solid var(--border-2); border-radius: var(--radius-s); outline: none;
  }
  .login-reset input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
  .login-reset-row { display: flex; gap: 8px; }
  .login-reset-row input { flex: 1 1 auto; min-width: 0; }
  .login-reset-row .btn-xs { flex: 0 0 auto; white-space: nowrap; }
  .login-reset-msg { min-height: 16px; font-size: 12px; line-height: 1.5; }
  .login-reset-msg.ok { color: var(--accent); }
  .login-reset-msg.err { color: #d9534f; }
  /* 错误提示：默认隐藏，.show 时显示（修复密码错误无反应） */
  .error-msg {
    color: #d9534f; font-size: 13px; margin-top: 14px; min-height: 18px; text-align: center;
    opacity: 0; transition: opacity .2s ease;
  }
  .error-msg.show { opacity: 1; }
  .error-msg.shake { animation: shake .4s ease; }
  @keyframes shake {
    0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
  }

  /* ============================================================
     主应用
     ============================================================ */
  #app-view { display: none; height: 100vh; }
  .app-shell { display: flex; height: 100vh; }
  .sidebar {
    width: 244px; flex-shrink: 0; background: var(--bg-surface);
    border-right: 1px solid var(--border-1); display: flex; flex-direction: column;
    padding: 14px 12px;
    /* 展开/收起更丝滑：
       ① 曲线用「先快后缓」，收尾不戛然而止；时长 .3s（.22s 太仓促）
       ② scrollbar-gutter: stable —— 宽度动画时滚动条不再闪现/消失（这是"不丝滑"的主因之一） */
    transition: width .3s cubic-bezier(.22,.61,.36,1), padding .3s cubic-bezier(.22,.61,.36,1),
                background .3s ease, border-color .3s ease;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-gutter: stable;
  }
  .sidebar::-webkit-scrollbar { width: 6px; }
  .sidebar::-webkit-scrollbar-thumb { background: var(--border-3); border-radius: 6px; }

  /* 收起状态（图标条） */
  /* 文字类元素【不能】用 display:none 收起：display 不可过渡，会在宽度动画中途"啪"地消失/出现，
     这正是"展开不够丝滑"的观感来源。改为「透明度 + max-width 收缩 + 轻微位移」三者一起过渡。 */
  .side-brand .name,
  .side-section > span,
  .side-section .chev,
  .nav-item > span:not(.count),
  .side-foot .who,
  .logout-btn {
    max-width: 200px; opacity: 1; white-space: nowrap; overflow: hidden;
    transition: opacity .18s ease, transform .3s cubic-bezier(.22,.61,.36,1),
                max-width .3s cubic-bezier(.22,.61,.36,1);
  }
  .app-shell.sidebar-collapsed .sidebar { width: 64px; padding: 14px 8px; }
  .app-shell.sidebar-collapsed .side-brand .name,
  .app-shell.sidebar-collapsed .side-section > span,
  .app-shell.sidebar-collapsed .side-section .chev,
  .app-shell.sidebar-collapsed .nav-item > span:not(.count),
  .app-shell.sidebar-collapsed .side-foot .who,
  .app-shell.sidebar-collapsed .logout-btn {
    max-width: 0; opacity: 0; transform: translateX(-6px); pointer-events: none;
    transition: opacity .12s ease, transform .3s cubic-bezier(.22,.61,.36,1),
                max-width .3s cubic-bezier(.22,.61,.36,1);
  }
  .app-shell.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
  /* 图标在收起时轻微回弹，手感更"跟手" */
  .nav-item img, .side-brand img { transition: transform .3s cubic-bezier(.22,.61,.36,1); }
  .app-shell.sidebar-collapsed .nav-item img { transform: scale(1.06); }
  .app-shell.sidebar-collapsed .side-brand { justify-content: center; padding: 8px 0 16px; }
  .app-shell.sidebar-collapsed .side-foot { justify-content: center; }
  /* ★收起时把 flex gap 归零：文字虽已 max-width:0，但 gap 仍占位，
     会让图标（尤其 side-foot 的头像，有两个 gap + 登出按钮 padding）偏离中心。
     gap 本身可过渡，加进基类的 transition 里保持收/展丝滑。 */
  .app-shell.sidebar-collapsed .nav-item,
  .app-shell.sidebar-collapsed .side-foot,
  .app-shell.sidebar-collapsed .side-brand { gap: 0; }
  .app-shell.sidebar-collapsed .logout-btn { padding: 0; }
  /* 收起时隐藏所有数字角标 */
  .app-shell.sidebar-collapsed .nav-item .count { display: none; }
  /* 收起时好友新消息以小红点提示 */
  .nav-item { position: relative; }
  .dot-badge {
    display: none; position: absolute; top: 6px; right: 12px;
    width: 8px; height: 8px; border-radius: 50%; background: #e5484d;
    box-shadow: 0 0 0 2px var(--bg-surface);
  }
  .app-shell.sidebar-collapsed .nav-item .dot-badge.show { display: block; }
  .app-shell.sidebar-collapsed .nav-item .dot-badge { right: 8px; top: 4px; }
  /* 收起时所有分组默认展开（只显示图标） */
  .app-shell.sidebar-collapsed .side-group .group-items { display: block; }
  .app-shell.sidebar-collapsed .side-group .side-section { cursor: default; }
  .app-shell.sidebar-collapsed .side-group .side-section:hover { background: transparent; }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 8px 10px 16px; transition: gap .3s cubic-bezier(.22,.61,.36,1); }
  .side-brand .mark {
    width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-subtle); border: 1px solid var(--border-2);
  }
  .side-brand .mark img { width: 20px; height: 20px; image-rendering: auto; }
  .side-brand .name { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
  .side-section { font-size: 11px; color: var(--text-caption); padding: 12px 10px 6px; letter-spacing: .6px; }
  .side-group .side-section {
    display: flex; align-items: center; justify-content: space-between; cursor: pointer;
    user-select: none; border-radius: var(--radius-s); transition: background .15s ease;
  }
  .side-group .side-section:hover { background: var(--bg-hover); color: var(--text-secondary); }
  .side-group .chev { font-size: 10px; transition: transform .28s cubic-bezier(.22,.61,.36,1); transform: rotate(-90deg); }
  .side-group.open .chev { transform: rotate(0deg); }
  /* 分组内容的最终显隐仍由 CSS 决定（JS 失败时退回"直接出现"，不会坏）；
     平滑展开由 sidebar.js 的高度过渡完成，这里补"逐项错落淡入"，避免整块一次性弹出。 */
  .side-group .group-items { display: none; }
  .side-group.open .group-items { display: block; }
  .side-group.open .group-items .nav-item {
    animation: sr-nav-in .36s cubic-bezier(.22,.61,.36,1) backwards;
  }
  .side-group.open .group-items .nav-item:nth-child(1) { animation-delay: 0ms; }
  .side-group.open .group-items .nav-item:nth-child(2) { animation-delay: 28ms; }
  .side-group.open .group-items .nav-item:nth-child(3) { animation-delay: 56ms; }
  .side-group.open .group-items .nav-item:nth-child(4) { animation-delay: 84ms; }
  .side-group.open .group-items .nav-item:nth-child(5) { animation-delay: 112ms; }
  .side-group.open .group-items .nav-item:nth-child(6) { animation-delay: 140ms; }
  .side-group.open .group-items .nav-item:nth-child(7) { animation-delay: 168ms; }
  .side-group.open .group-items .nav-item:nth-child(n+8) { animation-delay: 196ms; }
  @keyframes sr-nav-in {
    from { opacity: 0; transform: translateY(-7px) scale(.985); }
    to   { opacity: 1; transform: none; }
  }
  .nav-item {
    display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px;
    border-radius: var(--radius-s); cursor: pointer; color: var(--text-secondary);
    font-size: 14px; user-select: none;
    transition: background .15s ease, color .15s ease, gap .3s cubic-bezier(.22,.61,.36,1);
  }
  .nav-item .mc-ico { opacity: .9; }
  .nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
  .nav-item.active { background: var(--bg-active); color: var(--text-primary); font-weight: 600; }
  .nav-item .count {
    margin-left: auto; font-size: 11px; color: var(--text-caption);
    background: var(--bg-subtle); padding: 1px 7px; border-radius: 999px;
  }
  .sidebar .spacer { flex: 1; }
  .side-foot {
    display: flex; align-items: center; gap: 10px; padding: 9px;
    border-radius: var(--radius-s); cursor: pointer;
    transition: background .15s ease, gap .3s cubic-bezier(.22,.61,.36,1);
  }
  .side-foot:hover { background: var(--bg-hover); }
  .avatar {
    border-radius: 50%; flex-shrink: 0; display: flex; align-items: center;
    justify-content: center; color: #fff; font-weight: 600; overflow: hidden;
  }
  .avatar.has-img img {
    width: 100%; height: 100%; object-fit: contain; padding: 14%;
    image-rendering: pixelated; image-rendering: crisp-edges;
  }
  /* 上传的自定义头像照片：填满圆形（不做方形内嵌） */
  .avatar.has-photo img {
    object-fit: cover; padding: 0; image-rendering: auto;
  }
  /* 自定义头像预览：正圆 */
  .avatar.round-preview { border-radius: 50%; }
  .side-foot .who { flex: 1; min-width: 0; }
  .side-foot .who .n { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-foot .who .r { font-size: 11px; color: var(--text-caption); }
  .logout-btn {
    border: none; background: transparent; cursor: pointer; color: var(--text-tertiary);
    padding: 6px; border-radius: 6px; display: flex; transition: all .15s ease;
  }
  .logout-btn:hover { background: var(--bg-active); color: var(--text-primary); }
  .content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  .topbar {
    height: 58px; flex-shrink: 0; display: flex; align-items: center; gap: 14px;
    padding: 0 24px; border-bottom: 1px solid var(--border-1);
    background: var(--bg-surface); transition: background .3s ease;
  }
  .topbar .title { font-size: 15px; font-weight: 600; white-space: nowrap; }
  .search-wrap { flex: 1; max-width: 420px; position: relative; }
  .search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-caption); pointer-events: none; }
  .search-wrap input {
    width: 100%; height: 36px; padding: 0 12px 0 34px; font-size: 13px; color: var(--text-primary);
    border: 1px solid var(--border-2); border-radius: var(--radius-s); background: var(--bg-page);
    outline: none; transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
  }
  .search-wrap input::placeholder { color: var(--text-caption); }
  .search-wrap input:focus { border-color: var(--text-tertiary); box-shadow: 0 0 0 3px var(--focus-ring); background: var(--bg-surface); }
  .topbar .right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
  .theme-toggle {
    display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
    border: 1px solid var(--border-2); border-radius: var(--radius-s); background: var(--bg-surface);
    color: var(--text-secondary); cursor: pointer; font-size: 13px; transition: all .16s ease;
  }
  .theme-toggle:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-3); }
  .theme-toggle .mc-ico { image-rendering: pixelated; }

  .main { flex: 1; overflow-y: auto; padding: 26px 30px 60px; }
  .page { max-width: 980px; margin: 0 auto; animation: pageIn .32s ease both; }
  @keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
  .page-head { margin-bottom: 20px; }
  .page-head h2 { font-size: 20px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
  .page-head p { font-size: 13px; color: var(--text-tertiary); }

  /* ============================================================
     视图切换过渡（router.js 每次渲染后给 #main-content 挂 .view-in）
     只动 opacity/transform，合成层渲染；约 0.24s，简约不抢戏
     ============================================================ */
  @keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }
  #main-content.view-in { animation: viewIn .24s cubic-bezier(.22, 1, .36, 1); }


/* 侧边栏「已锁定」占位行（2026-09-22）
   用途：某个导航项因玩法门槛被隐藏时，顶上这行灰字说明，
   避免分组变成「点开什么都没有」的空壳。与 .nav-item 互斥显示。 */
.nav-locked {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px; margin: 2px 6px;
  font-size: 11.5px; line-height: 1.45; color: var(--text-caption);
  border: 1px dashed var(--border-2); border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--bg-subtle) 60%, transparent);
  cursor: default; user-select: none;
}
.nav-locked .lk { font-size: 11px; opacity: .75; flex-shrink: 0; }
