:root {
  color-scheme: light;
  --blue: #2563eb;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --blue-soft: #e7f3ff;
  --focus-ring: #cfe4ff;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #101828;
  --muted: #65676b;
  --muted-2: #8a8d91;
  --line: #e4e6eb;
  --line-strong: #ced0d4;
  --hover: #f2f2f2;
  --media-bg: #eef0f2;
  --tile-bg: #e4e6eb;
  --drop-bg: #f5f9ff;
  --drop-border: #b9d4f8;
  --drop-hover: #eaf3ff;
  --status-bg: #e7f0ff;
  --status-text: #124a9c;
  --status-error-bg: #fdeaea;
  --status-error-text: #a8142f;
  --danger: #e41e3f;
  --ok: #31a24c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .1);
  --radius: 8px;
  --topbar: 56px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --blue: #7db3ff;
  --blue-soft: #1b3352;
  --focus-ring: rgba(125, 179, 255, .35);
  --bg: #0f1115;
  --card: #191c22;
  --text: #e7eaf0;
  --muted: #a7aebb;
  --muted-2: #7f8795;
  --line: #2a3039;
  --line-strong: #404856;
  --hover: #252b34;
  --media-bg: #0b0d11;
  --tile-bg: #242a33;
  --drop-bg: #141b28;
  --drop-border: #33517a;
  --drop-hover: #1a2a44;
  --status-bg: #16243a;
  --status-text: #cfe4ff;
  --status-error-bg: #3a1a21;
  --status-error-text: #ffb3c0;
  --danger: #ff6b81;
  --ok: #4ade80;
  --shadow: 0 1px 3px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, video { max-width: 100%; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, .55); outline-offset: 2px; }

.icon { display: inline-flex; flex: 0 0 auto; }
.icon svg { width: 100%; height: 100%; display: block; }

