/* 神評 · 網頁版（對應 App C 的外觀）。亮 / 暗色自動跟隨系統。 */
:root {
  --bg: #f2f2f2; --card: #fff; --bubble: #fff; --bubble-me: #95ec69; --bubble-me-text: #1b1b1b;
  --text: #1c1c1e; --sub: #8a8a8e; --line: rgba(0,0,0,.08); --primary: #3b7ddd; --primary-text: #fff;
  --chip: rgba(0,0,0,.05); --chip-on: rgba(59,125,221,.16); --shadow: 0 4px 18px rgba(0,0,0,.14);
  --sheet: #fff; --danger: #d64545;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212; --card: #1e1e1e; --bubble: #2c2c2c; --bubble-me: #2f6b3a; --bubble-me-text: #f2f2f2;
    --text: #ececec; --sub: #9a9aa0; --line: rgba(255,255,255,.1); --primary: #6ea4f5; --primary-text: #0b1b33;
    --chip: rgba(255,255,255,.08); --chip-on: rgba(110,164,245,.25); --shadow: 0 4px 18px rgba(0,0,0,.5);
    --sheet: #242424; --danger: #ff7b7b;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
a { color: var(--primary); }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 720px; margin: 0 auto; position: relative; }
#top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; min-height: 48px; flex: none; }
#top h1 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { border: 0; background: var(--chip); border-radius: 18px; min-width: 36px; height: 36px; padding: 0 12px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.icon-btn[hidden] { display: none; }
#scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; cursor: pointer; user-select: none; -webkit-user-select: none; }
#list { padding: 4px 12px 140px; }

/* 目錄 */
.cat-item { display: flex; gap: 12px; background: var(--card); border-radius: 10px; padding: 10px; margin: 8px 0; text-decoration: none; color: inherit; align-items: center; }
.cat-thumb { width: 56px; height: 56px; border-radius: 8px; background: var(--chip); flex: none; object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--sub); overflow: hidden; }
.cat-body { flex: 1; min-width: 0; }
.cat-title { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cat-meta { font-size: 12px; color: var(--sub); margin-top: 2px; }
.empty { text-align: center; color: var(--sub); padding: 60px 0; }

/* 貼文卡 */
.post { background: var(--card); border-radius: 10px; padding: 14px; margin-top: 4px; cursor: default; }
.post-text { white-space: pre-wrap; word-break: break-word; font-size: 16px; line-height: 1.5; }
.media { margin-top: 10px; }
.media:first-child { margin-top: 0; }
.media-box { position: relative; width: min(100%, calc(62vh * var(--r, 1.5))); aspect-ratio: var(--r, 1.5); margin: 0 auto; border-radius: 8px; overflow: hidden; background: var(--chip); }
.media-box > img, .media-box > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; -webkit-user-drag: none; }
.media-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; transition: opacity .6s ease; }
.media-box canvas.done { opacity: 0; pointer-events: none; }
.reveal-skip { display: block; margin: 6px auto 0; border: 0; background: none; color: var(--sub); font-size: 12px; cursor: pointer; padding: 4px 10px; text-decoration: underline; }
.reveal-hint { text-align: center; color: var(--sub); font-size: 12px; margin-top: 6px; }

.audio-chip { display: flex; align-items: center; gap: 8px; margin-top: 10px; background: var(--chip); border-radius: 20px; padding: 6px 12px; font-size: 13px; }
.audio-chip .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-chip button { border: 0; background: none; cursor: pointer; font-size: 18px; padding: 0 2px; }

.embed { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; margin-top: 10px; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.link-card { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--chip); text-decoration: none; color: inherit; }
.link-card .g { font-size: 20px; }
.link-card .l { flex: 1; min-width: 0; }
.link-card .l b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.link-card .l span { display: block; font-size: 12px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 互動列（像 WhatsApp 頻道） */
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; }
.chip { border: 0; background: var(--chip); border-radius: 16px; padding: 3px 10px; min-height: 30px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font-size: 14px; }
.chip.on { background: var(--chip-on); outline: 1.5px solid var(--primary); }
.chip .n { font-size: 12px; color: var(--sub); }
.chip.on .n { color: var(--primary); }
.chip.pop { animation: pop .28s ease; }
@keyframes pop { 50% { transform: scale(1.25); } }
.actions .sp { flex: 1; }

