:root {
  color-scheme: dark;
  --ink: #edf5f7;
  --muted: #8fa7b3;
  --canvas: #071a2c;
  --panel: #0d2744;
  --panel-raised: #123257;
  --line: #1c4a63;
  --teal: #2fd4d0;
  --blue: #2196f3;
  --coral: #e39b76;
  --danger: #ff838b;
  --radius: 16px;
  font-family: "Segoe UI Variable", "Aptos", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; background: var(--canvas); color: var(--ink); }
body { min-height: 100vh; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.auth-layout { --auth-accent: #5ce1d1; position: relative; isolation: isolate; overflow: hidden; min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 0.92fr) minmax(440px, 1.08fr); background: #081722; }
.auth-aside { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 38px clamp(30px, 6vw, 92px); background: linear-gradient(145deg, #102b3b 0%, #0b202e 58%, #0a1c29 100%); border-right: 1px solid rgba(92,225,209,.14); animation: auth-rise .8s cubic-bezier(.2,.7,.2,1) both; }
.auth-aside::before { content: ""; position: absolute; inset: 0; opacity: .42; background: repeating-linear-gradient(145deg, transparent 0 62px, rgba(92,225,209,.055) 63px 64px, transparent 65px 126px); pointer-events: none; }
.auth-aside::after { content: ""; position: absolute; width: min(42vw, 520px); aspect-ratio: 1; right: -28%; bottom: -18%; border-radius: 50%; background: radial-gradient(circle, rgba(92,225,209,.12), rgba(92,225,209,.035) 38%, transparent 70%); filter: blur(8px); pointer-events: none; }
.brand-lockup { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); font-size: 21px; font-weight: 700; }
.brand-lockup img { width: 35px; height: 35px; object-fit: contain; }
.auth-copy { position: relative; z-index: 1; max-width: 430px; margin: auto 0; padding: 70px 0; }
.auth-layout .eyebrow { margin: 0 0 12px; color: var(--auth-accent); font-size: 11px; font-weight: 700; letter-spacing: 1.6px; }
.auth-copy h1 { margin: 0; font-family: "Segoe UI Variable", "Aptos", sans-serif; font-size: clamp(42px, 5vw, 66px); line-height: 1.08; font-weight: 600; letter-spacing: -.045em; text-wrap: balance; }
.auth-copy > p:last-child { max-width: 350px; margin-top: 22px; line-height: 1.75; color: #a8bbc3; }
.signal-art { position: relative; height: 70px; border-top: 1px solid rgba(92,225,209,.18); }
.signal-art::before, .signal-art::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--teal), transparent); transform: rotate(-3deg); }
.signal-art::before { top: 28px; }
.signal-art::after { top: 42px; opacity: .45; }
.signal-art i { position: absolute; top: 18px; width: 5px; height: 5px; background: var(--coral); border-radius: 50%; }
.signal-art i:nth-child(1) { left: 23%; }.signal-art i:nth-child(2) { left: 61%; top: 38px; }.signal-art i:nth-child(3) { left: 84%; }
.signal-art b { position: absolute; right: 14%; top: 23px; width: 18px; height: 18px; border: 1px solid var(--teal); border-radius: 50%; }
.auth-main { position: relative; display: grid; place-items: center; padding: 32px; background: radial-gradient(ellipse at 82% 14%, rgba(42,117,128,.12), transparent 42%), linear-gradient(140deg, #091824, #0b1d2a 60%, #102433); }
.auth-card { position: relative; width: min(100%, 430px); padding: 38px; background: linear-gradient(145deg, rgba(16,37,51,.96), rgba(10,27,40,.97)); border: 1px solid rgba(92,225,209,.18); border-radius: 20px; box-shadow: 0 30px 90px rgba(0,0,0,.38), 0 0 44px rgba(92,225,209,.045); animation: auth-rise .8s .08s cubic-bezier(.2,.7,.2,1) both; transition: border-color .3s ease, box-shadow .3s ease; }
.auth-card:hover { border-color: rgba(92,225,209,.28); box-shadow: 0 34px 100px rgba(0,0,0,.42), 0 0 52px rgba(92,225,209,.07); }
.mobile-brand { display: none; margin-bottom: 30px; }
.auth-heading { margin-bottom: 32px; }
.auth-heading h2 { margin: 0; font-size: 28px; font-weight: 650; letter-spacing: -.025em; }
.auth-heading .muted { margin: 10px 0 0; font-size: 14px; line-height: 1.6; }
.auth-card .form-stack { display: grid; gap: 20px; }
.auth-card .form-stack label { display: grid; gap: 9px; color: #d0dde1; font-size: 13px; font-weight: 550; }
.auth-card .form-stack input { width: 100%; min-height: 48px; color: var(--ink); background: rgba(5,20,30,.72); border: 1px solid #244555; border-radius: 10px; padding: 13px 15px; transition: border-color .22s ease, background-color .22s ease, box-shadow .22s ease, transform .22s ease; }
.auth-card .form-stack input::placeholder { color: #708691; }
.auth-card .form-stack input:hover { border-color: #356071; }
.auth-card .form-stack input:focus { outline: none; border-color: var(--auth-accent); background: rgba(7,25,36,.96); box-shadow: 0 0 0 3px rgba(92,225,209,.09), 0 0 22px rgba(92,225,209,.14); }
.auth-card .password-field { display: flex; }
.auth-card .password-field input { min-width: 0; }
.auth-card .primary-button, .auth-card .secondary-button { min-height: 48px; border-radius: 10px; transition: background-color .22s ease, box-shadow .22s ease, transform .22s ease, border-color .22s ease; }
.auth-card .primary-button { background: linear-gradient(105deg, #5ce1d1, #72e8da); color: #071a23; box-shadow: 0 6px 22px rgba(92,225,209,.16); }
.auth-card .primary-button:not(:disabled):hover { background: #79eddf; box-shadow: 0 8px 28px rgba(92,225,209,.3), 0 0 18px rgba(92,225,209,.18); transform: translateY(-1px); }
.auth-card .secondary-button { border: 1px solid rgba(92,225,209,.2); background: rgba(92,225,209,.08); color: var(--auth-accent); }
.auth-card .secondary-button:not(:disabled):hover { border-color: rgba(92,225,209,.4); background: rgba(92,225,209,.13); box-shadow: 0 0 18px rgba(92,225,209,.1); }
.auth-card .text-button { transition: color .2s ease, text-shadow .2s ease; }
.auth-card .text-button:hover { color: #9af4e9; text-shadow: 0 0 16px rgba(92,225,209,.28); }
.auth-card button:focus-visible { outline-color: var(--auth-accent); outline-offset: 3px; }
.primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
.text-button { border: 0; padding: 8px 0; background: transparent; color: var(--teal); text-align: center; }
.auth-switch { width: 100%; margin-top: 18px; }
.notice { min-height: 20px; margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.notice.error { color: var(--danger); }.notice.success { color: var(--teal); }
.legal-note { margin: 30px 0 0; color: #718995; font-size: 11px; line-height: 1.5; }
@keyframes auth-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .auth-aside, .auth-card { animation: none; } .auth-card, .auth-card * { scroll-behavior: auto; transition-duration: .01ms !important; } }


.app-shell { display: flex; flex-direction: column; gap: 14px; width: 100%; height: 100vh; padding: 18px; }
.workspace { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--panel); border-radius: 24px; }
.workspace::after { content: ""; position: absolute; inset: auto 0 0; height: 36px; pointer-events: none; background: radial-gradient(ellipse at 50% 100%, rgba(47,212,208,.18), transparent 70%); }
.page { height: 100%; overflow: auto; padding: 42px 42px 48px; }
.page h1 { margin: 0 0 6px; font-size: 26px; }
.muted.small { font-size: 12px; } .center { text-align: center; margin-top: 60px; }
.chats-page.active-page { display: flex; padding: 0; }
.chat-list-pane { display: flex; flex-direction: column; width: min(340px, 36%); padding: 26px 20px; border-right: 1px solid var(--line); }
.pane-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.pane-header h1 { margin: 0; font-size: 21px; }
.round-button { display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--panel-raised); color: var(--ink); cursor: pointer; }
.round-button.big { width: 52px; height: 52px; } .round-button:disabled { opacity: .6; cursor: default; }
.search-box { display: flex; margin-bottom: 14px; background: var(--panel-raised); border-radius: 12px; }
.search-box input { width: 100%; padding: 10px 12px; color: var(--ink); background: transparent; border: 0; outline: 0; }
.search-box.pill { background: transparent; border: 1px solid var(--teal); border-radius: 999px; }
.conversation-list { flex: 1; min-height: 0; overflow: auto; }
.empty-list { display: grid; justify-items: center; gap: 8px; padding: 40px 10px; color: var(--muted); }
.empty-mark { font-size: 30px; }
.chat-pane { display: flex; flex: 1; min-width: 0; flex-direction: column; padding: 26px 22px; }
.chat-head { padding: 16px 20px; background: var(--panel-raised); border-radius: 14px; }
.chat-head h2 { margin: 0; font-size: 17px; }
.chat-body { flex: 1; padding: 20px; }
.composer { display: flex; align-items: center; gap: 10px; }
.composer input { flex: 1; padding: 12px 16px; color: var(--ink); background: var(--panel-raised); border: 1px solid var(--teal); border-radius: 999px; }
.tab-row { display: flex; gap: 10px; margin: 22px 0 16px; }
.tab { flex: 1; padding: 12px; color: var(--ink); background: var(--panel-raised); border: 1px solid transparent; border-radius: 12px; cursor: pointer; }
.tab.active { border-color: var(--teal); }
.content-state { padding: 30px 0; color: var(--muted); } .content-state h2 { color: var(--ink); font-size: 17px; }
.settings-list { display: grid; margin-top: 18px; }
.setting-row { display: flex; align-items: center; gap: 16px; padding: 12px 10px; color: var(--ink); text-align: left; background: transparent; border: 0; cursor: pointer; }
.setting-row:hover { background: rgba(255,255,255,.03); border-radius: 12px; }
.setting-row span:nth-child(2) { display: grid; flex: 1; gap: 3px; } .setting-row small { color: var(--muted); font-size: 12px; } .setting-row i { color: var(--muted); font-style: normal; }
.setting-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--panel-raised); }
.profile-head { display: flex; align-items: center; gap: 20px; margin-bottom: 8px; }
.profile-head > div:nth-child(2) { flex: 1; min-width: 0; } .profile-head h1 { overflow-wrap: anywhere; }
.profile-head .eyebrow { margin: 0 0 4px; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--blue); font-weight: 700; }
.avatar.big { width: 86px; height: 86px; font-size: 30px; background: var(--panel-raised); }
.primary-button.wide { width: 100%; min-height: 52px; border-radius: 999px; background: var(--blue); }
.primary-button:disabled { opacity: .75; cursor: default; }
.tabbar { display: flex; gap: 8px; padding: 8px; background: var(--panel); border-radius: 24px; }
.nav-item { display: grid; flex: 1; justify-items: center; gap: 3px; padding: 10px 6px; color: var(--ink); font-size: 12px; background: transparent; border: 1px solid transparent; border-radius: 18px; cursor: pointer; }
.nav-item span { font-size: 18px; } .nav-item.active { background: var(--panel-raised); border-color: var(--teal); }
.toast { position: absolute; right: 22px; bottom: 22px; z-index: 2; max-width: 320px; padding: 12px 16px; background: var(--panel-raised); border: 1px solid var(--teal); border-radius: 12px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; }
.toast.visible { opacity: 1; transform: none; }
@media (max-width: 760px) {
  .app-shell { padding: 10px; } .page { padding: 24px 16px 40px; }
  .chat-list-pane { width: 100%; border-right: 0; } .chat-pane { display: none; }
  .profile-head { flex-wrap: wrap; }
  .auth-layout { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-main { min-height: 100vh; padding: 22px; }
  .auth-card { width: min(100%, 460px); padding: 30px; }
  .auth-card .mobile-brand { display: inline-flex; margin-bottom: 34px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

@media (max-width: 420px) { .auth-main { padding: 14px; } .auth-card { padding: 24px 20px; border-radius: 16px; } }

.password-field { position: relative; display: block; }
.password-field input { padding-right: 92px; }
.toggle-password { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); border: 0; padding: 6px 8px; background: transparent; color: var(--teal); font-size: 12px; cursor: pointer; }
#resendCode:disabled { opacity: .6; cursor: not-allowed; }

.setting-row.danger strong { color: var(--danger); }
.person-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; margin-bottom: 8px; background: var(--panel-raised); border-radius: 14px; color: var(--ink); }
.content-state p { margin: 0; }

/* Текст интерфейса не выделяется и не показывает курсор ввода; поля ввода работают как обычно */
body { -webkit-user-select: none; user-select: none; caret-color: transparent; }
input, textarea { -webkit-user-select: text; user-select: text; caret-color: auto; }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
#accountAvatar { cursor: pointer; }
.posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 18px; }
.post-card { position: relative; margin: 0; overflow: hidden; background: var(--panel-raised); border-radius: 14px; }
.post-card img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.post-card figcaption { padding: 10px 12px; font-size: 13px; overflow-wrap: anywhere; }
.post-delete { position: absolute; top: 8px; right: 8px; padding: 5px 10px; border: 0; border-radius: 999px; background: rgba(7,26,44,.8); color: var(--ink); font-size: 12px; cursor: pointer; }
.modal { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(4,12,22,.78); }
.modal-card { display: grid; gap: 14px; width: min(380px, 100%); max-height: 100%; overflow: auto; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; }
.modal-card h2 { margin: 0; font-size: 18px; }
.modal-card canvas { width: 100%; height: auto; border-radius: 14px; touch-action: none; cursor: grab; }
.zoom-row { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.modal-actions { display: flex; gap: 10px; } .modal-actions button { flex: 1; min-height: 44px; }
.post-preview { width: 100%; max-height: 320px; object-fit: contain; border-radius: 12px; background: #071a2c; }
.modal-card input[type="text"] { padding: 12px 14px; color: var(--ink); background: var(--panel-raised); border: 1px solid var(--line); border-radius: 12px; }

.back-link { margin-bottom: 8px; text-align: left; }
.settings-panel { display: grid; gap: 14px; max-width: 640px; }
.settings-panel h1 { margin: 0 0 4px; } .settings-panel h2 { margin: 8px 0 0; font-size: 16px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; background: var(--panel-raised); border-radius: 14px; cursor: pointer; }
.toggle-row span { display: grid; gap: 3px; } .toggle-row small { color: var(--muted); font-size: 12px; }
.switch { appearance: none; flex: 0 0 auto; width: 46px; height: 26px; margin: 0; border-radius: 999px; background: #36506a; position: relative; cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch:checked { background: var(--teal); } .switch:checked::after { transform: translateX(20px); }
.choice-list { display: flex; flex-wrap: wrap; gap: 10px; }
.choice { padding: 12px 20px; color: var(--ink); background: var(--panel-raised); border: 1px solid transparent; border-radius: 12px; cursor: pointer; }
.choice.active { border-color: var(--teal); }
.swatches { display: flex; gap: 12px; } .swatch { width: 38px; height: 38px; border: 2px solid transparent; border-radius: 50%; cursor: pointer; }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--panel); }
.panel-block { display: grid; gap: 10px; padding: 16px; background: var(--panel-raised); border-radius: 16px; }
.panel-block h2 { margin: 0; } .panel-block p { margin: 0; }
.danger-zone { border: 1px solid rgba(255,131,139,.4); }
.danger-button { background: var(--danger); color: #1a0b0d; }
.setting-icon { display: grid; place-items: center; font-size: 18px; }
.nav-item b { font-weight: 400; }
.compact .setting-row, .compact .person-row, .compact .toggle-row { padding-top: 6px; padding-bottom: 6px; }
:root[data-theme="midnight"] { --canvas: #05070f; --panel: #0b1022; --panel-raised: #141b35; --line: #232c52; }
:root[data-theme="graphite"] { --canvas: #121416; --panel: #1b1e21; --panel-raised: #272b30; --line: #3a4047; }

/* Профиль, меню, чат */
.person-row { cursor: pointer; } .person-row:hover { filter: brightness(1.12); }
.icon-btn { width: 40px; height: 40px; color: var(--ink); background: var(--panel-raised); border: 1px solid var(--line); border-radius: 50%; font-size: 18px; cursor: pointer; }
.menu-wrap { position: relative; }
.popup-menu { position: absolute; right: 0; top: 46px; z-index: 6; display: grid; min-width: 200px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.popup-menu button { padding: 11px 12px; text-align: left; color: var(--ink); background: none; border: 0; border-radius: 10px; cursor: pointer; font: inherit; }
.popup-menu button:hover { background: var(--panel-raised); } .popup-menu .danger { color: #ff7b7b; }
.profile-card { justify-items: center; } .profile-card h2 { overflow-wrap: anywhere; text-align: center; }
.card-top { display: flex; justify-content: space-between; width: 100%; }
.card-actions { display: grid; gap: 8px; width: 100%; } .card-actions button { min-height: 44px; } .card-actions button:disabled { opacity: .45; cursor: not-allowed; }
.field-col { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.modal-card textarea, .modal-card input[type="date"] { padding: 12px 14px; color: var(--ink); background: var(--panel-raised); border: 1px solid var(--line); border-radius: 12px; font: inherit; resize: vertical; }
.chat-head { display: flex; align-items: center; gap: 10px; }
.chat-body { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 0; }
.bubble { max-width: 75%; padding: 9px 13px; border-radius: 16px; background: var(--panel-raised); overflow-wrap: anywhere; white-space: pre-wrap; user-select: text; }
.bubble.mine { align-self: flex-end; background: var(--blue); }
.bubble small { display: block; margin-top: 3px; font-size: 11px; opacity: .65; }
.conv-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 6px; width: 100%; color: var(--ink); text-align: left; background: var(--panel-raised); border: 0; border-radius: 14px; cursor: pointer; font: inherit; }
.conv-row.active { outline: 1px solid var(--teal); }
.conv-row > span:last-child { min-width: 0; display: grid; } .conv-row small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 761px) { .chat-back { display: none !important; } }
@media (max-width: 760px) { .chats-page.chat-open .chat-list-pane { display: none; } .chats-page.chat-open .chat-pane { display: flex; } }
