/* support/page.css — 消息页专属样式（版本 20261009s4）。只用 usage.css / portal.css 的变量，不写死颜色；深浅色自动适配。
   类名前缀 sp-。布局：桌面左栏（分类 + 列表）+ 右栏（当前会话）；≤ 860px 变成「列表 / 会话」两个视图（#layout 的 data-view 切换）。 */

.support-page { --sp-h: clamp(540px, calc(100vh - 182px), 900px); --sp-hm: calc(100vh - 124px); }
@supports (height: 100dvh) {
  .support-page { --sp-h: clamp(540px, calc(100dvh - 182px), 900px); --sp-hm: calc(100dvh - 124px); }
}

/* ============================== 布局 ============================== */
.sp-layout { display: grid; grid-template-columns: 392px minmax(0, 1fr); gap: 10px; align-items: stretch; min-width: 0; }
.sp-side, .sp-main { display: flex; flex-direction: column; min-width: 0; height: var(--sp-h); overflow: hidden; }

/* ============================== 左栏 ============================== */
.sp-side-top { display: grid; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); }
.sp-compose { height: 36px; }
.sp-cats { display: flex; flex-wrap: wrap; gap: 8px 5px; padding-top: 4px; }
.sp-cat {
  position: relative; display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--card); color: var(--ink-2); font-size: 12.5px; font-weight: 500; white-space: nowrap;
}
.sp-cat:hover { border-color: var(--accent); color: var(--ink); }
.sp-cat[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); font-weight: 600; }
/* 未读角标：贴在标签右上角（不占行内宽度，五个标签能排在一行） */
.sp-count {
  position: absolute; top: -8px; right: -8px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; font-variant-numeric: tabular-nums; box-shadow: 0 0 0 2px var(--card); pointer-events: none;
}
html.dark .sp-count { color: #1b0a10; }
.sp-filter-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.sp-filter-row .seg { flex: none; width: auto; }
.sp-filter-row .seg button { flex: none; }
.sp-total { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.sp-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.sp-items { list-style: none; margin: 0; padding: 0; }
.sp-li { margin: 0; }
.sp-item {
  position: relative; display: grid; gap: 4px; padding: 10px 14px 10px 26px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.sp-item:hover { background: var(--hover); }
.sp-item:focus-visible { outline-offset: -2px; }
.sp-item.is-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.sp-dot { position: absolute; left: 11px; top: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.sp-item-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.sp-item-subject { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 500; color: var(--ink); }
.sp-item.is-unread .sp-item-subject { font-weight: 700; }
.sp-item-time { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sp-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.sp-item-new { font-size: 11.5px; font-weight: 700; color: var(--bad-ink); }
.sp-item-preview {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 12.5px; line-height: 1.5; color: var(--ink-2); overflow-wrap: anywhere;
}
@keyframes sp-flash {
  0%, 55% { background: var(--warn-bg); box-shadow: inset 0 0 0 2px var(--warn-line); }
  100% { background: transparent; box-shadow: inset 0 0 0 0 transparent; }
}
.sp-item.is-flash { animation: sp-flash 3s ease-out 1; }

.sp-skel { display: grid; }
.sp-skel-item { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sp-skel-item .skel-line { margin: 6px 0; }
.sp-more { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 12px; padding: 12px; }
.sp-more-note { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sp-list-state { padding: 6px 4px; }
.sp-list-state .blank { min-height: 0; padding: 26px 16px; }

/* ============================== 右栏：占位 / 加载 / 出错 ============================== */
.sp-main > .sp-view, .sp-main > .sp-placeholder, .sp-main > .sp-loading-wrap, .sp-main > .sp-gone { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.sp-placeholder { align-items: center; justify-content: center; gap: 14px; padding: 20px; }
.sp-placeholder .blank { min-height: 0; }
.sp-quick { display: grid; gap: 8px; justify-items: center; text-align: center; }
.sp-quick-label { font-size: 12.5px; color: var(--muted); }
.sp-quick-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.sp-loading { display: grid; align-content: start; gap: 12px; width: 100%; padding: 16px; }
.sp-skel-msg { height: 54px; width: 62%; border-radius: 14px; }
.sp-skel-msg.mine { justify-self: end; width: 48%; }
.sp-backbar { display: none; padding: 8px 10px 0; }
.sp-gone .blank { flex: 1 1 auto; }

/* ============================== 右栏：会话 ============================== */
.sp-head { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sp-head-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 6px; }
.sp-title { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.4; letter-spacing: -.005em; overflow-wrap: anywhere; }
.sp-title:focus { outline: none; }
.sp-head-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; color: var(--muted); }
.sp-head-info { white-space: nowrap; }
.sp-head-info + .sp-head-info::before { content: "·"; margin-right: 8px; color: var(--line-strong); }
.sp-head-actions { flex: none; display: flex; gap: 8px; }
.sp-back { display: none; }

.sp-notes:empty { display: none; }
.sp-note { padding: 10px 16px 0; }
.sp-alert-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.sp-msgs-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.sp-msgs { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; padding: 14px 16px 12px; }
.sp-msg { display: grid; gap: 4px; max-width: min(82%, 680px); min-width: 0; align-self: flex-start; }
.sp-msg.mine { align-self: flex-end; justify-items: end; }
.sp-msg-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sp-msg.mine .sp-msg-meta { flex-direction: row-reverse; }
.sp-bubble {
  max-width: 100%; padding: 9px 13px; border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; background: var(--card-2); color: var(--ink);
  font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.sp-msg.mine .sp-bubble { border-radius: 14px 14px 4px 14px; background: var(--accent-soft); border-color: var(--accent-line); }
.sp-link { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.sp-link:hover { color: var(--accent); }
.sp-divider { display: flex; align-items: center; gap: 10px; margin: 2px 0; font-size: 12px; font-weight: 600; color: var(--bad-ink); }
.sp-divider::before, .sp-divider::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--bad-line); }
.sp-jump { position: absolute; left: 50%; bottom: 10px; z-index: 2; transform: translateX(-50%); box-shadow: var(--pop-shadow); }
.sp-empty-msgs { margin: auto; font-size: 13px; color: var(--muted); }

.sp-reply { display: grid; gap: 8px; padding: 10px 14px 12px; border-top: 1px solid var(--line); background: var(--card); }
.sp-reply-hint { margin: 0; padding: 5px 10px; border: 1px solid var(--warn-line); border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-size: 12.5px; line-height: 1.5; }
textarea.sp-reply-input { min-height: 64px; max-height: 220px; resize: none; line-height: 1.6; }
.sp-reply.is-sending .sp-reply-input { opacity: .75; }
.sp-reply-bar { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sp-reply-spacer { flex: 1 1 auto; }
.sp-reply-count, .sp-kbd-hint { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sp-full:empty { display: none; }
.sp-mail-hint { margin: 0; }
.sp-mail-hint a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }

/* ============================== 新建消息对话框 ============================== */
.modal.sp-modal { --modal-w: 640px; }
.sp-form-intro { margin: 0; font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.sp-form-alert:empty { display: none; }
.sp-radios { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sp-body-input { min-height: 150px; }
.fgroup.has-error .sp-radios .rc-body { border-color: var(--bad-line); }

/* ============================== 导航栏里的「消息」未读角标（nav.js 里还没有入口时由本页追加） ============================== */
.nav-link .sp-navbadge {
  display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--bad); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
html.dark .nav-link .sp-navbadge { color: #1b0a10; }

/* ============================== 响应式 ============================== */
@media (max-width: 1100px) {
  .sp-layout { grid-template-columns: 340px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  /* 手机 / 窄屏：列表和会话是两个视图，用「返回列表」切换 */
  .sp-layout { grid-template-columns: minmax(0, 1fr); }
  .sp-layout[data-view="list"] .sp-main { display: none; }
  .sp-layout[data-view="thread"] .sp-side { display: none; }
  .sp-side { height: auto; min-height: 320px; }
  .sp-list { overflow: visible; }
  .sp-main { height: var(--sp-hm); min-height: 440px; }
  .sp-back { display: inline-flex; }
  .sp-backbar { display: block; }
  .support-page.sp-in-thread .page-head { display: none; }
  .sp-head { padding: 10px 12px; }
  .sp-msgs { padding: 12px 12px 10px; }
  .sp-msg { max-width: 92%; }
  .sp-reply { padding: 8px 12px 10px; }
  .sp-note { padding: 8px 12px 0; }
}
@media (max-width: 560px) {
  /* 新建消息：整屏对话框 */
  .modal.sp-modal { height: 100vh; max-height: 100vh; border-radius: 0; border: 0; transform: translateY(24px); }
  .sp-radios { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sp-body-input { min-height: 180px; }
  .sp-cat { padding: 0 8px; }
}
@supports (height: 100dvh) {
  @media (max-width: 560px) {
    .modal.sp-modal { height: 100dvh; max-height: 100dvh; }
  }
}
@media (hover: none) {
  .sp-kbd-hint { display: none; }
}
@media (hover: none) and (pointer: coarse) {
  .sp-cat { height: 34px; }
  .sp-reply-input { min-height: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  .sp-item.is-flash { animation: none; background: var(--warn-bg); box-shadow: inset 0 0 0 2px var(--warn-line); }
}