/* 評論氣泡 */
.row { display: flex; gap: 8px; padding: 5px 0; align-items: flex-start; animation: rise .22s ease-out both; }
.row.right { flex-direction: row-reverse; }
.row.still { animation: none; }
.row.pop { animation: popin .32s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes popin { from { opacity: 0; transform: translateY(14px) scale(1.22); } to { opacity: 1; transform: none; } }
.av { width: 36px; height: 36px; border-radius: 6px; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 17px; }
.av.two { font-size: 13px; }
.col { max-width: 74%; display: flex; flex-direction: column; }
.row.right .col { align-items: flex-end; }
.nick { font-size: 12px; color: var(--sub); margin-bottom: 3px; }
.bubble { background: var(--bubble); border-radius: 8px; padding: 9px 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.row.right .bubble { background: var(--bubble-me); color: var(--bubble-me-text); }
.bubble.shake { outline: 1.2px solid rgba(255,82,82,.55); }
.bubble.ind { font-size: 13px; font-style: italic; opacity: .7; }
.sys { text-align: center; margin: 14px 24px; }
.sys span { display: inline-block; font-size: 13px; color: var(--sub); background: var(--chip); border-radius: 6px; padding: 6px 12px; animation: rise .22s ease-out both; }
.sys.tip span { background: none; font-size: 12px; opacity: .8; }

/* 底部提示列 */
#bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 12px calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; }
#bar .hint { background: color-mix(in srgb, var(--bg) 88%, transparent); color: var(--sub); font-size: 12px; padding: 6px 14px; border-radius: 20px; }
#bar .btns { display: flex; gap: 12px; pointer-events: auto; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 8px 18px; cursor: pointer; }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; }

/* 留言 / 轉發面板 */
.mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.mask[hidden] { display: none; }
.sheet { background: var(--sheet); width: 100%; max-width: 720px; border-radius: 16px 16px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px)); max-height: 80vh; max-height: 80dvh; display: flex; flex-direction: column; box-shadow: var(--shadow); cursor: default; }
.sheet h2 { margin: 0 0 8px; font-size: 16px; display: flex; align-items: center; }
.sheet h2 span { flex: 1; }
.sheet .list { overflow-y: auto; flex: 1; min-height: 60px; margin-bottom: 10px; }
.cmt { padding: 8px 0; border-bottom: 1px solid var(--line); word-break: break-word; white-space: pre-wrap; }
.cmt small { display: block; color: var(--sub); font-size: 11px; margin-top: 2px; }
.cmt.mine { animation: rise .25s ease-out both; }
.form { display: flex; gap: 8px; }
.form input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 18px; padding: 8px 14px; font: inherit; outline: none; }
.note { font-size: 11px; color: var(--sub); margin: 6px 2px 0; }
.ai-bubble { background: var(--bubble-me); color: var(--bubble-me-text); border-radius: 12px; padding: 8px 12px; margin: 0 0 10px; font-size: 14px; animation: rise .25s ease-out both; transition: opacity .6s ease; }
.ai-bubble.out { opacity: 0; }
.ai-bubble b { display: block; font-size: 11px; opacity: .7; font-weight: 600; margin-bottom: 2px; }
.share-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 0; }
.share-grid a, .share-grid button { text-align: center; padding: 10px; border-radius: 10px; background: var(--chip); text-decoration: none; color: var(--text); border: 0; cursor: pointer; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: rgba(30,30,30,.92); color: #fff; padding: 8px 16px; border-radius: 18px; font-size: 13px; z-index: 40; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 86vw; text-align: center; }
#toast.on { opacity: 1; }
.loading, .err { text-align: center; color: var(--sub); padding: 60px 20px; }
.err button { margin-top: 12px; }
