:root {
  --bg: #0b1117;
  --bg-elevated: #17212b;
  --bg-soft: #202b36;
  --border: #101921;
  --text: #ffffff;
  --text-secondary: #708499;
  --accent: #5288c1;
  --link: #6ab3f4;
  --danger: #ff7a8a;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(82, 136, 193, 0.14), transparent 32rem),
    radial-gradient(circle at 90% 20%, rgba(255, 255, 255, 0.05), transparent 28rem), var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 0%, black, transparent 75%);
}

.tgme_background {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url('https://telegram.org/img/tgme/pattern.svg?1');
  background-repeat: repeat;
  filter: invert(100%);
  pointer-events: none;
  opacity: 0.35;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: rgba(23, 33, 43, 0.82);
  backdrop-filter: blur(20px);
}

.topbar_inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.brand_avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(145deg, var(--accent), #2b5378);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(82, 136, 193, 0.35);
}

.brand_avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand_text {
  font-size: 16px;
  font-weight: 600;
}

.search {
  position: relative;
  width: min(320px, 48vw);
}

.search_icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-secondary);
  border-radius: 50%;
  transform: translateY(-60%);
}

.search_icon::after {
  content: '';
  position: absolute;
  left: 9px;
  top: 10px;
  width: 7px;
  height: 2px;
  background: var(--text-secondary);
  transform: rotate(45deg);
  transform-origin: left center;
}

.search input {
  width: 100%;
  padding: 8px 14px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.search input:focus {
  border-color: var(--accent);
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 20px 60px;
  display: flex;
  gap: 26px;
  align-items: flex-start;
}

.feed_column {
  flex: 1;
  min-width: 0;
}

.feed_meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 0 8px 12px;
}

.feed_meta[hidden] {
  display: none;
}

.feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.unread_divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.unread_divider::before,
.unread_divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.post_card {
  position: relative;
  min-width: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 30px 14px 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
  animation: rise 0.45s ease both;
  cursor: pointer;
  transition:
    border-color 0.2s,
    transform 0.2s;
}

.post_card:hover {
  border-color: rgba(82, 136, 193, 0.55);
  transform: translateY(-1px);
}

.post_card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.post_author {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.post_avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #3a658f, #233f5c);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.post_public_id {
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post_time {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.post_content {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.rich_text {
  min-width: 0;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

.rich_text a {
  color: var(--link);
  text-decoration: none;
}

.rich_text a:hover {
  text-decoration: underline;
}

.entity_code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--bg-soft);
  font-family: Consolas, 'Courier New', monospace;
  font-size: 0.92em;
}

.entity_pre {
  max-width: 100%;
  padding: 10px;
  overflow-x: auto;
  border-radius: 8px;
  background: var(--bg-soft);
  font-family: Consolas, 'Courier New', monospace;
  font-size: 13px;
}

.entity_blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid var(--accent);
  background: rgba(82, 136, 193, 0.1);
}

.entity_spoiler {
  padding: 0 3px;
  border-radius: 4px;
  background: var(--bg-soft);
  cursor: pointer;
}

.entity_spoiler.revealed {
  background: transparent;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag {
  padding: 3px 9px;
  border-radius: 10px;
  background: rgba(82, 136, 193, 0.16);
  color: var(--link);
  font-size: 12px;
}

.media_grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.media_item {
  position: relative;
  min-height: 140px;
  border-radius: 10px;
  overflow: hidden;
  background: #10161e;
}

.media_item:only-child {
  grid-column: 1 / -1;
}

.media_item img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 140px;
  max-height: 420px;
  object-fit: cover;
}

.video_placeholder {
  min-height: 140px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  font-size: 13px;
  background:
    radial-gradient(circle at 50% 40%, rgba(82, 136, 193, 0.2), transparent 60%), var(--bg-soft);
}

.post_footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.post_footer_info {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.post_footer_info > span {
  color: var(--text-secondary);
  font-size: 12px;
}

.post_public_id {
  min-width: 0;
  flex: 1;
}

.comment_count {
  flex-shrink: 0;
  white-space: nowrap;
}

.post_footer_meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
  min-width: 0;
}

.post_footer_meta .post_time {
  flex-shrink: 0;
}

.open_link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: var(--link);
  text-decoration: none;
  border-radius: 8px;
  background: rgba(82, 136, 193, 0.12);
  transition: background 0.2s;
}

