/* ============================================================
   硅基经纬 — 消息通知模块
   铃铛未读角标 + 下拉面板（分类 tab / 相对时间 / 全部已读）+ 详情弹窗
   实底云白卡 + 发丝线 + 宝蓝 accent，与晨光小窗同语言；
   夜间差异走 body.theme-night 覆盖
   ============================================================ */

/* ---------------- 铃铛锚点 + 未读角标 ---------------- */

.nt-bell {
  position: relative;
}

.nt-bell.is-ringing {
  animation: ntBellPulse 0.78s ease-out;
}

.nt-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

body.theme-night .nt-badge {
  border-color: var(--bg);
}

@keyframes ntBellPulse {
  0% { transform: scale(1); }
  24% { transform: scale(1.08); }
  56% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

/* ---------------- 铃铛轻提醒卡 ---------------- */

.nt-peek {
  position: fixed;
  z-index: 1180;
  width: 356px;
  max-width: calc(100vw - 24px);
  border-radius: 16px;
  border: 1px solid rgba(38, 76, 150, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(248, 251, 255, 0.94));
  box-shadow: 0 24px 60px rgba(31, 62, 122, 0.16), 0 8px 24px rgba(31, 62, 122, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.985);
  transition:
    opacity 0.18s ease-out,
    transform 0.18s ease-out,
    visibility 0.18s ease-out;
}

.nt-peek.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.nt-peek-arrow {
  position: absolute;
  top: -8px;
  right: 42px;
  width: 16px;
  height: 16px;
  border-top: 1px solid rgba(38, 76, 150, 0.14);
  border-left: 1px solid rgba(38, 76, 150, 0.14);
  background: rgba(255, 255, 255, 0.95);
  transform: rotate(45deg);
}

.nt-peek-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 11px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(135deg, #1948b8, #2f67e9 62%, #5bbdff);
  color: #fff;
}

.nt-peek-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.nt-peek-kicker svg,
.nt-peek-close svg,
.nt-peek-primary svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
}

.nt-peek-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition:
    background-color 0.22s ease,
    transform 0.22s ease;
}

.nt-peek-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.nt-peek-body {
  padding: 16px 18px 6px;
}

.nt-peek-title {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink);
}

.nt-peek-summary {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.8;
  color: rgba(35, 57, 93, 0.78);
}

.nt-peek-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 18px 18px;
}

.nt-peek-ghost,
.nt-peek-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition:
    transform 0.22s ease,
    opacity 0.22s ease,
    background-color 0.22s ease;
}

.nt-peek-ghost {
  padding: 9px 12px;
  background: transparent;
  color: var(--ink-soft);
}

.nt-peek-ghost:hover {
  opacity: 0.72;
}

.nt-peek-primary {
  padding: 9px 14px;
  background: rgba(46, 107, 255, 0.1);
  color: var(--accent);
}

.nt-peek-primary:hover {
  background: rgba(46, 107, 255, 0.14);
  transform: translateY(-1px);
}

/* ---------------- 下拉面板 ---------------- */

.nt-panel {
  position: fixed;
  z-index: 1150;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 480px;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid rgba(20, 33, 60, 0.08);
  box-shadow: 0 24px 64px rgba(20, 33, 60, 0.18);
  /* 圆角裁剪内容，配合 .nt-list 的 min-height:0 保证内滚正确 */
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  visibility: hidden;
  transition:
    opacity 0.18s ease-out,
    transform 0.18s ease-out,
    visibility 0.18s ease-out;
}

.nt-panel.is-open {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

/* 头部：衬线标题 + 全部已读 */
.nt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
}

.nt-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.nt-readall {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  color: var(--accent);
  cursor: pointer;
  transition: opacity 0.25s ease;
}

.nt-readall:hover {
  opacity: 0.7;
}

.nt-readall:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 1;
}

.nt-readall svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.7;
}

/* 分类 tab */
.nt-tabs {
  display: flex;
  gap: 6px;
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
}

.nt-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.25s ease,
    color 0.25s ease;
}

.nt-tab:hover {
  background: rgba(20, 33, 60, 0.04);
}

.nt-tab.is-active {
  background: rgba(46, 107, 255, 0.08);
  color: var(--accent);
}

/* 分类未读数小角标 */
.nt-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* 列表：flex 子项必须 min-height:0 才能收缩出滚动区，
   否则内容多时把 footer 顶出 max-height 面板（「全部」tab 截断 bug 的根因） */
.nt-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}

.nt-item {
  position: relative;
  display: flex;
  gap: 11px;
  width: 100%;
  padding: 12px 12px 12px 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.nt-item + .nt-item {
  border-top: 1px solid var(--hairline);
}

.nt-item:hover {
  background: rgba(20, 33, 60, 0.03);
}

/* 未读点：2px 宝蓝竖点，已读淡出隐藏 */
.nt-dot {
  position: absolute;
  left: 4px;
  top: 18px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.nt-item.is-read .nt-dot {
  opacity: 0;
}

.nt-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  flex-shrink: 0;
}

.nt-item-icon svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.7;
}

.nt-item-body {
  flex: 1;
  min-width: 0;
}

.nt-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  transition: font-weight 0.2s ease;
}

.nt-item.is-read .nt-item-title {
  font-weight: 400;
}

