:root { color-scheme: light; font: 16px/1.5 "Segoe UI", system-ui, sans-serif; color: #202a23; background: #f2f3ed; --ink: #202a23; --muted: #58665d; --line: #e0e6df; --accent: #274d39; --hover: #edf2eb; --canvas: #e8eee3; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; display: grid; place-items: center; padding: clamp(16px, 5vw, 56px); }
.access { width: min(100%, 450px); background: #fff; border: 1px solid #d8ded4; border-radius: 16px; padding: clamp(22px, 5vw, 42px); }
.access header { display: flex; align-items: center; gap: 12px; font-weight: 650; }
.access header img { display: block; border-radius: 12px; }
h1, h2 { line-height: 1.14; letter-spacing: -.025em; }
h1 { margin: 30px 0 12px; font-size: clamp(1.65rem, 5vw, 2.1rem); }
h2 { margin: 20px 0 10px; font-size: 1.25rem; }
p { margin: 0 0 20px; color: #46574a; }
label { display: block; margin: 0 0 16px; font-weight: 560; }
input, button { width: 100%; min-height: 46px; font: inherit; border-radius: 8px; }
input { display: block; padding: 9px 12px; margin-top: 5px; color: #202a23; background: #fff; border: 1px solid #89998a; }
button { background: #274d39; border: 1px solid #274d39; color: #fff; padding: 9px 14px; font-weight: 650; cursor: pointer; }
button:hover { background: #1e3d2c; }
button:disabled { opacity: .52; cursor: default; }
button.secondary { color: #274d39; background: #fff; }
button.secondary:hover { background: #eaf0e7; }
:focus-visible { outline: 3px solid #4d7b59; outline-offset: 3px; }
output { display: block; margin: 0 0 22px; padding: 12px; text-align: center; border-radius: 8px; background: #eaf0e7; font-size: 1.75rem; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
#notice { margin: 14px 0 0; }
#notice[data-error] { color: #942a23; }
#notice:empty, #link-status:empty, #linked-history:empty { display: none; }
#start-link { margin: 4px 0 8px; }
#start-link[hidden] + #scan-hint { display: none; }
#scan-hint { font-size: .9rem; }
#login { border-top: 1px solid #d8ded4; padding-top: 18px; }
#login > p { margin-bottom: 12px; }
#link-image { display: block; margin: 0 auto 12px; max-width: 100%; height: auto; }
#link-code { margin-bottom: 8px; }
.link-actions { display: grid; gap: 12px; margin-bottom: 18px; }
.link-actions a { color: #274d39; justify-self: center; }
#link-status { margin: 14px 0 0; }
.access:has(#device-link:not([hidden]))>h1 { display: none; }
#link-instructions p { font-size: 14px; }
#legacy-history { padding: 0; list-style: none; overflow-wrap: anywhere; }
#legacy-history li { border-top: 1px solid var(--line); padding-top: 12px; }
#legacy-history p { white-space: pre-wrap; }
#legacy-chat-filter select { width: 100%; padding: 10px; font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
body.linked-session { display: block; padding: 0; height: 100dvh; min-height: 0; overflow: hidden; }
.messenger { display: grid; grid-template-rows: 64px minmax(0, 1fr); width: 100%; height: 100dvh; background: #fff; font-size: 14px; }
.messenger:has(#linked-copy-notice:not([hidden])) { grid-template-rows: 64px auto minmax(0, 1fr); }
.linked-copy-notice { padding: 8px 20px; color: var(--muted); background: #f1f4ee; font-size: 12px; }
.draft-recovery { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; }
#linked-history .draft-explanation { margin-top: 6px; color: var(--muted); font-size: 12px; }
.messenger p { margin: 0; color: inherit; }
.messenger button { width: auto; margin: 0; min-height: 40px; color: var(--ink); background: transparent; border: 0; border-radius: 9px; font-weight: 500; }
.messenger button:hover { background: var(--hover); }
.messenger a { color: var(--accent); text-decoration: none; }
.app-bar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.app-brand { display: flex; align-items: center; gap: 11px; font-size: 17px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.app-brand img { border-radius: 9px; }
.app-nav { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-nav .nav-link { display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.nav-link svg { width: 16px; height: 16px; }
.app-nav .nav-link:hover { color: var(--accent); background: var(--hover); border-radius: 8px; }
.account-button { display: flex; align-items: center; gap: 9px; padding: 4px 8px !important; max-width: 240px; }
.account-button>span:not(.avatar) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-button svg { width: 16px; height: 16px; color: var(--muted); }
#linked-request-count { display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; }
.messenger-body { display: grid; grid-template-columns: 336px minmax(0, 1fr); min-height: 0; }
.chat-sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); background: #fff; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 22px 20px 12px; }
.sidebar-heading h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.025em; }
.messenger .icon-button { display: inline-grid; place-items: center; width: 40px; min-width: 40px; height: 40px; padding: 8px; }
.chat-search { display: flex; align-items: center; gap: 9px; min-height: 44px; margin: 0 18px 18px; padding: 0 12px; border-radius: 10px; background: #f1f4f0; color: var(--muted); }
.chat-search svg { width: 18px; height: 18px; }
.chat-search input { width: 100%; min-width: 0; min-height: 42px; margin: 0; padding: 0; border: 0; background: transparent; font-size: 14px; font-weight: 400; outline-offset: 6px; }
input::placeholder, textarea::placeholder { color: #66736a; opacity: 1; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 12px; }
.messenger .chat-row { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 12px; width: 100%; padding: 14px 10px; text-align: left; border-radius: 10px; }
.chat-row[aria-current="true"] { background: #e8efe4; }
.chat-row-body { min-width: 0; }
.chat-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.chat-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 650; }
.chat-row-time { flex: none; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chat-row-preview { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.avatar { display: inline-grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 50%; color: #365047; background: #dfeadb; font-weight: 650; font-size: 17px; user-select: none; }
.avatar[data-tone="1"] { color: #35576a; background: #e0edf3; }
.avatar[data-tone="2"] { color: #635044; background: #eee6dc; }
.avatar-small { width: 30px; height: 30px; font-size: 12px; }
.avatar-large { width: 76px; height: 76px; font-size: 25px; }
.sidebar-footer { display: flex; flex-direction: column; gap: 4px; padding: 16px 22px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.45; }
.sync-state { display: flex; align-items: center; gap: 7px; }
.sync-state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #5e7a60; }
.sync-state[data-offline="true"]::before { background: #ac713f; }
.list-empty { flex: 1; padding: 26px 22px; text-align: center; color: var(--muted); }
.conversation { display: grid; grid-template-rows: 74px minmax(0, 1fr) auto; min-width: 0; min-height: 0; background: var(--canvas); }
.conversation-header { display: flex; align-items: center; gap: 12px; padding: 0 28px; border-bottom: 1px solid var(--line); background: #fff; }
.peer-summary { display: flex; flex: 1; align-items: center; gap: 12px; min-width: 0; padding: 0 !important; text-align: left; }
.peer-summary:hover { background: transparent !important; }
.peer-heading { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.peer-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 650; }
.peer-heading>span { color: var(--muted); font-size: 12px; }
.thread-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 28px 34px; }
#linked-history { display: flex; flex-direction: column; gap: 10px; max-width: 900px; margin: 0 auto; padding: 0; list-style: none; }
#linked-history li { position: relative; align-self: flex-start; max-width: min(78%, 660px); min-width: 90px; padding: 12px 15px 8px; border-radius: 14px 14px 14px 4px; background: #fff; overflow-wrap: anywhere; }
#linked-history li[data-outgoing="true"] { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: #dceece; }
#linked-history li>strong { display: none; }
#linked-history li.has-message-actions { padding-right: 38px; }
#linked-history p { margin: 0; white-space: pre-wrap; font-size: 15px; line-height: 1.55; color: var(--ink); }
.linked-message-meta { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 4px; color: #5c6b5b; font-size: 11px; font-variant-numeric: tabular-nums; }
.linked-message-meta time { white-space: nowrap; }
.linked-message-meta [aria-label="Просмотрено"] { color: #326a8a; }
#linked-history li[data-status="deletion_pending"] { color: #556052; background: #dce0d9; }
.messenger .message-menu-trigger { position: absolute; top: 3px; right: 4px; width: 28px; min-width: 28px; height: 28px; min-height: 28px; padding: 5px; border-radius: 7px; color: #4d6152; background: inherit; opacity: 0; }
.message-menu-trigger svg { width: 18px; height: 18px; }
#linked-history li:hover .message-menu-trigger, #linked-history li:focus-within .message-menu-trigger { opacity: 1; }
.messenger .linked-file-button { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; max-width: 100%; margin-top: 8px; padding: 8px 12px; border-radius: 8px; color: var(--accent); background: #eef3e9; font-size: 13px; font-weight: 600; }
.linked-media { display: block; max-width: 100%; max-height: 360px; border-radius: 8px; }
.conversation-footer { padding: 12px 34px 14px; }
.composer { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: end; gap: 8px; max-width: 900px; margin: 0 auto; padding: 8px; border-radius: 15px; background: #fff; }
.compose-field { min-width: 0; margin: 0; font-weight: 400; }
.composer textarea { display: block; width: 100%; min-height: 40px; max-height: 160px; field-sizing: content; margin: 0; padding: 9px 8px; border: 0; outline-offset: 2px; background: transparent; color: var(--ink); font: inherit; font-size: 15px; line-height: 1.5; resize: none; }
.messenger .send-button { color: #fff; background: var(--accent); border-radius: 11px; }
.messenger .send-button:hover { background: #1d3b2b; }
.composer-status { display: flex; justify-content: space-between; gap: 12px; min-height: 23px; max-width: 900px; margin: 7px auto 0; padding: 0 4px; color: #53614f; font-size: 11px; }
#linked-command-status:empty { display: none; }
#linked-compose-note { margin-left: auto; white-space: nowrap; }
.thread-empty { display: grid; place-content: center; justify-items: center; min-height: 100%; padding: 20px; text-align: center; color: #52634f; }
.thread-empty svg { width: 46px; height: 46px; margin-bottom: 14px; stroke-width: 1.3; }
.thread-empty h2 { margin: 0 0 8px; font-size: 21px; font-weight: 600; }
.thread-empty p { max-width: 280px; font-size: 14px; }
.messenger .text-button, .text-button { width: auto; min-height: 40px; padding: 8px 0; border: 0; color: var(--accent); background: transparent; font-size: 14px; font-weight: 600; }
.text-button:hover { background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.mobile-back { display: none !important; }
.context-menu { inset: auto; position: fixed; width: 225px; max-width: calc(100vw - 24px); margin: 0; padding: 6px; border: 0; border-radius: 12px; background: #fff; color: var(--ink); box-shadow: 0 8px 30px #17251e2b; }
.context-menu button { display: block; width: 100%; min-height: 42px; padding: 10px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; font-size: 14px; font-weight: 500; }
.context-menu button:hover { background: var(--hover); }
.danger-text { color: #a43b36 !important; }
dialog { width: min(100% - 32px, 440px); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 26px; color: var(--ink); background: #fff; border: 0; border-radius: 16px; box-shadow: 0 12px 48px #13271d38; }
dialog::backdrop { background: #1c302665; }
dialog h2 { margin: 0; font-size: 21px; }
dialog p { color: var(--muted); font-size: 14px; }
dialog input, dialog select { display: block; width: 100%; min-height: 44px; margin-top: 6px; padding: 10px 12px; border: 1px solid #94a08f; border-radius: 8px; color: var(--ink); background: #fff; font: inherit; }
dialog label { font-size: 14px; }
dialog form>button { margin-top: 4px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog-heading .icon-button { display: grid; place-items: center; width: 34px; min-height: 34px; padding: 6px; border: 0; color: var(--muted); background: transparent; }
.contact-card { display: grid; justify-items: center; gap: 12px; padding: 0 0 24px; font-size: 20px; }
#linked-key-details { margin: 0 0 22px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 14px; }
#linked-key-details summary { cursor: pointer; font-weight: 600; }
.fingerprint { margin: 12px 0 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#linked-delete-dialog p { margin: 16px 0; }
#linked-delete-dialog button { margin-top: 10px; }
#linked-requests .request-row { padding: 16px 0; border-top: 1px solid var(--line); }
#linked-requests .request-row strong { display: block; margin-bottom: 8px; }
#linked-requests .request-row button { margin-top: 8px; }
::selection { color: #fff; background: var(--accent); }
input, textarea { caret-color: var(--accent); }
.chat-list, .thread-scroll { scrollbar-width: thin; scrollbar-color: #aab6a6 transparent; }
@media (max-width: 1000px) { .messenger-body { grid-template-columns: 300px minmax(0, 1fr); } .app-bar { padding: 0 18px; } .account-button { max-width: 170px; } .thread-scroll, .conversation-footer { padding-left: 22px; padding-right: 22px; } }
@media (max-width: 760px) {
  .messenger { grid-template-rows: 56px minmax(0, 1fr); }
  .messenger:has(#linked-copy-notice:not([hidden])) { grid-template-rows: 56px auto minmax(0, 1fr); }
  .app-bar { padding: 0 14px; gap: 12px; }
  .app-brand { gap: 8px; font-size: 16px; }
  .app-brand img { width: 30px; height: 30px; }
  .app-nav { gap: 2px; }
  .app-nav .nav-link { padding: 8px; font-size: 13px; }
  .app-nav .nav-link svg { display: none; }
  .account-button>span:not(.avatar), .account-button>svg { display: none; }
  .account-button { max-width: 40px; padding: 3px !important; }
  .messenger-body { display: block; }
  .chat-sidebar, .conversation { height: 100%; }
  .chat-sidebar { border: 0; }
  .messenger[data-view="thread"] .chat-sidebar, .messenger[data-view="list"] .conversation { display: none; }
  .mobile-back { display: inline-grid !important; }
  .conversation { grid-template-rows: 66px minmax(0, 1fr) auto; }
  .conversation-header { gap: 8px; padding: 0 10px; }
  .conversation-header .avatar { width: 38px; height: 38px; font-size: 14px; }
  .peer-summary { gap: 9px; }
  .peer-heading strong { font-size: 15px; }
  .thread-scroll { padding: 18px 12px; }
  #linked-history { gap: 9px; }
  #linked-history li { max-width: 87%; padding: 10px 13px 7px; }
  #linked-history p { font-size: 14px; }
  .messenger .message-menu-trigger { top: 0; right: 0; width: 44px; height: 44px; min-height: 44px; opacity: 1; }
  #linked-history li.has-message-actions { padding-right: 44px; }
  .conversation-footer { padding: 8px 10px 7px; }
  .composer { gap: 3px; padding: 5px; }
  .composer textarea { font-size: 16px; }
  .composer-status { flex-wrap: wrap; gap: 4px; padding: 0 6px; font-size: 10px; }
  #linked-command-status { width: 100%; }
  #linked-compose-note { margin: 0; }
}
@media (prefers-reduced-motion: no-preference) { .chat-row, .icon-button, .nav-link { transition: background-color 160ms ease-out; } }
