:root {
  --bg: #16181d;
  --panel: #1f2229;
  --line: #2e323b;
  --text: #e8eaee;
  --muted: #9aa1ad;
  --accent: #3ba55c;
  --accent-hover: #46bd6a;
  --danger: #d9534f;
  --warn: #e0a030;
  font-family: "Microsoft JhengHei UI", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1em; }
.spacer { flex: 1; }

button {
  background: var(--line); color: var(--text); border: 0; border-radius: 6px;
  padding: 7px 14px; font: inherit; cursor: pointer;
}
button:hover { filter: brightness(1.15); }
button:disabled { opacity: .5; cursor: default; filter: none; }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); filter: none; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button.link { background: none; color: var(--muted); padding: 0 4px; text-decoration: underline; }
button.big { padding: 12px 24px; font-size: 16px; }

input, textarea, select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 10px; font: inherit; width: 100%;
}

.login-box { max-width: 380px; margin: 18vh auto 0; text-align: center; }
.login-box h1 { margin-bottom: 4px; }
.code { font-size: 32px; letter-spacing: 6px; font-weight: bold; margin: 12px 0; user-select: all; }

#topbar { display: flex; align-items: center; gap: 4px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); height: 52px; }
.brand { font-weight: bold; margin-right: 16px; }
.tab { background: none; border-radius: 0; padding: 16px 12px; border-bottom: 2px solid transparent; }
.tab.active { border-bottom-color: var(--accent); }

main { padding: 16px; max-width: 1100px; margin: 0 auto; }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar label { display: flex; gap: 6px; align-items: center; white-space: nowrap; color: var(--muted); }
.toolbar label input { width: auto; }

