/* UI по мотивам Telegram Web K (tweb, GPL-3.0) — pattern.svg из их репозитория */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --tg-primary: #3390ec;
  --tg-primary-dark: #2481cc;
  --tg-out-bg: #eeffde;
  --tg-in-bg: #ffffff;
  --tg-text: #0f1419;
  --tg-subtitle: #6b7280;
  --tg-time: #707579;
  --tg-topbar-h: 56px;
  --tg-composer-min: 52px;
  --tg-bubble-max: 480px;
  --tg-font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mk-radius-sm: 10px;
  --mk-radius-md: 14px;
  --mk-shadow-soft: 0 8px 28px rgba(15, 30, 60, 0.12);
  --mk-shadow-notice: 0 10px 32px rgba(15, 30, 60, 0.18);
}

html,
body {
  height: 100%;
  margin: 0;
}

body.tg-page {
  font-family: var(--tg-font);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  color: var(--tg-text);
  background: #99ba92;
  overflow: hidden;
}

.tg-shell {
  height: 100%;
  display: flex;
  justify-content: center;
  background: #99ba92 url("/images/tg-pattern.svg") center center repeat;
  background-size: 420px;
}

.tg-chat {
  position: relative;
  width: 100%;
  max-width: 960px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.tg-topbar {
  flex-shrink: 0;
  height: var(--tg-topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 16px;
  background: var(--tg-in-bg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 2;
}

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

.tg-peer-photo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(145deg, #6fc276, #45a049);
  color: #fff;
  font-weight: 500;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tg-peer-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-peer-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin: 3px 0 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--tg-subtitle);
  line-height: 1.3;
}

.tg-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(15, 20, 25, 0.05);
}

.tg-stat--online {
  background: rgba(79, 173, 45, 0.12);
}

.tg-stat--online .tg-stat__label,
.tg-stat--online .tg-stat__val {
  color: #3d9a2a;
}

.tg-stat__label {
  font-weight: 500;
  opacity: 0.9;
}

.tg-stat__val {
  font-weight: 700;
  color: #374151;
}

.tg-stat-foot {
  font-size: 11px;
  font-weight: 500;
  color: #9ca3af;
}

.tg-topbar__actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tg-coins {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-subtitle);
  white-space: nowrap;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 236, 179, 0.45), rgba(255, 236, 179, 0.2));
  border: 1px solid rgba(201, 162, 39, 0.25);
}

.tg-coins__val {
  color: #b8860b;
  font-weight: 600;
  line-height: 1;
}

.tg-coins__icon {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}

.tg-topbar__btn {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.tg-topbar__btn:active {
  transform: scale(0.98);
}

.tg-topbar__btn--primary {
  color: #fff;
  background: linear-gradient(135deg, #3b9aed, #2481cc);
  box-shadow: 0 2px 8px rgba(36, 129, 204, 0.35);
}

.tg-topbar__btn--primary:hover {
  filter: brightness(1.05);
}

.tg-topbar__btn--muted {
  color: #5d6d78;
  background: rgba(15, 20, 25, 0.06);
}

.tg-topbar__btn--muted:hover {
  color: var(--tg-primary);
  background: rgba(51, 144, 236, 0.1);
}

.tg-bubbles {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 16px 12px;
  scroll-behavior: smooth;
}

.tg-date {
  display: flex;
  justify-content: center;
  margin: 12px 0 8px;
}

.tg-date span {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 10px;
  border-radius: 12px;
  user-select: none;
}

.tg-msg {
  display: flex;
  margin-bottom: 2px;
  max-width: 100%;
}

.tg-msg--out {
  justify-content: flex-end;
}

.tg-msg--in {
  justify-content: flex-start;
  align-items: flex-end;
  gap: 8px;
}

.tg-msg__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  margin-bottom: 2px;
  visibility: hidden;
}

.tg-msg--in.tg-msg--show-avatar .tg-msg__avatar {
  visibility: visible;
}

.tg-msg__avatar--spacer {
  visibility: hidden !important;
}

.tg-bubble-col {
  max-width: min(var(--tg-bubble-max), 85%);
  display: flex;
  flex-direction: column;
}

.tg-msg--out .tg-bubble-col {
  align-items: flex-end;
}

.tg-author {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  margin: 0 0 2px 4px;
  padding-top: 4px;
}

.tg-author--admin {
  color: #d32f2f;
  font-weight: 600;
}

.tg-author--mod {
  border: none;
  background: none;
  padding: 0;
  margin: 0 0 2px 4px;
  padding-top: 4px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  text-align: left;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.tg-author--mod:hover {
  opacity: 0.85;
}

.tg-system {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 24px 10px;
  text-align: center;
}

.tg-system__text {
  max-width: 92%;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 500;
  color: #4b5563;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--mk-radius-md);
  padding: 10px 14px;
  box-shadow: var(--mk-shadow-soft);
}

.tg-system__meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--tg-subtitle);
}

