/* messenger.css — защищённый мессенджер в стиле Jungle Bubbles.
   Тёмно-зелёная «джунглевая» палитра, тёплое золото акцентом, крупные элементы. */

#ov-root {
  --bg: #0c1610;
  --bg-2: #0a130d;
  --panel: #13241a;
  --panel-2: #182c20;
  --line: #244430;
  --line-soft: #1c3626;
  --txt: #eaf3ec;
  --muted: #8fb39c;
  --gold: #ffd45e;
  --gold-deep: #f0b429;
  --leaf: #56c98a;
  --leaf-deep: #3aa06a;
  --me: #1d3b2a;
  --me-2: #204832;
  --them: #172a1e;
  --danger: #ef6b73;
  --ok: #57c98a;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.55);

  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--txt);
  background:
    radial-gradient(1200px 620px at 82% -12%, rgba(86, 201, 138, 0.10), transparent 60%),
    radial-gradient(1000px 560px at -8% 112%, rgba(255, 212, 94, 0.08), transparent 60%),
    var(--bg);
}
#ov-root.open { display: block; }
#ov-root * { box-sizing: border-box; }
#ov-root ::-webkit-scrollbar { width: 10px; height: 10px; }
#ov-root ::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }

/* ------------------------------ экран входа -------------------------- */
.ov-login { height: 100%; display: grid; place-items: center; padding: 24px; }
.ov-login-card {
  width: min(420px, 94vw);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 32px;
  box-shadow: var(--shadow);
}
.ov-lock {
  width: 58px; height: 58px; border-radius: 16px;
  display: grid; place-items: center; margin-bottom: 18px; font-size: 28px;
  background: radial-gradient(circle at 30% 25%, rgba(255, 212, 94, 0.25), rgba(86, 201, 138, 0.12));
  border: 1px solid rgba(255, 212, 94, 0.4);
}
.ov-login h2 { margin: 0 0 6px; font-size: 25px; font-weight: 800; letter-spacing: -0.01em; }
.ov-login p.sub { margin: 0 0 24px; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.ov-field { margin-bottom: 15px; }
.ov-field label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 7px; }
.ov-field input {
  width: 100%; padding: 14px 15px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--txt);
  font-size: 16px; outline: none;
}
.ov-field input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 212, 94, 0.16); }
.ov-btn {
  width: 100%; padding: 14px; border: 0; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #2a1c00;
  font-weight: 800; font-size: 16px; margin-top: 8px;
}
.ov-btn:active { transform: translateY(1px); }
.ov-btn:disabled { opacity: 0.6; cursor: default; }
.ov-btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 600; }
.ov-error { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 10px; }
.ov-hint { color: var(--muted); font-size: 12.5px; margin-top: 16px; line-height: 1.55; }

/* ------------------------------ приложение --------------------------- */
.ov-app { height: 100%; display: none; grid-template-columns: 340px 1fr; }
#ov-root.logged .ov-app { display: grid; }
#ov-root.logged .ov-login { display: none; }

.ov-side { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.ov-side-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.ov-avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 17px; color: #14251a; background: linear-gradient(150deg, var(--gold), var(--leaf)); flex: 0 0 auto; }
.ov-me { min-width: 0; }
.ov-me b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-me span { font-size: 12px; color: var(--ok); }
.ov-side-actions { margin-left: auto; display: flex; gap: 8px; }
.ov-icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); cursor: pointer; font-size: 17px; display: grid; place-items: center; }
.ov-icon-btn:hover { color: var(--txt); border-color: var(--gold); }

.ov-search { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.ov-search input {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--txt); font-size: 14.5px; outline: none;
}
.ov-search input:focus { border-color: var(--leaf); }

