:root {
  --tg-bg: #e6ebee;
  --tg-ink: #0f1720;
  --tg-muted: rgba(15, 23, 32, 0.55);
  --tg-line: rgba(15, 23, 32, 0.10);
  --tg-card: #ffffff;
  --tg-shadow: 0 10px 26px rgba(15, 23, 32, 0.10);
  --tg-radius: 16px;
  --tg-accent: #2a84d2;
  --code-bg: rgba(15, 23, 32, 0.06);
  --code-line: rgba(15, 23, 32, 0.10);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans", Arial, sans-serif;
}

html[data-theme="dark"] {
  --tg-bg: #0b0f14;
  --tg-ink: #e9eef3;
  --tg-muted: rgba(233, 238, 243, 0.60);
  --tg-line: rgba(233, 238, 243, 0.12);
  --tg-card: rgba(17, 23, 31, 0.92);
  --tg-shadow: 0 12px 30px rgba(0, 0, 0, 0.40);
  --tg-accent: #5fb3ff;
  --code-bg: rgba(233, 238, 243, 0.08);
  --code-line: rgba(233, 238, 243, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--tg-ink);
  background: var(--tg-bg);
}

.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1100px 720px at 8% 16%, rgba(42, 132, 210, 0.16), transparent 60%),
    radial-gradient(900px 620px at 92% 10%, rgba(72, 199, 142, 0.14), transparent 60%),
    radial-gradient(1000px 780px at 50% 100%, rgba(255, 255, 255, 0.55), transparent 65%),
    repeating-linear-gradient(135deg, rgba(15,23,32,0.03) 0 2px, transparent 2px 10px);
  pointer-events: none;
}

html[data-theme="dark"] .bg {
  background:
    radial-gradient(1100px 720px at 10% 18%, rgba(95, 179, 255, 0.18), transparent 60%),
    radial-gradient(900px 620px at 92% 12%, rgba(72, 199, 142, 0.10), transparent 60%),
    radial-gradient(1000px 780px at 50% 100%, rgba(255, 255, 255, 0.04), transparent 65%),
    repeating-linear-gradient(135deg, rgba(0,0,0,0.40) 0 3px, rgba(0,0,0,0.00) 3px 12px);
}

.shell { position: relative; min-height: 100%; }

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid var(--tg-line);
}

html[data-theme="dark"] .top {
  background: rgba(12, 16, 22, 0.78);
  border-bottom: 1px solid var(--tg-line);
}

.top__inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(42, 132, 210, 0.95), rgba(72, 199, 142, 0.92));
  box-shadow: 0 10px 18px rgba(15, 23, 32, 0.14);
  flex: 0 0 auto;
  background-size: cover;
  background-position: center;
  overflow: hidden;
  border: 1px solid var(--tg-line);
  position: relative;
}

.avatar__img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  opacity: 0;
  transition: opacity 120ms ease;
}
.avatar__img.is-on {
  opacity: 1;
}

.brand__meta { min-width: 0; }
.brand__title {
  font-weight: 760;
  letter-spacing: 0.2px;
  font-size: 16px;
  line-height: 1.1;
}
.brand__about {
  color: var(--tg-muted);
  font-size: 12px;
  line-height: 1.2;
  max-width: 560px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top__actions { display: flex; align-items: center; gap: 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--tg-line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--tg-ink);
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0.1px;
  user-select: none;
  white-space: nowrap;
}
html[data-theme="dark"] .badge {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(233, 238, 243, 0.14);
}
.badge:empty { display: none; }
.badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: rgba(15, 23, 32, 0.40);
}
html[data-theme="dark"] .badge__dot {
  background: rgba(233, 238, 243, 0.35);
}
.badge.is-up .badge__dot { background: rgba(72, 199, 142, 0.95); }
.badge.is-down .badge__dot { background: rgba(255, 94, 94, 0.95); }

.btn {
  appearance: none;
  border: 1px solid var(--tg-line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  text-decoration: none;
  color: var(--tg-ink);
  background: rgba(255, 255, 255, 0.94);
  transition: transform 120ms ease, box-shadow 120ms ease;
  user-select: none;
  cursor: pointer;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(15,23,32,0.10); }
.btn:active { transform: translateY(0px); box-shadow: none; }
.btn--ghost { background: rgba(255,255,255,0.55); }

html[data-theme="dark"] .btn {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(233, 238, 243, 0.14);
  box-shadow: none;
}
html[data-theme="dark"] .btn--ghost {
  background: rgba(255, 255, 255, 0.08);
}
html[data-theme="dark"] .btn:hover {
  box-shadow: 0 14px 30px rgba(0,0,0,0.35);
}

.main {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 14px 44px 14px;
}

.feed { display: grid; grid-template-columns: 1fr; gap: 12px; }

.status {
  color: var(--tg-muted);
  font-size: 12px;
  padding: 6px 2px;
}

.list { display: grid; gap: 10px; }

.datechip {
  justify-self: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--tg-line);
  background: rgba(255, 255, 255, 0.70);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 22px rgba(15, 23, 32, 0.10);
  color: var(--tg-ink);
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0.2px;
  margin: 6px 0;
}
html[data-theme="dark"] .datechip {
  background: rgba(17, 23, 31, 0.70);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
}

