:root {
  --bg: #f0f2f5;
  --surface: #fbfcfd;
  --surface-strong: #ffffff;
  --text: #17202a;
  --muted: #606b78;
  --soft: #eef1f5;
  --line: #d9dee7;
  --line-soft: #e7ebf0;
  --brand: #2864d8;
  --brand-dark: #174da8;
  --good: #24824d;
  --shadow: 0 1px 2px rgb(15 23 42 / 8%), 0 8px 24px rgb(15 23 42 / 5%);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --topbar-height: 58px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 360px) minmax(420px, 1fr) minmax(220px, 360px);
  align-items: center;
  height: var(--topbar-height);
  gap: var(--space-md);
  padding: 0 var(--space-lg);
  background: rgb(255 255 255 / 96%);
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 1px 6px rgb(15 23 42 / 7%);
  backdrop-filter: blur(12px);
}

.search input {
  width: 100%;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  outline: none;
  background: var(--soft);
  color: var(--text);
}

.search {
  grid-column: 1;
}

.search input:focus {
  border-color: color-mix(in srgb, var(--brand), white 38%);
  background: var(--surface-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand), transparent 84%);
}

.main-tabs {
  grid-column: 2;
  display: flex;
  justify-content: center;
  justify-self: center;
  height: 100%;
  gap: var(--space-sm);
}

.main-tabs a {
  display: grid;
  min-width: 86px;
  place-items: center;
  padding: 0 var(--space-lg);
  color: var(--muted);
  font-weight: 650;
  border-radius: var(--radius-sm);
}

.main-tabs a:hover,
.main-tabs a:focus-visible {
  background: var(--soft);
  outline: none;
}

.main-tabs a[aria-current="page"] {
  color: var(--brand);
  box-shadow: inset 0 -3px 0 var(--brand);
  border-radius: 0;
}

.mini-avatar,
.post-avatar-fallback {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  color: var(--text);
  font-weight: 750;
}

.mini-avatar,
.post-avatar-fallback {
  background: linear-gradient(135deg, #335c99, #63926d);
  color: #fff;
  font-size: 0.8rem;
}

.shell {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(560px, 820px) minmax(240px, 320px);
  justify-content: center;
  align-items: start;
  gap: var(--space-xl);
  width: min(100%, 1540px);
  margin: 0 auto;
  padding: calc(var(--topbar-height) + var(--space-xl)) var(--space-xl) var(--space-2xl);
}

.feed-column {
  grid-column: 2;
}

.sidebar-right {
  grid-column: 3;
}

.sidebar {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-lg));
  display: grid;
  gap: var(--space-lg);
}

.side-section,
.card,
.post {
  background: var(--surface-strong);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.side-section {
  padding: var(--space-sm);
}

.side-section a {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-height: 42px;
  padding: 8px 10px;
  color: var(--text);
  border-radius: var(--radius-sm);
  font-weight: 620;
}

.side-section a:hover,
.side-section a:focus-visible {
  background: var(--soft);
  outline: none;
}

.side-section h2 {
  margin: var(--space-xs) var(--space-sm) var(--space-sm);
  color: var(--muted);
  font-size: 0.94rem;
  letter-spacing: 0;
}

.trends a {
  display: grid;
  align-items: start;
  gap: 2px;
  min-height: auto;
  padding-block: 10px;
}

.trends strong {
  font-size: 0.94rem;
  line-height: 1.25;
}

.trends span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.contacts a {
  position: relative;
}

.contact-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px #def1e6;
}

.feed-column {
  display: grid;
  gap: var(--space-lg);
  min-width: 0;
}

.card {
  overflow: hidden;
}

.composer {
  display: grid;
  gap: var(--space-md);
  padding: var(--space-lg);
}

.composer-top {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.composer-prompt {
  flex: 1;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  text-align: left;
}

.composer-prompt:hover,
.composer-prompt:focus-visible {
  background: #e4e9f1;
  outline: none;
}

.composer-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  padding-top: var(--space-md);
  border-top: 1px solid var(--line-soft);
}

.composer-actions button,
.post-action {
  min-height: 38px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.composer-actions button:hover,
.composer-actions button:focus-visible,
.post-action:hover,
.post-action:focus-visible {
  background: var(--soft);
  color: var(--text);
  outline: none;
}

.stories {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-md);
  padding: var(--space-md);
  background: transparent;
  border: 0;
  box-shadow: none;
}