/* ---------------- upload ---------------- */
.upload-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(900px 420px at 15% 0%, #dcebff 0%, transparent 70%),
    radial-gradient(700px 380px at 100% 20%, #e7e0ff 0%, transparent 70%),
    var(--bg);
}
.upload-card {
  width: min(500px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 34px 34px 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .06);
}
.upload-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  line-height: 1;
}
.upload-brand .logo-mark { width: 40px; height: 40px; border-radius: 11px; }
.upload-brand .logo-mark svg { width: 23px; height: 23px; }
.upload-brand .brand-name { font-size: 28px; font-weight: 800; letter-spacing: -1.4px; }
.upload-brand .brand-tag {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
  align-self: flex-end;
  padding-bottom: 4px;
}
.upload-card h1 {
  margin: 20px 0 8px;
  font-size: 25px;
  letter-spacing: -.4px;
}
.upload-lede { margin: 0 0 22px; color: var(--muted); font-size: 15px; }
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 2px dashed var(--drop-border);
  border-radius: 14px;
  background: var(--drop-bg);
  padding: 30px 18px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
  text-align: center;
}
.drop-zone:hover, .drop-zone.dragging { border-color: var(--blue); background: var(--drop-hover); }
.drop-zone.dragging { transform: scale(1.01); }
.drop-icon { width: 42px; height: 42px; color: var(--blue); margin-bottom: 6px; }
.drop-zone strong { font-size: 16px; color: var(--blue); }
.drop-sub { color: var(--muted); font-size: 13px; }
.load-status {
  margin-top: 16px;
  background: var(--status-bg);
  color: var(--status-text);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.load-status.error { background: var(--status-error-bg); color: var(--status-error-text); }
.load-status .spinner {
  width: 15px; height: 15px; flex: 0 0 auto;
  border: 2px solid rgba(37, 99, 235, .25);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.privacy {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}
.privacy svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; }
.upload-hint { margin: 12px 0 0; font-size: 11.5px; color: var(--muted-2); line-height: 1.5; }

/* ---------------- chrome ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.topbar-inner {
  max-width: 1600px;
  height: 100%;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  line-height: 1;
  flex: 0 0 auto;
  margin-right: 2px;
}
.logo-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  flex: 0 0 auto;
}
.logo-mark svg { width: 19px; height: 19px; display: block; }
.logo-text { font-size: 23px; font-weight: 800; letter-spacing: -1.1px; }
.search {
  position: relative;
  display: flex;
  align-items: center;
  width: 240px;
  flex: 0 1 auto;
  transition: width .18s ease;
}
.search-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 20px;
  background: var(--bg);
  padding: 0 14px 0 38px;
  font-size: 14px;
  outline: none;
}
.search input:focus { background: var(--blue-soft); box-shadow: 0 0 0 2px var(--focus-ring) inset; }
.topnav { display: flex; align-items: center; gap: 2px; margin: 0 auto; height: 100%; }
.topnav-link {
  position: relative;
  width: clamp(56px, 7vw, 104px);
  height: 48px;
  margin-top: 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background .12s, color .12s;
}
.topnav-link .icon { width: 27px; height: 27px; }
.topnav-link:hover { background: var(--hover); }
.topnav-link.active { color: var(--blue); }
.topnav-link.active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -4px;
  height: 3px;
  background: var(--blue);
  border-radius: 3px 3px 0 0;
}
.topbar-user { display: flex; align-items: center; flex: 0 0 auto; }
.profile-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: var(--bg);
  border-radius: 22px;
  padding: 4px 12px 4px 4px;
  transition: background .12s;
}
.profile-chip:hover { background: var(--hover); }
.profile-chip-name {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 14px;
}

.layout {
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 280px minmax(0, 680px) 300px;
  gap: 20px;
  justify-content: center;
  align-items: start;
}
.sidebar { position: sticky; top: calc(var(--topbar) + 16px); max-height: calc(100vh - var(--topbar) - 32px); overflow-y: auto; scrollbar-width: none; }
.sidebar::-webkit-scrollbar { display: none; }
.rail { position: sticky; top: calc(var(--topbar) + 16px); max-height: calc(100vh - var(--topbar) - 32px); overflow-y: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.main { min-width: 0; }

/* ---------------- display tools ---------------- */
.topbar-tools { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  border: 0;
  border-radius: 18px;
  background: var(--bg);
  color: var(--muted);
  transition: background .12s, color .12s;
}
.tool-btn:hover { background: var(--hover); color: var(--text); }
.tool-btn .icon { width: 18px; height: 18px; }
.tool-btn .tool-label { font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.boot-tools {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.boot-tools .tool-btn { background: transparent; }
.boot-tools .tool-btn:hover { background: var(--hover); }

/* ---------------- avatars ---------------- */
.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  letter-spacing: -.2px;
  overflow: hidden;
  flex: 0 0 auto;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------------- sidebar ---------------- */
.side-profile {
  display: block;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 14px;
  padding-bottom: 12px;
  text-align: center;
}
.side-cover { height: 86px; background: linear-gradient(135deg, #8ab9ff, #2563eb); overflow: hidden; }
.side-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.side-avatar { margin-top: -32px; border: 3px solid var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.side-profile-name { font-weight: 700; font-size: 16px; margin-top: 6px; padding: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-profile-bio { font-size: 12.5px; color: var(--muted); padding: 0 16px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  transition: background .12s;
}
.side-link:hover { background: var(--hover); }
.side-link.active { background: var(--blue-soft); color: var(--blue); }
.side-link .icon { color: var(--blue); width: 28px; height: 28px; }
.side-link .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}
.side-divider { height: 1px; background: var(--line); margin: 10px 4px; }
.side-section { margin: 10px 0 4px; }
.side-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 10px;
}
.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
}
.side-item:hover { background: var(--hover); }
.side-item .icon { width: 22px; height: 22px; color: var(--muted); }
.side-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-reload {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
  border-radius: 8px;
  margin-top: 4px;
}
.side-reload:hover { background: var(--hover); }
.side-privacy { font-size: 11.5px; color: var(--muted-2); padding: 2px 10px 10px; margin: 0; line-height: 1.5; }

/* ---------------- rail ---------------- */
.rail-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; margin-bottom: 16px; }
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 8px; }
.rail-head h2 { font-size: 16px; margin: 0; letter-spacing: -.2px; }
.rail-link { color: var(--blue); font-size: 13px; font-weight: 600; }
.rail-link:hover { text-decoration: underline; }
.contact {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 7px 6px;
  border-radius: 8px;
  text-align: left;
}
.contact:hover { background: var(--hover); }
.contact-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); margin-left: auto; flex: 0 0 auto; }
.online-dot.on { background: var(--ok); }
.rail-empty { color: var(--muted); font-size: 13px; padding: 6px; }
.stat-row { display: flex; justify-content: space-between; padding: 7px 6px; border-radius: 8px; font-size: 13.5px; color: var(--text); }
.stat-row:hover { background: var(--hover); }
.stat-row b { color: var(--muted); font-weight: 600; }