.ov-contacts { overflow-y: auto; flex: 1; min-height: 0; }
.ov-section-label { padding: 12px 18px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.ov-contact { display: flex; align-items: center; gap: 13px; padding: 13px 18px; cursor: pointer; border-bottom: 1px solid var(--line-soft); }
.ov-contact:hover { background: var(--panel-2); }
.ov-contact.active { background: var(--panel-2); box-shadow: inset 4px 0 0 var(--gold); }
.ov-c-av { position: relative; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 19px; color: #14251a; background: linear-gradient(150deg, var(--leaf), #7ad0a3); flex: 0 0 auto; }
.ov-dot { position: absolute; right: -1px; bottom: -1px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--panel); background: var(--muted); }
.ov-dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(87, 201, 138, 0.7); }
.ov-c-body { min-width: 0; flex: 1; }
.ov-c-body b { font-size: 15.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-c-body small { font-size: 13px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.ov-c-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.ov-c-time { font-size: 11px; color: var(--muted); }
.ov-badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--gold); color: #2a1c00; font-size: 12.5px; font-weight: 800; display: grid; place-items: center; }
.ov-search-hit { font-size: 12px; color: var(--gold); }

/* ----------------------------- окно чата ----------------------------- */
.ov-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.ov-chat-head { padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 13px; background: var(--panel); }
.ov-chat-head .ov-c-av { width: 40px; height: 40px; font-size: 16px; }
.ov-chat-title { min-width: 0; }
.ov-chat-title b { font-size: 16.5px; }
.ov-chat-title small { font-size: 12.5px; color: var(--muted); display: block; }
.ov-head-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ov-e2e { font-size: 12px; color: var(--leaf); border: 1px solid rgba(86, 201, 138, 0.35); border-radius: 20px; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
.ov-e2e:hover { background: rgba(86, 201, 138, 0.1); }

/* закреплённое сообщение */
.ov-pinned { display: none; align-items: center; gap: 10px; padding: 10px 20px; background: var(--panel-2); border-bottom: 1px solid var(--line); cursor: pointer; }
.ov-pinned.show { display: flex; }
.ov-pinned .ic { color: var(--gold); font-size: 16px; }
.ov-pinned .pin-body { min-width: 0; flex: 1; }
.ov-pinned .pin-body b { font-size: 12px; color: var(--gold); display: block; }
.ov-pinned .pin-body small { font-size: 13px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-pinned .pin-x { color: var(--muted); font-size: 18px; padding: 0 4px; }

.ov-scroll { flex: 1; overflow-y: auto; padding: 20px 20px 8px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.ov-empty { margin: auto; text-align: center; color: var(--muted); font-size: 15px; max-width: 340px; line-height: 1.65; }

/* разделитель дат */
.ov-date-sep { align-self: center; margin: 14px 0 8px; font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line-soft); padding: 5px 14px; border-radius: 14px; }

.ov-row { display: flex; margin-top: 4px; }
.ov-row.me { justify-content: flex-end; }
.ov-row.highlight .ov-bubble { animation: msgFlash 1.4s ease; }
@keyframes msgFlash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 3px var(--gold); } }
.ov-bubble { position: relative; max-width: 74%; padding: 11px 15px; border-radius: 18px; font-size: 15.5px; line-height: 1.5; word-wrap: break-word; white-space: pre-wrap; }
.ov-row.them .ov-bubble { background: var(--them); border-bottom-left-radius: 6px; }
.ov-row.me .ov-bubble { background: linear-gradient(160deg, var(--me-2), var(--me)); border-bottom-right-radius: 6px; }
.ov-bubble:hover .ov-actions { opacity: 1; }

/* цитата ответа внутри пузыря */
.ov-quote { border-left: 3px solid var(--gold); padding: 4px 10px; margin-bottom: 6px; background: rgba(255, 212, 94, 0.08); border-radius: 6px; cursor: pointer; }
.ov-quote b { font-size: 12.5px; color: var(--gold); display: block; }
.ov-quote small { font-size: 13px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ov-meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; font-size: 11.5px; color: var(--muted); justify-content: flex-end; }
.ov-check { font-size: 13px; }
.ov-check.read { color: var(--leaf); }

/* действия над сообщением (наведение) */
.ov-actions { position: absolute; top: -14px; opacity: 0; transition: opacity 0.15s; display: flex; gap: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 3px 5px; box-shadow: var(--shadow); z-index: 3; }
.ov-row.me .ov-actions { right: 4px; }
.ov-row.them .ov-actions { left: 4px; }
.ov-actions button { border: 0; background: transparent; cursor: pointer; font-size: 15px; padding: 3px 5px; border-radius: 12px; color: var(--muted); }
.ov-actions button:hover { background: var(--panel-2); color: var(--txt); }

/* реакции под пузырём */
.ov-reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.ov-reaction { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13.5px; cursor: pointer; }
.ov-reaction.mine { border-color: var(--gold); background: rgba(255, 212, 94, 0.14); }
.ov-reaction b { font-size: 12px; color: var(--muted); font-weight: 700; }

/* медиа */
.ov-img, .ov-video { max-width: 300px; max-height: 320px; border-radius: 12px; display: block; margin-bottom: 5px; cursor: pointer; }
.ov-video { cursor: default; }
.ov-file { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--txt); padding: 4px 2px; }
.ov-file .ic { font-size: 26px; }
.ov-file b { font-size: 14.5px; }
.ov-file small { color: var(--muted); font-size: 12.5px; }
.ov-voice { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.ov-voice audio { height: 38px; }

.ov-typing { font-size: 13px; color: var(--leaf); padding: 2px 20px 6px; height: 20px; }

/* панель ответа над вводом */
.ov-reply-bar { display: none; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel-2); border-top: 1px solid var(--line); }
.ov-reply-bar.show { display: flex; }
.ov-reply-bar .rb-body { flex: 1; min-width: 0; border-left: 3px solid var(--gold); padding-left: 10px; }
.ov-reply-bar .rb-body b { font-size: 12.5px; color: var(--gold); display: block; }
.ov-reply-bar .rb-body small { font-size: 13px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-reply-bar .rb-x { color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 4px; }

.ov-compose { padding: 14px 16px; border-top: 1px solid var(--line); background: var(--panel); display: flex; align-items: flex-end; gap: 11px; position: relative; }
.ov-compose textarea {
  flex: 1; resize: none; max-height: 140px; min-height: 48px; padding: 12px 15px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--bg-2); color: var(--txt);
  font-size: 15.5px; font-family: inherit; outline: none; line-height: 1.45;
}
.ov-compose textarea:focus { border-color: var(--gold); }
.ov-cbtn { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font-size: 20px; cursor: pointer; flex: 0 0 auto; display: grid; place-items: center; }
.ov-cbtn:hover { color: var(--txt); border-color: var(--gold); }
.ov-send { border: 0; background: linear-gradient(160deg, var(--gold), var(--gold-deep)); color: #2a1c00; }
.ov-send:disabled { opacity: 0.5; cursor: default; }
.ov-mic.recording { background: var(--danger); color: #fff; border-color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 107, 115, 0.5); } 50% { box-shadow: 0 0 0 8px rgba(239, 107, 115, 0); } }
.ov-rec-hint { position: absolute; bottom: 78px; left: 50%; transform: translateX(-50%); background: var(--danger); color: #fff; padding: 7px 16px; border-radius: 20px; font-size: 13.5px; display: none; }
.ov-rec-hint.show { display: block; }

/* лайтбокс изображений/видео */
.ov-lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.9); display: none; place-items: center; z-index: 100000; padding: 30px; }
.ov-lightbox.open { display: grid; }
.ov-lightbox img, .ov-lightbox video { max-width: 92vw; max-height: 88vh; border-radius: 10px; }
.ov-lightbox a.dl { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--gold); color: #2a1c00; text-decoration: none; font-weight: 700; padding: 10px 22px; border-radius: 22px; }

/* контекстное меню сообщения */
.ov-menu { position: fixed; z-index: 100001; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: var(--shadow); display: none; min-width: 190px; }
.ov-menu.show { display: block; }
.ov-menu button { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: var(--txt); font-size: 14.5px; padding: 10px 14px; border-radius: 8px; cursor: pointer; }
.ov-menu button:hover { background: var(--panel-2); }
.ov-menu button.danger { color: var(--danger); }
.ov-menu .sep { height: 1px; background: var(--line-soft); margin: 4px 0; }

/* всплывающий выбор реакций */
.ov-reactpick { position: fixed; z-index: 100001; background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 6px 8px; box-shadow: var(--shadow); display: none; gap: 2px; }
.ov-reactpick.show { display: flex; }
.ov-reactpick button { border: 0; background: transparent; font-size: 22px; cursor: pointer; padding: 4px 6px; border-radius: 50%; transition: transform 0.1s; }
.ov-reactpick button:hover { transform: scale(1.35); }

/* панель проверки ключа (safety number) */
.ov-modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: none; place-items: center; z-index: 100002; padding: 24px; }
.ov-modal-back.show { display: grid; }
.ov-modal { width: min(440px, 94vw); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px; box-shadow: var(--shadow); }
.ov-modal h3 { margin: 0 0 8px; font-size: 19px; }
.ov-modal p { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0 0 16px; }
.ov-safety { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 18px; letter-spacing: 2px; color: var(--gold); background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; word-spacing: 6px; line-height: 1.8; }

/* ------------------------------ мобильно ----------------------------- */
@media (max-width: 760px) {
  .ov-app { grid-template-columns: 1fr; }
  #ov-root.chat-open .ov-side { display: none; }
  #ov-root.chat-open .ov-chat { display: flex; }
  .ov-chat { display: none; }
  .ov-back { display: grid !important; }
  .ov-bubble { max-width: 84%; }
}
.ov-back { display: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--txt); cursor: pointer; place-items: center; font-size: 18px; }
