:root {
  --page: #eef2f6;
  --panel: #ffffff;
  --text: #10151c;
  --muted: #718096;
  --line: #dfe6ef;
  --line-strong: #cfd8e3;
  --green: #55c411;
  --green-dark: #319000;
  --green-soft: #f2faed;
  --green-panel: #f5fcef;
  --shadow: 0 20px 60px rgba(16,24,40,.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
body.chat-mode { overflow: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.shell { width: min(1180px, calc(100vw - 28px)); margin: 0 auto; padding: 22px 0; }
body.chat-mode .shell { width: 100vw; max-width: none; height: 100dvh; margin: 0; padding: 0; }
.frame { display: none; }
.frame.is-active { display: block; }

.hero { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 28px; background: #fff; box-shadow: var(--shadow); }
.heroGrid { position: absolute; inset: 0; background: radial-gradient(circle at 90% 12%, rgba(85,196,17,.18), transparent 22%), radial-gradient(circle at 18% 82%, rgba(85,196,17,.10), transparent 22%); pointer-events: none; }
.heroInner { position: relative; padding: clamp(28px,5vw,54px); }
.heroBrandImage { width: min(360px, 76vw); height: auto; margin-bottom: 24px; }
.step { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid #cfe8c0; background: #f6fbf2; color: #45683d; font-size: 13px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
h1 {
  max-width: 1040px;
  margin: 18px 0 14px;
  font-size: clamp(36px, 5.25vw, 68px);
  line-height: .94;
  letter-spacing: -.045em;
  text-transform: uppercase;
}
.heroSloganStrip {
  width: min(620px, 78vw);
  height: auto;
  margin: 4px 0 22px;
  object-fit: contain;
}
.subtitle { max-width: 680px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.6; }
.homeInline { margin-top: 28px; width: min(680px, 100%); padding: 22px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.88); }
.homeInline h2 { margin: 0 0 8px; font-size: 26px; }
.hint { color: var(--muted); line-height: 1.6; margin: 0; }
.actions2 { display: flex; gap: 14px; margin-top: 18px; }
button[type="submit"], .actions2 button, #sendMessageButton { min-height: 54px; padding: 0 22px; border: 0; border-radius: 16px; background: linear-gradient(180deg,#74d92b,#53bf10); color: #fff; font-weight: 800; box-shadow: 0 12px 26px rgba(85,196,17,.24); }
.actions2 .secondary, .mini, .composerIcon, .composerMic, .searchBlock button, .dialogActions button { background: #fff; color: #344054; border: 1px solid var(--line); box-shadow: none; }
.flow { padding-top: 16px; }
.panel { width: min(720px,100%); margin: 0 auto; padding: 28px; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.panel h2 { margin: 12px 0 8px; font-size: 30px; }
label { display: block; margin: 18px 0 8px; font-size: 14px; font-weight: 700; }
input:not([type="checkbox"]):not([type="file"]), .phoneField, .searchBlock, .composer input, .modalCard input[type="file"] { width: 100%; min-height: 56px; border: 1px solid var(--line); border-radius: 16px; background: #fff; color: var(--text); outline: none; padding: 0 16px; }
input::placeholder { color: #9ba8ba; }
input:focus, .phoneField:focus-within, .searchBlock:focus-within, .composer input:focus { border-color: rgba(85,196,17,.75); box-shadow: 0 0 0 4px rgba(85,196,17,.13); }
.phoneField { display: grid; grid-template-columns: 54px 1fr; padding: 0; overflow: hidden; }
.phoneField span { display: grid; place-items: center; border-right: 1px solid var(--line); color: #657386; background: #fafcff; }
.phoneField input, .searchBlock input, .composer input { min-height: 54px; border: 0 !important; box-shadow: none !important; padding: 0; }
.result { margin-top: 18px; padding: 14px 16px; border-radius: 16px; background: #101820; color: #d9f99d; overflow: auto; font-size: 13px; }
.mini { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 14px; border-radius: 12px; font-weight: 700; }
.qrBox { margin-top: 18px; padding: 20px; border: 1px dashed var(--line-strong); border-radius: 20px; background: #fafcff; }
.qr { width: min(280px,100%); margin: 0 auto 16px; }
.otpauth { display: inline-block; color: var(--green-dark); font-weight: 700; margin-top: 10px; }
.manualSecret { margin-top: 12px; color: var(--muted); font-size: 14px; word-break: break-all; }

body.chat-mode #chatFrame { position: fixed; inset: 0; z-index: 10; width: 100vw; height: 100dvh; display: block; padding: 0; }
.chatFrame { padding: 0; }
.messenger { width: 100vw; height: 100dvh; min-height: 100dvh; display: grid; grid-template-columns: 390px minmax(0,1fr); background: #fff; overflow: hidden; border: 0; border-radius: 0; box-shadow: none; }
.chatSidebar { min-width: 0; min-height: 0; overflow: hidden; display: grid; grid-template-rows: auto auto auto auto auto auto auto minmax(0,1fr) auto; gap: 16px; align-content: start; padding: 22px; background: #fff; border-right: 1px solid var(--line); }
.sidebarBrand { display: flex; align-items: center; height: 82px; overflow: hidden; }
.sidebarBrand img { width: 215px; height: auto; object-fit: contain; }
.sidebarHeading { display: flex; align-items: center; justify-content: space-between; font-size: 24px; font-weight: 800; letter-spacing: -.03em; }
.sidebarHeading span { color: #8a96a8; font-size: 17px; }
.profileBadge { width: 100%; min-height: 82px; display: grid; grid-template-columns: 56px 1fr 26px; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: #fff; text-align: left; }
.avatarButton, .avatar.small, .activeAvatar, .messageAvatar { display: grid; place-items: center; width: 52px; height: 52px; flex: 0 0 auto; border-radius: 50%; border: 1px solid #d4edbd; background: linear-gradient(180deg,#eefbe4,#d8f3bd); color: #438f13; font-weight: 800; overflow: hidden; }
.avatar.small, .activeAvatar { width: 44px; height: 44px; font-size: 18px; }
#profileAvatarImg { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.profileText { min-width: 0; }
.profileText strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; }
.profileText small { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.profileMenu { color: #8793a5; font-size: 26px; text-align: center; }
.searchBlock { display: grid; grid-template-columns: 24px 1fr 44px; align-items: center; gap: 10px; padding: 0 8px 0 14px; }
.searchIcon { color: #98a5b7; font-size: 20px; }
.searchBlock button, .dialogActions button, .composerIcon, .composerMic { width: 42px; min-width: 42px; min-height: 42px; border-radius: 14px; }
.chatTabs { display: flex; align-items: center; gap: 12px; }
.chatTabs button { border: 0; background: transparent; padding: 0 0 11px; border-bottom: 2px solid transparent; color: #8793a5; font-weight: 800; }
.chatTabs button.is-active { color: var(--text); border-color: var(--green); }
.chatTabs b { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--green); color: #fff; font-size: 12px; }
.favoriteContact, .contactItem { width: 100%; min-width: 0; display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px; padding: 14px; border: 1px solid transparent; border-radius: 18px; background: transparent; text-align: left; }
.favoriteContact { align-self: start; }
.favoriteContact:hover, .contactItem:hover { background: #fafcff; }
.favoriteContact.is-selected, .contactItem.is-selected { background: var(--green-panel); border-color: #caeaae; box-shadow: inset 0 0 0 1px rgba(85,196,17,.12); }
.sectionTitle { align-self: start; margin: 2px 0 0; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
.contactList { min-height: 0; overflow: auto; display: grid; align-content: start; gap: 4px; padding-right: 2px; }
.contactMain { min-width: 0; }
.contactMain strong { display: flex; align-items: center; gap: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.contactMain small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.contactShield { color: var(--green); }
.contactMeta { display: grid; gap: 7px; justify-items: end; color: #97a3b4; font-size: 13px; }
.unreadBadge { display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 8px; border-radius: 999px; background: var(--green); color: #fff; font-size: 12px; font-weight: 800; }
.contactEmpty { padding: 10px 2px; color: var(--muted); font-size: 14px; }
.sidebarFooter .mini { width: 100%; min-height: 54px; border-radius: 16px; }

.dialogPane { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto auto; background: linear-gradient(180deg,#fff,#fbfcfd); }
.dialogHeader { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 14px; padding: 22px 28px; border-bottom: 1px solid var(--line); background: #fff; }
.backButton { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.dialogTitleBlock { min-width: 0; }
.dialogTitleBlock h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 20px; }
.dialogTitleBlock p { margin: 4px 0 0; color: var(--muted); }
.dialogActions { display: flex; gap: 10px; }
.messages { min-height: 0; overflow: auto; padding: 26px 26px 10px; background: radial-gradient(circle at 86% 8%, rgba(85,196,17,.08), transparent 15%), linear-gradient(180deg,#fff,#fbfcfd); }
.encryptionBanner { width: min(620px,100%); display: flex; align-items: center; gap: 12px; margin: 0 auto 22px; padding: 14px 18px; border: 1px solid #dcebd0; border-radius: 16px; background: #f8fcf4; color: #53626d; }
.encryptionBanner img { width: 28px; height: 28px; object-fit: contain; }
.encryptionBanner p { margin: 0; }
.emptyState { display: grid; place-items: center; min-height: 260px; color: var(--muted); }
.chatError { margin: 0 26px 12px; padding: 12px 16px; border: 1px solid #fdc9bf; border-radius: 14px; background: #fff4f3; color: #c2410c; }
.messageRow { display: flex; gap: 12px; max-width: 76%; margin: 16px 0; }
.messageRow.incoming { margin-right: auto; }
.messageRow.outgoing { margin-left: auto; justify-content: flex-end; }
.messageAvatar { width: 40px; height: 40px; font-size: 15px; }
.messageBubble { position: relative; min-width: 180px; max-width: 100%; padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: 0 8px 24px rgba(15,23,42,.04); }
.messageRow.outgoing .messageBubble { background: var(--green-panel); border-color: #caeaae; }
.messageQuote { display: block; width: 100%; margin: 0 0 10px; padding: 10px 12px; border: 0; border-left: 3px solid var(--green); border-radius: 12px; background: rgba(85,196,17,.08); text-align: left; }
.messageQuote strong { display: block; margin-bottom: 4px; font-size: 13px; }
.messageQuote span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.messageBubble > div:first-of-type { white-space: pre-wrap; line-height: 1.55; }
.messageMeta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.replyAction { position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: #8994a4; }
.messageBubble:hover .replyAction { border-color: var(--line); background: rgba(255,255,255,.9); }
.messageStatus { display: inline-flex; align-items: center; }
.receiptSvg { width: 24px; height: 14px; }
.receiptSvg .check { stroke-width: 2.15; }
.messageStatus.sent .main { stroke: #9aa4b2; }
.messageStatus.delivered .main, .messageStatus.delivered .back { stroke: var(--green); }
.messageStatus.read .main, .messageStatus.read .back { stroke: #38a5ff; }
.is-flashed { animation: flashMessage .9s ease; }
@keyframes flashMessage { 50% { box-shadow: 0 0 0 10px rgba(85,196,17,.18); } }
.composer { display: grid; grid-template-columns: 52px 1fr 52px 58px; align-items: center; gap: 12px; padding: 16px 22px; border-top: 1px solid var(--line); background: #fff; }
.replyPreview { grid-column: 1/-1; display: grid; grid-template-columns: 22px 1fr 28px; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #dcebd0; border-radius: 14px; background: #f6faef; }
.replyMark { color: var(--green); font-size: 18px; }
.replyPreview strong { display: block; font-size: 13px; }
.replyPreview small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
#cancelReply { border: 0; background: transparent; color: #8994a4; font-size: 18px; }
.composerFoot { grid-column: 1/-1; color: var(--muted); font-size: 13px; padding-left: 4px; }
#sendMessageButton { min-height: 52px; padding: 0; border-radius: 16px; }

.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(15,23,42,.38); backdrop-filter: blur(6px); }
.modalCard { max-height: min(92dvh,960px); overflow: auto; margin: 0; }
.checkRow { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.checkRow input { width: 18px; height: 18px; }
.metrikaInformerLink { position: fixed; right: 12px; bottom: 10px; z-index: 5; opacity: .75; }
body.chat-mode .metrikaInformerLink { display: none; }

@media (max-width: 1180px) { .messenger { grid-template-columns: 340px minmax(0,1fr); } .messageRow { max-width: 88%; } .dialogHeader, .messages { padding-left: 20px; padding-right: 20px; } }
@media (max-width: 980px) {
  .shell { width: calc(100vw - 16px); padding: 8px 0 16px; }
  body.chat-mode .shell { width: 100vw; padding: 0; }
  .heroInner { padding: 22px 20px; }
  .panel, .homeInline { width: 100%; }
  .panel { padding: 22px; }
  .messenger { grid-template-columns: 1fr; width: 100vw; height: 100dvh; min-height: 100dvh; }
  .chatSidebar { border-right: 0; padding: 18px 14px; grid-template-rows: auto auto auto auto auto auto auto minmax(0,1fr) auto; }
  .dialogPane { display: none; }
  body.dialog-open .chatSidebar { display: none; }
  body.dialog-open .dialogPane { display: grid; }
  .backButton { display: inline-grid; place-items: center; }
}
@media (max-width: 540px) {
  h1 { font-size: clamp(28px,10vw,40px); }
  .subtitle { font-size: 15px; }
  .actions2 { display: grid; grid-template-columns: 1fr; }
  .sidebarBrand { height: 68px; }
  .sidebarBrand img { width: 178px; }
  .dialogHeader { grid-template-columns: auto auto 1fr; }
  .dialogActions { display: none; }
  .messages { padding: 16px 14px 8px; }
  .messageRow { max-width: 96%; }
  .composer { grid-template-columns: 46px 1fr 54px; gap: 8px; padding: 10px 12px 14px; }
  .composerMic { display: none; }
  .composerIcon { width: 46px; min-height: 48px; }
  .modal { align-items: stretch; padding: 0; }
  .modalCard { width: 100%; min-height: 100dvh; max-height: none; border-radius: 0; }
}


/* DARK 1.0.23 auth-flow layout: login/registration fully replace the home page */
body.auth-mode {
  min-height: 100dvh;
  background: linear-gradient(180deg, #f5f7fa 0%, #edf2f7 100%);
}
body.auth-mode .shell {
  width: min(760px, calc(100vw - 32px));
  min-height: 100dvh;
  display: grid;
  align-items: center;
  margin: 0 auto;
  padding: clamp(18px, 4vw, 48px) 0;
}
body.auth-mode .flow {
  width: 100%;
  padding: 0;
}
body.auth-mode .panel.frame.is-active {
  display: block;
  width: 100%;
  margin: 0 auto;
}
.authLogo {
  display: flex;
  justify-content: center;
  margin-bottom: 26px;
}
.darkWordmark.authMark {
  grid-template-columns: 44px auto;
  gap: 12px;
  transform-origin: center;
}
.darkWordmark.authMark .darkEmblem {
  width: 44px;
  height: 44px;
}
.darkWordmark.authMark .darkWord strong {
  font-size: clamp(40px, 10vw, 54px);
  line-height: .74;
}
.darkWordmark.authMark .darkWord small {
  margin-top: 9px;
  font-size: clamp(9px, 2.3vw, 11px);
  letter-spacing: .36em;
}
body.auth-mode .panel .mini {
  margin-bottom: 22px;
}
.panel button[type="submit"] {
  width: 100%;
  margin-top: 22px;
}
#loginForm button[type="submit"],
#totpVerifyForm button[type="submit"],
#confirmTotpInlineButton,
#createTotpQrButton {
  width: 100%;
  margin-top: 24px;
}
#loginTotpCode {
  margin-bottom: 2px;
}
#totpSetupForm .qrBox button[type="submit"] {
  width: 100%;
}

@media (max-width: 540px) {
  body.auth-mode .shell {
    width: calc(100vw - 20px);
    padding: 12px 0;
    align-items: start;
  }
  body.auth-mode .panel.frame.is-active {
    min-height: calc(100dvh - 24px);
  }
  .authLogo {
    margin-bottom: 22px;
  }
}

/* DARK 1.0.23 main page slogan composition */
.hero .step { display: none; }
.hero .subtitle { margin-top: 0; }
@media (max-width: 640px) {
  .heroSloganStrip { width: min(100%, 520px); margin-bottom: 18px; }
  .hero h1 { font-size: clamp(30px, 9.6vw, 44px); }
}
