/* 留言版專屬樣式（共用樣式在 /static/base.css，來源 ui/base.css） */

/* ---------- 首頁介紹（未登入）---------- */
.landing {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 85% -10%, var(--glow-1) 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, var(--glow-2) 0%, transparent 60%),
    var(--bg);
}
.landing-card {
  width: min(460px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 36px 28px;
  box-shadow: 0 1px 2px rgb(var(--shadow-rgb) / 5%), 0 16px 40px rgb(var(--shadow-rgb) / 9%);
}
.landing-card h1 { font-size: 30px; }
.landing-card .lead { color: var(--text-2); }
.logo.xl { width: 64px; height: 64px; border-radius: 18px; font-size: 32px; }
.landing-actions { display: flex; gap: 10px; width: 100%; margin-top: 6px; }
.landing-actions .btn { flex: 1; }
.btn.big { padding: 11px 18px; font-size: 15px; border-radius: 11px; }

/* ---------- 側欄：在線名單 ---------- */
.online-card { max-height: 40vh; display: flex; flex-direction: column; }
.online { list-style: none; margin: 6px 0 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.online li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); min-width: 0; }
.online li span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online .avatar { width: 24px; height: 24px; font-size: 11px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }

/* ---------- 聊天區 ---------- */
.chat-content { height: 100vh; padding-top: 24px; padding-bottom: 24px; display: flex; }
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.conn { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.conn.live::before { background: var(--good); }
.conn.down::before { background: var(--crit); }

.messages { flex: 1; overflow-y: auto; padding: 16px 20px 34px; background: var(--panel-2); scroll-behavior: smooth; }
.load-more { display: block; margin: 0 auto 12px; }
.empty-chat { text-align: center; color: var(--muted); padding: 40px 0; }
.day { display: flex; align-items: center; gap: 12px; margin: 16px 0 10px; color: var(--muted); font-size: 12px; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.msg { display: flex; gap: 10px; align-items: flex-end; margin-top: 10px; max-width: min(72%, 960px); }  /* 太長的一行不好讀 */
.msg.cont { margin-top: 3px; }
.msg.cont .avatar { visibility: hidden; }
.msg .avatar { width: 34px; height: 34px; font-size: 13px; }
.msg .stack { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-items: flex-start; }
.msg .meta { font-size: 12px; color: var(--muted); padding: 0 4px; }
.msg .meta strong { color: var(--text-2); font-weight: 600; margin-right: 6px; }
.msg.cont .meta { display: none; }
.bubble {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px;
  padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; box-shadow: 0 1px 1px rgb(var(--shadow-rgb) / 4%);
}
.bubble a { color: var(--accent-strong); }
.bubble .time { display: inline-block; margin-left: 8px; font-size: 11px; color: var(--muted); vertical-align: baseline; }

/* 自己的留言靠右 */
.msg.mine { margin-left: auto; flex-direction: row-reverse; }
.msg.mine .stack { align-items: flex-end; }
.msg.mine .avatar { display: none; }
.msg.mine .bubble { background: var(--accent-soft); border-color: var(--accent-line); border-radius: 14px 14px 4px 14px; }

/* 留言工具列：浮在泡泡下方，自己的留言在左下、朋友的留言在右下（靠聊天室中間），滑鼠移上去才出現 */
.bubble-wrap { position: relative; display: flex; flex-direction: column; align-items: flex-start; max-width: 100%; }
.msg.mine .bubble-wrap { align-items: flex-end; }
.msg-tools {
  position: absolute; top: calc(100% + 5px); right: 0; z-index: 3;
  display: flex; gap: 1px; padding: 2px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); box-shadow: 0 4px 14px rgb(var(--shadow-rgb) / 12%);
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.msg.mine .msg-tools { right: auto; left: 0; }
/* 和泡泡之間留一點空隙；用透明的橋接住空隙，滑鼠往下移到工具列途中才不會消失 */
.msg-tools::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px; }
/* 電腦：滑鼠移上去才出現；手機：長按泡泡後出現（.menu-open，見 board.js setupLongPress） */
@media (hover: hover) { .msg:hover .msg-tools { opacity: 1; pointer-events: auto; } }
.msg-tools:focus-within, .msg.menu-open .msg-tools { opacity: 1; pointer-events: auto; }
.msg-tools .tool.copy { display: none; }
.msg-tools .tool {
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
  font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.msg-tools .tool:hover { color: var(--accent-strong); background: var(--accent-soft); }
.msg-tools .tool.del:hover { color: var(--crit); background: var(--crit-soft); }
.bubble .edited { color: var(--muted); }

/* 就地編輯 */
.msg.editing { max-width: min(960px, 100%); width: 100%; }
.msg.editing .stack { flex: 1; align-items: stretch; }
.msg.editing .bubble-wrap { align-items: stretch; }
.bubble.editor { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.msg.mine .bubble.editor { background: var(--panel); }
.edit-input { resize: none; min-height: 38px; max-height: 220px; line-height: 1.5; padding: 7px 10px; border-radius: 9px; }
.edit-bar { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.edit-bar .muted { margin-right: auto; }
.msg.new .bubble { animation: pop .25s ease-out; }
@keyframes pop { from { transform: translateY(4px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 輸入區 ---------- */
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea {
  flex: 1; resize: none; max-height: 160px; min-height: 42px; line-height: 1.5;
  padding: 9px 12px; border-radius: 12px;
}
.composer-tools { display: flex; gap: 4px; align-self: flex-end; padding-bottom: 3px; }
.tool-btn {
  display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 6px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2); cursor: pointer;
  font-weight: 800; font-size: 12px; letter-spacing: .03em;
}
.tool-btn:hover { background: var(--panel-2); color: var(--accent-strong); border-color: var(--line-strong); }
.tool-btn:disabled { opacity: .5; cursor: progress; }
.tool-btn svg { width: 20px; height: 20px; }
.composer-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.counter { min-height: 1em; }

/* ---------- 回覆 ---------- */
.quote {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; min-width: 160px; max-width: 420px;
  margin: 0 0 6px; padding: 5px 10px; border: 0; border-left: 3px solid var(--accent); border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 9%, transparent); font: inherit; font-size: 12.5px; line-height: 1.45; text-align: left;
  color: var(--text-2); cursor: pointer; white-space: normal;
}
.quote:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.quote strong { color: var(--accent-strong); font-size: 12px; }
.quote span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.quote.gone { border-left-color: var(--line); color: var(--muted); font-style: italic; cursor: default; background: var(--panel-2); }
.bubble.has-media .quote { margin: 2px 0 0; }
.msg.flash .bubble { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px var(--warn); } 100% { box-shadow: 0 0 0 3px transparent; } }

.reply-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 16px;
  border-top: 1px solid var(--line); background: var(--accent-soft); color: var(--text-2); font-size: 13px;
}
.reply-bar > svg { width: 18px; height: 18px; color: var(--accent-strong); flex: none; }
.reply-info { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-info strong { color: var(--accent-strong); margin: 0 6px 0 2px; }
.reply-bar .icon-btn { width: 30px; height: 30px; }
.reply-bar + .composer { border-top: 0; }

/* ---------- 釘選 ---------- */
.pin-bar {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--line); background: var(--warn-faint);
}
.pin-current {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 2px 0; border: 0; background: none;
  font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; text-align: left;
}
.pin-current svg { width: 17px; height: 17px; color: var(--warn-ink); flex: none; }
.pin-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-text strong { margin-right: 2px; }
.pin-current:hover .pin-text { text-decoration: underline; }
.pin-more {
  flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 12px;
  font: inherit; font-size: 12.5px; color: var(--text-2); cursor: pointer;
}
.pin-more:hover { border-color: var(--line-strong); }
.pin-list {
  position: absolute; left: 12px; right: 12px; top: calc(100% + 4px); z-index: 7; max-height: 50vh; overflow-y: auto;
  padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 36px rgb(var(--shadow-rgb) / 16%);
}
.pin-list-head { font-size: 12px; color: var(--muted); padding: 4px 8px 6px; }
.pin-item { display: flex; align-items: center; gap: 8px; padding: 2px; border-radius: 9px; }
.pin-item:hover { background: var(--panel-2); }
.pin-jump {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; background: none;
  font: inherit; text-align: left; cursor: pointer; color: var(--text);
}
.pin-jump > span { min-width: 0; display: flex; flex-direction: column; }
.pin-jump strong { font-size: 13px; }
.pin-jump small { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar.xs { width: 26px; height: 26px; font-size: 11px; }
.pinned-tag { margin-left: 6px; color: var(--warn-ink); font-size: 11.5px; }
.msg.pinned .bubble { border-color: var(--warn-line); }

/* ---------- 圖片 / GIF ---------- */
.bubble.has-media { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 6px; }
.bubble.has-media .time { align-self: flex-end; margin: 0 4px; }
.bubble.media-only { background: transparent; border: 0; box-shadow: none; padding: 0; }
.msg.mine .bubble.media-only { background: transparent; }
.bubble.media-only .time { margin-top: -2px; }
.bubble img.media { display: block; max-width: 100%; height: auto; border-radius: 10px; background: var(--panel-2); }
.media-link { display: block; line-height: 0; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 10px; }

/* 圖片放大檢視：同一頁中間顯示，右上角 X 關閉 */
dialog.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 24px;
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
  display: none; place-items: center;
}
dialog.lightbox[open] { display: grid; }
dialog.lightbox::backdrop { background: rgb(20 24 36 / 82%); }
.lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 100%; max-height: 100%; }
.lightbox img {
  display: block; max-width: 92vw; max-height: calc(100vh - 110px); object-fit: contain;
  border-radius: 12px; background: var(--panel); box-shadow: 0 20px 60px rgb(0 0 0 / 40%); cursor: default;
}
.lightbox figcaption { color: #e9ecf5; font-size: 13px; }
.lightbox figcaption:empty { display: none; }
.lightbox-close {
  position: fixed; top: 16px; right: 16px; z-index: 1; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--panel) 92%, transparent); color: var(--text); box-shadow: 0 4px 16px rgb(0 0 0 / 25%);
}
.lightbox-close:hover { background: var(--panel); }
.lightbox-close svg { width: 22px; height: 22px; }

.gif-panel {
  position: absolute; left: 16px; bottom: 74px; z-index: 5; width: min(420px, calc(100% - 32px));
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 36px rgb(var(--shadow-rgb) / 16%);
}
.gif-head { display: flex; gap: 6px; align-items: center; }
.gif-grid {
  height: 300px; overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  align-content: start;
}
.gif-item { border: 0; padding: 0; border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--panel-2); height: 96px; }
.gif-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-item:hover, .gif-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.gif-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.giphy-credit { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.drop-hint {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; pointer-events: none;
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent); border: 2px dashed var(--accent); border-radius: var(--radius);
  color: var(--accent-strong); font-weight: 700; font-size: 16px;
}

@media (max-width: 860px) {
  .online-card { display: none; }
  .chat-content { height: calc(100vh - 118px); padding: 12px; }
  .msg { max-width: 100%; }
  .gif-panel { left: 8px; width: calc(100% - 16px); }
  .gif-grid { height: 240px; }
}
/* 觸控裝置：長按泡泡開工具列（像 LINE），按鈕放大好點，泡泡不讓瀏覽器選字 / 跳出系統選單 */
@media (hover: none) {
  .bubble:not(.editor) { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .msg-tools { gap: 2px; padding: 3px; box-shadow: 0 6px 20px rgb(var(--shadow-rgb) / 18%); max-width: calc(100vw - 16px); flex-wrap: wrap; justify-content: center; border-radius: 18px; }
  .msg-tools .tool { padding: 8px 13px; font-size: 14px; }
  .msg-tools .tool.copy { display: inline-block; }
  .msg.menu-open .bubble { box-shadow: 0 0 0 2px var(--accent); transition: box-shadow .15s; }
  .messages { padding-bottom: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  .messages { scroll-behavior: auto; }
  .msg.new .bubble { animation: none; }
}