table.rooms { width: 100%; border-collapse: collapse; }
.rooms th { text-align: left; color: var(--muted); font-weight: normal; padding: 8px; border-bottom: 1px solid var(--line); }
.rooms td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.room-name { font-weight: bold; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.tag.warn { background: rgba(224, 160, 48, .15); color: var(--warn); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.card h2 { margin-top: 0; }
form.card label, details label { display: block; margin-bottom: 12px; color: var(--muted); }
form.card label input, form.card label textarea, form.card label select, details label input { margin-top: 4px; color: var(--text); }
details summary { cursor: pointer; color: var(--muted); }
details[open] summary { margin-bottom: 12px; }
.row { display: flex; gap: 8px; }

ul.players { list-style: none; padding: 0; margin: 0; }
ul.players li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }

.update-bar { display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: rgba(224, 160, 48, .15); border-bottom: 1px solid var(--warn); }
.update-bar span { flex: 1; }
.join-bar { display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: rgba(59, 165, 92, .15); border-bottom: 1px solid var(--accent); }
.join-bar span { flex: 1; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; max-width: 460px; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }

/* ---------- 帳號 ---------- */
a { color: var(--accent); }
.notice { background: rgba(59, 165, 92, .15); border: 1px solid var(--accent); border-radius: 6px; padding: 10px 12px; text-align: left; }
.provider-buttons { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.login-box.left { text-align: left; }
.card label.check, label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; margin: 0; }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; object-fit: cover; color: #fff; font-weight: bold; flex: none; vertical-align: middle; }
.me-btn { display: flex; align-items: center; gap: 6px; background: none; padding: 4px 6px; }
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head h2 { margin: 0; }
.badges { display: flex; gap: 6px; margin-top: 4px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--accent); color: #fff; }
label.button-like { display: inline-block; background: var(--line); color: var(--text); border-radius: 6px; padding: 7px 14px; cursor: pointer; margin: 0; }
form.card label.button-like { color: var(--text); margin-bottom: 0; }
.strong-link { font-weight: bold; }

/* ---------- 好友、訊息 ---------- */
.count-badge { display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 11px; line-height: 16px; text-align: center; }
.presence::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--muted); }
.presence.online::before { background: var(--accent); }
.presence.playing::before { background: var(--warn); }
.presence.offline { color: var(--muted); }
.person { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.small-btn { padding: 3px 10px; }
.subtabs { display: flex; gap: 4px; margin-bottom: 8px; }
.subtabs button { background: none; border-radius: 0; border-bottom: 2px solid transparent; color: var(--muted); }
.subtabs button.on { color: var(--text); border-bottom-color: var(--accent); }
ul.players li .spacer { text-align: right; }
#search-results:not(:empty) { margin-top: 8px; }
.dm { display: grid; grid-template-columns: 260px 1fr; gap: 16px; height: calc(100vh - 140px); }
.dm .card { margin: 0; display: flex; flex-direction: column; overflow: hidden; }
.dm-list ul { overflow-y: auto; }
.conv { cursor: pointer; border-radius: 6px; padding: 6px !important; border-bottom: 0 !important; }
.conv:hover, .conv.on { background: var(--line); }
.conv-text { flex: 1; min-width: 0; }
.conv-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-head { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); min-height: 36px; }
.thread-msgs { flex: 1; overflow-y: auto; padding: 10px 2px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 75%; align-self: flex-start; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg-body { display: inline-block; text-align: left; padding: 7px 11px; border-radius: 12px; background: var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine .msg-body { background: var(--accent); color: #fff; }
.thread-form { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.thread-form textarea { flex: 1; resize: none; }
#friend-rooms h3 { margin: 0 0 8px; }

/* ---------- @名稱 ---------- */
.handle-input { display: flex; align-items: center; margin-top: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); padding-left: 10px; }
.handle-input > span { color: var(--muted); }
.handle-input input { border: 0 !important; margin: 0 !important; background: transparent !important; padding-left: 4px; }
p.ok { color: var(--accent); }
p.error.small { min-height: 0; }

/* ---------- 貼文 ---------- */
.posts-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.posts-layout:has(#post-detail:not(.hidden)) { grid-template-columns: minmax(0, 1fr) 360px; }
.post-detail { position: sticky; top: 0; max-height: calc(100vh - 100px); overflow-y: auto; }
.detail-head { align-items: center; margin-bottom: 8px; }
.post-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.post-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; }
.post-hidden { margin: 8px 0 0; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--danger); color: var(--danger); }
.post-images { display: grid; gap: 4px; margin-top: 8px; border-radius: 8px; overflow: hidden; }
.post-images.n2, .post-images.n3, .post-images.n4 { grid-template-columns: 1fr 1fr; }
.post-images img { display: block; width: 100%; max-height: 420px; object-fit: cover; cursor: zoom-in; background: var(--line); }
.post-images.n2 img, .post-images.n3 img, .post-images.n4 img { aspect-ratio: 1; max-height: none; height: 100%; }
.post-images.n3 img:first-child { grid-row: span 2; }
.post-clip { display: block; width: 100%; max-height: 420px; margin-top: 8px; border-radius: 8px; background: #000; }
.yt { position: relative; display: block; width: 100%; padding: 0; margin-top: 8px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; }
.yt img { width: 100%; height: 100%; object-fit: cover; }
.yt-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 64px; height: 44px; border-radius: 12px; background: rgba(0,0,0,.7); color: #fff; font-size: 20px; line-height: 44px; }
.post-actions { display: flex; gap: 4px; margin-top: 8px; }
.post-act { background: none; color: var(--muted); padding: 4px 10px; }
.post-act:hover { background: var(--line); filter: none; }
.post-act.on { color: var(--danger); }
#post-more, #pf-posts-more { display: block; margin: 0 auto 16px; }
.composer textarea { resize: vertical; }
.composer input[type=url] { margin-top: 8px; }
.composer input[type=url]:disabled { opacity: .5; }
.cmp-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.cmp-bar label.button-like.disabled { opacity: .5; pointer-events: none; }
.cmp-previews { display: flex; gap: 8px; flex-wrap: wrap; }
.cmp-previews:not(:empty) { margin-top: 8px; }
.cmp-thumb { position: relative; width: 80px; height: 80px; border-radius: 6px; overflow: hidden; background: var(--line); }
.cmp-thumb img, .cmp-thumb video { width: 100%; height: 100%; object-fit: cover; }
.cmp-x { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; padding: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; line-height: 20px; }
ul.comment-list li.comment { display: block; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; align-items: flex-end; }
.comment-form textarea { flex: 1; resize: vertical; }
.notify { cursor: pointer; border-radius: 6px; padding: 8px 6px !important; }
.notify:hover { background: var(--line); }
.notify-text { text-align: left !important; overflow-wrap: anywhere; }
.notify.unread .notify-text { font-weight: bold; }
.report-dialog form label.check { margin: 6px 0; }
.report-dialog textarea { margin-top: 8px; }
.report-actions { justify-content: flex-end; margin-top: 12px; }
#pf-posts { margin-top: 8px; }

/* ---------- 程式內個人頁、⋯ 選單、備註、頭像裁切 ---------- */
.dropdown { position: relative; display: inline-block; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-width: 160px; padding: 4px; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.menu-item { display: block; width: 100%; text-align: left; background: none; padding: 7px 10px; white-space: nowrap; }
.menu-item:hover { background: var(--line); filter: none; }
.icon-btn { background: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px 8px; }
.icon-btn:hover { background: var(--line); filter: none; }
button.done, button.done:disabled { background: var(--line); color: var(--muted); opacity: 1; cursor: default; }
.back-link { margin-bottom: 8px; text-decoration: none; }
#tab-user .profile-head h2 { margin: 0; }
#tab-user .counts { margin: 10px 0 4px; }
.presence-line { margin: 4px 0; }
.profile-actions { flex-wrap: wrap; align-items: center; margin-top: 10px; }
.bio { white-space: pre-wrap; overflow-wrap: anywhere; }
.user-room { display: flex; align-items: center; gap: 12px; margin: 12px 0 0; }
.note-box { margin: 10px 0 0; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; display: grid; gap: 6px; justify-items: start; }
.note-box textarea { resize: vertical; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; width: 340px; }
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.crop-canvas { display: block; width: 280px; height: 280px; margin: 8px auto; border-radius: 8px; background: #000; cursor: grab; touch-action: none; }
.crop-canvas:active { cursor: grabbing; }
.crop-zoom { display: flex; align-items: center; gap: 10px; }
.crop-zoom input { flex: 1; }
.post-detail.inline { position: static; max-height: none; overflow: visible; }
.post-detail.inline .detail-head, .post-detail.inline #detail-post { display: none; }
.post .post-body.open, .post-time { cursor: pointer; }
.post-time { color: var(--muted); text-decoration: none; }
.post-time:hover { text-decoration: underline; }
.lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
.lightbox::backdrop { background: rgba(0,0,0,.85); }
.lightbox-inner { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.lightbox-inner img { max-width: calc(100vw - 140px); max-height: calc(100vh - 60px); object-fit: contain; border-radius: 4px; }
.lightbox-btn { position: absolute; background: rgba(0,0,0,.5); color: #fff; font-size: 26px; line-height: 1; padding: 10px 14px; border-radius: 999px; }
.lightbox-btn:hover { background: rgba(0,0,0,.75); filter: none; }
.lightbox-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 20px; top: 50%; transform: translateY(-50%); }
.lightbox-close { right: 20px; top: 20px; font-size: 20px; }
.lightbox-count { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); color: #ddd; font-size: 13px; }

.mention-box { position: fixed; z-index: 60; list-style: none; margin: 0; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.35); max-width: 320px; }
.mention-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.mention-item.on { background: var(--line); }
.mention-name { overflow: hidden; text-overflow: ellipsis; }
.mention-handle { color: var(--muted); font-size: 13px; }
.host-help summary { cursor: pointer; font-weight: 600; }
.host-help ol { margin: 8px 0; padding-left: 22px; line-height: 1.7; }
.host-help p { margin: 4px 0 0; }

/* ---------- Addon ---------- */
.addon-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.addon-toolbar .subtabs { margin: 0; }
.addon-toolbar select { width: auto; }
.addon-toolbar input[type=search] { width: 220px; }
.addon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.addon-card { display: block; text-align: left; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; color: inherit; }
.addon-card:hover { filter: none; border-color: var(--accent); }
.addon-card img, .addon-card .addon-noshot { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--line); }
.addon-noshot { display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--line); }
.addon-card-body { padding: 8px 10px 10px; display: grid; gap: 2px; }
.addon-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addon-page { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 16px; align-items: start; }
.addon-gallery { margin-bottom: 16px; }
.addon-shot-main { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; cursor: zoom-in; background: var(--line); }
.addon-thumbs { display: flex; gap: 6px; margin-top: 6px; }
.addon-thumbs img { width: 80px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; cursor: pointer; opacity: .6; border: 2px solid transparent; }
.addon-thumbs img.on { opacity: 1; border-color: var(--accent); }
.addon-info h2 { margin: 0 0 8px; overflow-wrap: anywhere; }
.addon-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 10px 0; }
.addon-actions { flex-wrap: wrap; align-items: center; }
.addon-status { margin-top: 10px; }
.addon-status progress { width: 100%; }
.addon-status.ok { border-left: 3px solid var(--accent); padding-left: 10px; }
.addon-status p { margin: 4px 0; }
.addon-form { display: grid; gap: 10px; }
.addon-form h2, .addon-form p { margin: 0; }
.addon-form .row { align-items: center; }
.addon-form label.button-like { display: inline-block; }
.addon-form > button { justify-self: start; }
#addon-detail .card h3 { margin-top: 0; }
.addon-form .row label { flex: 1; }
.post-addon { display: flex; gap: 10px; align-items: center; width: 100%; margin-top: 8px; padding: 8px; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: inherit; }
.post-addon:hover { filter: none; border-color: var(--accent); }
.post-addon img, .post-addon .addon-noshot { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; flex: none; }
.cmp-addon { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; position: relative; }
.cmp-addon .cmp-x { position: static; }
@media (max-width: 900px) { .addon-page { grid-template-columns: 1fr; } }

/* ---------- 主題（淺色）與設定頁 ---------- */
:root[data-theme="light"] { --bg: #f3f4f6; --panel: #ffffff; --line: #dde1e7; --text: #1d2025; --muted: #5f6773; --accent: #2f9150; --accent-hover: #37a65d; color-scheme: light; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) { --bg: #f3f4f6; --panel: #ffffff; --line: #dde1e7; --text: #1d2025; --muted: #5f6773; --accent: #2f9150; --accent-hover: #37a65d; color-scheme: light; }
}
.settings h2 { margin-top: 0; }
.settings > label { display: block; margin: 10px 0; }
.settings select { width: auto; margin-left: 8px; }
.seg { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.seg label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.seg input, .settings .check input { width: auto; }
input[type=radio], input[type=checkbox] { accent-color: var(--accent); }
.c-actions { display: flex; gap: 14px; align-items: center; margin-top: 4px; }
button.link.c-act { font-size: 12px; color: var(--muted); text-decoration: none; }
button.link.c-act:hover { color: var(--text); }
button.link.c-act.on { color: var(--danger); }
button.link.reply-toggle { color: var(--accent); }
ul.players.reply-list { margin: 6px 0 0 14px; padding-left: 14px; border-left: 2px solid var(--line); }
.players li.comment.reply { border-bottom: 0; padding: 6px 0; }
.reply-form { margin-left: 28px; }
.reply-form-btns { display: flex; flex-direction: column; gap: 4px; }
.edit-box { margin: 6px 0; }
.edit-box textarea { width: 100%; box-sizing: border-box; }
.edit-box .row { gap: 8px; margin-top: 4px; }
#group-create { margin-bottom: 8px; }
.group-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; flex: none; }
.group-invite { display: block !important; background: var(--line); border-radius: 6px; padding: 8px !important; margin-bottom: 6px; }
.group-invite .row { gap: 8px; margin-top: 6px; }
.msg-system { align-self: center; text-align: center; }
.msg-from { display: flex; align-items: center; gap: 4px; margin-bottom: 2px; color: var(--muted); }
.group-dialog { width: min(460px, 90vw); max-height: 80vh; overflow-y: auto; }
.group-dialog h3 { margin: 12px 0 4px; font-size: 14px; }
.group-dialog input { width: 100%; box-sizing: border-box; }
.group-dialog .row input { flex: 1; }
.person-checks { max-height: 240px; overflow-y: auto; }
.person-check { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
/* 首頁：每一類一橫列，左右捲動 */
.home-section { margin-bottom: 20px; }
.home-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.home-head h2 { margin: 0; font-size: 17px; }
.hrow { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; }
.hcard { flex: 0 0 210px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; position: relative; min-height: 120px; }
button.hcard { cursor: pointer; }
button.hcard:hover { border-color: var(--accent); }
.hcard-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hcard-foot { margin-top: auto; align-items: center; }
.hthumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--line); display: flex; align-items: center; justify-content: center; }
.hauthor { display: flex; align-items: center; gap: 6px; }
.hbody { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: pre-wrap; overflow-wrap: anywhere; }
.hbody.long { -webkit-line-clamp: 5; }
.hlabel { position: absolute; top: 6px; right: 6px; z-index: 1; font-size: 11px; padding: 1px 6px; border-radius: 8px; background: var(--accent); color: #fff; }
.hempty { margin: 8px 0; }
/* 登入方式的品牌圖示 */
.brand-icon { display: inline-flex; flex: none; vertical-align: middle; }
.brand-icon svg { width: 100%; height: 100%; }
button:has(> .brand-icon) { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.provider-btn { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; font-weight: 500; }
.provider-btn:hover { background: #f6f8fa; }
.rooms-top { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.myroom-panel { margin-bottom: 16px; }
/* 首頁公告 */
.announce { border: 1px solid var(--accent); border-left-width: 4px; border-radius: 8px; background: var(--panel); padding: 12px 14px; margin-bottom: 20px; }
.announce-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.announce-text { white-space: pre-wrap; overflow-wrap: anywhere; }
/* 好友清單：有沒有按鈕的列都一樣高 */
#friend-list li { min-height: 48px; box-sizing: border-box; }
/* 群組：頭貼、@ 標記 */
.group-icon { flex: none; }
.mention { color: var(--accent); font-weight: 500; }
.msg.mine .mention { color: #fff; text-decoration: underline; }
.msg.at-me .msg-body { box-shadow: 0 0 0 2px var(--accent); }
.mention-flag { color: var(--danger); font-weight: 600; }
.group-avatar-row { align-items: center; gap: 10px; margin-bottom: 8px; }
/* 沒有縮圖的卡片：標籤放在第一行右邊，不蓋住文字 */
.hlabel.inline { position: static; align-self: flex-end; margin-bottom: -2px; }
/* 對話列表：名字和 ID 同一行，太長就用「…」 */
.conv-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 訊息之間多留一點空間，時間跟泡泡分開 */
.thread-msgs { gap: 16px; }
.msg-time { margin-top: 4px; font-size: 11px; }
/* 個人頁：暱稱、ID，右邊是 Xbox 框 */
.profile-names h2 { line-height: 1.25; }
.profile-handle { font-size: 17px; margin-top: 2px; }
.xbox-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); white-space: nowrap; }
.xbox-chip .brand-icon { color: #107c10; }
.xbox-name { font-weight: 500; }

/* ---------- 共用畫面的外框（ui/shell.js） ---------- */
#topbar { position: sticky; top: 0; z-index: 30; }
#topbar .brand { color: var(--text); text-decoration: none; }
#tabs { display: flex; align-items: stretch; height: 100%; }
.tab { display: flex; align-items: center; gap: 4px; color: var(--text); }
.tab-icon { display: none; }
#top-right { display: flex; align-items: center; gap: 10px; }
.me-name { color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#top-right .menu { right: 0; left: auto; }
.login-menu { min-width: 260px; padding: 10px; }
.login-menu .provider-buttons { margin: 0; }
.provider-buttons { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.provider-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; }
.need-login { text-align: center; max-width: 420px; margin: 40px auto; }

/* 連結做成按鈕的樣子 */
a.btn, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--line); color: var(--text); border: 0; border-radius: 6px;
  padding: 7px 14px; font: inherit; cursor: pointer; text-decoration: none; }
a.btn.primary, .btn.primary { background: var(--accent); color: #fff; }
.btn.small, button.small { padding: 4px 10px; font-size: 13px; }
a { color: var(--accent); }
a.person { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.person-name { font-weight: 500; }

/* 對話框 */
.dialog { width: min(460px, 92vw); max-height: 85vh; overflow-y: auto; }
.dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

#foot { max-width: 1100px; margin: 24px auto; padding: 0 16px 24px; }
.footer-links { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.footer-links a { color: var(--muted); }

/* 窄螢幕（手機）：分頁移到底部，只顯示圖示和短標籤 */
@media (max-width: 700px) {
  #topbar { height: 48px; padding: 0 12px; }
  #tabs { position: fixed; left: 0; right: 0; bottom: 0; height: 56px; background: var(--panel); border-top: 1px solid var(--line); z-index: 40;
    justify-content: space-around; padding-bottom: env(safe-area-inset-bottom); }
  .tab { flex-direction: column; justify-content: center; gap: 2px; padding: 4px 2px; flex: 1; border-bottom: 0; border-top: 2px solid transparent; font-size: 11px; position: relative; }
  .tab.active { border-top-color: var(--accent); border-bottom: 0; }
  .tab-icon { display: block; font-size: 18px; line-height: 1; }
  .tab .count-badge { position: absolute; top: 2px; right: 18%; }
  main { padding: 12px 12px 76px; }
  .me-name { display: none; }
  #foot { padding-bottom: 76px; }
}

/* 整張卡片是連結：不要底線、維持一般文字顏色 */
a.hcard, a.hcard:hover { text-decoration: none; color: var(--text); }
a.hcard .muted { color: var(--muted); }
a.hcard-title { color: var(--text); text-decoration: none; }

/* 單一房間頁（/r/:id） */
.room-card { display: flex; gap: 16px; align-items: center; }
.room-main { flex: 1; min-width: 0; }
.room-main h2 { margin: 0 0 6px; }
.room-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.room-side .count { font-size: 18px; font-weight: 600; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.hint { margin: 8px 0; }
a.room-name { color: var(--text); text-decoration: none; }
a.room-name:hover { text-decoration: underline; }
.rooms td a { color: var(--text); }
@media (max-width: 700px) {
  .rooms .col-world, .rooms .col-version, .rooms .col-host, .rooms td.col-world, .rooms td.col-version { display: none; }
  .toolbar { flex-wrap: wrap; }
  .room-card { flex-direction: column; align-items: stretch; }
  .room-side { align-items: stretch; }
}

/* 單篇貼文頁的留言 */
.comments h2 { margin-top: 0; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comment-body { margin: 4px 0 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.players li.comment { display: block; }
.yt-box { margin-top: 8px; }
.yt-frame { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; }
.post-time { text-decoration: none; }
.post-time:hover { text-decoration: underline; }
.notify { cursor: pointer; }
.need-login .provider-buttons { align-items: center; }

/* 留言底下的小按鈕（愛心、回覆、查看回覆）：文字連結的樣子 */
button.c-act { background: none; padding: 0; color: var(--muted); font-size: 12px; }
button.c-act:hover { color: var(--text); filter: none; }
button.c-act.on { color: var(--danger); }
button.reply-toggle { color: var(--accent); }

/* 作品頁：網站上的安裝說明；卡片是連結 */
.addon-hint { margin-top: 10px; }
.addon-hint p { margin: 4px 0; }
a.addon-card, a.addon-card:hover { text-decoration: none; color: var(--text); }
a.addon-card .muted { color: var(--muted); }

/* 好友清單：有沒有按鈕的列都一樣高 */
.friend-list li { min-height: 48px; box-sizing: border-box; }

/* 訊息：窄螢幕時列表和對話一次只顯示一個 */
.group-create { width: 100%; margin-bottom: 8px; }
.dm-back { display: none; }
.dm .thread-head { flex-wrap: wrap; }
@media (max-width: 700px) {
  .dm { grid-template-columns: 1fr; height: calc(100vh - 150px); }
  .dm .dm-thread { display: none; }
  .dm.thread-open .dm-list { display: none; }
  .dm.thread-open .dm-thread { display: flex; }
  .dm-back { display: inline-block; }
}

.with-icon { display: inline-flex; align-items: center; gap: 8px; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
.danger-zone h3 { color: var(--danger); margin: 0 0 6px; }
#bars .notice { max-width: 1100px; margin: 10px auto 0; }

/* 下載頁 */
.download-big { display: inline-block; font-size: 18px; padding: 14px 26px; margin: 8px 0; }
.download-page h3 { margin: 18px 0 6px; font-size: 16px; }

/* 底部分頁列：標籤固定一行（日文、英文比較長） */
@media (max-width: 700px) {
  .tab-label { white-space: nowrap; font-size: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
}

/* 分頁標籤不換行；寬度不夠時上方分頁列可以左右捲動 */
.tab { white-space: nowrap; }
@media (min-width: 701px) { #tabs { overflow-x: auto; scrollbar-width: none; min-width: 0; flex-shrink: 1; } }

/* 手機：用 dvh（網址列展開時的實際可見高度），並扣掉底部分頁列與 iPhone 的安全區域 */
@media (max-width: 700px) {
  main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  #foot { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .dm { height: calc(100vh - 48px - 56px - 32px - env(safe-area-inset-bottom)); height: calc(100dvh - 48px - 56px - 32px - env(safe-area-inset-bottom)); }
}