.msg {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: start;
}

.bubble {
  background: var(--tg-card);
  border: 1px solid var(--tg-line);
  border-radius: var(--tg-radius);
  box-shadow: var(--tg-shadow);
  overflow: hidden;
  max-width: 740px;
  width: 100%;
}

html[data-theme="dark"] .bubble {
  background: linear-gradient(180deg, rgba(17, 23, 31, 0.96), rgba(11, 15, 20, 0.96));
}

.bubble__head {
  padding: 10px 14px 0 14px;
}
.hrow {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.havatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(42, 132, 210, 0.95), rgba(72, 199, 142, 0.92));
  flex: 0 0 auto;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--tg-line);
}
.htxt { min-width: 0; }
.hname {
  font-weight: 720;
  font-size: 14px;
  line-height: 1.15;
  color: var(--tg-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.htag {
  color: var(--tg-muted);
  font-weight: 560;
}

.bubble__body { padding: 12px 14px 10px 14px; }

.bubble__text {
  font-size: 14px;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble__text a {
  color: var(--tg-accent);
  text-decoration: none;
}
.bubble__text a:hover { text-decoration: underline; }

.bubble__text code {
  font-family: var(--mono);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--code-bg);
  border: 1px solid var(--code-line);
}

.bubble__text pre {
  margin: 10px 0 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--code-bg);
  border: 1px solid var(--code-line);
  overflow: auto;
}
.bubble__text pre code {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 12px;
  line-height: 1.4;
  display: block;
  white-space: pre;
}

.codeblock {
  position: relative;
}
.copybtn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  border: 1px solid var(--tg-line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--tg-ink);
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
}
html[data-theme="dark"] .copybtn {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(233, 238, 243, 0.14);
}
.copybtn:hover { transform: translateY(-1px); }

.bubble__media {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.media__img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--tg-line);
  display: block;
}

.media__file {
  border: 1px solid var(--tg-line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(230, 235, 238, 0.60);
}
.media__file a { color: var(--tg-ink); text-decoration: none; }
.media__file a:hover { text-decoration: underline; }
.media__file .meta { color: var(--tg-muted); font-family: var(--mono); font-size: 11px; }

.bubble__foot {
  padding: 0 14px 10px 14px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--tg-muted);
  font-size: 11px;
  font-family: var(--mono);
}
.views {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ico {
  width: 14px;
  height: 14px;
  display: inline-block;
  opacity: 0.75;
  background-size: 14px 14px;
  background-repeat: no-repeat;
}
.ico-eye {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='rgba(233,238,243,0.75)' d='M12 5c5.5 0 9.7 4.1 11 7-1.3 2.9-5.5 7-11 7S2.3 14.9 1 12c1.3-2.9 5.5-7 11-7Zm0 2C7.9 7 4.5 10 3.3 12 4.5 14 7.9 17 12 17s7.5-3 8.7-5C19.5 10 16.1 7 12 7Zm0 2.5A2.5 2.5 0 1 1 9.5 12 2.5 2.5 0 0 1 12 9.5Z'/%3E%3C/svg%3E");
}
html:not([data-theme="dark"]) .ico-eye {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='rgba(15,23,32,0.55)' d='M12 5c5.5 0 9.7 4.1 11 7-1.3 2.9-5.5 7-11 7S2.3 14.9 1 12c1.3-2.9 5.5-7 11-7Zm0 2C7.9 7 4.5 10 3.3 12 4.5 14 7.9 17 12 17s7.5-3 8.7-5C19.5 10 16.1 7 12 7Zm0 2.5A2.5 2.5 0 1 1 9.5 12 2.5 2.5 0 0 1 12 9.5Z'/%3E%3C/svg%3E");
}

.sentinel { height: 1px; }
.tail { color: var(--tg-muted); font-size: 12px; padding: 6px 2px; }

@media (max-width: 560px) {
  .brand__about { display: none; }
  .bubble__body { padding: 12px 12px 10px 12px; }
  .bubble__foot { padding: 0 12px 10px 12px; }
  .bubble__head { padding: 10px 12px 0 12px; }
}
