:root {
  --bg: #07100e;
  --bg-soft: #0a1512;
  --panel: #0d1b18;
  --panel-2: #11231e;
  --panel-3: #173029;
  --line: #203b34;
  --line-soft: rgba(142, 255, 201, .11);
  --text: #edf8f3;
  --muted: #91aaa1;
  --dim: #658178;
  --lime: #a8ff60;
  --mint: #48e3c2;
  --blue: #67a7ff;
  --warning: #f7c863;
  --danger: #ff7171;
  --shadow: 0 28px 80px rgba(0, 0, 0, .32);
  --radius: 18px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 9% 10%, rgba(72, 227, 194, .08), transparent 23rem),
    radial-gradient(circle at 92% 88%, rgba(168, 255, 96, .05), transparent 30rem),
    var(--bg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}
.hidden { display: none !important; }
.mono { font-family: var(--mono); }

.welcome {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.welcome-card {
  position: relative;
  width: min(1120px, 100%);
  min-height: min(720px, calc(100vh - 48px));
  display: grid;
  grid-template-columns: 1.06fr .94fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: rgba(13, 27, 24, .94);
  box-shadow: var(--shadow);
}
.welcome-copy { padding: clamp(36px, 7vw, 92px); display: flex; flex-direction: column; justify-content: center; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 740; letter-spacing: -.02em; }
.brand img { width: 42px; height: 42px; }
.brand small { color: var(--muted); font-weight: 500; }
.eyebrow { margin: 62px 0 16px; color: var(--lime); font: 700 12px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; }
.welcome h1 { max-width: 650px; margin: 0; font-size: clamp(42px, 6vw, 78px); line-height: .98; letter-spacing: -.065em; }
.welcome h1 span { color: var(--lime); }
.lead { max-width: 610px; margin: 26px 0 34px; color: var(--muted); font-size: 17px; line-height: 1.7; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.primary, .secondary, .ghost, .icon-button {
  border: 0;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, color .18s ease;
}
.primary:hover, .secondary:hover, .ghost:hover, .icon-button:hover { transform: translateY(-1px); }
.primary { min-height: 46px; padding: 0 20px; border-radius: 12px; color: #08110e; background: var(--lime); font-weight: 760; }
.secondary { min-height: 46px; padding: 0 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-weight: 680; }
.ghost { padding: 9px 11px; border-radius: 10px; background: transparent; color: var(--muted); }
.fineprint { margin-top: 28px; color: var(--dim); font-size: 12px; line-height: 1.6; }
.welcome-visual { position: relative; display: grid; place-items: center; min-height: 420px; border-left: 1px solid var(--line-soft); background: #091411; overflow: hidden; }
.welcome-visual::before { content: ""; position: absolute; inset: 0; opacity: .25; background-image: linear-gradient(var(--line-soft) 1px, transparent 1px), linear-gradient(90deg, var(--line-soft) 1px, transparent 1px); background-size: 34px 34px; mask-image: radial-gradient(circle, #000, transparent 75%); }
.orb { position: relative; width: min(330px, 68%); aspect-ratio: 1; border: 1px solid rgba(168, 255, 96, .28); border-radius: 50%; box-shadow: inset 0 0 100px rgba(72, 227, 194, .07), 0 0 110px rgba(72, 227, 194, .08); }
.orb::before, .orb::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(168,255,96,.18); }
.orb::before { inset: 13%; }
.orb::after { inset: 27%; background: url('/logo.svg') center/62% no-repeat; border-color: rgba(72,227,194,.35); }
.orbit-tag { position: absolute; z-index: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(13,27,24,.92); color: var(--muted); font: 600 11px/1 var(--mono); }
.orbit-tag.one { left: 8%; top: 23%; }
.orbit-tag.two { right: 8%; bottom: 26%; }
.orbit-tag.three { left: 14%; bottom: 13%; color: var(--lime); }

.shell { height: 100vh; display: grid; grid-template-columns: 76px minmax(264px, 330px) minmax(440px, 1fr) 310px; background: rgba(5, 12, 10, .88); }
.rail { z-index: 3; padding: 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; border-right: 1px solid var(--line); background: #081310; }
.rail-logo { width: 44px; height: 44px; margin: 2px 0 16px; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: transparent; color: var(--muted); }
.icon-button:hover, .icon-button.active { color: var(--lime); background: var(--panel-2); }
.icon-button svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-spacer { flex: 1; }
.profile-dot { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; background: linear-gradient(145deg, #2a5548, #173029); color: var(--lime); font-weight: 800; cursor: pointer; }

.sidebar { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--bg-soft); }
.sidebar-head { padding: 20px 18px 14px; }
.sidebar-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sidebar-title h2 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.new-chat { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--lime); cursor: pointer; font-size: 21px; }
.search { position: relative; }
.search input { width: 100%; height: 42px; padding: 0 38px 0 13px; border: 1px solid transparent; border-radius: 12px; color: var(--text); background: var(--panel); outline: none; }
.search input:focus { border-color: #315c50; }
.search kbd { position: absolute; right: 10px; top: 10px; padding: 3px 5px; border: 1px solid var(--line); border-radius: 5px; color: var(--dim); background: transparent; font: 10px var(--mono); }
.folders { display: flex; gap: 5px; padding: 0 18px 12px; overflow: auto; scrollbar-width: none; }
.folders button { padding: 7px 10px; border: 0; border-radius: 9px; color: var(--dim); background: transparent; cursor: pointer; white-space: nowrap; font-size: 12px; font-weight: 650; }
.folders button.active { color: var(--text); background: var(--panel-2); }
.chat-list { flex: 1; padding: 4px 9px 16px; overflow-y: auto; }
.chat-row { width: 100%; display: grid; grid-template-columns: 46px 1fr auto; gap: 11px; align-items: center; padding: 11px 10px; border: 0; border-radius: 14px; color: inherit; background: transparent; text-align: left; cursor: pointer; }
.chat-row:hover { background: rgba(17,35,30,.65); }
.chat-row.active { background: var(--panel-2); box-shadow: inset 2px 0 var(--lime); }
.avatar { position: relative; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; color: #dffcf2; background: var(--avatar, #27463d); font-weight: 780; }
.avatar.online::after { content: ""; position: absolute; width: 9px; height: 9px; right: -1px; bottom: -1px; border: 3px solid var(--bg-soft); border-radius: 50%; background: var(--lime); }
.chat-copy { min-width: 0; }
.chat-copy strong, .chat-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-copy strong { margin-bottom: 5px; font-size: 13px; }
.chat-copy span { color: var(--dim); font-size: 12px; }
.chat-meta { align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; color: var(--dim); font-size: 10px; }
.badge { min-width: 20px; height: 20px; display: grid; place-items: center; border-radius: 999px; color: #08110e; background: var(--lime); font-size: 10px; font-weight: 800; }

.conversation { min-width: 0; display: flex; flex-direction: column; background: #0a1412; }
.conversation-head { height: 74px; padding: 0 22px; display: flex; align-items: center; gap: 13px; border-bottom: 1px solid var(--line); background: rgba(10,20,18,.88); backdrop-filter: blur(18px); }
.mobile-back { display: none; }
.conversation-person { min-width: 0; flex: 1; }
.conversation-person strong { display: block; font-size: 14px; }
.conversation-person span { display: block; margin-top: 3px; color: var(--mint); font-size: 11px; }
.head-actions { display: flex; gap: 3px; }
.security-strip { min-height: 42px; padding: 8px 22px; display: flex; align-items: center; justify-content: center; gap: 8px; border-bottom: 1px solid var(--line-soft); color: var(--muted); background: rgba(72,227,194,.035); font-size: 11px; }
.security-strip > svg, .security-status > svg, .option strong > svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.security-strip b { color: var(--lime); }
.security-strip button { border: 0; color: var(--mint); background: transparent; cursor: pointer; }
.messages { flex: 1; padding: 26px clamp(18px, 5vw, 66px); overflow-y: auto; scroll-behavior: smooth; }
.date-separator { display: flex; align-items: center; gap: 12px; margin: 5px 0 24px; color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.date-separator::before, .date-separator::after { content: ""; height: 1px; flex: 1; background: var(--line-soft); }
.message { max-width: min(650px, 82%); margin: 7px 0; }
.message.mine { margin-left: auto; }
.bubble { position: relative; padding: 11px 14px 8px; border: 1px solid var(--line-soft); border-radius: 15px 15px 15px 5px; background: var(--panel-2); box-shadow: 0 8px 22px rgba(0,0,0,.1); }
.mine .bubble { border-color: rgba(168,255,96,.13); border-radius: 15px 15px 5px 15px; background: #173127; }
.bubble p { margin: 0; font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble footer { margin-top: 5px; display: flex; justify-content: flex-end; gap: 6px; color: var(--dim); font-size: 9px; }
.bubble footer .sent { color: var(--mint); }
.reply { margin-bottom: 8px; padding-left: 9px; border-left: 2px solid var(--mint); color: var(--muted); font-size: 11px; }
.system-message { max-width: 560px; margin: 18px auto; padding: 10px 13px; border: 1px solid rgba(247,200,99,.18); border-radius: 12px; color: #d8c79e; background: rgba(247,200,99,.05); text-align: center; font-size: 11px; line-height: 1.5; }
.composer-wrap { padding: 12px 20px 18px; }
.reply-preview { display: none; max-width: 840px; margin: 0 auto; padding: 9px 13px; border: 1px solid var(--line); border-bottom: 0; border-radius: 13px 13px 0 0; color: var(--muted); background: var(--panel); font-size: 11px; }
.composer { max-width: 840px; min-height: 54px; margin: 0 auto; padding: 7px 8px; display: flex; align-items: flex-end; gap: 6px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); box-shadow: 0 18px 50px rgba(0,0,0,.18); }
.composer textarea { flex: 1; max-height: 140px; min-height: 38px; padding: 9px 6px; resize: none; border: 0; outline: none; color: var(--text); background: transparent; line-height: 1.45; }
.composer textarea::placeholder { color: var(--dim); }
.composer .icon-button { width: 38px; height: 38px; flex: none; }
.send { width: 40px; height: 40px; border: 0; border-radius: 12px; color: #08110e; background: var(--lime); cursor: pointer; font-size: 18px; font-weight: 900; }
.composer-note { max-width: 840px; margin: 7px auto 0; color: var(--dim); font-size: 9px; text-align: center; }

.details { min-width: 0; overflow-y: auto; border-left: 1px solid var(--line); background: var(--bg-soft); }
.details-head { padding: 25px 20px 19px; border-bottom: 1px solid var(--line); }
.details-head .avatar { width: 70px; height: 70px; margin: 0 auto 14px; border-radius: 22px; font-size: 20px; }
.details-head h3 { margin: 0; text-align: center; font-size: 16px; }
.details-head p { margin: 6px 0 0; color: var(--muted); text-align: center; font-size: 11px; }
.detail-section { padding: 18px 18px; border-bottom: 1px solid var(--line-soft); }
.detail-label { margin: 0 0 13px; color: var(--dim); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.security-card { padding: 13px; border: 1px solid rgba(168,255,96,.16); border-radius: 13px; background: rgba(168,255,96,.035); }
.security-status { display: flex; align-items: center; gap: 8px; color: var(--lime); font-size: 12px; font-weight: 700; }
.fingerprint { margin: 11px 0 0; color: var(--muted); font: 10px/1.55 var(--mono); overflow-wrap: anywhere; }
.detail-row { width: 100%; padding: 10px 2px; display: flex; justify-content: space-between; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.detail-row span:last-child { color: var(--dim); }
.danger-row { color: var(--danger); }

.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(2,7,6,.76); backdrop-filter: blur(10px); }
.modal { width: min(520px, 100%); max-height: min(700px, calc(100vh - 40px)); overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); }
.modal.large { width: min(760px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.modal h2 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.modal .subtitle { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; }
.form-grid { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--muted); font-size: 11px; font-weight: 650; }
.field input { height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: var(--bg-soft); outline: none; }
.field input:focus { border-color: var(--mint); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.option-list { display: grid; gap: 8px; }
.option { padding: 13px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--bg-soft); }
.option strong { display: block; font-size: 12px; }
.option small { display: block; margin-top: 4px; color: var(--dim); line-height: 1.4; }
.toggle { position: relative; width: 38px; height: 22px; flex: none; border: 0; border-radius: 999px; background: #294139; cursor: pointer; }
.toggle::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: var(--muted); transition: .2s; }
.toggle.on { background: rgba(168,255,96,.28); }
.toggle.on::after { left: 19px; background: var(--lime); }
.tor-diagnostic { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.metric { padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--bg-soft); }
.metric strong { display: block; margin-bottom: 5px; color: var(--lime); font-size: 15px; }
.metric span { color: var(--dim); font-size: 10px; }
.notice { padding: 12px 14px; border: 1px solid rgba(247,200,99,.18); border-radius: 12px; color: #d7c9a6; background: rgba(247,200,99,.05); font-size: 11px; line-height: 1.55; }
.toast { position: fixed; z-index: 40; left: 50%; bottom: 24px; padding: 11px 15px; transform: translate(-50%, 20px); border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: #142721; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Network messenger */
.auth-card .register-field { display: none; }
.auth-card .register-mode .register-field { display: grid; }
.auth-tabs { display: flex; gap: 6px; margin: 24px 0 16px; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: var(--bg-soft); }
.auth-tabs button { flex: 1; padding: 10px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; }
.auth-tabs button.active { color: var(--text); background: var(--panel-2); box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.auth-submit { width: 100%; margin-top: 4px; }
.connection { display: block; margin-top: 4px; color: var(--dim); font-size: 10px; }
.connection::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #8d7964; }
.connection.online { color: var(--mint); }
.connection.online::before { background: var(--lime); box-shadow: 0 0 8px rgba(168,255,96,.5); }
.empty-list { padding: 34px 18px; display: grid; gap: 7px; color: var(--dim); text-align: center; font-size: 11px; line-height: 1.5; }
.empty-list strong { color: var(--muted); font-size: 13px; }
.empty-pane { grid-column: span 2; display: grid; place-items: center; text-align: center; }
.empty-pane > div { max-width: 330px; }
.empty-pane img { width: 74px; opacity: .75; }
.empty-pane h2 { margin: 18px 0 7px; font-size: 18px; }
.empty-pane p, .empty-conversation span { color: var(--dim); font-size: 12px; line-height: 1.6; }
.empty-conversation { min-height: 100%; display: grid; place-content: center; gap: 7px; text-align: center; }
.empty-conversation strong { font-size: 15px; }
.upload-preview { max-width: 840px; min-height: 0; margin: 0 auto 6px; color: var(--mint); font-size: 11px; }
.upload-preview:empty { display: none; }
.upload-preview button { margin-left: 7px; border: 0; color: var(--danger); background: transparent; cursor: pointer; }
.media-open { display: block; max-width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.message-image, .message-video { display: block; max-width: min(420px, 100%); max-height: 360px; margin-bottom: 8px; border-radius: 10px; object-fit: contain; background: #07100e; }
.message-audio { width: min(360px, 100%); margin-bottom: 7px; }
.file-card { min-width: 230px; margin-bottom: 7px; padding: 12px; display: flex; justify-content: space-between; gap: 18px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; background: rgba(0,0,0,.14); }
.file-card span { color: var(--dim); font-size: 10px; }
.contact-result { margin-top: 16px; padding: 12px; display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 14px; }
.contact-result strong, .contact-result small { display: block; }
.contact-result small { margin-top: 5px; color: var(--dim); font: 10px/1.4 var(--mono); }
.contact-result .primary { min-height: 38px; padding: 0 13px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 12px; }
.gallery button, .gallery a { min-width: 0; padding: 8px; display: grid; gap: 7px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); background: var(--bg-soft); text-decoration: none; cursor: pointer; text-align: left; }
.gallery img { width: 100%; aspect-ratio: 1; border-radius: 8px; object-fit: cover; }
.gallery span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.gallery-file { display: grid; place-items: center; aspect-ratio: 1; border-radius: 8px; color: var(--lime); background: var(--panel-2); font-size: 32px !important; }
.gallery-preview { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 12px; object-fit: contain; }
.call-ui { text-align: center; }
.call-ui > .avatar { width: 78px; height: 78px; margin: 0 auto 14px; border-radius: 25px; font-size: 20px; }
.call-ui h2 { margin: 0; }
.call-ui > p { color: var(--mint); }
.call-media { position: relative; min-height: 220px; margin: 18px 0; overflow: hidden; border-radius: 16px; background: #050b09; }
#remote-media { width: 100%; height: 420px; display: block; object-fit: cover; }
#local-media { position: absolute; width: 150px; height: 105px; right: 12px; bottom: 12px; border: 1px solid var(--line); border-radius: 12px; object-fit: cover; background: #0e1c18; }
.call-actions { display: flex; justify-content: center; gap: 12px; }
.call-accept, .call-reject { min-width: 120px; min-height: 44px; border: 0; border-radius: 999px; cursor: pointer; font-weight: 750; }
.call-accept { color: #08110e; background: var(--lime); }
.call-reject { color: #fff; background: #b84646; }

@media (max-width: 1180px) {
  .shell { grid-template-columns: 68px 290px minmax(420px, 1fr); }
  .details { display: none; }
  .empty-pane { grid-column: auto; }
}
@media (max-width: 760px) {
  body { overflow: hidden; }
  .welcome { padding: 0; }
  .welcome-card { min-height: 100vh; grid-template-columns: 1fr; border: 0; border-radius: 0; }
  .welcome-copy { padding: 34px 24px 42px; }
  .welcome-visual { display: none; }
  .eyebrow { margin-top: 65px; }
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; height: 64px; padding: 8px 15px; flex-direction: row; justify-content: space-around; border: 0; border-top: 1px solid var(--line); }
  .rail-logo, .rail-spacer, .profile-dot { display: none; }
  .rail .icon-button { width: 46px; height: 46px; }
  .sidebar { padding-bottom: 64px; }
  .sidebar.hidden-mobile { display: none; }
  .conversation { display: none; padding-bottom: 64px; }
  .conversation.active-mobile { display: flex; }
  .mobile-back { display: grid; }
  .conversation-head { height: 66px; padding: 0 10px; }
  .conversation-head > .avatar { width: 40px; height: 40px; border-radius: 13px; }
  .head-actions .icon-button:nth-child(-n+2) { display: none; }
  .security-strip { padding: 7px 14px; justify-content: flex-start; overflow: hidden; white-space: nowrap; }
  .messages { padding: 18px 13px; }
  .message { max-width: 90%; }
  .composer-wrap { padding: 8px 10px 10px; }
  .composer-note { display: none; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal, .modal.large { width: 100%; max-height: 88vh; border-radius: 24px 24px 0 0; }
  .tor-diagnostic { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
