:root {
  color-scheme: light;
  --tg-blue: #2aabee;
  --tg-blue-dark: #1c93d0;
  --tg-text: #202b36;
  --tg-muted: #708499;
  --tg-border: #dfe6ed;
  --tg-bg: #d9e2cd;
  --tg-bg-deep: #9bb78d;
  --tg-card: #ffffff;
  --tg-panel: #ffffff;
  --tg-shadow: 0 1px 2px rgba(31, 45, 61, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--tg-text);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.18) 25%, transparent 25%) 0 0 / 32px 32px,
    linear-gradient(-45deg, rgba(255, 255, 255, 0.16) 25%, transparent 25%) 0 0 / 32px 32px,
    linear-gradient(180deg, var(--tg-bg) 0%, var(--tg-bg-deep) 100%);
  background-attachment: fixed;
  font: 14px/1.42 Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

a {
  color: var(--tg-blue-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 3px rgba(31, 45, 61, 0.08);
  backdrop-filter: blur(14px);
}

.site-header__inner {
  display: flex;
  width: min(1040px, calc(100vw - 28px));
  min-height: 54px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.site-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--tg-text);
}

.site-brand:hover {
  text-decoration: none;
}

.site-brand__avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #d8eefb;
}

.site-brand__avatar--placeholder,
.channel-panel__avatar--placeholder,
.post-card__avatar--placeholder {
  display: block;
  background: linear-gradient(135deg, #7bc8f6 0%, #2aabee 55%, #1c93d0 100%);
}

.site-brand__text {
  display: grid;
  min-width: 0;
}

.site-brand__text strong {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-brand__text small {
  overflow: hidden;
  color: var(--tg-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-search {
  display: flex;
  width: min(320px, 38vw);
  height: 34px;
  overflow: hidden;
  border: 1px solid #d7e0e8;
  border-radius: 18px;
  background: #f4f7fa;
}

.site-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  padding: 0 12px;
  background: transparent;
  color: var(--tg-text);
  font: inherit;
  outline: 0;
}

.site-search button {
  width: 42px;
  border: 0;
  color: var(--tg-muted);
  background: transparent;
  font-size: 20px;
  cursor: pointer;
}

.site-main {
  width: min(1040px, calc(100vw - 28px));
  margin: 18px auto 44px;
}

.site-shell {
  display: grid;
  grid-template-columns: minmax(0, 670px) 320px;
  gap: 18px;
  align-items: start;
}

.site-feed,
.post-list,
.post-detail {
  display: grid;
  min-width: 0;
  gap: 10px;
}

.channel-panel,
.empty-state,
.search-heading,
.preview-banner,
.related-posts {
  border: 1px solid var(--tg-border);
  border-radius: 8px;
  background: var(--tg-panel);
  box-shadow: var(--tg-shadow);
}

.channel-panel {
  position: sticky;
  top: 72px;
  padding: 16px;
}

.channel-panel__header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.channel-panel__avatar {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 50%;
  object-fit: cover;
}

.channel-panel h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.channel-panel p {
  margin: 2px 0 0;
  color: var(--tg-muted);
  font-size: 13px;
}

.channel-panel__description {
  padding-top: 14px;
  border-top: 1px solid var(--tg-border);
}

.channel-panel__button {
  display: block;
  margin-top: 14px;
  border-radius: 7px;
  padding: 9px 12px;
  background: var(--tg-blue);
  color: #fff;
  text-align: center;
  font-weight: 600;
}

.channel-panel__button:hover {
  text-decoration: none;
  background: var(--tg-blue-dark);
}

.post-card {
  max-width: 670px;
}

.post-card__message {
  position: relative;
  width: fit-content;
  max-width: 100%;
  min-width: min(320px, 100%);
  border-radius: 0 10px 10px;
  padding: 10px 12px 8px;
  background: var(--tg-card);
  box-shadow: var(--tg-shadow);
}

.post-card__message::before {
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid var(--tg-card);
  border-left: 8px solid transparent;
  content: "";
}

.post-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.post-card__avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  object-fit: cover;
}

.post-card__channel {
  display: grid;
  min-width: 0;
}

.post-card__channel strong {
  color: var(--tg-blue-dark);
  font-size: 14px;
  line-height: 1.2;
}

.post-card__channel span {
  color: var(--tg-muted);
  font-size: 12px;
}

.post-card__body {
  overflow-wrap: anywhere;
}

.post-card__body :first-child {
  margin-top: 0;
}

.post-card__body :last-child {
  margin-bottom: 0;
}

.post-card__body p {
  margin: 8px 0;
}

.post-card__body blockquote {
  margin: 10px 0;
  padding: 7px 10px;
  border-left: 3px solid var(--tg-blue);
  border-radius: 0 7px 7px 0;
  background: #eef8fe;
  color: #395064;
}

.post-card__media {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.post-card__media figure {
  margin: 0;
}

.post-card__media img,
.post-card__media video {
  display: block;
  max-width: min(100%, 560px);
  height: auto;
  max-height: 760px;
  border-radius: 8px;
  object-fit: contain;
  background: #edf2f6;
}

.post-card__media video {
  width: min(100%, 560px);
}

.post-card__media audio {
  width: min(100%, 420px);
}

.post-card__media figcaption {
  margin-top: 5px;
  color: var(--tg-muted);
  font-size: 12px;
}

.post-card__attachment {
  margin: 0;
}

.post-card__footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 5px;
  color: var(--tg-muted);
  font-size: 12px;
  line-height: 1.2;
}

.post-card__views::before {
  content: "◷ ";
}

.empty-state,
.search-heading,
.preview-banner,
.related-posts {
  max-width: 670px;
  padding: 16px;
}

.empty-state h1,
.empty-state h2,
.search-heading h1,
.related-posts h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.empty-state p,
.search-heading p {
  margin: 0;
  color: var(--tg-muted);
}

.preview-banner {
  border-color: #f2ce72;
  background: #fff7dd;
  color: #765b16;
}

.related-posts {
  display: grid;
  gap: 8px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.pagination a,
.pagination span {
  border: 1px solid var(--tg-border);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  box-shadow: var(--tg-shadow);
}

@media (max-width: 900px) {
  .site-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .channel-panel {
    position: static;
    order: -1;
  }
}

@media (max-width: 640px) {
  .site-header__inner {
    width: min(100vw - 20px, 1040px);
    min-height: 50px;
    gap: 10px;
  }

  .site-brand__text small {
    display: none;
  }

  .site-search {
    width: min(190px, 44vw);
  }

  .site-main {
    width: min(100vw - 18px, 1040px);
    margin-top: 10px;
  }

  .post-card__message {
    width: 100%;
    min-width: 0;
    border-radius: 8px;
  }

  .post-card__message::before {
    display: none;
  }

  .post-card__media img,
  .post-card__media video {
    max-width: 100%;
    max-height: none;
  }
}
