:root {
  --bg: #f3f2ef;
  --card: #ffffff;
  --line: #e0dfdc;
  --text: #1d1d1f;
  --muted: #666;
  --blue: #1a5fd0;
  --blue-soft: #e8f0fd;
  --radius: 10px;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
button { font: inherit; cursor: pointer; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* Noto emoji images (app.js swaps emoji characters for these) */
img.emoji { height: 1.2em; width: 1.2em; vertical-align: -0.25em; margin: 0 0.05em; display: inline-block; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1128px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 6px 16px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 34px; height: 34px; display: block; }
.brand-name { font-weight: 700; font-size: 18px; }
.search { background: #eef3f8; border-radius: 6px; padding: 7px 12px; color: var(--muted); width: 260px; }
.nav { margin-left: auto; display: flex; gap: 20px; }
.nav-item { position: relative; display: flex; flex-direction: column; align-items: center; color: var(--muted); padding-bottom: 2px; }
.nav-ico { font-size: 20px; line-height: 1; height: 24px; display: flex; align-items: center; }
.nav-ico img.emoji { height: 22px; width: 22px; vertical-align: 0; margin: 0; }
.nav-item small { font-size: 11px; }
.nav-item.active { color: var(--text); border-bottom: 2px solid var(--text); }
.badge { position: absolute; top: -4px; right: -10px; background: #cc1016; color: #fff; font-size: 10px; border-radius: 8px; padding: 0 4px; }

/* layout */
.layout { max-width: 1128px; margin: 20px auto; padding: 0 16px; display: grid; grid-template-columns: 225px minmax(0, 555px) 300px; gap: 24px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.left, .right { position: sticky; top: 72px; }

.profile { text-align: center; overflow: hidden; padding-bottom: 12px; }
.profile-banner { height: 56px; background: linear-gradient(120deg, #f5c27a, #e98aa8); }
.profile .avatar.big { width: 68px; height: 68px; font-size: 26px; margin: -34px auto 8px; border: 2px solid #fff; }
.profile-name { font-weight: 600; font-size: 16px; }
.profile-title { color: var(--muted); font-size: 12px; margin: 4px 12px 12px; }
.profile-stat { display: flex; justify-content: space-between; padding: 4px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.profile-stat b { color: var(--blue); }
.link-btn { background: none; border: none; color: var(--blue); font-size: 12px; margin-top: 6px; }

.right .card { padding: 12px 16px; }
.right h3 { margin: 0 0 8px; font-size: 15px; }
.trending { list-style: none; margin: 0; padding: 0; }
.trending li { padding: 6px 0; }
.trending .tag { color: var(--blue); font-weight: 600; }
.trending .n { color: var(--muted); font-size: 12px; display: block; }
.small-print { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* composer, back bar, more link */
.composer { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.composer-fake { flex: 1; border: 1px solid #bbb; border-radius: 30px; padding: 12px 16px; color: var(--muted); }
.back-bar, .more-link { display: block; padding: 12px 16px; font-weight: 600; color: var(--blue); }
.back-bar:hover, .more-link:hover { background: var(--blue-soft); }
.more-link { text-align: center; }
.status-line { color: var(--muted); font-size: 12px; text-align: center; margin: 4px 0 10px; min-height: 14px; }
.new-posts { display: block; margin: 0 auto 10px; background: var(--blue); color: #fff; border: none; border-radius: 20px; padding: 6px 16px; box-shadow: 0 2px 6px rgba(0,0,0,.2); position: sticky; top: 70px; z-index: 5; }

/* avatars */
.avatar { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; flex: none; background: #888; font-size: 17px; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }

/* posts */
.post { padding: 12px 0 0; }
.post.highlight { box-shadow: 0 0 0 2px var(--blue); }
.post-head { display: flex; gap: 8px; padding: 0 16px; align-items: flex-start; }
.who { flex: 1; min-width: 0; }
.name { font-weight: 600; display: inline-block; }
a.name:hover { color: var(--blue); text-decoration: underline; }
.title, .meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
a.meta:hover { text-decoration: underline; }
.follow { background: none; border: none; color: var(--blue); font-weight: 600; padding: 4px 8px; border-radius: 4px; }
.follow:hover { background: var(--blue-soft); }
.follow.on { color: var(--muted); }
.body { padding: 10px 16px 0; white-space: pre-wrap; line-height: 1.45; overflow-wrap: anywhere; }
.body.collapsed { max-height: calc(7.25em + 10px); overflow: hidden; }
.see-more { background: none; border: none; color: var(--muted); display: block; margin: 0 16px 0 auto; padding: 0; }
.see-more:hover { color: var(--blue); text-decoration: underline; }
.hashtag, .mention { color: var(--blue); font-weight: 600; }

/* post image: fixed aspect box + shimmer while loading, click to open lightbox */
.image-wrap { position: relative; display: block; width: 100%; margin: 10px 0 0; padding: 0; border: none; cursor: zoom-in;
  background: linear-gradient(100deg, #ececec 30%, #f7f7f7 50%, #ececec 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
.image-wrap.loaded { animation: none; background: #111; }
.image-wrap > img { width: 100%; height: auto; display: block; opacity: 0; transition: opacity .3s; }
.image-wrap.loaded > img { opacity: 1; }
.zoom-hint { display: flex; align-items: center; gap: 4px; position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 14px; opacity: 0; transition: opacity .2s; }
.image-wrap:hover .zoom-hint, .image-wrap:focus-visible .zoom-hint { opacity: 1; }
@keyframes shimmer { to { background-position: -300% 0; } }
.image-pending { margin: 10px 16px 0; padding: 30px; text-align: center; color: var(--muted); background: repeating-linear-gradient(45deg, #fafafa, #fafafa 10px, #f0f0f0 10px, #f0f0f0 20px); border-radius: 6px; }

.counts { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; color: var(--muted); font-size: 12px; }
.reactions { display: flex; align-items: center; }
.rx img.emoji { width: 16px; height: 16px; margin: 0 -3px 0 0; vertical-align: middle; }
.like-count { margin-left: 8px; }
.comment-count { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }
.comment-count:hover { color: var(--blue); text-decoration: underline; }
.actions { display: flex; border-top: 1px solid var(--line); margin: 0 12px; padding: 2px 0; }
.act { flex: 1; background: none; border: none; color: var(--muted); font-weight: 600; padding: 10px 4px; border-radius: 4px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.act-ico img.emoji { width: 18px; height: 18px; margin: 0; vertical-align: middle; }
.act:hover { background: #f2f2f2; }
.act.like.on { color: var(--blue); }
.act.like.on .act-ico { animation: pop .3s ease; }
@keyframes pop { 50% { transform: scale(1.35); } }

/* comments */
.comments { padding: 8px 16px 12px; }
.comment-form { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.comment-input { flex: 1; min-width: 0; border: 1px solid #bbb; border-radius: 20px; padding: 8px 14px; font: inherit; }
.post-btn { background: var(--blue); color: #fff; border: none; border-radius: 16px; padding: 6px 14px; font-weight: 600; }
.comment { display: flex; gap: 8px; margin-bottom: 8px; }
.bubble { background: #f2f2f2; border-radius: 0 8px 8px 8px; padding: 8px 12px; flex: 1; min-width: 0; }
.bubble .cname { font-weight: 600; font-size: 13px; }
.bubble .ctitle { color: var(--muted); font-size: 11px; }
.bubble .ctext { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }

.loading { text-align: center; color: var(--muted); padding: 20px; }
.missing { padding: 40px 20px; text-align: center; }
.missing h2 { margin: 0 0 8px; }
.missing p { color: var(--muted); margin: 0 0 16px; }
.missing a { color: var(--blue); font-weight: 600; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(10,10,12,.88); display: flex; align-items: center; justify-content: center; padding: 24px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.lb-figure { margin: 0; max-width: min(92vw, 900px); display: flex; flex-direction: column; align-items: center; }
.lb-figure img { max-width: 100%; max-height: calc(100vh - 140px); border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); background: #222; }
.lb-figure figcaption { color: #ddd; margin-top: 12px; font-size: 13px; text-align: center; display: flex; flex-direction: column; gap: 8px; }
.lb-caption { font-style: italic; }
.lb-actions { display: flex; gap: 16px; justify-content: center; }
.lb-actions a { color: #9cc3ff; font-weight: 600; cursor: pointer; }
.lb-actions a:hover { text-decoration: underline; }
.lb-close { position: absolute; top: 14px; right: 18px; background: rgba(255,255,255,.12); color: #fff; border: none; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; }
.lb-close:hover { background: rgba(255,255,255,.25); }
body.no-scroll { overflow: hidden; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 18px; border-radius: 6px; z-index: 150; box-shadow: 0 4px 12px rgba(0,0,0,.3); max-width: 90vw; overflow-wrap: anywhere; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr) 280px; }
  .left { display: none; }
}
@media (max-width: 720px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 6px; margin-top: 8px; }
  .right { display: none; }
  .search { display: none; }
  .nav { gap: 14px; }
  .nav-item small { display: none; }
  .act-label { display: none; }
  .zoom-hint { opacity: 1; }
}