.story-card {
  position: relative;
  display: flex;
  min-height: 154px;
  align-items: end;
  overflow: hidden;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgb(17 24 39 / 0%) 20%, rgb(17 24 39 / 76%) 100%),
    linear-gradient(135deg, #5074a7, #b0c17a);
  color: #fff;
  font-weight: 750;
  box-shadow: var(--shadow);
}

.story-card:nth-child(3) {
  background:
    linear-gradient(180deg, rgb(17 24 39 / 0%) 20%, rgb(17 24 39 / 78%) 100%),
    linear-gradient(135deg, #866947, #8eabb5);
}

.story-card:nth-child(4) {
  background:
    linear-gradient(180deg, rgb(17 24 39 / 0%) 20%, rgb(17 24 39 / 78%) 100%),
    linear-gradient(135deg, #486f67, #c38775);
}

.story-card:nth-child(5) {
  background:
    linear-gradient(180deg, rgb(17 24 39 / 0%) 20%, rgb(17 24 39 / 78%) 100%),
    linear-gradient(135deg, #334b82, #87986f);
}

.story-create {
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--space-sm);
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--line-soft);
}

.story-plus {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
}

.feed {
  display: grid;
  gap: var(--space-lg);
}

.post {
  overflow: hidden;
  animation: post-enter 220ms ease-out both;
}

@keyframes post-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.post-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-lg) var(--space-md);
}

.post-avatar,
.comment-avatar {
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 50%;
  background: var(--soft);
}

.post-avatar {
  width: 44px;
  height: 44px;
}

.post-avatar img,
.comment-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-avatar-fallback {
  width: 100%;
  height: 100%;
}

.post-meta {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.post-author {
  font-weight: 780;
}

.post-time {
  color: var(--muted);
  font-size: 0.84rem;
}

.post-menu {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
}

.post-menu:hover,
.post-menu:focus-visible {
  background: var(--soft);
  outline: none;
}

.post-caption {
  margin: 0;
  padding: 0 var(--space-lg) var(--space-md);
}

.post-image-wrap {
  background: #d8dde5;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.post-image {
  width: 100%;
  max-height: 560px;
  object-fit: cover;
  background: #d8dde5;
}

.image-placeholder {
  display: grid;
  min-height: 360px;
  place-items: center;
  padding: var(--space-xl);
  background:
    linear-gradient(135deg, rgb(255 255 255 / 35%) 25%, transparent 25%) 0 0 / 28px 28px,
    linear-gradient(135deg, transparent 75%, rgb(255 255 255 / 35%) 75%) 0 0 / 28px 28px,
    #dce2eb;
  color: #526171;
  text-align: center;
  font-weight: 700;
}

.post-stats {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  color: var(--muted);
  font-size: 0.9rem;
}

.post-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xs);
  margin: 0 var(--space-lg);
  padding: var(--space-xs) 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.post-comments {
  display: grid;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg) var(--space-lg);
}

.comment {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.comment-avatar {
  width: 30px;
  height: 30px;
}

.comment-bubble {
  max-width: min(100%, 560px);
  padding: 8px 11px;
  border-radius: 14px;
  background: var(--soft);
}

.comment-name {
  display: block;
  margin-bottom: 1px;
  font-size: 0.82rem;
  font-weight: 780;
}

.comment-text {
  margin: 0;
}

.feed-status {
  min-height: 44px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 160ms ease;
}

.feed-status.is-visible {
  opacity: 1;
}

.load-sentinel {
  width: 100%;
  height: 1px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: minmax(200px, 320px) minmax(360px, 1fr) minmax(200px, 320px);
  }

  .shell {
    grid-template-columns: minmax(0, 820px);
  }

  .feed-column {
    grid-column: 1;
  }

  .sidebar-right {
    display: none;
  }
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: minmax(140px, 1fr) auto;
    padding-inline: var(--space-md);
  }

  .main-tabs {
    display: none;
  }

  .shell {
    display: block;
    padding: calc(var(--topbar-height) + var(--space-md)) var(--space-md) var(--space-xl);
  }

  .sidebar {
    display: none;
  }

  .feed-column {
    max-width: 680px;
    margin: 0 auto;
  }

  .stories {
    grid-template-columns: repeat(3, 1fr);
  }

  .story-card:nth-child(n + 4) {
    display: none;
  }
}

@media (max-width: 520px) {
  .stories {
    grid-template-columns: repeat(2, 1fr);
  }

  .story-card:nth-child(n + 3) {
    display: none;
  }

  .composer-actions {
    grid-template-columns: 1fr;
  }

  .post-stats {
    display: grid;
  }
}
