:root {
  --bg: #f0f2f5;
  --ink: #050505;
  --muted: #65676b;
  --line: #ccd0d5;
  --soft: #e4e6eb;
  --accent: #0866ff;
  --accent-soft: #e7f0ff;
  --card: #ffffff;
  --danger: #e41e3f;
  --radius: 10px;
  --font: "Manrope", "Segoe UI", Helvetica, Arial, sans-serif;
  --shadow: 0 1px 2px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* —— Facebook-like top bar —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 56px;
  padding: 0 .75rem;
  background: var(--card);
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.top-left {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
}
.logo {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: var(--bg);
  border-radius: 999px;
  padding: .45rem .85rem;
  min-width: 0;
  width: min(240px, 36vw);
}
.search-ico { color: var(--muted); font-size: .95rem; }
.search input {
  border: 0;
  background: transparent;
  font: inherit;
  width: 100%;
  outline: none;
  color: var(--ink);
}
.search input:disabled { opacity: .7; cursor: default; }

.top-center {
  display: flex;
  justify-content: center;
  gap: .25rem;
}
.ticon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
  width: 112px;
  height: 52px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  position: relative;
}
.ticon span { font-size: .68rem; font-weight: 700; }
.ticon:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.ticon.on {
  color: var(--accent);
}
.ticon.on::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -2px;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}