.mod-modal[hidden] {
  display: none !important;
}

.mod-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.mod-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.mod-modal__card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--mk-radius-md);
  padding: 20px 18px 18px;
  box-shadow: var(--mk-shadow-notice);
}

.mod-modal__hint {
  margin: -4px 0 14px;
  font-size: 12px;
  line-height: 1.4;
  color: #9ca3af;
}

.mod-modal__title {
  margin: 0 0 6px;
  font-size: 18px;
}

.mod-modal__user {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--tg-subtitle);
}

.mod-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mod-label {
  font-size: 12px;
  color: #5d6d78;
}

.mod-input {
  font: inherit;
  padding: 9px 10px;
  border: 1px solid #d5dbe0;
  border-radius: 8px;
}

.mod-textarea {
  resize: vertical;
  min-height: 72px;
}

.mod-error {
  margin: 0;
  font-size: 13px;
  color: #c0392b;
}

.mod-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.mod-btn {
  font: inherit;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  color: #fff;
  background: var(--tg-primary);
}

.mod-btn--ghost {
  color: var(--tg-primary);
  background: transparent;
  border: 1px solid #c8dcef;
}

.tg-bubble {
  position: relative;
  padding: 6px 9px 5px 9px;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.01em;
  word-wrap: break-word;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

.tg-msg--in .tg-bubble {
  background: var(--tg-in-bg);
  color: var(--tg-text);
  border-radius: 12px 12px 12px 0;
}

.tg-msg--out .tg-bubble {
  background: var(--tg-out-bg);
  color: var(--tg-text);
  border-radius: 12px 12px 0 12px;
}

.tg-msg--in.tg-msg--grouped .tg-bubble {
  border-radius: 0 12px 12px 0;
}

.tg-msg--in.tg-msg--grouped.tg-msg--group-end .tg-bubble {
  border-radius: 0 12px 12px 12px;
}

.tg-msg--out.tg-msg--grouped .tg-bubble {
  border-radius: 12px 0 0 12px;
}

.tg-msg--out.tg-msg--grouped.tg-msg--group-end .tg-bubble {
  border-radius: 12px 0 12px 12px;
}

.tg-text {
  white-space: pre-wrap;
  display: inline;
}

.tg-meta {
  float: right;
  margin: 6px 0 -4px 12px;
  font-size: 12px;
  line-height: 1;
  color: var(--tg-time);
  user-select: none;
  position: relative;
  top: 4px;
}

.tg-msg--out .tg-meta {
  color: rgba(0, 0, 0, 0.45);
}

.tg-views {
  white-space: nowrap;
}

.tg-attach {
  margin-top: 4px;
}

.tg-attach img {
  max-width: 100%;
  border-radius: 6px;
  display: block;
}

.tg-attach a {
  color: var(--tg-primary);
  text-decoration: none;
  font-size: 15px;
}

.tg-composer {
  flex-shrink: 0;
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  background: var(--tg-in-bg);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 2;
}

.tg-composer__plate {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-height: var(--tg-composer-min);
}

.tg-icon-btn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  color: #8b959e;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tg-icon-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}

.tg-input-wrap {
  flex: 1;
  background: #f0f0f0;
  border-radius: 22px;
  padding: 9px 14px;
  min-height: 44px;
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}

.tg-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font: 16px/1.3125 var(--tg-font);
  max-height: 150px;
  background: transparent;
}

.tg-input::placeholder {
  color: #a2acb4;
}

.tg-send-btn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #8b959e;
  transition: background 0.15s, color 0.15s;
}

.tg-send-btn--active {
  background: var(--tg-primary);
  color: #fff;
}

.tg-send-btn--active:hover {
  background: var(--tg-primary-dark);
}

.composer__pending {
  font-size: 13px;
  color: var(--tg-subtitle);
  padding: 0 16px 6px;
  background: var(--tg-in-bg);
}