/* ---------------- shared ---------------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 2px 2px 12px; }
.section-head h1 { font-size: 24px; margin: 0; letter-spacing: -.5px; }
.section-head p { color: var(--muted); font-size: 13px; margin: 0; }
.empty {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}
.empty .icon { width: 44px; height: 44px; color: var(--muted-2); margin-bottom: 10px; }
.empty h3 { margin: 0 0 4px; color: var(--text); font-size: 17px; }
.empty p { margin: 0; font-size: 13.5px; }
.muted { color: var(--muted); }
.inline-search {
  width: 100%;
  height: 38px;
  border: 0;
  background: var(--bg);
  border-radius: 19px;
  padding: 0 14px;
  outline: none;
  margin-bottom: 14px;
}
.inline-search:focus { background: var(--blue-soft); box-shadow: 0 0 0 2px var(--focus-ring) inset; }

/* ---------------- composer ---------------- */
.composer { padding: 12px 16px 10px; }
.composer-top { display: flex; gap: 10px; align-items: center; }
.composer-input {
  flex: 1;
  min-height: 40px;
  max-height: 180px;
  resize: none;
  border: 0;
  background: var(--bg);
  border-radius: 20px;
  padding: 10px 14px;
  outline: none;
  line-height: 1.4;
}
.composer-input:focus { background: var(--bg); box-shadow: 0 0 0 2px var(--focus-ring) inset; }
.composer-bottom { display: flex; justify-content: flex-end; margin-top: 8px; }
.btn {
  border: 0;
  background: var(--bg);
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg); }