.nt-item-summary {
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nt-item-time {
  flex-shrink: 0;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* 空分类 */
.nt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 0;
  color: var(--muted);
  font-size: 12.5px;
}

.nt-empty svg {
  width: 40px;
  height: 40px;
  stroke-width: 1.4;
  opacity: 0.2;
}

/* 底部 */
.nt-foot {
  padding: 12px 0;
  border-top: 1px solid var(--hairline);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* 头部 / tab / 底部不参与收缩，永远完整显示（footer 钉在最后一条之后） */
.nt-head,
.nt-tabs,
.nt-foot {
  flex-shrink: 0;
}

/* ---------------- 轻量 toast（与全站同款胶囊） ---------------- */

.nt-toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  z-index: 1300;
  transform: translateX(-50%) translateY(10px);
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  letter-spacing: 0.06em;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.25s ease-out,
    transform 0.25s ease-out;
}

.nt-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   夜间主题覆盖
   ============================================================ */

body.theme-night .nt-panel {
  border-color: rgba(233, 238, 250, 0.1);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

body.theme-night .nt-peek {
  border-color: rgba(143, 184, 255, 0.2);
  background: linear-gradient(180deg, rgba(12, 20, 36, 0.98), rgba(18, 28, 47, 0.95));
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.24);
}

body.theme-night .nt-peek-arrow {
  border-color: rgba(143, 184, 255, 0.2);
  background: rgba(12, 20, 36, 0.96);
}

body.theme-night .nt-peek-summary {
  color: rgba(220, 231, 251, 0.76);
}

body.theme-night .nt-peek-ghost {
  color: rgba(220, 231, 251, 0.8);
}

body.theme-night .nt-peek-primary {
  background: rgba(143, 184, 255, 0.12);
  color: #9fc2ff;
}

body.theme-night .nt-tab:hover {
  background: rgba(233, 238, 250, 0.05);
}

body.theme-night .nt-item:hover {
  background: rgba(233, 238, 250, 0.04);
}

/* ============================================================
   详情弹窗「一封信」（晨光小窗语言：实底卡 + 同款描边投影圆角）
   自包含样式，不依赖 auth.css（works / billing 页未加载）
   ============================================================ */

.nd-overlay {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 33, 60, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.15s ease-out,
    visibility 0.15s ease-out;
}

.nd-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.nd-card {
  position: relative;
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  padding: 26px 28px 24px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid rgba(20, 33, 60, 0.08);
  box-shadow: 0 24px 64px rgba(20, 33, 60, 0.18);
}

/* 入场：230ms 上浮回弹（与晨光小窗一致） */
.nd-overlay.is-open .nd-card {
  animation: ndCardIn 0.23s cubic-bezier(0.2, 0.9, 0.25, 1.15);
}

@keyframes ndCardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 关闭：150ms 淡出 */
.nd-overlay.is-open.is-closing .nd-card {
  animation: none;
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

/* 顶部：分类图标 + 分类名 / 完整时间 */
.nd-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nd-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(46, 107, 255, 0.1);
  color: var(--accent);
  flex-shrink: 0;
}

.nd-icon svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.7;
}

.nd-cat {
  font-size: 12px;
  color: var(--muted);
}

.nd-time {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 右上角 32px 圆形关闭钮 */
.nd-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(20, 33, 60, 0.06);
  color: var(--ink-soft);
  cursor: pointer;
  transition:
    color 0.3s ease,
    transform 0.3s ease;
}

.nd-close:hover {
  color: var(--accent);
  transform: rotate(90deg);
}

.nd-close svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
}

/* 标题：衬线 20px，与图标区间隔 20px */
.nd-title {
  margin-top: 20px;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ink);
}

/* 发丝线 */
.nd-sep {
  height: 1px;
  margin: 16px 0;
  background: var(--hairline);
}

/* 正文区：320px 内滚 */
.nd-body {
  overflow-y: auto;
  max-height: 320px;
  min-height: 0;
}

.nd-body p {
  font-size: 14px;
  line-height: 1.9;
  color: rgba(20, 33, 60, 0.85);
}

.nd-body p + p {
  margin-top: 14px;
}

/* 底部操作 */
.nd-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.nd-actions.is-center {
  justify-content: center;
}

.nd-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-left: auto;
  padding: 11px 26px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(120deg, #2560e8, #2e6bff 55%, #57b8ff);
  color: #fff;
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 12px 32px -12px var(--glow);
}

.nd-primary svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
}

.nd-ghost {
  padding: 11px 6px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.25s ease;
}

.nd-ghost:hover {
  color: var(--accent);
}

/* ---------------- 夜间覆盖 ---------------- */

body.theme-night .nd-overlay {
  background: rgba(0, 0, 0, 0.6);
}

body.theme-night .nd-card {
  border-color: rgba(233, 238, 250, 0.1);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

body.theme-night .nd-close {
  background: rgba(233, 238, 250, 0.1);
}

body.theme-night .nd-body p {
  color: rgba(233, 238, 250, 0.85);
}

/* ---------------- 无障碍：减少动态偏好 ---------------- */

@media (prefers-reduced-motion: reduce) {
  .nt-panel,
  .nt-peek,
  .nt-bell,
  .nt-dot,
  .nt-toast,
  .nd-overlay,
  .nd-card,
  .nd-overlay.is-open.is-closing .nd-card,
  .nd-overlay.is-open .nd-card,
  .nd-close {
    animation: none;
    transition: none;
  }
}
