/* Palette and solid wallpaper color from Telegram Desktop's built-in Night theme.
   https://github.com/telegramdesktop/tdesktop/blob/dev/Telegram/Resources/night-green.tdesktop-theme */
.telegram {
  --tg-window: #282e33;
  --tg-wallpaper: #18191d;
  --tg-text: #f5f5f5;
  --tg-muted: #82868a;
  --tg-accent: #4be1c3;
  --tg-message: #33393f;
  --tg-time: #828d94;
  --tg-active-chat: #009687;
  --tg-service: #363c43c8;
  background: var(--tg-window);
  border: 1px solid #3a3f45;
  border-radius: 9px;
  color: var(--tg-text);
  font-family: "Segoe UI", Arial, sans-serif;
}
.tg-sidebar {
  width: 172px;
  background: var(--tg-window);
  border-right: 1px solid #1f2328;
  padding: 0;
  text-align: left;
}
.tg-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  padding: 0 10px;
  color: var(--tg-time);
}
.tg-search {
  flex: 1;
  padding: 7px 10px;
  background: #202429;
  border-radius: 5px;
  font-size: 12px;
}
.tg-conversation {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 8px;
  background: var(--tg-active-chat);
  color: #fff;
}
.tg-conversation .avatar {
  width: 34px;
  height: 34px;
}
.tg-conversation-copy { min-width: 0; }
.tg-conversation-copy strong,
.tg-conversation-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}
.tg-conversation-copy small { margin-top: 3px; color: #e2f9f3; }
.tg-chat { display: flex; flex-direction: column; }
.tg-header {
  min-height: 60px;
  padding: 10px 16px;
  background: var(--tg-window);
  color: var(--tg-text);
  border-bottom: 1px solid #22262b;
}
#chat-title { font-size: 14px; font-weight: 600; }
.tg-header small { margin-top: 3px; color: var(--tg-muted); font-size: 11px; }
.avatar { flex: none; color: #fff; background: linear-gradient(150deg, #5bcbe3, #359ad4); }
.more { color: var(--tg-time); }
.chat-area {
  flex: 1;
  min-height: 441px;
  padding: 14px 16px 18px;
  background: var(--tg-wallpaper);
}
.date {
  display: table;
  margin: 0 auto 16px;
  padding: 4px 11px;
  border-radius: 20px;
  background: var(--tg-service);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.bubble {
  position: relative;
  width: fit-content;
  max-width: min(420px, 100%);
  padding: 9px 11px 6px;
  border-radius: 10px 10px 10px 2px;
  background: var(--tg-message);
  color: var(--tg-text);
}
.bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  bottom: 0;
  width: 9px;
  height: 10px;
  background: var(--tg-message);
  clip-path: polygon(62% 0, 100% 0, 100% 100%, 0 100%, 42% 65%);
}
.sender { color: var(--tg-accent); font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.message { font-size: 13px; line-height: 1.42; }
.time { color: var(--tg-time); font-size: 10px; margin-top: 4px; }
.keyboard { gap: 3px; margin-top: 4px; }
.key-row { gap: 3px; }
.key-row button {
  min-height: 35px;
  background: var(--tg-service);
  border: 0;
  border-radius: 5px;
  color: #fff;
  font: 12px "Segoe UI", Arial, sans-serif;
  padding: 7px 5px;
}
.key-row button:hover { background: #464c53; }
.composer {
  min-height: 49px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 13px;
  padding: 10px 15px;
  background: var(--tg-window);
  color: var(--tg-muted);
  font-size: 13px;
}
.composer .tg-placeholder { flex: 1; color: var(--tg-muted); }
.composer svg { flex: none; }
.composer svg:last-child { color: var(--tg-accent); }
@media (max-width: 1080px) {
  .tg-sidebar { display: none; }
}

/* The chat comes before the decorative guide on phones. */
main {
  grid-template-areas: "intro chat" "extras chat";
  grid-template-rows: auto 1fr;
  column-gap: 6%;
  row-gap: 0;
}
.story { grid-area: intro; min-width: 0; }
.stage { grid-area: chat; min-width: 0; }
.demo-extras { grid-area: extras; min-width: 0; }
.demo-extras .source { margin-top: 12px; }
@media (max-width: 850px) {
  main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "intro" "chat" "extras";
    grid-template-rows: auto;
    gap: 20px;
    padding: 22px 5% 30px;
  }
  header { padding: 16px 5%; gap: 8px; }
  header a { line-height: 1.4; }
  .story h1 { font-size: clamp(32px, 9vw, 48px); margin: 12px 0; }
  .story > p { line-height: 1.55; }
  .chapters { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px; margin: 14px 0 0; }
  .chapter { width: 100%; min-height: 44px; padding: 7px 6px; overflow-wrap: anywhere; }
  .stage-caption { margin-bottom: 8px; }
  .telegram { min-height: 0; }
  .chat-area { min-height: 0; padding: 12px 10px 15px; }
  .tg-header { min-height: 54px; padding-inline: 10px; }
  .key-row button { min-height: 44px; font-size: 11px; overflow-wrap: anywhere; }
  .stage-bottom { gap: 10px; margin-top: 12px; }
  .stage-bottom button { min-height: 44px; white-space: normal; flex: 0 0 auto; max-width: 46%; }
  .demo-extras { display: grid; gap: 8px; }
  .demo-guide { margin-top: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr); align-items: center; }
  .demo-guide img { width: 100%; max-width: 225px; }
  .demo-extras .source { justify-self: start; margin-bottom: 0; }
}

.demo-contact { margin-block-start: 1.25rem; font-size: .85rem; }
.demo-contact a { color: #c3ebdc; text-underline-offset: .25em; }