/* ---------------- post ---------------- */
.post { padding: 14px 16px 0; }
.post-head { display: flex; align-items: center; gap: 10px; }
.post-author { font-weight: 600; font-size: 14.5px; line-height: 1.2; }
.post-meta { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.post-meta .icon { width: 12px; height: 12px; }
.post-text { margin-top: 10px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.48; }
.post-text.clamped { max-height: 216px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 80%, transparent); mask-image: linear-gradient(#000 80%, transparent); }
.see-more { border: 0; background: none; padding: 2px 0; color: var(--muted); font-weight: 600; font-size: 14px; }
.see-more:hover { text-decoration: underline; }

.post-media { display: grid; gap: 2px; margin: 12px -16px 0; background: var(--media-bg); }
.post-media.count-1 { display: block; }
.post-media.count-2, .post-media.count-3, .post-media.count-4 { grid-template-columns: 1fr 1fr; }
.post-media.count-3 .media-cell:first-child { grid-column: span 2; }
.media-cell {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: var(--tile-bg);
  overflow: hidden;
  min-height: 0;
}
.media-cell img, .media-cell video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.post-media.count-1 .media-cell { max-height: 600px; background: #0c0d0e; }
.post-media.count-1 .media-cell img, .post-media.count-1 .media-cell video { object-fit: contain; max-height: 600px; }
.post-media.count-2 .media-cell, .post-media.count-3 .media-cell, .post-media.count-4 .media-cell { height: 250px; }
.media-more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font-size: 30px;
  font-weight: 300;
}
.media-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
}
.media-play .icon { width: 46px; height: 46px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.media-missing { display: flex; align-items: center; justify-content: center; height: 160px; color: var(--muted); font-size: 13px; }

.post-stats { display: flex; align-items: center; gap: 8px; padding: 9px 2px 7px; color: var(--muted); font-size: 13px; min-height: 34px; }
.reaction-pill { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 11px; }
.post-stats .right { margin-left: auto; }
.post-actions { display: flex; border-top: 1px solid var(--line); margin: 0 -2px; }
.action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 4px;
  border-radius: 6px;
  margin: 2px;
}
.action:hover { background: var(--hover); }
.action .icon { width: 19px; height: 19px; }
.action.liked { color: var(--blue); }
.action.liked .icon { color: var(--blue); }
.comments { border-top: 1px solid var(--line); padding: 10px 2px 12px; margin-top: 2px; }
.comment { display: flex; gap: 8px; margin-bottom: 8px; }
.comment-bubble { background: var(--bg); border-radius: 14px; padding: 7px 11px; max-width: calc(100% - 42px); }
.comment-author { font-weight: 600; font-size: 12.5px; }
.comment-text { font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-time { font-size: 11px; color: var(--muted); margin: 2px 0 0 11px; }
.comment-form { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.comment-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: var(--bg);
  height: 34px;
  border-radius: 17px;
  padding: 0 12px;
  outline: none;
  font-size: 13.5px;
}
.comment-input:focus { box-shadow: 0 0 0 2px var(--focus-ring) inset; }
.send-mini {
  border: 0;
  background: transparent;
  color: var(--blue);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.send-mini:hover { background: var(--blue-soft); }
.send-mini .icon { width: 20px; height: 20px; }

/* ---------------- messages ---------------- */
.messages-view {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  height: calc(100vh - var(--topbar) - 32px);
  min-height: 480px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.thread-list { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; }
.thread-list-head { padding: 14px 14px 8px; display: flex; align-items: baseline; justify-content: space-between; }
.thread-list-head h1 { font-size: 22px; margin: 0; letter-spacing: -.4px; }
.thread-list-head span { color: var(--muted); font-size: 12.5px; }
.thread-search { margin: 0 12px 8px; }
.thread-scroll { overflow-y: auto; padding: 0 6px 10px; min-height: 0; }
.thread-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: 9px;
  text-align: left;
}
.thread-row:hover { background: var(--hover); }
.thread-row.active { background: var(--blue-soft); }
.thread-main { min-width: 0; flex: 1; }
.thread-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-preview { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.thread-preview.unread { color: var(--text); font-weight: 600; }
.thread-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; }
.thread-time { font-size: 11.5px; color: var(--muted); }
.thread-archived { font-size: 10px; color: var(--muted); border: 1px solid var(--line-strong); padding: 1px 4px; border-radius: 4px; }
.conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--card); }
.conv-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 60px; }
.conv-title { font-weight: 700; font-size: 15px; }
.conv-sub { font-size: 11.5px; color: var(--muted); }
.conv-body { flex: 1; overflow-y: auto; padding: 14px 16px 6px; background: var(--card); }
.conv-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 30px; }
.conv-empty .icon { width: 54px; height: 54px; color: var(--muted-2); margin-bottom: 10px; }
.day-divider { text-align: center; margin: 16px 0 12px; }
.day-divider span { background: var(--bg); color: var(--muted); font-size: 11.5px; padding: 4px 10px; border-radius: 10px; }
.msg-row { display: flex; gap: 7px; align-items: flex-end; margin-bottom: 5px; }
.msg-row.own { justify-content: flex-end; }
.msg-group { max-width: 72%; display: flex; flex-direction: column; }
.msg-row.own .msg-group { align-items: flex-end; }
.msg-sender { font-size: 11.5px; color: var(--muted); margin: 0 0 2px 8px; }
.bubble {
  background: var(--bg);
  border-radius: 16px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-row.own .bubble { background: var(--brand); color: #fff; }
.msg-time { font-size: 10.5px; color: var(--muted); margin: 3px 8px 0; }
.bubble a { text-decoration: underline; }
.share-card {
  display: block;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
  color: var(--text);
}
.share-card-body { padding: 9px 11px; }
.share-card-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 3px; }
.share-card-text { font-size: 12.5px; line-height: 1.4; max-height: 5.6em; overflow: hidden; white-space: pre-wrap; }
.msg-media { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.msg-media img, .msg-media video { border-radius: 10px; max-width: 260px; max-height: 260px; object-fit: cover; }
.conv-composer { border-top: 1px solid var(--line); padding: 10px 14px; display: flex; gap: 8px; align-items: flex-end; }
.conv-input {
  flex: 1;
  min-height: 38px;
  max-height: 140px;
  resize: none;
  border: 0;
  background: var(--bg);
  border-radius: 19px;
  padding: 9px 14px;
  outline: none;
  font-size: 14px;
}
.conv-input:focus { box-shadow: 0 0 0 2px var(--focus-ring) inset; }
.send-btn { width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: var(--blue); display: grid; place-items: center; }
.send-btn:hover { background: var(--blue-soft); }
.send-btn .icon { width: 21px; height: 21px; }
.back-btn { display: none; border: 0; background: transparent; width: 34px; height: 34px; border-radius: 50%; place-items: center; }
.back-btn:hover { background: var(--bg); }
.back-btn .icon { width: 22px; height: 22px; }

/* ---------------- photos ---------------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 0;
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 7px 13px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
}
.chip:hover { background: var(--hover); }
.chip.active { background: var(--brand); color: #fff; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-tile {
  position: relative;
  border: 0;
  padding: 0;
  background: var(--tile-bg);
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .media-play .icon { width: 38px; height: 38px; }
.photo-meta { color: var(--muted); font-size: 12.5px; margin: 0 2px 10px; }

/* ---------------- about ---------------- */
.profile-hero { overflow: hidden; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); margin-bottom: 16px; }
.hero-cover { height: 210px; background: linear-gradient(135deg, #79a9f5, #2563eb); }
.hero-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-bottom { padding: 0 22px 18px; }
.hero-avatar { margin-top: -58px; border: 4px solid var(--card); box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.hero-name { font-size: 27px; font-weight: 700; letter-spacing: -.5px; margin: 8px 0 0; }
.hero-bio { color: var(--muted); margin: 2px 0 0; font-size: 14.5px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.detail-card { padding: 18px 20px; }
.detail-card h2 { font-size: 17px; margin: 0 0 12px; }
.detail-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; }
.detail-row .icon { width: 18px; height: 18px; color: var(--muted); }
.detail-row a { color: var(--blue); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat-box { background: var(--bg); border-radius: 8px; padding: 12px; text-align: center; }
.stat-box b { display: block; font-size: 19px; }
.stat-box span { color: var(--muted); font-size: 11.5px; }
.mini-list { display: flex; flex-direction: column; gap: 2px; }
.mini-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 7px; font-size: 14px; }
.mini-item:hover { background: var(--hover); }
.mini-item .icon { width: 20px; height: 20px; color: var(--muted); }
.mini-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-item time { color: var(--muted); font-size: 11.5px; flex: 0 0 auto; }

/* ---------------- activity ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 10px; margin-bottom: 8px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 11px 10px; font-weight: 600; font-size: 13.5px; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { background: var(--hover); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.activity-list { padding: 2px 8px 10px; }
.activity-item { display: flex; gap: 11px; padding: 11px 8px; border-radius: 8px; }
.activity-item:hover { background: var(--hover); }
.activity-icon { width: 34px; height: 34px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; flex: 0 0 auto; color: var(--muted); }
.activity-icon .icon { width: 18px; height: 18px; }
.activity-main { min-width: 0; }
.activity-title { font-size: 13.5px; color: var(--muted); }
.activity-text { font-size: 14px; overflow-wrap: anywhere; }
.activity-text a { color: var(--blue); text-decoration: underline; }
.activity-date { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* ---------------- overlay / lightbox / modal ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade .12s ease;
}
@keyframes fade { from { opacity: 0; } }
body.no-scroll { overflow: hidden; }
.lightbox { position: relative; width: min(1100px, 100%); height: min(90vh, 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lightbox-stage { max-width: 100%; max-height: calc(100% - 76px); display: flex; align-items: center; justify-content: center; }
.lightbox-stage img, .lightbox-stage video { max-width: 100%; max-height: calc(90vh - 96px); border-radius: 4px; object-fit: contain; background: #000; }
.lightbox-meta { color: #fff; text-align: center; margin-top: 12px; font-size: 13px; opacity: .9; }
.lightbox-close {
  position: absolute;
  top: -4px; right: 0;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  display: grid; place-items: center;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .28); }
.lightbox-close .icon { width: 22px; height: 22px; }
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  display: grid; place-items: center;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, .3); }
.lightbox-nav.prev { left: -6px; }
.lightbox-nav.next { right: -6px; }
.lightbox-nav .icon { width: 24px; height: 24px; }
.modal {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 16px 50px rgba(0,0,0,.3);
  overflow: hidden;
}
.modal-cover { height: 110px; background: linear-gradient(135deg, #8ab9ff, #2563eb); }
.modal-body { padding: 0 22px 20px; text-align: center; }
.modal-avatar { margin-top: -46px; border: 4px solid var(--card); }
.modal-name { font-size: 21px; font-weight: 700; margin: 8px 0 2px; }
.modal-sub { color: var(--muted); font-size: 13px; }
.modal-actions { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #1c1e21;
  color: #fff;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13.5px;
  z-index: 200;
  box-shadow: 0 4px 18px rgba(0,0,0,.25);
  max-width: calc(100vw - 40px);
}

/* ---------------- mobile nav ---------------- */
.mobile-nav { display: none; }

/* ---------------- responsive ---------------- */
@media (max-width: 1280px) {
  .layout { grid-template-columns: 280px minmax(0, 680px); }
  .rail { display: none; }
}
@media (max-width: 1100px) {
  .profile-chip-name { display: none; }
  .topbar-user .profile-chip { padding: 4px; }
  .search { width: 200px; }
}
@media (max-width: 1020px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); gap: 16px; }
  .side-profile-name { font-size: 15px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); max-width: 720px; padding: 12px; }
  .sidebar { position: static; max-height: none; overflow: visible; order: 0; }
  .main { order: 1; }
  .side-profile, .side-section, .side-divider, .side-reload, .side-privacy { display: none; }
  .side-nav { flex-direction: row; overflow-x: auto; gap: 2px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 5px; scrollbar-width: none; }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-link { flex: 0 0 auto; padding: 8px 10px; font-size: 13px; gap: 7px; }
  .side-link .icon { width: 23px; height: 23px; }
  .side-link .count { display: none; }
  .post-media.count-2 .media-cell, .post-media.count-3 .media-cell, .post-media.count-4 .media-cell { height: 210px; }
}
@media (max-width: 900px) and (min-width: 761px) {
  .messages-view { height: calc(100vh - var(--topbar) - 100px); }
}
@media (max-width: 760px) {
  .topnav { display: none; }
  .topbar-user .profile-chip { padding: 3px; background: transparent; }
  .profile-chip-name { display: none; }
  .search { flex: 1; width: auto; max-width: none; }
  .layout { padding: 10px 10px 80px; }
  .messages-view { height: calc(100vh - var(--topbar) - 86px); border-radius: 0; box-shadow: none; grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .messages-view.has-thread .thread-list { display: none; }
  .messages-view:not(.has-thread) .conversation { display: none; }
  .back-btn { display: grid; }
  .thread-list { border-right: 0; }
  .mobile-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    display: flex;
    background: var(--card);
    border-top: 1px solid var(--line);
    padding: 3px 0 max(3px, env(safe-area-inset-bottom));
  }
  .mnav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 5px 0;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
  }
  .mnav-link .icon { width: 25px; height: 25px; }
  .mnav-link.active { color: var(--blue); }
  .upload-card { padding: 26px 20px 22px; border-radius: 14px; }
  .upload-brand .brand-name { font-size: 25px; }
  .upload-card h1 { font-size: 22px; }
  .topbar-tools .tool-label { display: inline; }
  .topbar-tools .lang-tool .icon { display: none; }
  .topbar-tools .tool-btn { width: 38px; min-width: 38px; padding: 0; font-size: 12px; }
  .section-head h1 { font-size: 21px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .lightbox-nav.prev { left: 2px; }
  .lightbox-nav.next { right: 2px; }
}
@media (max-width: 600px) {
  .logo-text { display: none; }
}
@media (max-width: 520px) {
  body { font-size: 14px; }
  .topbar-inner { padding: 0 10px; gap: 7px; }
  .logo-mark { width: 30px; height: 30px; border-radius: 8px; }
  .logo-mark svg { width: 18px; height: 18px; }
  .post { padding: 12px 12px 0; }
  .post-media { margin-left: -12px; margin-right: -12px; }
  .composer { padding: 10px 12px 8px; }
  .post-media.count-1 .media-cell img, .post-media.count-1 .media-cell video { max-height: 460px; }
  .post-media.count-2 .media-cell, .post-media.count-3 .media-cell, .post-media.count-4 .media-cell { height: 150px; }
  .post-media.count-3 .media-cell:first-child { grid-column: auto; }
  .post-media.count-3, .post-media.count-4 { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------- friends / search ---------------- */
.friends-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.friend-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
}
.friend-card:hover { background: var(--hover); }
.friend-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.friend-info { min-width: 0; }
.friend-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-since { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.friend-msg { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; color: var(--blue); font-size: 13px; padding: 6px 8px; }
.friend-msg .icon { color: var(--blue); }
.search-result {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 9px 8px;
}
.search-result:hover { background: var(--hover); }
.search-result + .search-result { border-top: 1px solid var(--line); border-radius: 0; }
.search-result-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-size: 14px; }
.search-result-head .activity-date { margin-top: 0; }
.detail-link { color: var(--blue); }
.flash { animation: flashHighlight 1.6s ease-out; }
@keyframes flashHighlight { from { background: var(--blue-soft); } to { background: var(--card); } }

@media (max-width: 620px) {
  .friends-grid { grid-template-columns: 1fr; }
}

/* ---------------- dark theme details ---------------- */
:root[data-theme="dark"] .upload-screen {
  background:
    radial-gradient(900px 420px at 15% 0%, #12233c 0%, transparent 70%),
    radial-gradient(700px 380px at 100% 20%, #221a3a 0%, transparent 70%),
    var(--bg);
}
:root[data-theme="dark"] .upload-card { box-shadow: 0 18px 50px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .4); }
:root[data-theme="dark"] .topbar { box-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
:root[data-theme="dark"] .toast { background: var(--text); color: var(--bg); }
:root[data-theme="dark"] .post-media.count-1 .media-cell { background: #000; }
:root[data-theme="dark"] .load-status .spinner { border-color: rgba(125, 179, 255, .25); border-top-color: var(--blue); }
:root[data-theme="dark"] .share-card { border-color: var(--line-strong); }
:root[data-theme="dark"] .lightbox-stage img,
:root[data-theme="dark"] .lightbox-stage video { background: #000; }