.open_link svg {
  display: block;
  width: 16px;
  height: 16px;
}

.open_link:hover {
  background: rgba(82, 136, 193, 0.24);
}

.side_column {
  width: 320px;
  flex-shrink: 0;
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.channel_card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.channel_avatar {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(145deg, var(--accent), #2b5378);
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(82, 136, 193, 0.32);
}

.channel_avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.channel_card h1 {
  margin: 0 0 8px;
  font-size: 18px;
  text-align: center;
}

.channel_card p {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.channel_stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.channel_stats div {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-soft);
}

.channel_stats strong {
  font-size: 16px;
}

.channel_stats span {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 2px;
}

.channel_actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.channel_action {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(82, 136, 193, 0.12);
  color: var(--link);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.2s;
}

.channel_action:hover {
  background: rgba(82, 136, 193, 0.24);
}

.channel_action.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.channel_action.primary:hover {
  background: #5e97d2;
}

.channel_action.disabled {
  color: var(--text-secondary);
  background: var(--bg-soft);
  opacity: 0.55;
  pointer-events: none;
}

.detail_view,
.detail_card {
  min-width: 0;
  max-width: 100%;
}

.detail_view {
  width: 100%;
  animation: rise 0.3s ease both;
}

.back_button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.back_button:hover {
  border-color: var(--accent);
}

.detail_card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 6px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}

.detail_head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.detail_public_id {
  min-width: 0;
  color: var(--link);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail_content {
  font-size: 16px;
}

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.reaction_item {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  font-size: 13px;
}

.reaction_empty {
  color: var(--text-secondary);
  font-size: 13px;
}

.detail_actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.action_button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(82, 136, 193, 0.12);
  color: var(--link);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.2s;
}

.action_button:hover {
  background: rgba(82, 136, 193, 0.24);
}

.action_button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.action_button.primary:hover {
  background: #5e97d2;
}

.action_button.secondary {
  background: var(--bg-soft);
}

.action_button.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.comments_section {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.comments_section h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.comments_empty {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.comments_list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment_item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
}

.comment_head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.comment_name {
  font-size: 13px;
  color: var(--link);
}

.comment_time {
  color: var(--text-secondary);
  font-size: 12px;
}

.comment_text {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.comment_votes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.comment_vote {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-secondary);
  text-decoration: none;
}

.comment_vote:hover {
  border-color: var(--accent);
  color: var(--link);
}

.comment_vote.disabled {
  opacity: 0.8;
}

.continue_button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(82, 136, 193, 0.92);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.continue_button[hidden] {
  display: none;
}

.empty_state {
  padding: 30px 16px;
  color: var(--text-secondary);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

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

@media (max-width: 860px) {
  .layout {
    flex-direction: column;
    align-items: stretch;
  }

  .side_column {
    position: static;
    width: 100%;
    order: -1;
  }

  .channel_card {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 0 14px;
    align-items: center;
  }

  .channel_avatar {
    grid-row: span 2;
    margin: 0;
  }

  .channel_card h1,
  .channel_card p {
    text-align: left;
  }

  .channel_stats,
  .channel_actions {
    grid-column: 1 / -1;
  }

  .channel_actions {
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .topbar_inner {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }

  .brand_text {
    display: none;
  }

  .search {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .brand_avatar {
    width: 30px;
    height: 30px;
  }

  .layout {
    padding: 16px 12px 70px;
  }

  .media_grid {
    grid-template-columns: 1fr;
  }

  .detail_card {
    padding: 16px;
  }

  .detail_actions {
    flex-direction: column;
  }

  .action_button {
    width: 100%;
    text-align: center;
  }
}