.top-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .45rem;
}
.pill {
  background: var(--soft);
  color: var(--ink);
  font-weight: 700;
  font-size: .85rem;
  padding: .45rem .8rem;
  border-radius: 999px;
  text-decoration: none;
}
.pill:hover { background: #d8dade; text-decoration: none; }
.ghost {
  border: 0;
  background: var(--soft);
  color: var(--ink);
  padding: .4rem .7rem;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: #1877f2;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar.sm { width: 36px; height: 36px; font-size: .9rem; }
.avatar.xs { width: 28px; height: 28px; font-size: .75rem; background: #42b72a; }

/* —— 3 columns —— */
.shell {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(0, 680px) minmax(220px, 1fr);
  gap: 1rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: .85rem 1rem 2.5rem;
  align-items: start;
}
.left-rail, .right-rail {
  position: sticky;
  top: 68px;
  max-height: calc(100vh - 80px);
  overflow: auto;
  padding-right: .25rem;
}
.stage { min-width: 0; display: grid; gap: .85rem; }

.rail-me {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .45rem .5rem;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  margin-bottom: .25rem;
}
.rail-me:hover { background: var(--soft); text-decoration: none; }
.rail-label {
  margin: .85rem .5rem .35rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.rail-nav { display: grid; gap: .1rem; }
.rail-nav a {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .5rem;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}
.rail-nav a:hover { background: var(--soft); text-decoration: none; }
.rail-nav a.on { background: var(--accent-soft); }
.dot {
  width: 28px; height: 28px; border-radius: 50%;
  flex-shrink: 0;
}
.dot.feed { background: linear-gradient(135deg, #0866ff, #54a0ff); }
.dot.chat { background: linear-gradient(135deg, #45bd62, #2ea44f); }
.dot.admin { background: linear-gradient(135deg, #f02849, #f7b928); }
.dot.sec { background: linear-gradient(135deg, #a033ff, #7b61ff); }
.rail-empty { display: block; padding: .5rem; color: var(--muted); font-size: .9rem; }

.rail-card {
  background: transparent;
}
.rail-card-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .55rem;
}
.rail-card-h h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--muted);
}
.rail-card-h a { font-weight: 700; font-size: .88rem; }
.chat-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .45rem .35rem;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}
.chat-row:hover { background: var(--soft); text-decoration: none; }
.create-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: .55rem;
  padding: .55rem;
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
.create-chat:hover { background: #d8dade; text-decoration: none; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .9rem 1rem;
}
.composer { padding: .75rem .9rem .55rem; }
.composer-row {
  display: flex;
  align-items: center;
  gap: .65rem;
}
.composer-input {
  flex: 1;
  background: var(--bg);
  border-radius: 999px;
  padding: .7rem 1rem;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.composer-input:hover { background: #e4e6eb; text-decoration: none; }
.composer-actions {
  display: flex;
  justify-content: space-around;
  border-top: 1px solid var(--soft);
  margin-top: .7rem;
  padding-top: .35rem;
}
.ca {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem .7rem;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
  font-size: .9rem;
  text-decoration: none;
  flex: 1;
  justify-content: center;
}
.ca:hover { background: var(--bg); text-decoration: none; }
.ca-ico {
  width: 18px; height: 18px; border-radius: 4px;
}
.ca-ico.live { background: #f02849; }
.ca-ico.photo { background: #45bd62; }
.ca-ico.feel { background: #f7b928; }

.feed { display: grid; gap: .85rem; }
.post-head {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: .65rem;
}
.post-who { display: grid; line-height: 1.2; }
.post-name { font-weight: 700; color: var(--ink); text-decoration: none; }
.post-name:hover { text-decoration: underline; }
.post-who time { font-size: .8rem; color: var(--muted); }
.post-title {
  margin: 0 0 .55rem;
  font-size: 1.05rem;
  font-weight: 750;
  line-height: 1.35;
}
.post-title a { color: var(--ink); text-decoration: none; }
.post-title a:hover { color: var(--accent); }
.post-body {
  color: #050505;
  line-height: 1.5;
  max-height: 8.5em;
  overflow: hidden;
  mask-image: linear-gradient(#000 55%, transparent);
}
.post-body p { margin: 0 0 .5rem; }
.post-foot {
  display: flex;
  gap: .5rem;
  margin-top: .75rem;
  padding-top: .55rem;
  border-top: 1px solid var(--soft);
}
.post-foot a {
  flex: 1;
  text-align: center;
  padding: .55rem;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}
.post-foot a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.post-link { display: block; color: inherit; text-decoration: none; }
.post-link:hover { text-decoration: none; }
.empty-card { color: var(--muted); }
.empty-card p { margin: 0; }

.section-banner h1, .stage-head h1, .material-card h1 {
  margin: 0 0 .25rem;
  font-size: 1.35rem;
  font-weight: 800;
}
.section-banner .crumb, .material-card .crumb { margin: 0 0 .45rem; font-size: .88rem; color: var(--muted); }
.muted, .lead, .crumb { color: var(--muted); }
.lead { margin: .25rem 0 0; }
.material-card .body { line-height: 1.6; font-size: 1.02rem; }
.material-card .body p { margin: 0 0 .9rem; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: .65rem 0 0; }
.chips a {
  display: inline-block;
  padding: .35rem .75rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font-weight: 700;
  font-size: .85rem;
  text-decoration: none;
}
.chips .on a { background: var(--accent-soft); color: var(--accent); }

.chat-log {
  min-height: 280px;
  max-height: min(55vh, 520px);
  overflow-y: auto;
}
.msg { padding: .55rem 0; border-top: 1px solid var(--soft); }
.msg:first-child { border-top: 0; }
.msg-meta {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: .2rem;
}
.msg-body { white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .55rem;
  align-items: end;
}
.chat-form textarea {
  font: inherit;
  padding: .7rem .85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  resize: vertical;
  min-height: 2.6rem;
}
.chat-form button {
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: .7rem 1.1rem;
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  height: 2.6rem;
}

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
  background: var(--bg);
}
.auth-card {
  width: min(380px, 100%);
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}
.eyebrow { margin: 0 0 .35rem; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; font-size: .75rem; font-weight: 700; }
.auth-card h1 { margin: 0; font-size: 1.4rem; }
.stack { display: grid; gap: .85rem; margin-top: 1rem; }
.stack label { display: grid; gap: .3rem; font-size: .9rem; color: var(--muted); font-weight: 650; }
.stack input {
  font: inherit;
  padding: .7rem .75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.stack button {
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: .75rem 1rem;
  font: inherit;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
}
.error { color: var(--danger); margin: .75rem 0 0; }
.wrap { width: min(680px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 220px minmax(0, 1fr); }
  .right-rail { display: none; }
}
@media (max-width: 860px) {
  .topbar { grid-template-columns: 1fr auto; }
  .top-center { display: none; }
  .shell { grid-template-columns: 1fr; padding: .65rem .65rem 2rem; }
  .left-rail {
    position: static;
    max-height: none;
    display: flex;
    gap: .35rem;
    overflow-x: auto;
    padding-bottom: .25rem;
  }
  .rail-me, .rail-label, .rail-empty { display: none; }
  .rail-nav { display: contents; }
  .rail-nav a { white-space: nowrap; background: var(--card); box-shadow: var(--shadow); }
}
@media (max-width: 560px) {
  .chat-form { grid-template-columns: 1fr; }
  .search { display: none; }
  .composer-actions .ca:last-child { display: none; }
}