.mk-notice {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(var(--tg-composer-min) + 16px);
  z-index: 6;
  padding: 12px 16px;
  border-radius: var(--mk-radius-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
  box-shadow: var(--mk-shadow-notice);
}

.mk-notice[hidden] {
  display: none !important;
}

.mk-notice--visible {
  opacity: 1;
  transform: translateY(0);
}

.mk-notice--draft {
  z-index: 5;
  color: #f8fafc;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.94), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.mk-notice--queue {
  color: #0f172a;
  background: linear-gradient(135deg, #e8f4ff, #f0f9ff);
  border: 1px solid rgba(51, 144, 236, 0.25);
}

.mk-notice__title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.mk-notice__desc {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  opacity: 0.92;
}

.mk-notice__desc strong {
  font-weight: 700;
  font-size: 15px;
}

.tg-legal-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px 8px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  color: #9ca3af;
  background: linear-gradient(180deg, #fff, #fafbfc);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.tg-legal-bar__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  min-width: 0;
}

.tg-legal-bar__links a {
  color: #5d6d78;
  text-decoration: none;
}

.tg-legal-bar__links a:hover {
  color: var(--tg-primary);
  text-decoration: underline;
}

.tg-legal-bar__sep {
  opacity: 0.45;
  user-select: none;
}

.tg-legal-bar__op {
  flex-shrink: 0;
  text-align: right;
  font-size: 10px;
  opacity: 0.85;
  max-width: 42%;
}

.easter-hit {
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}

.cookie-banner {
  position: fixed;
  right: 10px;
  bottom: 10px;
  left: auto;
  z-index: 30;
  max-width: min(280px, calc(100vw - 20px));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.95);
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.92));
  border-radius: var(--mk-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--mk-shadow-soft);
}

.cookie-banner[hidden] {
  display: none !important;
}

.cookie-banner__text {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.cookie-banner__text a {
  color: #9ecfff;
}

.cookie-banner__btn {
  flex-shrink: 0;
  border: none;
  border-radius: 5px;
  padding: 3px 8px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  color: #fff;
  background: var(--tg-primary);
}

.cookie-banner__btn:hover {
  background: var(--tg-primary-dark);
}

body.mk-scroll-lock {
  overflow: hidden;
}

.mk-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.mk-overlay[hidden] {
  display: none !important;
}

.mk-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.mk-overlay__card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  max-height: min(92vh, 640px);
  overflow: auto;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 20px;
  padding: 28px 24px 24px;
  box-shadow: var(--mk-shadow-notice);
  border: 1px solid rgba(255, 255, 255, 0.85);
}

.mk-overlay__title {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.mk-overlay__close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  color: #6b7280;
  background: rgba(0, 0, 0, 0.05);
  cursor: pointer;
}

.mk-overlay__close:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #374151;
}

.mk-overlay--sheet {
  align-items: flex-end;
  padding: 0;
}

.mk-overlay__sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 920px;
  max-height: 92vh;
  overflow: auto;
  margin: 0 auto;
  background: linear-gradient(180deg, #eef2f7 0%, #e8ecf1 100%);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 40px rgba(15, 30, 60, 0.2);
}

.mk-overlay--sheet .mk-overlay__close {
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.9);
}

.mk-overlay__card--auth .login-card__brand {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tg-primary);
}

.mk-overlay__card--auth .login-card__sub {
  margin: 0 0 24px;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
  color: var(--tg-subtitle);
}

.mk-overlay__card--auth .login-max-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: 14px;
  padding: 15px 18px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  background: linear-gradient(135deg, #7b61ff 0%, #5b8def 50%, #3390ec 100%);
  box-shadow: 0 8px 24px rgba(91, 141, 239, 0.35);
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.mk-overlay__card--auth .login-max-btn:hover {
  filter: brightness(1.04);
}

.mk-overlay__card--auth .login-max-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.mk-overlay__card--auth .login-hint {
  margin: 18px 0 0;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  color: #1d4ed8;
  background: rgba(51, 144, 236, 0.08);
  border-radius: 12px;
  border: 1px solid rgba(51, 144, 236, 0.15);
}

.mk-overlay__card--auth .login-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.08);
  border-radius: 10px;
}

.mk-overlay__card--auth .login-legal-note {
  margin: 18px 0 0;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 500;
  color: #9ca3af;
}

.mk-overlay__card--auth .login-legal-note a {
  color: var(--tg-primary);
  text-decoration: none;
}

@media (max-width: 640px) {
  .tg-shell {
    background-size: 360px;
  }

  .mk-overlay--sheet .mk-overlay__sheet {
    max-height: 96vh;
    border-radius: 12px 12px 0 0;
  }

  .tg-legal-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .tg-legal-bar__op {
    max-width: none;
    text-align: left;
  }
}
