.ch { display: grid; grid-template-columns: minmax(300px, 507px) minmax(0, 1fr); height: calc(100vh - 116px); min-height: 520px; margin: 0 -20px; }
.ch-list { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ch-title { padding: 29px 20px 24px; font-size: 24px; line-height: 32px; font-weight: 700; color: var(--text); }
.ch-rows { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a3c47 transparent; }
.ch-row { position: relative; display: flex; align-items: center; gap: 16px; padding: 12px 20px; color: var(--text); transition: background .18s; }
.ch-row::after { content: ""; position: absolute; right: 0; bottom: 0; left: 104px; height: 1px; background: var(--line); }
.ch-row:hover, .ch-row.on { background: var(--bg-soft-2); }
.ch-av { position: relative; display: block; flex: none; width: 68px; height: 68px; }
.ch-av-img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ch-dark { display: none; }
html[data-theme="dark"] .ch-light { display: none; }
html[data-theme="dark"] .ch-dark { display: block; }
.ch-dot { position: absolute; right: 0; bottom: 0; width: 20px; height: 20px; border: 2px solid var(--bg); border-radius: 50%; background: #10a350; }
.ch-txt { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.ch-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ch-name { display: inline-flex; align-items: center; min-width: 0; font-size: 18px; line-height: 28px; font-weight: 600; color: var(--text); }
.ch-ver { width: 20px; height: 20px; margin-left: 2px; flex: none; fill: none; stroke: none; }
.ch-time { flex: none; font-size: 14px; line-height: 24px; color: var(--muted); }
.ch-prev { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; max-height: 40px; font-size: 16px; line-height: 20px; color: var(--muted); word-break: break-word; }

.ch-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--line); }
.ch-empty { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 14px; line-height: 24px; }
.ch-empty img { width: 56px; height: 56px; }
.ch-head { display: flex; align-items: center; gap: 12px; height: 84px; padding: 0 20px; border-bottom: 1px solid var(--line); flex: none; }
.ch-back { display: none; width: 36px; height: 36px; place-items: center; border-radius: 50%; color: var(--text); }
.ch-back svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; }
.ch-head .ch-av { width: 40px; height: 40px; }
.ch-av-s .ch-dot { width: 14px; height: 14px; border-width: 2px; }
.ch-hn { display: flex; flex-direction: column; min-width: 0; }
.ch-hn .ch-name { font-size: 16px; line-height: 24px; }
.ch-hn .ch-ver { width: 18px; height: 18px; }
.ch-sub { font-size: 14px; line-height: 20px; color: var(--muted); }
.ch-scroll { display: flex; flex: 1; flex-direction: column; gap: 12px; min-height: 0; padding: 20px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a3c47 transparent; }
.ch-hint { align-self: center; max-width: 520px; padding: 8px 16px; border-radius: 12px; background: var(--bg-soft-2); color: var(--muted); font-size: 14px; line-height: 20px; text-align: center; }
.ch-hint a { color: #5286ff; }
.ch-msg { display: flex; flex: none; }
.ch-msg.out { justify-content: flex-end; }
.ch-bub { position: relative; max-width: min(70%, 640px); padding: 12px 16px 8px; border-radius: 12px; background: var(--bg-soft-2); color: var(--text); font-size: 16px; line-height: 24px; }
html[data-theme="dark"] .ch-bub { background: #25262e; }
.ch-bub p { margin: 0; word-break: break-word; }
.ch-bub time { display: block; margin-top: 2px; text-align: right; font-size: 12px; line-height: 16px; color: var(--muted); }
.ch-msg.out .ch-bub { background: #4d7cf8; color: #fff; }
.ch-msg.out .ch-bub time { color: rgba(255, 255, 255, .72); }
.ch-typing { display: flex; gap: 5px; align-items: center; height: 40px; padding: 0 16px; }
.ch-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: ch-dot 1s infinite ease-in-out; }
.ch-typing i:nth-child(2) { animation-delay: .15s; }
.ch-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ch-dot { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ch-error { align-self: center; display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-radius: 12px; background: var(--red-soft); color: var(--red); font-size: 14px; line-height: 20px; }
.ch-error button { padding: 0; border: 0; background: none; color: inherit; font: 700 14px/20px var(--font); text-decoration: underline; }
.ch-form { display: flex; align-items: flex-end; gap: 12px; padding: 16px 20px; border-top: 1px solid var(--line); flex: none; }
.ch-form textarea { flex: 1; min-width: 0; min-height: 48px; max-height: 140px; padding: 12px 20px; border: 0; border-radius: 12px; outline: 0; resize: none; background: var(--bg-soft-2); color: var(--text); font: 400 16px/24px var(--font); box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .2s; }
html[data-theme="dark"] .ch-form textarea { background: #25262e; }
.ch-form textarea:focus { box-shadow: inset 0 0 0 2px var(--blue); }
.ch-form textarea::placeholder { color: var(--muted); }
.ch-form textarea:disabled { opacity: .7; }
.ch-send, .ch-clip { display: grid; flex: none; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; transition: background .18s, opacity .18s; }
.ch-send { background: #4d7cf8; color: #fff; }
.ch-send:hover:not(:disabled) { background: #3f6ee8; }
.ch-send:disabled { opacity: .4; cursor: not-allowed; }
.ch-clip { background: none; color: var(--muted); }
.ch-clip:disabled { opacity: .5; cursor: not-allowed; }
.ch-send svg, .ch-clip svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; }

@media (max-width: 1023px) {
  .ch { grid-template-columns: minmax(0, 1fr); margin: 0 -16px; }
  .ch-title { padding: 20px 16px 16px; }
  .ch-row { padding: 10px 16px; gap: 12px; }
  .ch-row::after { left: 84px; }
  .ch-av { width: 56px; height: 56px; }
  .ch-pane { display: none; border-left: 0; }
  .ch-open .ch-pane { display: flex; }
  .ch-open .ch-list { display: none; }
  .ch-back { display: grid; }
  .ch-head { height: 64px; padding: 0 12px; }
  .ch-scroll { padding: 16px; }
  .ch-form { padding: 12px 16px; }
  .ch-bub { max-width: 86%; }
}

@media (max-width: 960px) {
  .ch { height: calc(100vh - 230px - env(safe-area-inset-bottom)); min-height: 420px; }
}

@media (prefers-reduced-motion: reduce) {
  .ch-typing i { animation: none; }
}

.sp-thread { position: relative; display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 12px 16px; border: 0; border-radius: 12px; background: var(--bg-soft-2); color: var(--text); text-align: left; font: 400 16px/24px var(--font); }
html[data-theme="dark"] .sp-thread { background: #282933; }
.sp-thread:hover { box-shadow: inset 0 0 0 2px var(--blue); }
.sp-thread b { font-weight: 600; }
.sp-thread span { overflow: hidden; color: var(--muted); font-size: 14px; line-height: 20px; text-overflow: ellipsis; white-space: nowrap; }
.sp-thread i { position: absolute; top: 12px; right: 16px; min-width: 22px; padding: 0 6px; border-radius: 11px; background: var(--blue); color: #fff; font-size: 12px; font-style: normal; line-height: 22px; text-align: center; }

.ch-item { position: relative; }
.ch-pin { position: absolute; top: 50%; right: 20px; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); opacity: 0; transform: translateY(-50%); transition: opacity .18s, color .18s, background-color .18s; cursor: pointer; }
.ch-pin svg { width: 20px; height: 20px; fill: none; stroke: none; transform: rotate(45deg); }
.ch-item:hover .ch-pin, .ch-pin:focus-visible { opacity: 1; }
.ch-item.pinned .ch-pin { opacity: .7; }
.ch-item.pinned:hover .ch-pin { opacity: 1; }
.ch-pin:hover { background: var(--bg-soft-2); color: var(--blue); }
.ch-pin:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.ch-item .ch-prev { padding-right: 44px; }
@media (hover: none) { .ch-pin { opacity: .7; } }

.ch { height: calc(100dvh - 116px); }
.ch-item .ch-top { padding-right: 36px; }
.ch-time { white-space: nowrap; }
.ch-pin { right: 8px; width: 28px; height: 28px; }
@media (max-width: 960px) {
  .ch.ch-open { position: fixed; z-index: 60; inset: 0; height: var(--vvh, 100dvh); min-height: 0; margin: 0; background: var(--bg); }
  .ch.ch-open .ch-pane { flex: 1; min-height: 0; height: 100%; }
  .ch:not(.ch-open) { height: calc(100dvh - 230px - env(safe-area-inset-bottom)); }
  .ch-form { padding-bottom: calc(12px + env(safe-area-inset-bottom)); background: var(--bg); }
}
.ch-hn { flex: 1; gap: 2px; }
.ch-hn .ch-name { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.ch-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; line-height: 18px; }
.ch-form { align-items: center; }
.ch-form textarea { min-height: 48px; }
@media (max-width: 960px) {
  .ch-head { gap: 10px; height: 60px; }
  .ch-head .ch-av { width: 36px; height: 36px; }
  .ch-form { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .ch-form textarea { min-height: 44px; padding: 10px 16px; border-radius: 22px; font-size: 16px; }
  .ch-send, .ch-clip { width: 44px; height: 44px; }
}
