:root {
  --ink: #182034;
  --paper: #f5f0e7;
  --blue: #bfcce8;
  --blue-deep: #345479;
  --line: rgba(24, 32, 52, 0.16);
  --shadow: 0 22px 54px rgba(23, 35, 60, 0.18);
  --display: Georgia, 'Times New Roman', serif;
  --body: 'Trebuchet MS', 'Noto Sans TC', sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: #dce4f0; font-family: var(--body); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.grain { position: fixed; inset: 0; pointer-events: none; opacity: .18; background-image: radial-gradient(rgba(24,32,52,.28) .55px, transparent .7px); background-size: 5px 5px; mix-blend-mode: soft-light; }

.app-shell { position: relative; display: grid; grid-template-columns: 316px minmax(0, 1fr); height: 100dvh; overflow: hidden; }
.rail { z-index: 2; display: flex; flex-direction: column; min-height: 0; padding: 26px 20px 18px; color: var(--paper); background: var(--ink); box-shadow: 10px 0 36px rgba(24,32,52,.12); overflow: hidden; }
.eyebrow { margin: 0 0 6px; color: var(--blue-deep); font-size: .67rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.rail .eyebrow { color: #aec0e3; }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 500; letter-spacing: -.04em; }
h1 { font-size: clamp(1.9rem, 2.8vw, 2.7rem); line-height: .88; }
h1 em { color: #aec0e3; }

.archive-stats { display: flex; justify-content: space-between; margin: 18px 0 12px; padding: 10px 0; border-top: 1px solid rgba(245,240,231,.22); border-bottom: 1px solid rgba(245,240,231,.22); font-size: .7rem; color: #cad5e8; }

.member-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.member-card { display: flex; align-items: center; gap: 10px; width: 100%; border: 1px solid rgba(245,240,231,.14); border-radius: 10px; padding: 8px 10px; cursor: pointer; text-align: left; color: var(--paper); background: rgba(255,255,255,.04); font: inherit; transition: background .16s ease, border-color .16s ease, transform .14s ease; }
.member-card:hover { background: rgba(255,255,255,.11); border-color: rgba(245,240,231,.36); }
.member-card.is-active { background: rgba(174,192,227,.22); border-color: #aec0e3; }
.member-card img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #2d3952; }
.member-card-meta { min-width: 0; flex: 1; }
.member-card-name { display: block; font-size: .86rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-card-sub { display: block; margin-top: 2px; font-size: .68rem; color: #b8c7e0; }

.search-wrap input { width: 100%; border: 1px solid rgba(245,240,231,.42); border-radius: 6px; outline: 0; padding: 9px 11px; color: var(--paper); background: rgba(255,255,255,.05); font: inherit; font-size: .82rem; }
.search-wrap input:focus { border-color: #fff; background: rgba(255,255,255,.1); }
.search-wrap input::placeholder { color: #afbdd6; }
.search-status { min-height: 1.1em; margin: 7px 0 0; color: #aec0e3; font-size: .69rem; }
.search-results { flex: 1; min-height: 0; overflow-y: auto; margin-top: 6px; border-top: 1px solid rgba(245,240,231,.22); border-bottom: 1px solid rgba(245,240,231,.22); }
.search-result { display: block; width: 100%; border: 0; border-bottom: 1px solid rgba(245,240,231,.12); padding: 9px 4px; cursor: pointer; text-align: left; color: var(--paper); background: transparent; font: inherit; }
.search-result:hover { color: #fff; background: rgba(255,255,255,.09); }
.search-result strong, .search-result span { display: block; }
.search-result strong { margin-bottom: 3px; color: #aec0e3; font-size: .68rem; letter-spacing: .04em; }
.search-result span { overflow: hidden; font-size: .74rem; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }

.rail-tools { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(245,240,231,.18); }
.date-jump-wrap { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .73rem; color: #cad5e8; }
.date-jump-wrap select { flex: 1; max-width: 175px; padding: 6px 8px; border: 1px solid rgba(245,240,231,.35); border-radius: 6px; background: #222c44; color: var(--paper); font: inherit; font-size: .76rem; }
.mode-button { width: 100%; padding: 8px 10px; border: 1px solid rgba(245,240,231,.28); border-radius: 6px; background: transparent; color: #cad5e8; font: inherit; font-size: .74rem; cursor: pointer; transition: background .16s ease, color .16s ease; }
.mode-button:hover { background: rgba(255,255,255,.1); color: #fff; }

.thumbnail-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; flex: 1; min-height: 0; overflow-y: auto; margin-top: 12px; padding-right: 3px; }
.thumbnail { position: relative; aspect-ratio: 9 / 16; overflow: hidden; border: 1px solid transparent; padding: 0; cursor: pointer; background: #344157; transition: transform .18s ease, border-color .18s ease; }
.thumbnail:hover { transform: translateY(-2px); border-color: #fff; }
.thumbnail img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.thumbnail span { position: absolute; right: 0; bottom: 0; padding: 3px 5px; color: var(--ink); background: #fff; font-size: .63rem; font-weight: 700; }

.viewer { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100dvh; padding: clamp(16px, 2.6vw, 34px) clamp(16px, 3.2vw, 44px); background: radial-gradient(circle at 80% 8%, #f7fafc 0, transparent 27%), linear-gradient(135deg, #e3eaf3, #c5d0e4); overflow: hidden; }
.viewer-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.viewer-title-group { display: flex; align-items: center; gap: 14px; min-width: 0; }
.header-avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.85); box-shadow: 0 4px 14px rgba(24,32,52,.16); }
.viewer-header h2 { font-size: clamp(1.5rem, 2.8vw, 2.5rem); line-height: 1.05; }
.header-actions { display: flex; align-items: center; gap: 10px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-pill { border: 1px solid rgba(24,32,52,.18); border-radius: 999px; padding: 6px 12px; background: rgba(255,255,255,.55); color: var(--ink); font: inherit; font-size: .76rem; font-weight: 700; cursor: pointer; transition: background .15s ease, color .15s ease; }
.filter-pill:hover { background: rgba(255,255,255,.9); }
.filter-pill.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.icon-button, .text-button, .close-button { border: 0; cursor: pointer; color: var(--ink); background: transparent; font: inherit; }
.icon-button { display: none; padding: 8px; font-size: 1.4rem; }

.chat-feed { min-height: 0; overflow-y: auto; margin: 16px 0; padding: 22px clamp(14px, 3vw, 40px); border: 1px solid rgba(24,32,52,.14); border-radius: 18px; background: linear-gradient(145deg, rgba(205,215,239,.92), rgba(181,195,227,.94)); box-shadow: inset 0 1px rgba(255,255,255,.52), var(--shadow); scroll-behavior: smooth; }

.date-divider { display: flex; justify-content: center; margin: 20px 0 14px; }
.date-divider span { padding: 4px 14px; border-radius: 999px; background: rgba(24,32,52,.16); color: #24324d; font-size: .73rem; font-weight: 700; letter-spacing: .04em; }

.chat-row { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 12px; content-visibility: auto; contain-intrinsic-size: auto 72px; }
.chat-row.is-right { flex-direction: row-reverse; }
.chat-row.is-grouped { margin-top: -6px; }
.chat-row.is-highlighted .chat-bubble,
.chat-row.is-highlighted .media-card { outline: 3px solid #2b6cb0; box-shadow: 0 0 0 6px rgba(43, 108, 176, .22); }

.msg-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #cbd5e1; margin-top: 2px; }
.msg-avatar-spacer { width: 36px; flex-shrink: 0; }

.chat-message { display: flex; flex-direction: column; max-width: min(82%, 560px); }
.chat-row.is-right .chat-message { align-items: flex-end; }
.chat-sender { margin: 0 0 4px; color: #2c3d59; font-size: .74rem; font-weight: 700; }

.bubble-line { display: flex; align-items: flex-end; gap: 7px; }
.chat-row.is-right .bubble-line { flex-direction: row-reverse; }
.chat-time { color: #4a5c7a; font-size: .67rem; white-space: nowrap; flex-shrink: 0; padding-bottom: 2px; }

.chat-bubble { border: 0; border-radius: 6px 18px 18px 18px; padding: 10px 14px; text-align: left; color: var(--ink); background: rgba(255,255,255,.96); box-shadow: 0 3px 10px rgba(41,57,91,.11); font: .96rem/1.52 var(--body); white-space: pre-wrap; word-break: break-word; }
.chat-row.is-right .chat-bubble { border-radius: 18px 6px 18px 18px; background: #fff0a9; }
button.chat-bubble { cursor: pointer; }

.reply-quote { margin-bottom: 7px; padding-bottom: 7px; border-bottom: 1px solid rgba(24,32,52,.12); font-size: .82rem; color: #52627c; }
.reply-quote-label { display: block; font-size: .7rem; font-weight: 700; color: #345479; margin-bottom: 2px; }
.reply-quote-sticker { display: block; width: 64px; height: 64px; margin: 4px 0; object-fit: contain; }
.reply-quote-text { display: block; white-space: pre-wrap; }
.reply-quote-translation { display: block; margin-top: 3px; font-size: .78rem; color: #3d5a80; white-space: pre-wrap; }
.reply-arrow { color: #345479; font-weight: 700; margin-right: 4px; }
.chat-original { display: block; }
.chat-translation { display: block; margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(24,32,52,.14); color: #355275; font-size: .9rem; line-height: 1.48; white-space: pre-wrap; }
.chat-feed.hide-translations .chat-translation,
.chat-feed.hide-translations .reply-quote-translation { display: none; }

.media-card { overflow: hidden; border-radius: 14px; background: rgba(255,255,255,.92); box-shadow: 0 4px 14px rgba(41,57,91,.14); }
.chat-photo { display: block; max-width: min(320px, 72vw); max-height: 420px; width: auto; height: auto; cursor: zoom-in; object-fit: cover; }
.chat-sticker { display: block; width: 136px; height: 136px; object-fit: contain; }

.audio-card { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; min-width: 245px; max-width: 320px; }
.audio-card-head { display: flex; justify-content: space-between; align-items: center; font-size: .74rem; font-weight: 700; color: #345479; }
.audio-card audio { width: 100%; height: 36px; }

.video-card { display: flex; flex-direction: column; max-width: min(340px, 74vw); }
.video-card video { display: block; width: 100%; max-height: 460px; background: #0f172a; }
.video-card-foot { display: flex; justify-content: space-between; padding: 6px 10px; font-size: .72rem; color: #40516c; }

.pop-card { padding: 12px 15px; border-radius: 14px; background: linear-gradient(135deg, #273759, #3b5384); color: #f8fafc; box-shadow: 0 6px 18px rgba(24,32,52,.2); min-width: 220px; }
.pop-card-tag { display: inline-block; font-size: .64rem; font-weight: 700; letter-spacing: .12em; color: #c7d9ff; margin-bottom: 4px; }
.pop-card-title { font-size: .95rem; font-weight: 700; margin: 0 0 4px; }
.pop-card-time { font-size: .72rem; color: #d8e4fb; margin: 0; }

.empty-state { text-align: center; padding: 48px 16px; color: #34445f; font-size: .95rem; }

.viewer-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: .74rem; color: #40516c; }
.jump-actions { display: flex; gap: 14px; }
.text-button { color: var(--blue-deep); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.lightbox { width: min(96vw, 860px); max-height: 96dvh; padding: 0; border: 0; background: #111827; box-shadow: 0 32px 80px rgba(0,0,0,.45); }
.lightbox::backdrop { background: rgba(13, 20, 35, .78); backdrop-filter: blur(4px); }
.lightbox img { display: block; max-width: 100%; max-height: 94dvh; margin: auto; }
.close-button { position: fixed; top: 14px; right: 20px; color: white; font-size: 2.5rem; line-height: 1; }

@media (max-width: 820px) {
  .app-shell { display: block; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); transform: translateX(-104%); transition: transform .26s ease; }
  .rail.is-open { transform: translateX(0); }
  .icon-button { display: block; }
  .viewer { height: 100dvh; padding: 14px; }
  .viewer-footer p { display: none; }
  .chat-feed { padding: 16px 12px; border-radius: 12px; }
  .chat-message { max-width: 86%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
