@font-face { font-family: Montserrat; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/fonts/montserrat-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Montserrat; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/fonts/montserrat-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #0F1115; --bar: #15181D; --surface: #171A20; --surface-2: #1C2027; --line: #23272F; --line-2: #343A46;
  --text: #ECEEF2; --text-2: #C5CBD6; --muted: #9AA3B2;
  --accent: #6EE7B7; --accent-ink: #0B1F18; --accent-bg: #1D3A32; --accent-text: #EAFBF4;
  --warn: #F5C26B; --warn-bg: #2E2613; --danger: #FF9A9A;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 Montserrat, system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
#app { height: 100dvh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 6px 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { display: inline-flex; flex: none; }

/* buttons */
.btn { min-height: 52px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent; font-size: 16px; font-weight: 600; background: transparent; width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #8AF0C8; }
.btn.ghost { border-color: var(--line-2); }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { border-color: #5A2F33; color: var(--danger); }
.btn.danger:hover { background: #241517; }
.btn.small { min-height: 44px; width: auto; padding: 0 16px; font-size: 14px; border-color: var(--line-2); border-radius: 12px; }
.btn.small:hover { background: var(--surface-2); }
.btn.link { min-height: 44px; width: auto; padding: 0 4px; color: var(--accent); font-size: 14px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.icon-btn { flex: none; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--surface-2); }

/* first screens */
.auth { flex: 1; overflow-y: auto; width: 100%; max-width: 440px; margin: 0 auto; padding: max(48px, 10vh) 28px 32px; display: flex; flex-direction: column; gap: 26px; }
.auth-mark { flex: none; width: 72px; height: 72px; border-radius: 22px; background: var(--accent-bg); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.auth-head { display: flex; flex-direction: column; gap: 10px; }
.auth-head p { color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
input[type=text], input[type=password] { height: 54px; width: 100%; border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); font-size: 17px; padding: 0 16px; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.pin-input { letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.hint, .fineprint { font-size: 13px; line-height: 1.55; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; font-weight: 500; }
.error:empty { display: none; }

/* layout */
.app { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 360px) 1fr; }
.sidebar, .pane { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.sidebar { border-right: 1px solid var(--line); }
.bar { flex: none; display: flex; align-items: center; gap: 8px; min-height: 72px; padding: 12px 12px 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--bar); border-bottom: 1px solid var(--line); }
.bar-title { flex: 1; font-size: 17px; font-weight: 600; }
.back { display: none; margin-left: -8px; }
.banner { flex: none; padding: 10px 16px; background: var(--warn-bg); color: var(--warn); font-size: 13px; font-weight: 500; }
.placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 32px; text-align: center; color: var(--muted); }
@media (max-width: 759px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; }
  .app .pane { display: none; }
  .app.pane-open .pane { display: flex; }
  .app.pane-open .sidebar { display: none; }
  .back { display: flex; }
}

/* contact list */
.contacts { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.contact { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 0; border-radius: 14px; background: transparent; text-align: left; }
.contact:hover { background: var(--surface); }
.contact.active { background: var(--surface-2); }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-bg); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; }
.contact-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.contact-top, .contact-bottom { display: flex; align-items: center; gap: 8px; }
.contact-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-time { flex: none; font-size: 12px; color: var(--muted); }
.contact-preview { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.empty-list { padding: 32px 16px; display: flex; flex-direction: column; gap: 16px; text-align: center; color: var(--muted); }

/* chat */
.chat-head { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.chat-title { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-name { font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-status { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--accent); }
.chat-status.unverified { color: var(--warn); }
.warning { flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--warn-bg); color: var(--warn); font-size: 13px; line-height: 1.45; }
.warning span { flex: 1; }
.warning .btn { color: var(--warn); border-color: #6B5A2C; flex: none; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.notice { align-self: center; display: flex; align-items: center; gap: 6px; background: var(--surface); color: var(--muted); font-size: 12px; padding: 7px 12px; border-radius: 999px; text-align: center; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.more { align-self: center; }
.day { align-self: center; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.msg { max-width: min(78%, 560px); display: flex; flex-direction: column; gap: 4px; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 10px 14px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.in .bubble { background: var(--surface-2); border-radius: 18px 18px 18px 4px; }
.msg.out .bubble { background: var(--accent-bg); color: var(--accent-text); border-radius: 18px 18px 4px 18px; }
.meta { font-size: 12px; color: var(--muted); }
.msg.failed .meta { color: var(--danger); }
.composer { flex: none; display: flex; align-items: flex-end; gap: 10px; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: var(--bar); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; min-width: 0; min-height: 48px; max-height: 140px; resize: none; border: 1px solid #2A2F39; border-radius: 24px; background: var(--bg); font-size: 16px; line-height: 1.4; padding: 12px 18px; }
.send { flex: none; width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; }
.send:hover { background: #8AF0C8; }

/* secondary panes */
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 28px 32px; display: flex; flex-direction: column; gap: 20px; width: 100%; max-width: 560px; }
.lead { color: var(--text-2); line-height: 1.55; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.card { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid #2A2F39; border-radius: 16px; padding: 16px; }
.card-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; word-break: break-all; user-select: all; }
.pin { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 34px; font-weight: 600; letter-spacing: 0.12em; color: var(--accent); user-select: all; }
.safety { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 19px; font-weight: 600; letter-spacing: 0.06em; }
.safety span { text-align: center; padding: 12px 0; background: var(--surface); border-radius: 10px; }
.info { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border-radius: 14px; padding: 14px 16px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.info .icon { color: var(--accent); margin-top: 1px; }
.ok { color: var(--accent); font-weight: 500; }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100% - 32px); background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; padding: 12px 18px; border-radius: 12px; z-index: 10; }
@media (prefers-reduced-motion: no-preference) { .btn, .icon-btn, .contact, .send { transition: background-color 0.12s; } }
